private async Task GetServiceInfo() { var t = new Geoprocessor(new Uri(ServiceUri)); string message = null; try { var result = await t.GetServiceInfoAsync(); #region Display Service Info var sb = new StringBuilder(); if (result != null) { sb.Append("{"); sb.AppendLine(string.Format("\t\"name\" : \"{0}\",", result.Name)); sb.AppendLine(string.Format("\t\"displayName\" : \"{0}\",", result.DisplayName)); sb.AppendLine(string.Format("\t\"category\" : \"{0}\",", result.Category)); sb.AppendLine(string.Format("\t\"helpUrl\" : \"{0}\",", result.HelpUrl)); sb.AppendLine(string.Format("\t\"executionType\" : \"esriExecutionType{0}\",", result.ExecutionType)); sb.AppendLine("\t\"parameters\" : ["); foreach (var p in result.Parameters) { sb.AppendLine("\t{"); sb.AppendLine(string.Format("\t\t\"name\" : \"{0}\",", p.Name)); sb.AppendLine(string.Format("\t\t\"dataType\" : \"{0}\",", p.DataType)); sb.AppendLine(string.Format("\t\t\"displayName\" : \"{0}\",", p.DisplayName)); sb.AppendLine(string.Format("\t\t\"direction\" : \"esriGPParameterDirection{0}\",", p.Direction)); sb.AppendLine(string.Format("\t\t\"defaultValue\" : \"{0}\",", p.DefaultValue)); sb.AppendLine(string.Format("\t\t\"parameterType\" : \"esriGPParameterType{0}\",", p.ParameterType)); sb.AppendLine(string.Format("\t\t\"category\" : \"{0}\"", p.Category)); if (p.ChoiceList != null) { sb.AppendLine("\t\t\"choiceList\" : ["); foreach (var c in p.ChoiceList) { sb.AppendLine(string.Format("\t\t\t\"{0}\"", c)); } sb.AppendLine("\t\t\"]"); } sb.AppendLine("\t},"); } sb.AppendLine("\t]"); sb.Append("}"); message = sb.ToString(); } #endregion } catch (Exception ex) { message = ex.Message; } if (message != null) { await new MessageDialog(message, "Service Info").ShowAsync(); } }
// Sets up UI choices from the extract data service information private async Task SetupUI() { try { var info = await _gpTask.GetServiceInfoAsync(); listLayers.ItemsSource = info.Parameters.First(p => p.Name == "Layers_to_Clip").ChoiceList; comboFormat.ItemsSource = info.Parameters.First(p => p.Name == "Feature_Format").ChoiceList; if (comboFormat.ItemsSource != null && comboFormat.Items.Count > 0) { comboFormat.SelectedIndex = 0; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Sample Error"); } }
public ExtractData() { InitializeComponent(); _processingTimer = new System.Windows.Threading.DispatcherTimer(); _processingTimer.Interval = new TimeSpan(0, 0, 0, 0, 800); _processingTimer.Tick += ProcessingTimer_Tick; _geoprocessorTask = new Geoprocessor("http://sampleserver4.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/Incident_Data_Extraction/GPServer/Extract%20Data%20Task"); _geoprocessorTask.GetServiceInfoCompleted += _geoprocessorTask_GetServiceInfoCompleted; _geoprocessorTask.Failed += _geoprocessorTask_Failed; _geoprocessorTask.UpdateDelay = 5000; _geoprocessorTask.JobCompleted += _geoprocessorTask_JobCompleted; _geoprocessorTask.GetResultDataCompleted += _geoprocessorTask_GetResultDataCompleted; _geoprocessorTask.GetServiceInfoAsync(); _drawObject = new Draw(MyMap) { LineSymbol = LayoutRoot.Resources["CustomAnimatedRedLineSymbol"] as LineSymbol, FillSymbol = LayoutRoot.Resources["CustomAnimatedRedFillSymbol"] as FillSymbol }; _drawObject.DrawComplete += MyDrawObject_DrawComplete; _graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; }
public ExtractData() { InitializeComponent(); _processingTimer = new System.Windows.Threading.DispatcherTimer(); _processingTimer.Interval = new TimeSpan(0, 0, 0, 0, 800); _processingTimer.Tick += ProcessingTimer_Tick; _geoprocessorTask = new Geoprocessor("http://sampleserver4.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/Incident_Data_Extraction/GPServer/Extract%20Data%20Task"); _geoprocessorTask.GetServiceInfoCompleted += _geoprocessorTask_GetServiceInfoCompleted; _geoprocessorTask.Failed += _geoprocessorTask_Failed; _geoprocessorTask.UpdateDelay = 5000; _geoprocessorTask.JobCompleted += _geoprocessorTask_JobCompleted; _geoprocessorTask.GetResultDataCompleted += _geoprocessorTask_GetResultDataCompleted; _geoprocessorTask.GetServiceInfoAsync(); _drawObject = new Draw(MyMap) { LineSymbol = LayoutRoot.Resources["CustomAnimatedRedLineSymbol"] as LineSymbol, FillSymbol = LayoutRoot.Resources["CustomAnimatedRedFillSymbol"] as FillSymbol }; _drawObject.DrawComplete += MyDrawObject_DrawComplete; _graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; }
private async Task GetServiceInfo() { var t = new Geoprocessor(new Uri(ServiceUri)); string message = null; try { var result = await t.GetServiceInfoAsync(); #region Display Service Info var sb = new StringBuilder(); if (result != null) { sb.Append("{"); sb.AppendLine(string.Format("\t\"name\" : \"{0}\",", result.Name)); sb.AppendLine(string.Format("\t\"displayName\" : \"{0}\",", result.DisplayName)); sb.AppendLine(string.Format("\t\"category\" : \"{0}\",", result.Category)); sb.AppendLine(string.Format("\t\"helpUrl\" : \"{0}\",", result.HelpUrl)); sb.AppendLine(string.Format("\t\"executionType\" : \"esriExecutionType{0}\",", result.ExecutionType)); sb.AppendLine("\t\"parameters\" : ["); foreach (var p in result.Parameters) { sb.AppendLine("\t{"); sb.AppendLine(string.Format("\t\t\"name\" : \"{0}\",", p.Name)); sb.AppendLine(string.Format("\t\t\"dataType\" : \"{0}\",", p.DataType)); sb.AppendLine(string.Format("\t\t\"displayName\" : \"{0}\",", p.DisplayName)); sb.AppendLine(string.Format("\t\t\"direction\" : \"esriGPParameterDirection{0}\",", p.Direction)); sb.AppendLine(string.Format("\t\t\"defaultValue\" : \"{0}\",", p.DefaultValue)); sb.AppendLine(string.Format("\t\t\"parameterType\" : \"esriGPParameterType{0}\",", p.ParameterType)); sb.AppendLine(string.Format("\t\t\"category\" : \"{0}\"", p.Category)); if (p.ChoiceList != null) { sb.AppendLine("\t\t\"choiceList\" : ["); foreach (var c in p.ChoiceList) sb.AppendLine(string.Format("\t\t\t\"{0}\"", c)); sb.AppendLine("\t\t\"]"); } sb.AppendLine("\t},"); } sb.AppendLine("\t]"); sb.Append("}"); message = sb.ToString(); } #endregion } catch (Exception ex) { message = ex.Message; } if (message != null) await new MessageDialog(message, "Service Info").ShowAsync(); }