What is an Activity Block?
According to WFMC, an Activity Block is defined as:
|
"A set of activities within a process definition which share one or more common properties which cause the workflow management software to take certain actions with respect to the block in total.. For example a group of activities may be classified as a block if they require a common resource allocation policy."
|
It means that an activity block is a block or group of some activities, which are treated as one unit by the workflow management system. These activities inside an activity block also share one or more common properties with each other.
How to Retrieve Activity Blocks in a Process?
Using the simplest API of Aspose.Workflow , developers can retrieve all activity blocks included in a workflow process. To do so, first log on to Aspose.Workflow engine and then just follow the steps below:
- Create a reference of IPackageAdmin interface using PackageAdmin property of IEngine object
- Pass the ID of any desired workflow package to the GetPackage method of the IPackageAdmin object to obtain the reference of that specified package. GetPackage creates the reference of IPackage interface
- Use GetProcess method of the IPackage object and pass the ID of the desired process to GetProcess method as a parameter. Then an instance of IProcess interface containing the process definitions of that specific process, is returned by GetProcess method
- Once the object of desired process (IProcess) is obtained then use ActivityBlocks property of the IProcess object. ActivityBlocks property will return all activity blocks (in the form of an array of IActivityBlock interface, which represents an activity block in Aspose.Workflow) present in that workflow process.
Afterwards, developers can iterate through all activity blocks of the workflow process to retrieve information about all those activities which are the part of each activity block. And this can be done by using Activities property of each instance of IActivityBlock.
The implementation of above steps is shown below in an example.
Example:
[C#]
//Instantiate an object of EngineManager
EngineManager manager = EngineManager.Instance;
//Configure the EngineManager object
manager.Configure();
//Create an object of IEngine interface
IEngine engine = manager.Engine;
//Login to the Aspose.Workflow engine
engine.Login("aspose","aspose");
//Create an instance of IPackageAdmin interface
IPackageAdmin packageAdmin = engine.PackageAdmin;
//Storing the package ID
string packageID="ContractPackage";
//Getting the reference of the package using its ID
IPackage package = packageAdmin.GetPackage(packageID);
//Getting the instance of a specified process in the package
IProcess process=package.GetProcess("DemoProcess");
//Iterating through all activity blocks in the workflow process
foreach(IActivityBlock aBlock in process.ActivityBlocks)
{
//Retrieving the activities that are the part of an activity block
IActivity[] activities=aBlock.Activities;
}
[VB.NET]
'Instantiate an object of EngineManager
Dim manager As EngineManager = EngineManager.Instance
'Configure the EngineManager object
manager.Configure()
'Create an object of IEngine interface
Dim engine As IEngine = manager.Engine
'Login to the Aspose.Workflow engine
engine.Login("aspose","aspose")
'Create an instance of IPackageAdmin interface
Dim packageAdmin As IPackageAdmin = engine.PackageAdmin
'Storing the package ID
Dim packageID As String = "ContractPackage"
'Getting the reference of the package using its ID
Dim package As IPackage = packageAdmin.GetPackage(packageID)
'Getting the instance of a specified process in the package
Dim process As IProcess = package.GetProcess("DemoProcess")
'Iterating through all activity blocks in the workflow process
Dim aBlock As IActivityBlock
For Each aBlock In process.ActivityBlocks
'Retrieving the activities that are the part of an activity block
Dim activities() As IActivity = aBlock.Activities
Next