As said previously it is 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.
- First select a sequential workflow project. In this case, we have selected Sequential workflow console application to keep the sample simple.
- 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.
- So let us 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 Execute Code 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.
- This is the behind code of the workflow.
Figure 4: - Sequential workflow using designer