Thursday, 27 September 2012

How To Use If Activity


If Activity

This is a conditional activity just like you have If Else blocks in your application. You can have a branch of activities based on a certain condition.

Namespace System.Activities

Steps:
1). Start VS2010
2). Go to File Menu Select New Project then select Workflow Console Application.
3). In this project workflow1.xaml file will be seen.
4). From the toolbox, Drag the Sequence Activity from the Control Flow tab.
5). Now Drag assign and writeline activity.
6). After that we can drag if activity from control flow on sequence and set the condition if condition is true i.e. then is executed and else is executed.

The Workflow is look like this:



Output

                                          


Introduction To Window WorkFlow Foundation


WINDOW WORKFLOW FOUNDATION


A workflow is a set of activities which is stored as a model and they depict a process.Every task is an activity and a group of activities depicts a complete workflow. A workflow is run by the workflow run-time engine.

The workflow model can be written in pure .NET code, pure XAML, or a mix of XAML and .NET   
code. A workflow model is compiled and can execute under Windows, ASP.NET, Web Services,
or Windows Services application.


Example:
Simon needs a loan to purchase a new Ferrari to impress his new girlfriend.
I.            He goes to bank and explains his need.
II.            Bank checks his credit history.
III.            Based on credit history, Simon was offered multiple loan options.
IV.            Simon selects one of options.
V.            Bank approves loan, money gets transferred to Simon's account.


Why Workflow?


1). One of the main reason for creating workflow is that you are actually creating a model.

2). Main focus is on business logic.

3). Before WF we would make couple of UML diagrams or a simple flow chart, writing pseudocode,        
     explain in text how an operation should work and then finally you will get to writing code.



How to use Delay Activity in Workflow 4.0


Delay Activity

This activity allows you to build interval-based pauses into a workflow. You may call it as a timer activity that will set duration so that the workflow will pause before continuing to execute.
Namespace System.Activities

Steps:
1). Start VS2010
2). Go to File Menu Select New Project then select Workflow Console Application.
3). In this project workflow1.xaml file will be seen.
4). From the toolbox, Drag the Sequence Activity from the Control Flow tab.
5). After that Drag the Delay Activity from the Primitive tab in the Sequence.
6). Right click on delay activity and click on properties. Here we can see the expression editor property.
Set i.e. TimeSpan.fromSeconds(5)





7). Press F5
Output: (Note: if you cannot see the result then please write Console.ReadLine () in Program.cs after invoking.