May 272013
 

BootstrapRecently, I was directed towards an open source web front end framework called Bootstrap.  The current version (as if this writing) is version 2.3.2, which you can download from here.

The aim of this initiative is to create an intuitive, abstract combination of JavaScript and CSS to allow designers and developers to create responsive user interfaces which can render seamlessly across a range of different consumer devices, such as desktop, mobile and tablet devices.

Bootstrap accomplishes this seemingly impossible task by leveraging some of the more advanced aspects of HTML5 as well as combining an intelligent set of CSS classes which extend HTML in a very logical and well ordered way.

Be more specific

Fair enough.  Many frameworks have claimed to extend hypertext mark-up to create some ingenious new toolkit or framework, but very few succeed.  What makes Bootstrap any different?

For one thing, it appears to have been built from the code up.  The CSS classes extend basic HTML elements in a very logical – and reusable – fashion.  Bootstrap uses a sequence of  live grids to orient content depending on your requirements.

HTML mark-up can also be decorated with classes to reorder or re-orient content depending on the type of device which is requesting HTML content (referred to as the ‘Responsive’ utility classes).  For more on this, check out the responsive design layouts section.

Components

Bootstrap makes available a number of very useful components, which I’ve lifted from the site for your benefit:

List of components

Together, the Components and JavaScript plugins sections provide the following interface elements:

  • Button groups
  • Button dropdowns
  • Navigational tabs, pills, and lists
  • Navbar
  • Labels
  • Badges
  • Page headers and hero unit
  • Thumbnails
  • Alerts
  • Progress bars
  • Modals
  • Dropdowns
  • Tooltips
  • Popovers
  • Accordion
  • Carousel
  • Typeahead

Aside from the various examples of scaffolding, in addition to the copious amount of documentation explaining the new CSS classes, there’s also a site dedicated to additional supporting documentation which can be located over here.

Examples

On the weekend, I decided to take Bootstrap for a spin.  Using the example scaffolding as a starting point, I created a number of static HTML pages and reused the JavaScript and CSS includes.

This required a fair amount of hand editing, made far easier by the use of Visual Studio (2010) as a HTML editor, as the intellisense provided easy access to CSS class definitions and so forth.

Aussie Wine Sales

My example site was posted last night and if you’d like to check out my initial handiwork, navigate to Aussie Wine Sales.

More to come

This article is just an introduction.  When I have a little bit more time, I’ll write a follow up article which goes into a bit more detail about my experiences in building the Aussie Wine Sales website, calling out specifically concepts which were very intuitive as well as some of the (occasional) drawbacks.

I’ll leave you with one final thought – Bootstrap actually made the experience of hand coding HTML bearable.. possibly even, dare I say it, fun!

May 162013
 

PowerGUI_Badge_SeeYouAtFollowing on from the last instalment where I looked at supporting PowerShell script development in Visual Studio 2010, I’m going to take a closer look at PowerShell integration with the newer Visual Studio 2012.

Again, I’ll be leveraging the excellent Quest PowerGUI product and the associated Visual Studio extension.

Installation

You’ll also need PowerGUI 3.2, but this time there’s an updated Visual Studio extension which you’ll need, version 1.6.1

Install PowerGUI 3.2 first, and once complete then install the Visual Studio extension.  PowerGUI has a dependency on the .NET Framework 3.5, on newer OSes (like Windows 8) you might not have this pre-installed, don’t worry – the installer will warn you if anything’s missing.

Getting Started

Once you’ve installed, you will see a new option in Visual Studio’s File –> New Project dialog for PowerShell.  This creates a fairly sparse new project with a .ps1 file in it ready to go.

Troubleshooting

The first two times I tried to get everything installed and running, I kept getting issues with Visual Studio 2012 warning it couldn’t load PowerGUI.  I tried everything until I realised what the problem was.  I’d downloaded the .vsix but one thing finally dawned on me:

image
Unblock

Therefore, unblocking the file before installing seemed to do the trick.  If you’re having problems loading the extension this might be a problem for you as well.

Looking at the Project

As with Visual Studio 2010, you get the PowerShell project type available in the New Project dialog:

image
New Project

A closer look

Some of the advantages of using Visual Studio to write your PowerShell scripts are easy to highlight.  The debugging support is obviously a huge advantage, but so to is the Intellisense support. 

It’s really evident when there’s an issue with the script, if you aren’t seeing the right info in Intellisense.  Rather than go into detail, they say a picture is worth a thousand words, so let’s see some examples of the value in writing your PowerShell scripts in Visual Studio:

image
Debugging Support

image
IntelliSense Support

image
PowerGUI integrated Console

image
Best of all – Tooltips which provide CmdLet syntax

