GPTool Table Results

4280
16
Jump to solution
05-23-2012 08:01 AM
BrianLeroux
Occasional Contributor III
Hi-
I created a geoprocessing service that outputs a table in the scratch GDB. I am trying to retrieve the results to diplay in a datagrid but I am having issues. I have tried many methods with no luck. Below I try to count the outparameters but it is always 0. Does anyone know how to retruieve the table data?

private void GeoprocessorTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.GPExecuteCompleteEventArgs args)         {             btnPoint.IsEnabled = true;             MessageBox.Show(args.Results.OutParameters.Count().ToString());          }


Thanks!
0 Kudos
1 Solution

Accepted Solutions
DominiqueBroux
Esri Frequent Contributor
If you come back to your ItemSources set to the Features:

dg1.ItemsSource = gpLayer.FeatureSet.Features;


you should be able to bind your columns by using the Attributes dictionary:

<sdk:DataGridTextColumn Binding="{Binding Path=Attributes[OID]}" Header="OID"/>

View solution in original post

0 Kudos
16 Replies
JenniferNery
Esri Regular Contributor
Have you tried executing Geoprocessor Task from your web browser, through the REST endpoint? Do you get the same results?

If it is a server asynchronous operation, you will need to call SubmitJob() instead.

Example of server synchronous: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#MessageInABottle

Example of server asynchronous operation: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ClipFeatures

I think you want to return GPFeatureRecordSetLayer in order to display its FeatureSet in FeatureDataGrid.
0 Kudos
BrianLeroux
Occasional Contributor III
Hi Jennifer- Thanks for the reply. When i run from the rest enpoint to the %SCRATCHWORKSPACE% i get results but they disappear from the jobs folder to check what is in the results table. I changed the output of the service to a dbf temporarily and I see my results fine. I get the messages seen below when running the gp fom rest.

The gp service is synchrounous so the execute should be fine.

I belive you are right with the GPFeatureRecordSetLayer. How do I go about that?


Results:

Messages:
�?� esriJobMessageTypeInformative: Executing (HailAnalysis): HailAnalysis "Feature Set" "100 Miles"
�?� esriJobMessageTypeInformative: Start Time: Wed May 23 11:06:24 2012
�?� esriJobMessageTypeInformative: Executing (Buffer): Buffer "Feature Set" D:\arcgisserver\arcgisjobs\gptools_gpserver\j1ef0965a68274e9e8f798b023f3ea66e\scratch\Buffer.shp "100 Miles" FULL ROUND NONE #
�?� esriJobMessageTypeInformative: Start Time: Wed May 23 11:06:24 2012
�?� esriJobMessageTypeInformative: Succeeded at Wed May 23 11:06:25 2012 (Elapsed Time: 1.00 seconds)
�?� esriJobMessageTypeInformative: Executing (Clip): Clip D:\agsResources\ArcSDE.sde\ArcSDE.A10ID.HailClaims D:\arcgisserver\arcgisjobs\gptools_gpserver\j1ef0965a68274e9e8f798b023f3ea66e\scratch\Buffer.shp D:\arcgisserver\arcgisjobs\gptools_gpserver\j1ef0965a68274e9e8f798b023f3ea66e\scratch\HailClaims_Clip.shp #
�?� esriJobMessageTypeInformative: Start Time: Wed May 23 11:06:25 2012
�?� esriJobMessageTypeInformative: Reading Features...
�?� esriJobMessageTypeInformative: Cracking Features...
�?� esriJobMessageTypeInformative: Assembling Features...
�?� esriJobMessageTypeInformative: Succeeded at Wed May 23 11:06:25 2012 (Elapsed Time: 0.00 seconds)
�?� esriJobMessageTypeInformative: Executing (Summary Statistics): Statistics D:\arcgisserver\arcgisjobs\gptools_gpserver\j1ef0965a68274e9e8f798b023f3ea66e\scratch\HailClaims_Clip.shp D:\arcgisserver\arcgisjobs\gptools_gpserver\j1ef0965a68274e9e8f798b023f3ea66e\scratch\HailClaims_Clip_Statistics.dbf "LossAmt MEAN;ExpAmt MEAN;LossAmt SUM;ExpAmt SUM" LossDt
�?� esriJobMessageTypeInformative: Start Time: Wed May 23 11:06:25 2012
�?� esriJobMessageTypeInformative: Succeeded at Wed May 23 11:06:25 2012 (Elapsed Time: 0.00 seconds)
�?� esriJobMessageTypeInformative: Executing (Sort): Sort D:\arcgisserver\arcgisjobs\gptools_gpserver\j1ef0965a68274e9e8f798b023f3ea66e\scratch\HailClaims_Clip_Statistics.dbf D:\arcgisserver\arcgisjobs\gptools_gpserver\j1ef0965a68274e9e8f798b023f3ea66e\scratch\HailClaims_Clip_Statistics_S.dbf "FREQUENCY DESCENDING" UR
�?� esriJobMessageTypeInformative: Start Time: Wed May 23 11:06:25 2012
�?� esriJobMessageTypeInformative: Succeeded at Wed May 23 11:06:25 2012 (Elapsed Time: 0.00 seconds)
�?� esriJobMessageTypeInformative: Executing (Table Select): TableSelect D:\arcgisserver\arcgisjobs\gptools_gpserver\j1ef0965a68274e9e8f798b023f3ea66e\scratch\HailClaims_Clip_Statistics_S.dbf D:\arcgisserver\arcgisjobs\gptools_gpserver\j1ef0965a68274e9e8f798b023f3ea66e\scratch\scratch.gdb\Ouput "OID >= 5"
�?� esriJobMessageTypeInformative: Start Time: Wed May 23 11:06:25 2012
�?� esriJobMessageTypeInformative: Succeeded at Wed May 23 11:06:26 2012 (Elapsed Time: 1.00 seconds)
�?� esriJobMessageTypeInformative: Succeeded at Wed May 23 11:06:26 2012 (Elapsed Time: 2.00 seconds)
0 Kudos
JenniferNery
Esri Regular Contributor
I see. Does your Geoprocessor require input parameters? Do you send the same request from your Silverlight application (you can compare with browser request using Fiddler). I'm not sure if this help document will help: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00170000006p000000
0 Kudos
BrianLeroux
Occasional Contributor III
It does require input and I have already used Fiddler to verify the rquest I am sending is correct.

