/// <summary> /// This command shows how to add existing Batch Jobs to the current project. /// In this example you can browse and select multiple Reviewer Batch Jobs to add those to the current project. /// If the selected batch jobs contain any invalid batch jobs, those batch jobs will be reported to the user. /// </summary> /// <returns></returns> internal static async Task AddBatchJobs_Advanced() { try { //Step 1: Browse to select one or multiple batch jobs and get their path IEnumerable <string> rbjPaths = OpenBrowseBatchJobFileDialog(); if (null == rbjPaths || rbjPaths.Count() < 1) { return; } string strInvalidBatchJobs = ""; int invalidRbjCount = 0; await QueuedTask.Run(() => { foreach (string rbjPath in rbjPaths) { try { //Step 2: Create Reviewer BatchJobItems //This is done inside a try-catch so that you can Skip invalid batch jobs and continue with valid batch jobs IProjectItem rbjItem = DataReviewerModule.CreateBatchJobProjectItem(rbjPath); if (null != rbjItem) { //Step 3: Add BatchJobItems to the current project Project.Current.AddItem(rbjItem as IProjectItem); ReviewerBatchJobProjectItem rbjProjectItem = rbjItem as ReviewerBatchJobProjectItem; //Step 3: Add BatchJobItems to the gallery if (null != rbjProjectItem) { GalleryItemsChangedEvent.Publish(new GalleryItem(rbjProjectItem.TypeID, rbjProjectItem.Path, rbjProjectItem.Name), true); } } } catch (Exception) { //Exception for invalid batch job //Create a string to report invalid Batch Jobs invalidRbjCount++; strInvalidBatchJobs = strInvalidBatchJobs + "{0}" + invalidRbjCount.ToString() + ". " + rbjPath; } } }); //Display error message for invalid Batch Jobs if (invalidRbjCount > 0) { MessageBox.Show(string.Format("Selected Batch Jobs contain following invalid Batch Jobs :" + strInvalidBatchJobs, Environment.NewLine) + Environment.NewLine + "These Batch Jobs are not added to the project.", "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); } }
/// <summary> /// This command shows how to add a connection to Reviewer Results which are stored in an existing Reviewer workspace. /// In this example you can browse to a Reviewer workspace /// </summary> /// <returns></returns> internal static async Task AddReviewerResults_Advanced() { try { // You can add only one ResultsProjectItem connection to a project // If FrameworkApplication contains esri_datareviewer_addReviewerWorkspaceSettingState state that means the ResultsProjectItem is already added therefore no need to do anything if (FrameworkApplication.State.Contains(Constants.CanAddReviewerResultsState)) { MessageBox.Show("Data Reviewer results have already been added to the project.", "Warning", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning); return; } //Step 1: Browse to a Reviewer Workspace and get its path string strReviewerResultsWorkspacePath = OpenBrowseGeodatabaseDialog(); if (string.IsNullOrEmpty(strReviewerResultsWorkspacePath)) { return; } IProjectItem reviewerResultProjectItem = null; await QueuedTask.Run(() => { //Step 2: Check if the Reviewer workspace contains current Reviewer dataset. if (DataReviewerModule.HasValidReviewerDataset(strReviewerResultsWorkspacePath)) { //Step 3: Create the Reviewer ResultsItem reviewerResultProjectItem = DataReviewerModule.CreateResultsProjectItem(strReviewerResultsWorkspacePath); } else { MessageBox.Show("The geodatabase specified does not contain a current Reviewer dataset.", "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); } //Step 4: Add ResultsItem to the current project if (null != reviewerResultProjectItem) { Project.Current.AddItem(reviewerResultProjectItem); } }); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); } }
/// <summary> /// This command shows how to add a connection to Reviewer Results which are stored in an existing Reviewer workspace. /// In this example you can browse to a Reviewer workspace /// </summary> /// <returns></returns> internal static async Task AddReviewerResults_Advanced() { try { //Step 1: Browse to a Reviewer Workspace and get its path string strReviewerResultsWorkspacePath = OpenBrowseGeodatabaseDialog(); if (string.IsNullOrEmpty(strReviewerResultsWorkspacePath)) { return; } Item reviewerResultItem = null; await QueuedTask.Run(() => { //Step 2: Check if the Reviewer workspace contains current Reviewer dataset. if (DataReviewerModule.HasValidReviewerDataset(strReviewerResultsWorkspacePath)) { //Step 3: Create the Reviewer ResultsItem reviewerResultItem = DataReviewerModule.CreateResultsItem(strReviewerResultsWorkspacePath); } else { MessageBox.Show("The geodatabase specified does not contain a current Reviewer dataset.", "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); } }); //Step 4: Add ResultsItem to the current project // You can add only one ResultsItem connection to a project // Project.Current.CanAdd will return false, if you already have a connection to ResultsItem in the current project if (null != reviewerResultItem && Project.Current.CanAdd(reviewerResultItem)) { await Project.Current.AddAsync(reviewerResultItem); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); } }