public async void OpenTask() { #region Retrieve all the Task Items in a Project IEnumerable <TaskProjectItem> taskItems = Project.Current.GetItems <TaskProjectItem>(); foreach (var item in taskItems) { // do something } #endregion #region Open a Task File (*.esriTasks) // Open a task file try { // TODO - substitute your own .esriTasks file to be opened string taskFile = @"c:\Tasks\Get Started.esriTasks"; System.Guid guid = await TaskAssistantModule.OpenTaskAsync(taskFile); // TODO - retain the guid returned for use with CloseTaskAsync } catch (OpenTaskException e) { // exception thrown if task file doesn't exist or has incorrect format ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(e.Message); } #endregion #region Open a Project Task Item // 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 System.Guid guid = await TaskAssistantModule.OpenTaskItemAsync(taskItem.TaskItemGuid); // TODO - retain the guid returned for use with CloseTaskAsync } catch (OpenTaskException e) { ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(e.Message); } #endregion }
protected override async void OnClick() { // pass an .esriTasks File and it will be added to project and loaded in the Tasks pane try { Guid guid = await TaskAssistantModule.OpenTaskAsync(@"\\sbe1\solutions\Tasks\Get Started.esriTasks"); // keep the guid for CloseTaskAsync Module1.Current.taskGuid = guid; } catch (OpenTaskException e) { ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(e.Message); } }
public async Task MainMethodCode() { // Open a task file try { // TODO - substitute your own .esriTasks file to be opened System.Guid guid = await TaskAssistantModule.OpenTaskAsync(@"c:\Tasks\Get Started.esriTasks"); // TODO - retain the guid returned for use with CloseTaskAsync } catch (OpenTaskException e) { // exception thrown if task file doesn't exist or has incorrect format ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(e.Message); } }
public async void OpenSpecificTask() { #region Open a specific Task in a Task File (.esriTasks) // TODO - substitute your own .esriTasks file to be opened string taskFile = @"c:\Tasks\Get Started.esriTasks"; try { // retrieve the task item information TaskItemInfo taskItemInfo = await TaskAssistantModule.GetTaskItemInfoAsync(taskFile); // find the first task TaskInfo taskInfo = taskItemInfo.GetTasks().FirstOrDefault(); Guid guid = Guid.Empty; if (taskInfo != null) { // if a task exists, open it guid = await TaskAssistantModule.OpenTaskAsync(taskFile, taskInfo.Guid); } else { // else just open the task item guid = await TaskAssistantModule.OpenTaskAsync(taskFile); } // TODO - retain the guid returned for use with CloseTaskAsync } catch (OpenTaskException e) { // exception thrown if task file doesn't exist or has incorrect format ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(e.Message); } catch (TaskFileVersionException e) { // exception thrown if task file does not support returning task information ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(e.Message); } #endregion }
protected override async void OnClick() { // pass an .esriTasks File and it will be added to project and loaded in the Tasks pane try { string taskFile = @"c:\Tasks\Project Exploration Tasks.esriTasks"; if (!System.IO.File.Exists(taskFile)) { ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Cannot find file " + taskFile + ". Check file location."); return; } Guid guid = await TaskAssistantModule.OpenTaskAsync(taskFile); // keep the guid for CloseTaskAsync Module1.Current.taskGuid = guid; } catch (OpenTaskException e) { ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show(e.Message); } }