-
Notifications
You must be signed in to change notification settings - Fork 119
ProConcepts Tasks
The ArcGIS.Desktop.TaskAssistant namespace provides access to the classes and members that offer the ability to access, open, close or export task items.
ArcGIS.Desktop.TaskAssistant.dll
Language: C#
Subject: Tasks
Contributor: ArcGIS Pro SDK Team <[email protected]>
Organization: Esri, http://www.esri.com
Date: 12/21/2022
ArcGIS Pro: 3.1
Visual Studio: 2022
A project can contain multiple task items, and each item defines a collection of tasks. A task is a set of preconfigured steps that represents a workflow or business process. A task can be used to implement a best-practice workflow, improve the efficiency of a workflow, or create a series of interactive tutorial steps.
You retrieve the task items in a project using the Project.Current.GetItems
method:
IEnumerable<TaskProjectItem> taskItemss = Project.Current.GetItems<TaskProjectItem>();
A TaskProjectItem
has all the methods and properties inherited from its parent ArcGIS.Desktop.Core.Item
. It also has two additional properties, TaskItemGuid
and IsOpen
. The TaskItemGuid
property returns the unique GUID of the task item and is passed as the parameter to the OpenTaskItemAsync
, CloseTaskItemAsync
, and ExportTaskItemAsync
methods. IsOpen
is used to determine the task item currently open in the Tasks pane.
// get the first project task item
var taskItem = Project.Current.GetItems<TaskProjectItem>().FirstOrDefault();
// if there isn't a project task item, return
if (taskItem == null)
return;
try
{
// Open it
// At 2.x
//System.Guid guid = await TaskAssistantModule.OpenTaskItemAsync(taskItem.TaskItemGuid);
var guid = await TaskAssistantFactory.Instance.OpenTaskItemAsync(taskItem.TaskItemGuid);
}
catch (OpenTaskException e)
{
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(e.Message);
}
A task item is shared by exporting the task item to an .esriTasks file. An .esriTasks file can be imported and opened in a different project.
Use the static ExportTaskItemAsync
method to export a task item. ExportTaskException
is in the ArcGIS.Desktop.TaskAssistant.Exceptions namespace.
// Get the first project task item
var taskItem = Project.Current.GetItems<TaskProjectItem>().FirstOrDefault();
// If there isn't a project task item, return
if (taskItem == null)
return;
try
{
// Export the task item to the c:\Temp folder
string exportFolder = @"c:\temp";
//At 2.x
//string fileName = await TaskAssistantModule.ExportTaskAsync(taskItem.TaskItemGuid, exportFolder);
string fileName = await TaskAssistantFactory.Instance.ExportTaskItemAsync(taskItem.TaskItemGuid, exportFolder);
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Task saved to " + fileName);
}
catch (ExportTaskException e)
{
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Error saving task " + e.Message);
}
Use the static OpenTaskFileAsync
method to import and open an .esriTasks file. OpenTaskException
is in the ArcGIS.Desktop.TaskAssistant.Exceptions namespace.
// Open a task file
try
{
// substitute your own .esriTasks file to be opened
// retain the taskItem guid returned
string taskFile = @"c:\Tasks\Get Started.esriTasks";
//At 2.x
//System.Guid guid = await TaskAssistantModule.OpenTaskAsync(taskFile);
System.Guid guid = await TaskAssistantFactory.Instance.OpenTaskFileAsync(taskFile);
}
catch (OpenTaskException e)
{
// exception thrown if task file doesn't exist or has incorrect format
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(e.Message);
}
Retrieve information from a task item using the GetTaskItemInfoAsync
method available off the TaskProjectItem
object. You can obtain the Name, Description and Guid of the task item along with information about the tasks within the task item. This can be useful if you want to open a specific task within a task item.
// find the first task item in the project
var taskItem = Project.Current.GetItems<TaskProjectItem>().FirstOrDefault();
// if there isn't a project task item, return
if (taskItem == null)
return;
string message = await QueuedTask.Run(async () =>
{
bool isOpen = taskItem.IsOpen;
Guid taskGuid = taskItem.TaskItemGuid;
string msg = "";
try
{
TaskItemInfo taskItemInfo = await taskItem.GetTaskItemInfoAsync();
msg = "Name : " + taskItemInfo.Name;
msg += "\r\n" + "Description : " + taskItemInfo.Description;
msg += "\r\n" + "Guid : " + taskItemInfo.Guid.ToString("B");
msg += "\r\n" + "Task Count : " + taskItemInfo.GetTasks().Count();
// iterate the tasks in the task item
IEnumerable<TaskInfo> taskInfos = taskItemInfo.GetTasks();
foreach (TaskInfo taskInfo in taskInfos)
{
string name = taskInfo.Name;
Guid guid = taskInfo.Guid;
// do something
}
}
catch (OpenTaskException e)
{
// exception thrown if task file doesn't exist or has incorrect format
msg = e.Message;
}
catch (TaskFileVersionException e)
{
// exception thrown if task file does not support returning task information
msg = e.Message;
}
return msg;
});
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(message, "Task Information");
You can obtain the same information from an .esriTasks file using the static GetTaskItemInfoAsync
method from the TaskAssistantFactory object.
Tasks supports two events; TaskStartedEvent
and TaskEndedEvent
. The TaskStartedEvent is raised when execution of a task commences; the TaskEndedEvent is raised when execution of a task is completed or cancelled. TaskStartedEvent
and TaskEndedEvent
are in the ArcGIS.Desktop.TaskAssistant.Events namespace.
public void MainMethodCode()
{
TaskStartedEvent.Subscribe(OnTaskStarted);
TaskEndedEvent.Subscribe(OnTaskCompletedOrCancelled);
}
private void OnTaskStarted(TaskStartedEventArgs args)
{
// do something
// TaskStartedEventArgs contains information regarding the task
// item and task that was commenced including the UserID who
// executed the task and start time.
}
private void OnTaskCompletedOrCancelled(TaskEndedEventArgs args)
{
// do something
// TaskEndedEventArgs contains information regarding the task
// item and task that was ended including whether the task was
// completed or cancelled, the UserID who executed the task,
// start time, end time, duration.
}
Home | API Reference | Requirements | Download | Samples
- Overview of the ArcGIS Pro SDK
- What's New for Developers at 3.4
- Installing ArcGIS Pro SDK for .NET
- Release notes
- Resources
- Pro SDK Videos
- ProSnippets
- ArcGIS Pro API
- ProGuide: ArcGIS Pro Extensions NuGet
Migration
- ProSnippets: Framework
- ProSnippets: DAML
- ProConcepts: Framework
- ProConcepts: Asynchronous Programming in ArcGIS Pro
- ProConcepts: Advanced topics
- ProGuide: Custom settings
- ProGuide: Command line switches for ArcGISPro.exe
- ProGuide: Reusing ArcGIS Pro Commands
- ProGuide: Licensing
- ProGuide: Digital signatures
- ProGuide: Command Search
- ProGuide: Keyboard shortcuts
Add-ins
- ProGuide: Installation and Upgrade
- ProGuide: Your first add-in
- ProGuide: ArcGIS AllSource Project Template
- ProConcepts: Localization
- ProGuide: Content and Image Resources
- ProGuide: Embedding Toolboxes
- ProGuide: Diagnosing ArcGIS Pro Add-ins
- ProGuide: Regression Testing
Configurations
Customization
- ProGuide: The Ribbon, Tabs and Groups
- ProGuide: Buttons
- ProGuide: Label Controls
- ProGuide: Checkboxes
- ProGuide: Edit Boxes
- ProGuide: Combo Boxes
- ProGuide: Context Menus
- ProGuide: Palettes and Split Buttons
- ProGuide: Galleries
- ProGuide: Dockpanes
- ProGuide: Code Your Own States and Conditions
Styling
- ProSnippets: Content
- ProSnippets: Browse Dialog Filters
- ProConcepts: Project Content and Items
- ProConcepts: Custom Items
- ProGuide: Custom Items
- ProGuide: Custom browse dialog filters
- ArcGIS Pro TypeID Reference
- ProSnippets: Editing
- ProConcepts: Editing
- ProConcepts: COGO
- ProConcepts: Annotation Editing
- ProConcepts: Dimension Editing
- ProGuide: Editing Tool
- ProGuide: Sketch Tool With Halo
- ProGuide: Construction Tools with Options
- ProGuide: Annotation Construction Tools
- ProGuide: Annotation Editing Tools
- ProGuide: Knowledge Graph Construction Tools
- ProGuide: Templates
3D Analyst Data
Plugin Datasources
Topology
Linear Referencing
Object Model Diagram
- ProSnippets: Geometry
- ProSnippets: Geometry Engine
- ProConcepts: Geometry
- ProConcepts: Multipatches
- ProGuide: Building Multipatches
Relational Operations
- ProSnippets: Knowledge Graph
- ProConcepts: Knowledge Graph
- ProGuide: Knowledge Graph Construction Tools
Reports
- ProSnippets: Map Authoring
- ProSnippets: Annotation
- ProSnippets: Charts
- ProSnippets: Labeling
- ProSnippets: Renderers
- ProSnippets: Symbology
- ProSnippets: Text Symbols
- ProConcepts: Map Authoring
- ProConcepts: Annotation
- ProConcepts: Dimensions
- ProGuide: Tray buttons
- ProGuide: Custom Dictionary Style
- ProGuide: Geocoding
3D Analyst
CIM
Graphics
Scene
Stream
Voxel
- ProSnippets: Map Exploration
- ProSnippets: Custom Pane with Contents
- ProConcepts: Map Exploration
- ProGuide: Map Pane Impersonation
- ProGuide: TableControl
Map Tools
- ProGuide: Feature Selection
- ProGuide: Identify
- ProGuide: MapView Interaction
- ProGuide: Embeddable Controls
- ProGuide: Custom Pop-ups
- ProGuide: Dynamic Pop-up Menu
Network Diagrams
- ArcGIS Pro API Reference Guide
- ArcGIS Pro SDK (pro.arcgis.com)
- arcgis-pro-sdk-community-samples
- ArcGISPro Registry Keys
- ArcGIS Pro DAML ID Reference
- ArcGIS Pro Icon Reference
- ArcGIS Pro TypeID Reference
- ProConcepts: Distributing Add-Ins Online
- ProConcepts: Migrating to ArcGIS Pro
- FAQ
- Archived ArcGIS Pro API Reference Guides
- Dev Summit Tech Sessions