Datasheet
Chapter 1: Workfl ow Programming Principles
35
// Workflow1
//
this.Activities.Add(this.onWorkflowActivated1);
this.Activities.Add(this.logToHistoryListActivity1);
this.Activities.Add(this.whileActivity1);
this.Activities.Add(this.logToHistoryListActivity2);
this.Name = “Workflow1”;
this.CanModifyActivities = false;
}
void logToHistoryListActivity3_MethodInvoking(object sender,
EventArgs e)
{
System.Threading.Thread.Sleep(5000);
}
public Guid workflowId = default(System.Guid);
public SPWorkflowActivationProperties workflowProperties =
new SPWorkflowActivationProperties();
}
}
This workflow is a class named Workflow1, which inherits from the SequentialWorkflowActivity
activity, which is the base class for all sequential workflows. The workflow itself is nothing but a
custom activity, which is composed of other activities. In other words, the workflow itself is a custom
composite activity. Composite activities are the most common custom activities that you, as an activity
developer, will be developing, because it enables you to compose your custom activity from existing
activities, which promotes reusability (as opposed to starting from scratch and implementing the
features that existing activities already support). For example, our custom SequenceActivity activity
already contains the logic for executing a set of activities sequentially in linear fashion. By having our
custom activity use this activity, we save ourselves the effort of reimplementing this logic all over again.
Now back to the implementation of Workflow1. As you can see, the InitializeComponent method is
where the workflow instantiates and initializes its containing activities. This workflow is a sequence of
the following activities:
An OnWorkflowActivated activity named onWorkflowActivated1. This activity suspends its
execution and consequently the execution of the workflow and waits for the current workflow
instance to be activated. This activity must be the first activity in every SharePoint workflow. I
discuss this activity in more detail in the next chapter.
A LogToHistoryListActivity activity named logToHistoryListActivity1, which logs a workflow
history event to the workflow history list stating that the workflow has started. I also discuss the
LogToHistoryListActivity activity in the next chapter.
An instance of our custom WhileActivity activity .
A LogToHistoryListActivity activity named logToHistoryListActivity2, which logs a workflow
history event to the workflow history list stating that the workflow has completed .
❑
❑
❑
❑
c01.indd 35c01.indd 35 8/25/08 4:03:01 PM8/25/08 4:03:01 PM