private async Task<IFeatureSet> GetGeodatabaseVersionsAsync()
{
// Results will be returned as a feature set
IFeatureSet results = null;
// Create new geoprocessing task
var listVersionsTask = new GeoprocessingTask(new Uri(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)
{
var message = new MessageDialog("Executing geoprocessing failed. " + listVersionsJob.Error.Message, "Geoprocessing error");
await message.ShowAsync();
}
else
{
var message = new MessageDialog("An error occurred. " + ex.ToString(), "Sample error");
await message.ShowAsync();
}
}
finally
{
// Set the UI to indicate that the geoprocessing is not running
SetBusy(false);
}
return results;
}