private void GeoprocessorTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.GPExecuteCompleteEventArgs args) { btnPoint.IsEnabled = true; MessageBox.Show(args.Results.OutParameters.Count().ToString()); }
Solved! Go to Solution.
Geoprocessor geoprocessorTask = sender as Geoprocessor; geoprocessorTask.GetResultDataCompleted += GeoprocessorTask_GetResultDataCompleted; geoprocessorTask.Failed += GeoprocessorTask_Failed; geoprocessorTask.GetResultDataAsync("j0ecca8fcfee3406ba977cb29b53d09dd", "output");
foreach (GPParameter gpParameter in e.Results.OutParameters) { GPFeatureRecordSetLayer gpLayer = gpParameter as GPFeatureRecordSetLayer; foreach (Graphic graphic in gpLayer.FeatureSet.Features) { graphicsLayer.Graphics.Add(graphic); } }
foreach (GPParameter gpParameter in e.Results.OutParameters) if (gpParameter.Name == "output_dbf") { GPRecordSet gpLayer = gpParameter as GPRecordSet; MessageBox.Show(gpLayer.FeatureSet.Count().ToString()); dg1.ItemsSource = gpLayer.FeatureSet.Features; }
<sdk:DataGrid AutoGenerateColumns="True" Height="236" HorizontalAlignment="Left" Margin="12,52,0,0" Name="dg1" VerticalAlignment="Top" Width="476"> <sdk:DataGrid.Columns> <!--<sdk:DataGridTextColumn Binding="{Binding Path=OID}" SortMemberPath="OID" Header="OID"/>--> <!--<sdk:DataGridTextColumn Binding="{Binding Path=LossDt}" SortMemberPath="LossDt" Header="LossDt"/>--> <!--<sdk:DataGridTextColumn Binding="{Binding Path=FREQUENCY}" SortMemberPath="FREQUENCY" Header="FREQUENCY"/>--> <sdk:DataGridTextColumn Binding="{Binding MEAN_LossA}" SortMemberPath="MEAN_LossA" Header="MEAN_LossA"/> <!--<sdk:DataGridTextColumn Binding="{Binding Path=SUM_LossAm}" SortMemberPath="SUM_LossAm" Header="SUM_LossAm"/>--> <!--<sdk:DataGridTextColumn Binding="{Binding Path=MEAN_ExpAm}" SortMemberPath="MEAN_ExpAm" Header="MEAN_ExpAm"/>--> <!--<sdk:DataGridTextColumn Binding="{Binding Path=SUM_ExpAmt}" SortMemberPath="SUM_ExpAmt" Header="SUM_ExpAmt"/>--> </sdk:DataGrid.Columns> </sdk:DataGrid>
public interface HailData {} public class HailAttributes : HailData { //public double OID; //public string LossDt; // public double FREQUENCY; public string MEAN_LossA; //public double SUM_LossAm; //public double MEAN_ExpAm; //public double SUM_ExpAmt; } public string MEAN_LossA { get { return MEAN_LossA; } } private void GeoprocessorTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.GPExecuteCompleteEventArgs e) { try { this.dg1.ItemsSource = null; foreach (GPParameter gpParameter in e.Results.OutParameters) if (gpParameter.Name == "output_dbf") { GPRecordSet gpLayer = gpParameter as GPRecordSet; List<HailData> theList = new List<HailData>(); foreach (Graphic feature in gpLayer.FeatureSet.Features) { //MessageBox.Show(feature.Attributes["MEAN_LossA"].ToString()); theList.Add(new HailAttributes() { //OID = Convert.ToDouble(feature.Attributes["OID"]), //LossDt = feature.Attributes["LossDt"].ToString(), //FREQUENCY = Convert.ToDouble(feature.Attributes["FREQUENCY"]), MEAN_LossA = feature.Attributes["MEAN_LossA"].ToString(), //SUM_LossAm = Convert.ToDouble(feature.Attributes["SUM_LossAm"]), //MEAN_ExpAm = Convert.ToDouble(feature.Attributes["MEAN_ExpAm"]), //SUM_ExpAmt = Convert.ToDouble(feature.Attributes["SUM_ExpAmt"]), }); } MessageBox.Show(theList.Count().ToString()); this.dg1.ItemsSource = theList; } btnPoint.IsEnabled = true; } catch (OverflowException oEx) { MessageBox.Show(oEx.Message); btnPoint.IsEnabled = true; } catch (FormatException fEx) { MessageBox.Show(fEx.Message); btnPoint.IsEnabled = true; } catch (Exception ex) { MessageBox.Show(ex.Message + " stacktrace:" + ex.StackTrace); btnPoint.IsEnabled = true; } }
dg1.ItemsSource = gpLayer.FeatureSet.Features;
<sdk:DataGridTextColumn Binding="{Binding Path=Attributes[OID]}" Header="OID"/>
I think this guide doc might help: Geoprocessing task—ArcGIS API for Silverlight | ArcGIS for Developers