This blog is subject the DISCLAIMER below.

Sunday, September 16, 2007

Windows Workflow 2

In this post we will go deeper inside Windows Workflow and how to create a project from Workflow type.

You need to have VS2008 or VS2005 + VS2005 extensions for Workflow

From VS -> new project->Workflow Let’s understand the different types of Workflow projects

Empty Workflow Project: An empty workflow project that you start to add some of Visual C#/Visual Basic.net items the output of this type is .dll

Sequential Workflow Console Application: Workflow project from Sequential type if you don’t know what Sequential Workflow is please read http://fci-h.blogspot.com/2007/09/windows-workflow-1.html Workflow types section the output if this type is console application .exe

Sequential Workflow Library: Workflow project from Sequential type if you don’t know what Sequential Workflow is please read http://fci-h.blogspot.com/2007/09/windows-workflow-1.html Workflow types section the output if this type is .dll

State Machine Workflow Console Application: Workflow project from State Machine type if you don’t know what State Machine Workflow is please read http://fci-h.blogspot.com/2007/09/windows-workflow-1.html Workflow types section the output if this type is console application .exe

State Machine Workflow Library: Workflow project from State Machine type if you don’t know what State Machine Workflow is please read http://fci-h.blogspot.com/2007/09/windows-workflow-1.html Workflow types section the output if this type is .dll

Workflow Activity Library: This type let you create a custom activity to be used in more than project you can imagine it as component; I’ll talk about it later the output if this type is .dll

So, I’ll work on Sequential Workflow Console Application and explain some of Workflow ControlsOnce we selected Workflow project from Sequential Workflow Console Application type; VS opens a window to design our Workflow and as we see there is a start and end elements.

Let’s begin with “Code” Control: to use drag it and drop between the start and the end element of the Workflow as shown we will notice an exclamation mark inside red ball it notifies us that there is no method to be invoked at runtime, so click on code figure and go to its properties and then specify “Execute Code” and write HelloWorldMethod, we’ll find VS switch to .cs file and has generated a HelloWorldMethod method so I’ll write this code Console.WriteLine(“Hello World”);This method considered as the event that raised when the “Code” executed.

Tip: you use “Code” control only if you want to execute something just one time.

“While” Control: used for looping, it has Condition which has two types; Code condition and Declarative code condition. So, I’ve dragged a “while” control inside my design and dragged the “code” control that created before inside it, cool? Yes that’s very easy.

Condition like “Code” control’s condition, that’s the event that raised when “while” control executed I’ve two ways of condition
1- Code condition: specify the code to run, usually we don’t write code more than stopping it like here I increased counter and set “While” to stop when counter = 10 by assign Result = true.
2- Declarative Rule Condition: when selecting Declarative Rule Condition I must set the Condition name, a new window opens then select new a new windows opens to set my condition I wrote counter<10 href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjchIAg6y5_O1FUcneZzafwuXjK8ek9ZZ5zMzBJzOTjvxldxyGt7GhyphenhyphenZ29b2Zg49OeONKgXym11ZBjB3dq-pYQeA8uT2X-N7hNEW1G-VKl2JlTPHLvtLgos2mO_XQNYJV5BT-Wl/s1600-h/9.jpg">

No comments: