Sunday, June 28, 2009

Windows Workflow Foundation 4.0 (Part 2 The Designer)

In part two of this series we’ll look at the project types available in Visual Studio 2010 and take look at the feature changes in the workflow designer.

Project Templates


There have been a number of changes in the available projects between WWF 3.5 and WWF 4.0. Below is a screen shot of the Visual Studio 2008 new Workflow project dialog.



As you can see in addition to the empty workflow project, there are several variations of the Sequential workflow and the State machine workflow. These variations include SharePoint 2007, library and console workflow applications. All of these workflows are built on designer functionality that has been available in Visual Studio since Visual Studio .Net was released in 2002.

The Visual Studio 2010 new Workflow project dialog contains a lot less clutter, some new project types and some that are missing. There may potentially be more project types available upon release, but for now we’ll concentrate on what’s available in beta 1. Below is a screen shot of the Visual Studio 2010 new Workflow project dialog.



The projects listed in the new project dialog are Activity Designer Library, Activity Library, Flowchart workflow console application and the Sequential workflow console application. All of the projects in the dialog are new for workflow with the exception of the Sequential workflow, missing is the State Machine workflow. All of the workflows in the WWF 4.0 are based on xaml or extensible markup language. This is the same technology that is used in WPF and Silverlight just to name a few.


Here is a quick overview of the project templates that are available in Visual Studio 2010.

The Activity Designer Library template provides a way to create a user interface for a custom or standard activity.

The Activity Library template provides a way to create custom activities visually.

The Sequential template creates a workflow that executes activities in sequence, one after another.

The Flowchart template creates a workflow that executes activities one after another, but allows the flow to return to an earlier step. This template replaces the State Machine workflow and is much more flexible.

Workflow Designers

There is a visual difference between the new Workflow designer and the Visual Studio 2008 designer. Below is the Visual Studio 2008 designer for a sequential workflow.


Below is the Visual Studio 2010 designer with a sequential workflow opened up.


The Visual Studio 2010 designer has some noticeable changes from the previous designer in that now, rather than creating variables and arguments in code, the designer now provides facilities for creating them from the designer.


When defining arguments from the argument window, you provide a name, type, default value and a direction. Valid directions are In, Out, In/Out and property. We’ll discuss these later after we discuss the available Out of the box activities and start to build a work flow.

Variables are much like arguments in definition except that instead of defining the direction we define the scope of the variable.

Navigation to activities and child activities is provided via bread crumbs. This was a feature of the State Machine workflows in WWF 3.5 that has carried over into WWF 4.0. The bread crumb navigation makes it easy to drill into the activities in a workflow to set the properties.

Overall the Workflow designer in Visual Studio 2010 is an evolution of the designer in Visual Studio 2008. Variable and Argument dialogs go a long way toward reducing the coding chores. And bread crumb navigation makes moving within activities and child activities a breeze. In the Next part we’ll look at the huge list of Out of the box activities.

No comments: