Showing posts with label Vista. Show all posts
Showing posts with label Vista. Show all posts

How can we pass parameters to workflow?

When you call the startworkflow function you can pass as name / value pairs using the dictionary object.

How do you handle exceptions in workflow?

Exception handling in Workflow is somewhat different than how we do in normal .NET
application. Below is the numbered snapshot of how we can handle exceptions in Workflow.
1 - We have small tab which says view exceptions. If you click on view exception you will be redirected to a workflow design only for exception as shown in numbered snapshot
2. 2 - This is the workflow which will execute incase we have exceptions. We have put a code activity which points to a method called as raiseException. Incase of exception in the workflow this path will be followed.

How do we specify conditions in Work flow?

Yes you can define conditions in workflow by using conditionedActivitygroup. Below is the numbered snapshot which shows how to use conditionedActivitygroup.
1 - You can see in this snapshot we have defined a conditionedActivitygroup with two conditions. The two boxes inside the group define two conditions.
2 - You can select one of the condition box and define the condition using the WhenConditions property. If this condition is true you need to specify in the execute code which method to execute. For instance in the current snapshot we have said that old1 method should execute if age > 21. The same procedure we need to follow for the second condition box. In the second condition box we have specified to execute young1 method if age <>
3 - Workflow editor also provides a cool interface called as Rule Condition Editor which can be used to specify conditions. Age is a public property in the behind code. You can also get the Age in the intellisense of rule condition editor.
4 - Both the condition will execute inside the condition activity group. We need to also specify when this conditionactivitygroup should exit. So we have made a function called as exit. If the user inputs age as -1 it will exit from the loop or else it will take inputs from user and continue evaluating depending on the two conditions.

How do we create workflows using designer?

As said previously it’s very easy to design workflows using designer. So we will answer this question by actually doing a small sample. Below is the code snippet and image snapshot which shows how we can use the designer to create workflows. So lets understand all the below numbered snapshot.
1 -- First select a sequential workflow project. In this case we have selected Sequential workflow console application to keep the sample simple.
2 -- When you are done with creating the project you will see the solution explorer as shown in the second snapshot. There are two files one the WorkFlow1.cs and the other Workflow1.designer.cs.If you click on the WorkFlow1.cs you will get a designer pane as shown in snapshot 3. If you double click on Workflow1.designer.cs you will get behind code as shown in snapshot 4.
3 -- So let’s drag drop a code activity on the workflow designer and associate this activity with a method called as MyActivity1. This association is done by entering the method name in ExecuteCode property. In MyActivity1 we have just displayed in the console that this is my first activity. Again we have added one more code activity which points to MyActivity2. If you see the designer pane we have sequenced code1 first and code2 next. So in short code1 will execute first and the code2. This is clear from the output displayed below.
4 - This is the behind code of the workflow.

When should we use a sequential workflow and when should we use state machines?

If the workflow is very rigid then you go for sequential workflow and if the workflow is dynamic then go for State machine workflow. For instance you have placed an order and the order will not pass until your supervisor approves is a rigid flow. Because your order has to be approved by a supervisor or else it will not be approved. But if your order moves from one place to other place. For instance it moves from approval to waiting and then clarification a state machine work flow model is more appropriate.
Below is a simple code snippet which shows practically how to use sequential work flow. Let try to understand step by step as marked in the figure:- 1 – First you need to select System.workflow namespace. 2, 3 and 4 – In these three steps we created code object and linked them with activity. 5, 6, 7 and 8 – We start the workflow and create workflow instance object to run the sequential workflow. You can see the output in 8. Depending on how you add the activity in section 3 it executes sequentially. Because we have added codeactivity1 first it executes the first activity first. The sequence on how you add the activity to the activities collection the activities are run.

What are different types of Workflow in Windows Workflow foundation?

There are two basics type of workflow Sequential Workflow and State machines workflow. A sequential workflow has clear start and finish boundaries. Workflow controls execution in Sequential workflow. In sequential execution one task is executed after other. Sequential workflow is more rigid in format and execution path has a determistic nature. A State machine workflow is more dynamic in nature. Basically workflow has states and the state waits for events to help it move to next state. In State machine execution path is undetermestic nature. Below figure shows visual conceptualization of fundamentals. You can see in Sequential work flow the execution path is very determestic. Shiv performs the entire task sequentially and these tasks are very determestic. But now have a look at the second work flow. Every state goes to other state when it receives some external events. For instance when Shiv is seeing star trek there is an event of flashing news which triggers him to see the flashing new.


What is a Workflow?

A Workflow is a set of activities which is stored as model and they depict a process. Below figure depicts clearly the difference between Workflow and Activity. Every task is an activity and group of activity depicts a complete workflow. Workflow is run by the Workflow runtime engine.
Workflow model can be written either in pure .NET code, pure XAML or Mix of XAML and .NET Code. A workflow model is compiled and can execute under windows, ASP.NET, Web services or windows services application.

What is Windows Workflow Foundation?

WWF is a programming model for building work flow enabled applications on windows. System.WorkFlow namespace has all the necessary modules to develop any type of work flow.