/// <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 = ReviewerUtil.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 the basic functionality of how to add a connection to Reviewer Results which are stored in an existing Reviewer workspace. /// </summary> /// <returns></returns> internal static async Task AddReviewerResults_Basic() { 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; } //Get the data folder path string dataRootPath = @"C:\Data\DataReviewer"; //Get path of the Reviewer Workspace string strReviewerResultsWorkspacePath = System.IO.Path.Combine(dataRootPath, "ReviewerWorkspace.gdb"); if (!System.IO.Directory.Exists(strReviewerResultsWorkspacePath)) { MessageBox.Show("Unable to locate " + strReviewerResultsWorkspacePath + " geodatabase", "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); return; } IProjectItem reviewerResultProjectItem = null; await QueuedTask.Run(() => { //Step 1: First check if the Reviewer workspace contains current Reviewer dataset. if (ReviewerUtil.HasValidReviewerDataset(strReviewerResultsWorkspacePath)) { //Step 2: Create the Reviewer ResultsItem reviewerResultProjectItem = ReviewerUtil.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 3: Add ResultsItem to the current project if (null != reviewerResultProjectItem) { try { bool itemAdded = Project.Current.AddItem(reviewerResultProjectItem); } catch (Exception ex1) { MessageBox.Show(ex1.Message, "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 the basic functionality of how to add existing Batch Jobs to the current project. /// In this example we will add 3 batch jobs in the current project /// The path of these batch jobs is defined in the Constants.cs. Update these values as per the local path on your machine. /// </summary> /// <returns></returns> internal static async Task AddBatchJobs_Basic() { try { //Get the data folder path string dataRootPath = @"C:\Data\DataReviewer"; //Step 1: Create Reviewer BatchJobItems string batchJob1, batchJob2, batchJob3; batchJob1 = System.IO.Path.Combine(dataRootPath, "Parcel Validation.rbj"); batchJob2 = System.IO.Path.Combine(dataRootPath, "Point Validation.rbj"); batchJob3 = System.IO.Path.Combine(dataRootPath, "Attribute Validation.rbj"); if (!System.IO.File.Exists(batchJob1) || !System.IO.File.Exists(batchJob2) || !System.IO.File.Exists(batchJob3)) { MessageBox.Show("Batch Job files are not found", "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); return; } IProjectItem reviewerBatchJobProjectItem1 = null; IProjectItem reviewerBatchJobProjectItem2 = null; IProjectItem reviewerBatchJobProjectItem3 = null; await QueuedTask.Run(() => { reviewerBatchJobProjectItem1 = ReviewerUtil.CreateBatchJobProjectItem(batchJob1); reviewerBatchJobProjectItem2 = ReviewerUtil.CreateBatchJobProjectItem(batchJob2); reviewerBatchJobProjectItem3 = ReviewerUtil.CreateBatchJobProjectItem(batchJob3); //Step 2: Add BatchJobItems to the current project if (null != reviewerBatchJobProjectItem1) { Project.Current.AddItem(reviewerBatchJobProjectItem1); } if (null != reviewerBatchJobProjectItem2) { Project.Current.AddItem(reviewerBatchJobProjectItem2); } if (null != reviewerBatchJobProjectItem3) { Project.Current.AddItem(reviewerBatchJobProjectItem3); } }); } 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 (ReviewerUtil.HasValidReviewerDataset(strReviewerResultsWorkspacePath)) { //Step 3: Create the Reviewer ResultsItem reviewerResultProjectItem = ReviewerUtil.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); } }