According to WFMC, a Workflow Participant is defined as:
|
"A resource which performs the work represented by a workflow activity instance. This work is normally manifested as one or more work items assigned to the workflow participant via the worklist."
|
All workflow processes have some participants, which are defined by developers in XPDL. After the workflow package is uploaded to Aspose.Workflow engine in the form of an XPDL file, developers can access the participants of all or a specified process defined in a workflow package.
Aspose.Workflow provides IParticipant interface to represent a workflow participant. This interface defines some properties and methods that allows developers to retrieve information about the participants and perform operations on them. In this topic, we will learn that how can we retrieve the participants involved in workflow processes using Aspose.Workflow API.
Accessing the Participants of All Processes in a Package
We know that users may define as many workflow processes as they want in XPDL files. All processes have some participants involved with them. Developers can access the information about all these participants involved in workflow processes using Aspose.Workflow.
Please follow the steps below to access all participants of all workflow processes in a package:
- 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
- Once the reference of your desired package is created, call GetAllProcesses method of the IPackage instance to receive all processes defined in that package as an array of IProcess interface
- Iterate through all processes and use the Participants property of IProcess object to receive an array of all participants involved in that process
Please review the example given below for the demonstration purposes.
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);
//Iterating through all processes of the package
foreach(IProcess process in package.GetAllProcesses())
{
//Retrieving an array of all participants of the process
IParticipant[] participants = process.Participants;
}
[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)
'Iterating through all processes of the package
Dim process As IProcess
For Each process In package.GetAllProcesses()
'Retrieving an array of all participants of the process
Dim participants() As IParticipant = process.Participants
Next
Accessing the Participants of a Specific Process
To access the participants of a specific process in the workflow package, use GetProcess method of the IPackage object instead of calling its GetAllProcesses method. But, you will have to pass the ID of the desired process to GetProcess method as a parameter and then an instance of IProcess interface containing the process definitions of that specific process, will be returned. Use the Participants property of this newly created IProcess instance to receive an array of all participants involved in that specified process. Please check out the code snippet given below for the better understanding.
Example:
[C#]
//Getting a specific process in the package
IProcess process = package.GetProcess("DemoProcess");
//Retrieving an array of all participants of the process
IParticipant[] participants = process.Participants;
[VB.NET]
'Getting a specific process in the package
Dim process As IProcess = package.GetProcess("DemoProcess")
'Retrieving an array of all participants of the process
Dim participants() As IParticipant = process.Participants