Skip to content

ProConcepts Workflow Manager

UmaHarano edited this page May 6, 2024 · 5 revisions

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 <arcgisprosdk@esri.com>
Organization:  Esri, http://www.esri.com
Date:          04/04/2024
ArcGIS Pro:    3.3
Visual Studio: 2022

In this topic

Workflow connection

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.

Jobs Manager

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();
}

Searches

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.

Job Statistics

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;
});

Job

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 Job

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 Jobs

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.

Events

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.

Workflow Connection Changed 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);

Developing with ArcGIS Pro

    Migration


Framework

    Add-ins

    Configurations

    Customization

    Styling


Arcade


Content


CoreHost


DataReviewer


Editing


Geodatabase

    3D Analyst Data

    Plugin Datasources

    Topology

    Object Model Diagram


Geometry

    Relational Operations


Geoprocessing


Knowledge Graph


Layouts

    Reports


Map Authoring

    3D Analyst

    CIM

    Graphics

    Scene

    Stream

    Voxel


Map Exploration

    Map Tools


Networks

    Network Diagrams


Parcel Fabric


Raster


Sharing


Tasks


Workflow Manager Classic


Workflow Manager


Reference

Clone this wiki locally