Pages

Monday, 8 April 2013

Main Features of Windows Workflow Foundation 4.0

Main Features of Windows Workflow Foundation 4.0
 
In this article on WF 4.0, I will describe main features of Workflow Foundation 4.0. Some of the features of WF are new and some are enhanced. Various features of WF 4.0 (Workflow Foundation) are new Activity Designer, Custom Activity, Bookmarks, WorkflowDataContext, Extension, Persistence, WCF Integration, PropertyValueEditor, PersistenceParticipant, Type Converters and Validators. Lets discuss above Workflow Foundation features in detail.
 
1. Activity Designer
 
One of the major changes in Windows Workflow Foundation 4.0 is the Activity Designer. The new Activity Designer is based on WPF which gives lot of flexibility to the developer.  Creation of a custom look and feel using the new Activity Designer is very easy.
 
2. Custom Activity
 
WF4.0 supports the custom activity development. Custom Activity development involves two parts- designer development and execution logic implementation.
 
3. BookMark
 
In WF4.0, we use different ways of communication between Host application and workflow. There are different approaches like Bookmark, Extension methods, WCF Workflow services, workflow level arguments, etc. Here, we will discuss about the simple way of communication between host application and workflow using Bookmarks.
 
Bookmark is a pointer we create in the workflow execution. Bookmarks can be used for handling various events from Host application and also as data communication between Host and workflow. Bookmarks can be Non-blocking, None or Multi-Resume. Type of the Bookmark can be set using the BookmarkOptions enumerator. 
 
None: By default the bookmark will be of blocking type. When a bookmark encountered, the execution of the
workflow will go to the idle state. Workflow execution will wait for the resumption of one of the bookmarks.
 
Non-blocking: Here, the execution of the workflow continues.
 
Multi-Resume: This bookmark is of blocking type. We can resume the bookmark multiple times. 
 
4. WorkflowDataContext
 
If you want to pass some common data to all the activities defined in the workflow, we can use the workflowDataContext associated with the workflow. 
 
5. Extension
 
Extension is a normal class with public methods and properties. Once we add the extension class to the workflow application, we can use the same in any child activities. For each instance of the workflow application will have one instance of its extension class. Using the context associated with the custom activity, we can access the extensions.
 
6. Persistence
 
Persistence means storing the current state of a workflow. For better understanding, we will consider a document processing scenario.
 
In document processing, one user uploads the document and the workflow gets started. Then the document will go to the reviewer.  Reviewer will review the document, either accepts it or reject with comments. In this scenario, reviewing of the document can happen in a different application or can be done after many months.
 
When we deal with this kind of scenario, we will go for persistence. After uploading the document, the corresponding workflow state is stored in an InstanceStore. When the review starts, we can reload and continue execution of the workflow from the last executed state. In our scenario, the reviewer can use another application, which can reload the workflow from the InstanceStore and continue execution. Also, as we are storing the workflow to InstanceStore, we can manage the long running workflow effectively.
 
7. WCF Integration
 
When we create a new project, under the workflow project templates, we have the option to select the WCF Workflow Service Application.
 
Once, we create a WCF Workflow Service application, it will create a default WCF integrated workflow. The extension of our new workflow file is not .xaml, it is .xamlx.
 
8. PropertyValueEditor
 
We can either use the TypeConverter or PropertyValueEditor for managing the properties and associated editors in PropertyGrid. TypeConverters are same as those in WPF. PropertyValueEditors are similar to the PropertyEditors in WPF, which provides custom editor for our property.
 
9. PersistenceParticipant
 
We already discussed about Persistence and Extensions in workflow foundation 4.0. Persistence is the way of storing the current state of a workflow into an instance store. Extensions are special classes for sharing data among child activities, workflow and Host application. In case of normal Extension, the data shared using the Extension won’t be stored to the instance store as part of the Persistence.
 
In real business scenario, we may need to store the Extension data as part of the workflow state. For this purpose, workflow foundation 4.0 is providing a special kind of Extension called PersistenceParticipant.
 
10. Type Converter
 
Type Converters are used to pre-populate the expected values of a Property. We can either allow the user to edit new values or can restrict the user to only select from the given values using Type Converter.
 
11. Validation
 
Workflow Foundation 4.0 Argument Validation and Propery Validation.

No comments:

Post a Comment