private async Task <IFeatureSet> GetGeodatabaseVersionsAsync() { // Start animating the activity indicator. _progressBar.StartAnimating(); // Results will be returned as a feature set. IFeatureSet results = null; // Create new geoprocessing task. GeoprocessingTask listVersionsTask = await GeoprocessingTask.CreateAsync(_listVersionsUrl); // Create default parameters that are passed to the geoprocessing task. GeoprocessingParameters listVersionsParameters = await listVersionsTask.CreateDefaultParametersAsync(); // Create job that handles the communication between the application and the geoprocessing task. GeoprocessingJob listVersionsJob = listVersionsTask.CreateJob(listVersionsParameters); try { // Execute analysis and wait for the results. GeoprocessingResult analysisResult = await listVersionsJob.GetResultAsync(); // Get results from the outputs. GeoprocessingFeatures listVersionsResults = (GeoprocessingFeatures)analysisResult.Outputs["Versions"]; // Set results. results = listVersionsResults.Features; } catch (Exception ex) { // Error handling if something goes wrong. if (listVersionsJob.Status == JobStatus.Failed && listVersionsJob.Error != null) { UIAlertController alert = new UIAlertController { Message = "Executing geoprocessing failed. " + listVersionsJob.Error.Message }; alert.ShowViewController(this, this); } else { UIAlertController alert = new UIAlertController { Message = "An error occurred. " + ex }; alert.ShowViewController(this, this); } } finally { // Stop the activity animation. _progressBar.StopAnimating(); } return(results); }
private async Task <IFeatureSet> GetGeodatabaseVersionsAsync() { // Results will be returned as a feature set IFeatureSet results = null; // Create new geoprocessing task GeoprocessingTask listVersionsTask = await GeoprocessingTask.CreateAsync(new Uri(ListVersionsUrl)); // Create default parameters that are passed to the geoprocessing task GeoprocessingParameters listVersionsParameters = await listVersionsTask.CreateDefaultParametersAsync(); // Create job that handles the communication between the application and the geoprocessing task GeoprocessingJob listVersionsJob = listVersionsTask.CreateJob(listVersionsParameters); try { // Execute analysis and wait for the results GeoprocessingResult analysisResult = await listVersionsJob.GetResultAsync(); // Get results from the outputs GeoprocessingFeatures listVersionsResults = (GeoprocessingFeatures)analysisResult.Outputs["Versions"]; // Set results results = listVersionsResults.Features; } catch (Exception ex) { // Error handling if something goes wrong if (listVersionsJob.Status == JobStatus.Failed && listVersionsJob.Error != null) { AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this); alertBuilder.SetTitle("Geoprocessing error"); alertBuilder.SetMessage("Executing geoprocessing failed. " + listVersionsJob.Error.Message); alertBuilder.Show(); } else { AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this); alertBuilder.SetTitle("Sample error"); alertBuilder.SetMessage("An error occurred. " + ex.ToString()); alertBuilder.Show(); } } finally { // Set the UI to indicate that the geoprocessing is not running SetBusy(false); } return(results); }