ProConcepts Workflow Manager - Esri/arcgis-pro-sdk GitHub Wiki
The ArcGIS.Desktop.Workflow.Client namespace provides access to classes and members that allow you to to extend Workflow Manager functionality.
ArcGIS.Desktop.Workflow.Client.dll
Language: C#
Subject: Workflow Manager
Contributor: ArcGIS Pro SDK Team <[email protected]>
Organization: Esri, http://www.esri.com
Date: 10/06/2024
ArcGIS Pro: 3.4
Visual Studio: 2022
A workflow connection provides access job information within Workflow Manager server.
A prerequisite to using the Workflow Manager ArcGIS Pro SDK is that the workflow connection must be set up in the project in advance. For more information on how to configure a workflow connection, see Workflow connection.
An ArcGIS Pro project only supports one workflow connection at a time. The active workflow connection item id and server url can be accessed directly using the ItemId
and ServerUrl
properties from the WorkflowClientModule
class.
For more information on Workflow Manager, see An introduction to ArcGIS Workflow Manager.
For an example using the Workflow Manager Pro SDK in a Pro Add-In, see Workflow Manager ArcGIS Pro Add-In Sample.
The JobsManager
class provides access to the job information within Workflow Manager. A Job
is an object representing a single unit of work that is carried out within an organization. For information on creating jobs, see Create jobs, which uses a job template to configure a job with the desired properties and components (such as the Workflow and Maps).
// Get the job id associated with the active map view
await QueuedTask.Run(() =>
{
// This assumes there is already an active Workflow Manager connection and a job is associated with the active map view
var jobId = WorkflowClientModule.JobsManager.GetJobId();
}
Search for Workflow Manager jobs based on criteria such as who the job is assigned to or the priority of the job. Searches can be run by using the JobsManager
class method SearchJobs
.
// Search for jobs
QueuedTask.Run(() =>
{
var search = new SearchQuery()
{
// Search for open jobs assigned to the current user
Q = "\"assignedType='User' AND closed=0 AND assignedTo='\" + $currentUser + \"' \"",
Fields = new List<string> { "jobId", "jobName", "assignedTo", "dueDate"},
// Sort by job name in ascending order
SortFields = new List<SearchSortField>{ new SearchSortField() { FieldName = "jobName", SortOrder = SortOrder.Asc }}
};
var searchResults = WorkflowClientModule.JobsManager.SearchJobs(search);
var fields = searchResults.Fields;
var results = searchResults.Results;
});
For more information on finding jobs, see Find and run jobs.
Get statistics for jobs in the system. Get a count of total records that match the query results. Job statistics can be run by using the JobsManager
class method CalculateJobStatistics
.
// Get the number of jobs that match a criteria
QueuedTask.Run(() =>
{
var query = new JobStatisticsQuery()
{
// Get high priority jobs
Q = "\"assignedType='User' AND closed=0 AND assignedTo='\" + $currentUser + \"' \" + \" AND priority='High'\""
};
var numJobs = WorkflowClientModule.JobsManager.CalculateJobStatistics(query).Total;
});
A job is a single unit of work in the Workflow Manager system. In some organizations, a job may be known as a work order or a task. It can be assigned to a person, many people, or a group, and scheduled for completion by a certain date. It includes the workflow steps to complete and the job's details, outlining its scope. It can also contain additional help for completing steps, attachments, the job's location, and associations to spatial data. Many jobs of the same type can be created in the system.
Get the details of a job by jobId.
// Get the details of a job
QueuedTask.Run(() =>
{
// Get all details of a job including extended properties and hold information
var job = WorkflowClientModule.JobsManager.GetJob("job1", true, true);
});
For more information on finding and accessing job properties, see Find and run jobs and Manage job properties.
Run, stop and complete steps in a job. A step can be run, stopped or completed if the job is assigned to the current user, the job does not have an active hold and the job is not closed.
await QueuedTask.Run(() =>
{
// This assumes there is already an active Workflow Manager connection
// Start running a job. This will run the current step(s) in the workflow.
WorkflowClientModule.JobsManager.RunSteps(jobId);
// Stop any currently running step(s) on the job.
WorkflowClientModule.JobsManager.StopSteps(jobId);
// Finish work on current step(s) on a job and move on to the next step(s)
WorkflowClientModule.JobsManager.FinishSteps(jobId);
}
For more information on running jobs, refer to Work on jobs and Find and run jobs.
When interacting with Workflow Manager in ArcGIS Pro, certain events are triggered. To listen to an event, subscribe to that event using an event handler. Unsubscribe to an event using the subscription token provided when subscribing to the event.
The WorkflowConnectionChangedEvent
triggers when a user switches between workflow items.
var subscriptionToken = WorkflowConnectionChangedEvent.Subscribe(e =>
{
// Get the user's sign in status
var isUserSignedIn = e.IsSignedIn;
// Additional processing logic here...
// Finish executing the Task for the triggered event
return Task.CompletedTask;
});
// When you're done listening for WorkflowConnectionChangedEvents, unsubscribe from the event
WorkflowConnectionChangedEvent.Unsubscribe(subscriptionToken);