Using Aspose.Workflow, developers can easily obtain a list of all tasks pending on a specific user. This feature helps to track that which tasks are initiated by which users. Moreover, all information related to these tasks can also be retrieved.
How Does It Work?
First of all, to retrieve a list of all tasks for a particular user, it is required to log on to Aspose.Workflow engine using the user credentials of that user. And these user credentials include User Name and Password, which are passed to Login method of IEngine interface for connecting to Aspose.Workflow engine.
After a successful login to engine, you can call GetAllTasks method of the IEngine.Worklist object. This method will return all pending tasks for that user as an array of ITask interface.
Note: In Aspose.Workflow, ITask interface represents a workflow task.
Developers can iterate through the array of all tasks retrieved from the worklist. Each task in the array is represented by an object of ITask interface. Once an object of ITask is obtained, you can easily use the properties offered by the ITask to retrieve all information associated to that task. For example, you can use the following properties of ITask:
- Id , provides the ID of the specific task
- Name , provides the name of the specific task
- Activity , provides the activity related to the specific task
- State , provides the current state of the specific task
Please review the example below to access all workflow tasks in a worklist.
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 as a user "foo"
engine.Login("foo","bar");
//Getting all tasks pending on the user "foo"
ITask[] tasks = engine.Worklist.GetAllTasks();
//Iterating through all tasks
foreach(ITask task in tasks)
{
//Accessing the task ID
string taskId=task.Id;
//Accessing the task name
string taskName=task.Name;
//Accessing the activity related to the specific task
IActivity activity=task.Activity;
//Accessing the state of the task
string taskState=task.State;
}
[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 as a user "foo"
engine.Login("foo","bar")
'Getting all tasks pending on the user "foo"
Dim tasks() As ITask = engine.Worklist.GetAllTasks()
'Iterating through all tasks
Dim task As ITask
For Each task In tasks
'Accessing the task ID
Dim taskId As String = task.Id
'Accessing the task name
Dim taskName As String = task.Name
'Accessing the activity related to the specific task
Dim activity As IActivity = task.Activity
'Accessing the state of the task
Dim taskState As String = task.State
Next