I changed my execution type to asynchronous now so I can see my results on the server. I am now trying to update my web app to use this service. I am stuck on the part you mentioned about the GPFeatureRecordSetLayer. I see examples on how to iterate the recordset to add as graphics. I just can't seem to figure out how to iterate the records to add to a list so I can populate a table since what i am returning are just statistics that will display in a report.

GPFeatureRecordSetLayer gpLayer = e.Parameter as GPFeatureRecordSetLayer;

            foreach (Graphic graphic in gpLayer.FeatureSet.Features)
            {
               
            }
0 Kudos
JenniferNery
Esri Regular Contributor
You can look at this SDK sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ClipFeatures. The result is also a GPFeatureRecordSetLayer. You can add results to a GraphicsLayer. I imagine your feature attributes will contain the data to show in the data grid. You can then use FeatureDataGrid and set MyDataGrid.GraphicsLayer to this layer that contain the features. GraphicsLayer does not need to be part of map if there is no geometry.
0 Kudos
BrianLeroux
Occasional Contributor III
GraphicsLayer does not need to be part of map if there is no geometry.


I did not know this. That should clear everything up. I will give it a try. Thanks!!!
0 Kudos
BrianLeroux
Occasional Contributor III
Well I am not having much luck. I can't seem to retrieve my results from the GP Task. The GP Task runs fine and I do see the results in the jobs folder on the server. I then attempt to run a GetResultDataAsync to get the GPFeatureRecordSetLayer but it is getting hung up. It seems like my  geoprocessorTask.GetResultDataCompleted  is not firing as the completed or failed events never get triggered. Anyone see anything wrong in my code? This is the first time I try an Asynchronous request so there is verywell some user error involved here. I use the samples as a guide.

private void Geoprocessor_JobCompleted(object sender, JobInfoEventArgs e)
        
        {            
            Geoprocessor geoprocessorTask = sender as Geoprocessor;
            geoprocessorTask.GetResultDataCompleted += GeoprocessorTask_GetResultDataCompleted;
            geoprocessorTask.Failed += GeoprocessorTask_Failed;

            geoprocessorTask.GetResultDataAsync(e.JobInfo.JobId, "output");
            
        }

        private void GeoprocessorTask_GetResultDataCompleted(object sender, GPParameterEventArgs e)
        {
            GraphicsLayer graphicsLayer = MapApplication.Current.Map.Layers["MyResultGraphicsLayer"] as GraphicsLayer;
            GPFeatureRecordSetLayer gpLayer = e.Parameter as GPFeatureRecordSetLayer;

            MessageBox.Show(gpLayer.FeatureSet.Count().ToString());

            foreach (Graphic graphic in gpLayer.FeatureSet.Features)
            {                
                graphicsLayer.Graphics.Add(graphic);
            }

            MessageBox.Show(graphicsLayer.Count().ToString());

            this.dg.GraphicsLayer = graphicsLayer;
            btnPoint.IsEnabled = true; 
        }

        private void GeoprocessorTask_Failed(object sender, TaskFailedEventArgs e)
        {
            MessageBox.Show("Geoprocessing service failed: " + e.Error);
            btnPoint.IsEnabled = true;
        }      
0 Kudos
DominiqueBroux
Esri Frequent Contributor
You might check e.JobInfo.JobStatus in order to be sure the Job has succeeded (return value should be esriJobSucceeded)

Else check in your model that your parameter is called 'output'.

Else... no more idea.
0 Kudos
BrianLeroux
Occasional Contributor III
Hi dbroux,

I already have MessageBox.Show(e.JobInfo.JobStatus.ToString()); in my code for Geoprocessor_JobCompleted and it shows the esriJobSucceeded message. I have messageboxes in my GeoprocessorTask_GetResultDataCompleted so it will show me when that completes but I never get anything.

Here is my output parameter which does not look like an issue to me.

Parameter: output
Data Type: GPRecordSet
Display Name: output
Direction: esriGPParameterDirectionOutput
Default Value:
Parameter Type: esriGPParameterTypeRequired
Category:

Thanks for your response.
0 Kudos