Windows Workflow Foundation

Dear Buddies....


Here is I am going to explain the Windows Workflow Foundation for .Net Framework 3.0.

I welcomes all of you to Windows Workflow Foundation
One of the newest buzz phrases in the framework industry is "Windows Workflow Foundation" (WF). This article is like a tutorial for how to start with Windows Workflow Foundation in .Net framework 3.0. Basic knowledge of .NET Framework is the only prerequisite for marching on with this article.

First of all we need to What is Workflow?
The answer for the above question is in the following scenarios....

Mr. X see a beatiful girl and wants to propose love to her....

1. He goes to near her and give a smile.

2. He introduced himself

3. He came to know each other

4. He praised her fair

5. He proposed his love

From the above, there are 5 steps for a man propose a love to a girl. From here, the number of 'steps' for complete an 'action'. The desired action (love Proposal) is dependent on the number of steps. Looking around makes us realize everything around us follows a certain pattern/sequence of steps in order to achieve the desired result. Now this very realization leads us to the definition of workflow.

Workflow: Series of steps, decisions and rules needed to complete a specific task.

Windows Workflow Foundation:

Windows Workflow Foundation is a technology for defining, executing and managing workflows. This is one of three major frameworks (the other two are related to presentation and communication) that .NET 3.0 introduced.

Workflow Foundation consists of runtime, workflow library, services and a programming model. Workflow projects are not applications themselves, rather they constitute an application, so 'host' is needed for workflow runtime. As in the running loan-request workflow, a banking application will act like a 'host'. The host can be a: smart-client, ASP.NET worker thread, service, or a simple console application.

'Runtime' manages workflows, managing means creating workflow and responding to events like resuming, suspending, terminating, unloading etc.. As we have noticed, many business processes consist of similar activities but are used in different contexts. For example: conditional loops, parallel activities, and calling a web service are common activities that could be part of a different multitude of applications, so Microsoft has provided a base activity library that has a common set of usable activities. Of course, one can write their own custom activity or extend existing ones.

Services are another part of WF that help runtime perform various operations on workflow; again services can be extended / customized as needed. A few services that come with WF are: scheduling, transaction, persistence, tracking services.

There are two major types in Windows workflow Foundation:

Sequential: a series of activities are called in order.

State machine: activities are called on the basis of the 'state' of different parameters.

Steps to create a Windows Workflow Foundation...

Open up Visual Studio 2005 IDE and click on 'New Project'

Select 'Sequential Workflow Console Application' as project type. As pointed out earlier, there are two types of workflows: sequential and state machine. Our chosen scenario follows a particular sequence and doesn't have any state machine involved in it, hence the selection.

Select an appropriate project name, mine is 'MyWF'. Check the 'Location' of the project on disk drive and click 'OK'.

Workflow is currently empty and you can drag-drop any number of activities from the 'toolbox window' into it.

Here, first we select 'Code Activity' and drop it on Workflow Designer.

You can see from the 'properties' window that this new activity is named as 'codeActivity1'. To define what this code activity will do, we will click the 'Generate Handlers' hyperlink in 'properties' window. This will generate the default handler 'ExecuteCode' for this activity.
The following code will be produced after performing all of these steps.

public sealed partial class Workflow1: SequentialWorkflowActivity
{
public Workflow1()
{
InitializeComponent();
}
private void codeActivity1_ExecuteCode(object sender, EventArgs e)
{

} In the above event, we can add code for getting any value...

I am going to write as follows,

private void codeActivity1_ExecuteCode(object sender, EventArgs e)
{
Console.WriteLine("Enter Name : ");
string Name = Console.ReadLine();
Console.WriteLine("Your Name Saved!");

}
}

Hence we have started our Windows Workflow project. After here I will post next steps in Windows Workflow....

:)

Cheers...

...S.VinothkumaR.

1 comment:

ashis said...

Can you give an example how to add code in state machine work flow .