Beispiel #1
0
        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
            var listVersionsTask = await GeoprocessingTask.CreateAsync(ListVersionsUrl);

            // Create parameters that are passed to the used geoprocessing task
            GeoprocessingParameters listVersionsParameters =
                new GeoprocessingParameters(GeoprocessingExecutionType.SynchronousExecute);

            // Create job that handles the communication between the application and the geoprocessing task
            var listVersionsJob = listVersionsTask.CreateJob(listVersionsParameters);

            try
            {
                // Execute analysis and wait for the results
                GeoprocessingResult analysisResult = await listVersionsJob.GetResultAsync();

                // Get results from the outputs
                GeoprocessingFeatures listVersionsResults = analysisResult.Outputs["Versions"] as GeoprocessingFeatures;

                // 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();
                    alert.Message = "Executing geoprocessing failed. " + listVersionsJob.Error.Message;
                    alert.ShowViewController(this, this);
                }
                else
                {
                    UIAlertController alert = new UIAlertController();
                    alert.Message = "An error occurred. " + ex.ToString();
                    alert.ShowViewController(this, this);
                }
            }
            finally
            {
                // Set the UI to indicate that the geoprocessing is not running
                SetBusy(false);
            }

            return(results);
        }