What’s Next?

Now that we’ve explored both Visual Studio 2010 and Visual Studio 2012 options for PowerShell, the next step is to take a look at some of the advantages of using either environment when building your PowerShell scripts.  We’ll also look at trace/output options and how to best handle errors.

Check back for the next article..soon.

May 152013
 

PowerGUI_Badge_MyPSEditor-Pro1Recently I needed to write up a new Powershell script to automate some actions independently of our major release cycle.

This took me down a road with two possible options – write the script in Visual Studio 2012 or in Visual Studio 2010.  I’ve decided to pursue both avenues, just for kicks.  There are other options available, but I’m more comfortable with Visual Studio, and it integrates into our standard SDLC tools (Team Foundation Server), so I can associate the work to work items, e.t.c.

This article will cover writing PowerShell scripts in Visual Studio 2010 using PowerGUI and the PowerGUI VSX (Visual Studio Extension).  I’ll attempt a follow up showing how to accomplish the same outcome with Visual Studio 2012 later.

Be kind.. This is my first foray into the world of PowerShell scripting..  Just posting a few observations.

Installing Software For Visual Studio 2010

The first thing you need is Quest PowerGUI (my chosen PowerShell add-in) version 3.2 – note that this is not the latest version, 3.6!.  Unfortunately, the Visual Studio extension only supports version 3.2.  This required a little bit of Google-Fu, but I found a copy here on the PowerGUI forum.

You’ll also need PowerShell 2.0 installed (if not already installed), you can install from the Microsoft site.

Once installed, use Visual Studio’s Extension Manager (under Tools) to search for (in the online templates) the PowerGUI VSX extension and install.  Once done, you’ll need to restart your instance of Visual Studio.

vs-2010-extension

Once restarted, when you look under the File->New Project, you’ll see a new option for Powershell (note I have two VS extensions installed):

image

Once installed you can create a new project and we can start our scripting.

PowerShell

Well, I won’t go into too much detail here.  Once everything’s installed, you can create a new PowerShell project, which really just creates a project and allows you to add new PowerShell script files.

The main advantage here is the debugging and IntelliSense support, which really helps let you know if things are being written properly.  I did the majority of scripting within Visual Studio, although PowerGUI has a separate script application which isn’t bad.

PowerShell Challenge No.1

OK, so here’s what I was attempting to do.  From a given directory, iterate through XML files and read out the contents of each file.  For each file, the aim was to hit a WCF (SOAP) web service and store the XML data from the files.

Pretty basic stuff?  Agreed.  So I decided to tackle the trickiest part first.  Using Visual Studio was a bit of a help, because the IntelliSense gave me a good hint when the script was written properly.

Invoking a WCF Web Service from PowerShell

There’s actually an extremely straightforward way of doing this provided that the service is using a HTTP endpoint.  There’s a cmdlet in PowerShell 2.0 called New-WebServiceProxy which simplifies the calls to child’s play.

Let’s say I had a Web Service called FormManagement which had an operation called Save.  The Save operation takes two parameters, a string param called “AppNumber” and a string for the form data.  Assuming I had this service configured with basicHttpBinding and no authentication, to invoke the Save() operation from PowerShell I’d just do this:

$uri   = “http://tempuri.org/Forms/FormManagement.svc
$proxy = New-WebServiceProxy -uri $uri

Write-Output $appNumber
$proxy.Save($appNumber, $formData)

For all other cases – particularly when using a net.Tcp endpoint – (and potentially if you have dramas with wsHttpBindings) you’ll have to deal with programmatically creating at runtime a client proxy assembly to get the type goodness.  Luckily, someone else has a very elegant solution which is worth a look.

The Rest

Is Child’s play.  In fact, I wrote the logic into functions just because I can.  Essentially, I’m using a global variable ($directory) which is referenced by the Process-Folder function.  The rest is really too trivial to go into detail.

function global:Process-Folder()
{
    $files = Get-ChildItem $directory -Filter *.xml -Name
    foreach ($file in $files)
    {
        $processing = “Processing file: ” + $file
        Write-Output $processing
        Process-File $file
    }
}

The Process-File function takes a filename parameter and takes care of prepping the input data for the Web Service call in the previous section.

function global:Process-File
(
        [CmdletBinding()]
        [Parameter(Position=1, Mandatory=$true)][string] $fileName)
{
    $appNumber = $fileName.ToUpper().Replace(“.XML”, “”)
    $fqn = $directory + $fileName
    $formData = Get-Content $fqn #TODO: flatten the string array into a single string
   
    #Invoke the WCF service
}

It’s almost elegant.  Not bad for a first script?  I’ll be doing a second article on how to work with PowerShell in Visual Studio 2012.