Accessing Activity Instances via API (SourceCode.Workflow.Client or SourceCode.Workflow.Management)

  • 3 May 2017
  • 1 reply
  • 24 views

Is there a way to access activity instance information via the Client or Management APIs? All I can find is process instance info, which only references activites and not their instances. What I want to do is query a list of all activity instances given a process instance ID so I can call GotoActivity on any Waiting instances and pick up changes to the activity start time. I know you can get this information via the 'Activity Instance' smartobject that uses the 'Workflow Reporting Service', but I would rather use direct Client or Management API calls rather than redirect through the smartobject API if possible.


1 reply

Badge +4

There are 2 ways you can retrieve list of activity... See the sample code below

 

 

I have create a service object that has all different methods. I can attache DLL for you. (if you want). Deploy it to ServiceBroker in your environment and create a smartobject on top of that. It has all build it method for admin to do.

 

 

##############List activity by Process Name#############

private void ListActivitiesByProcessFullName(string processFullName)
{
string ConnectionString = this.Service.ServiceConfiguration["ConnectionString"].ToString();

WorkflowManagementServer wms = new WorkflowManagementServer();
wms.CreateConnection();
wms.Connection.Open(ConnectionString);
ServiceObject svo = this.Service.ServiceObjects[0];
svo.Properties.InitResultTable();
ProcessCriteriaFilter pcf = new ProcessCriteriaFilter();
pcf.AddRegularFilter(ProcessFields.ProcessFullName, Comparison.Equals, (string)processFullName);
Processes p = wms.GetProcesses(pcf);
Activities activities = wms.GetProcActivities(p[0].ProcID);

for (int i = 0; i < activities.Count; i++)
{
svo.Properties["ActivityName"].Value = activities.Name;
svo.Properties.BindPropertiesToResultTable();
}

wms.Connection.Close();
}

 

 

 

##############List activity by Process ID#############

private void ListActivitiesByProcessID(int processID)
{
string ConnectionString = this.Service.ServiceConfiguration["ConnectionString"].ToString();

WorkflowManagementServer wms = new WorkflowManagementServer();
wms.CreateConnection();
wms.Connection.Open(ConnectionString);
ServiceObject svo = this.Service.ServiceObjects[0];
svo.Properties.InitResultTable();
Activities activities = wms.GetProcActivities(processID);

for (int i = 0; i < activities.Count; i++)
{
svo.Properties["ActivityName"].Value = activities.Name;
svo.Properties.BindPropertiesToResultTable();
}

wms.Connection.Close();
}

Reply