Implement Multiple Activities in Workflow
Implement Multiple Activities in Workflow
By : Kasim Wirama, MCDBA, MVP SQL Server
It is seldom to find single activity inside a workflow. More often than not, you will find multiple activities inside a workflow. Generally you can straight away drag and drop multiple activity workflow components into designer. But some container acts as container of component doesn’t directly permit you to do that. This article, I would like to explore possibility composing multiple components inside container component.
First, I discuss about putting multiple workflow component inside While conditional looping component, then how to put make series of single steps that are committed/rollback as one unit of action through TransactionScopeActivity, other component is IfElse activity. Let’s look at them.
While activity only permits one and only one activity inside it, try to create more than one Code Activity inside the While Activity, I am sure that Visual Studio doesn’t allow you to do that, instead, you should put Sequence Activity inside While Activity, then just put some component activities inside the Sequence Activity.
If you would like to implement transaction activity, WWF provides TransactionScopeActivity. This activity component allows you put multiple activities inside it. This transaction activity give you options of transactions through TransactionOptions.IsolationLevel and TransactionOptions.TimeoutDuration. you can specify transaction to Serializable (default), Repeatable read, read committed, read uncommitted, snapshot or chaos. Actually TransactionScope activity implements .NET base classes in System.Transactions namespace.
Similar to TransactionScopeActivity, you will find CompensatableTransactionScopeActivity, this activity implements ICompensatableActivity interface, in designer, this component has hidden container for compensationHandler. To show the handler, right click on the component and choose View Compensation Handler. You can drop activity inside the compensation handler. This compensation word means that you can do some additional activities (as compensation word implies) for exception raised within the transaction scope.
Other type of activity is branching activity, WWF provide IfElse activity. The similarity to While activity is that both have Condition property. You can define Rule Condition or Code Condition for Condition property. If you choose Rule Condition, you define condition declaratively, so WWF will put it to separate file with rule extension, so you can modify the rule file without having to compile WWF assembly.
Happy exploring.