Accéder au contenu principal

Articles

Affichage des articles du mars, 2008

Creating a simple WF activity

In this article we are going to show how to create a Windows Workflow Activity. Our activity will be called GreetingsActivity and it has the purpose of displaying a Greetings message using the System.Console.WriteLine method. So the best type of application in which to host the workflow containing such an activity is the Console Application template. So let’s begin The first thing to do is to create a library class project that you can call after the name of the Activity : GreetingsActivity. Then add all the required reference for Workflow. Create also some using statements in order to enable you to use shortcut acces to the major classes and namespaces that we will be using using System; using System.ComponentModel; using System.Workflow.Activities; using System.Workflow.ComponentModel; using System.Workflow.ComponentModel.Compiler; using System.Workflow.ComponentModel.Design; After that I create a class which derives from System.Workflow.ComponentModel.Activity class The main method

Intro to WF

Windows Workflow Foundation supports multiple workflow authoring styles such as sequential, state machine, and data-driven. The sequential style is straightforward and useful for repetitive, predictable operations that are always the same, the state machine workflow style consists of a set of event-driven states, and the data-driven style relies on data to determine whether certain activities are run or not based on a local data state. In the state machine style of workflow authoring, the author models the workflow as a state machine. The workflow itself is made up of a set of states. One state is denoted as a start state. Each state can receive a certain set of events. Based on an event a transition can be made to another state. The state machine workflow can have a final state. When a transition is made to the final state the workflow completes.The following flowchart is an example of a state machine workflow The following table lists the state machine-related activities in the Windo