Select to view content in your preferred language

Facing a problem when running a geoprocessing service

2622
6
11-15-2011 03:01 PM
MuralidharMoka
Emerging Contributor
I am facing a problem when running a Geoprocessing service.

In a nut shell, the whole process is this,

1. We select two graphics from a featurelayer and save it to another Featurelayer1. To these graphics
     we add and attribute PRIM_TRANS_ID
               
2.The Geoprocessing service will now be kicked . The Geoprocessing service will merge these above two graphics and creates a resulting graphic and saves to another layer say FeatureLayer2 with the same PRIM_TRANS_ID.

3.We try to query the Featurelayer2 and get the graphic. 

The problem is the First steps happens sucessfully. The graphics are saved to Featurelayer1.
The Geoprocessing service says it succeeded and gives the job id, but does not create the final graphic in Featurelayer2. We get a 0 Count in the Featurelayer2.

Say if we run the Geoprocessing service once again with the same Trans_Id.Now the graphics get created. It looks like we are kicking the Geoprocessing service even before the graphics are created in the Featurelayer1. But we saw the the grapics are already before starting the geoprocessing task(We set a brek point and observed the graphics are there)

We just wanted to know what is happening. why does the resultant layer gets the graphic when we re run it. But not the first time.

 
private string PRIM_TRANS_ID = null; //global 

             public MainPage()
               {
                  DissolveFeature = MyMap.Layers["UtilityDissolveFeature"] as FeatureLayer; //this is nothing but Featurelayer1
                  DissolveFeature.EndSaveEdits += new EventHandler<EndEditEventArgs>(DissolveFeature_EndSaveEdits);

                }


private void btnProcessTask_Click(object sender, RoutedEventArgs e)
        {
            //after selectin the graphics this is called
            ProcessGeoProcessingTask();
        }

        private void ProcessGeoProcessingTask()
        {
            //STEP1:Get the selected Graphic and create a Copy
            PRIM_TRANS_ID = Guid.NewGuid().ToString();
            foreach (Graphic g in countylayer.SelectedGraphics)
            {
                if (g == null)
                {
                    MessageBox.Show("Graphic is Null select County Layer");
                    return;
                }
                Graphic countyGrpahic = g;
                Graphic copyGraphic = new Graphic()
                {
                    Geometry = countyGrpahic.Geometry
                };
                //add a Guid attribute

                copyGraphic.Attributes.Add("PRIM_TRANS_ID", PRIM_TRANS_ID);
                DissolveFeature.Graphics.Add(copyGraphic);
            }
            DissolveFeature.SaveEdits();
           

        }   

        void DissolveFeature_EndSaveEdits(object sender, EndEditEventArgs e)
        {
          
            ////STEP2 - Call GeoProcessing
            String geoprocessorTaskUrl = "http://geo.dev.fmh.com:6080/arcgis/rest/services/Utilities/Utility_Poly_Dissolve_Model/GPServer/poly...";
            Geoprocessor geoprocessorTask = new Geoprocessor(geoprocessorTaskUrl);
            geoprocessorTask.UpdateDelay = 10000;
            geoprocessorTask.JobCompleted += new EventHandler<JobInfoEventArgs>(geoprocessorTask_JobCompleted);
            geoprocessorTask.Failed += new EventHandler<TaskFailedEventArgs>(geoprocessorTask_Failed);
            List<GPParameter> parameters = new List<GPParameter>();
            parameters.Add(new GPString("Expression", string.Format("PRIM_TRANS_ID ='{0}'", PRIM_TRANS_ID)));

            geoprocessorTask.SubmitJobAsync(parameters);
            GlobalBusyIndicator.IsBusy = true;
        }

        void geoprocessorTask_JobCompleted(object sender, JobInfoEventArgs e)
        {
            //checking the jobstatus and if successful, querying the with PRIM_TRANS_ID the resultant graphic back
           
            if (e.JobInfo.JobStatus == esriJobStatus.esriJobSucceeded)
            {
                String ResulServiceUrl = "http://geo.dev.fmh.com:6080/arcgis/rest/services/Utilities/UTILITY_GEOPROCESS_RESULT_LAYERS/MapServe...";
                QueryTask qt = new QueryTask(ResulServiceUrl);
                qt.ExecuteCompleted += new EventHandler<QueryEventArgs>(qt_ExecuteCompleted);
                qt.Failed += new EventHandler<TaskFailedEventArgs>(qt_Failed);
                Query query = new Query();
                query.OutFields.Add("*");
                query.Where = "PRIM_TRANS_ID = '" + PRIM_TRANS_ID + "'"; ;
                query.ReturnGeometry = true;
                qt.ExecuteAsync(query);
            }
        }

        void qt_ExecuteCompleted(object sender, QueryEventArgs e)
        {
            FeatureSet feat = e.FeatureSet;
            if (feat != null)
            {
                if (feat.Features.Count > 0)
                {
                    foreach (Graphic resulgraphic in feat.Features)
                    {
                        Graphic g = new Graphic()
                        {
                            Geometry = resulgraphic.Geometry,
                            Symbol = RedFillSymbol
                        };
                        //graphicsLayer.Graphics.Add(g);
                    }
                }
            }
            GlobalBusyIndicator.IsBusy = false;
        }

Thanks
Muralidhar Moka
0 Kudos
6 Replies
MuralidharMoka
Emerging Contributor
Following shows Job Status messages when run from silverlight code and when run from browser directly.
===========================================================
Ran silverlight code UnSuccesful when run first time

esriJobMessageTypeInformative: Executing (poly_dissolve_model): utilitypolydissolvemodel "PRIM_TRANS_ID = '27105223-631c-4812-bee5-74cc3505b341'"
esriJobMessageTypeInformative: Start Time: Tue Nov 15 11:16:16 2011
esriJobMessageTypeInformative: Executing (utilitypolydissolvemodel): utilitypolydissolvemodel "PRIM_TRANS_ID = '27105223-631c-4812-bee5-74cc3505b341'"
esriJobMessageTypeInformative: Start Time: Tue Nov 15 11:16:16 2011
esriJobMessageTypeInformative: Executing (Select): Select "\\esri-arcsrvdev1\arcgisserver\directories\arcgisdata\SDE_Default connection to Oracle_ESRI_DEV.sde\SDE.UTIL_POLY_DISSOLVE" \\esri-arcsrvdev1\arcgisserver\directories\arcgisjobs\fmh\gp_util_poly_dissolve\scratch\scratch.gdb\poly_dissolve_selected_features "PRIM_TRANS_ID = '27105223-631c-4812-bee5-74cc3505b341'"
esriJobMessageTypeInformative: Start Time: Tue Nov 15 11:16:17 2011
esriJobMessageTypeWarning: WARNING 000117: Warning empty output generated.
esriJobMessageTypeInformative: Succeeded at Tue Nov 15 11:16:20 2011 (Elapsed Time: 3.00 seconds)
esriJobMessageTypeInformative: Executing (Dissolve): Dissolve \\esri-arcsrvdev1\arcgisserver\directories\arcgisjobs\fmh\gp_util_poly_dissolve\scratch\scratch.gdb\poly_dissolve_selected_features \\esri-arcsrvdev1\arcgisserver\directories\arcgisjobs\fmh\gp_util_poly_dissolve\scratch\scratch.gdb\poly_dissolved_features PRIM_TRANS_ID # SINGLE_PART DISSOLVE_LINES
esriJobMessageTypeInformative: Start Time: Tue Nov 15 11:16:20 2011
esriJobMessageTypeInformative: Sorting Attributes...
esriJobMessageTypeInformative: Dissolving...
esriJobMessageTypeWarning: WARNING 000953: Extent of the overlay operation will be empty.
esriJobMessageTypeWarning: WARNING 000117: Warning empty output generated.
esriJobMessageTypeInformative: Succeeded at Tue Nov 15 11:16:22 2011 (Elapsed Time: 2.00 seconds)
esriJobMessageTypeInformative: Executing (Append): Append \\esri-arcsrvdev1\arcgisserver\directories\arcgisjobs\fmh\gp_util_poly_dissolve\scratch\scratch.gdb\poly_dissolved_features "\\esri-arcsrvdev1\arcgisserver\directories\arcgisdata\SDE_Default connection to Oracle_ESRI_DEV.sde\SDE.UTIL_POLY_DISSOLVED" TEST # #
esriJobMessageTypeInformative: Start Time: Tue Nov 15 11:16:23 2011
esriJobMessageTypeInformative: Succeeded at Tue Nov 15 11:16:31 2011 (Elapsed Time: 8.00 seconds)
esriJobMessageTypeInformative: Succeeded at Tue Nov 15 11:16:32 2011 (Elapsed Time: 16.00 seconds)
esriJobMessageTypeInformative: Succeeded at Tue Nov 15 11:16:32 2011 (Elapsed Time: 16.00 seconds)

==============================================================

Sucessful when ran from browser with PRIM_TRANS_ID
The job is ran from the browser

esriJobMessageTypeInformative: Submitted.
esriJobMessageTypeInformative: Executing...
esriJobMessageTypeInformative: Executing (poly_dissolve_model): utilitypolydissolvemodel PRIM_TRANS_ID='243e7ee7-f694-44e6-b2e3-dc64fad30457'
esriJobMessageTypeInformative: Start Time: Tue Nov 15 10:58:36 2011
esriJobMessageTypeInformative: Executing (utilitypolydissolvemodel): utilitypolydissolvemodel PRIM_TRANS_ID='243e7ee7-f694-44e6-b2e3-dc64fad30457'
esriJobMessageTypeInformative: Start Time: Tue Nov 15 10:58:36 2011
esriJobMessageTypeInformative: Executing (Select): Select "\\esri-arcsrvdev1\arcgisserver\directories\arcgisdata\SDE_Default connection to Oracle_ESRI_DEV.sde\SDE.UTIL_POLY_DISSOLVE" \\esri-

arcsrvdev1\arcgisserver\directories\arcgisjobs\fmh\gp_util_poly_dissolve\scratch\scratch.gdb\poly_dissolve_selected_features PRIM_TRANS_ID='243e7ee7-f694-44e6-b2e3-dc64fad30457'
esriJobMessageTypeInformative: Start Time: Tue Nov 15 10:58:37 2011
esriJobMessageTypeInformative: Succeeded at Tue Nov 15 10:58:39 2011 (Elapsed Time: 2.00 seconds)
esriJobMessageTypeInformative: Executing (Dissolve): Dissolve \\esri-arcsrvdev1\arcgisserver\directories\arcgisjobs\fmh\gp_util_poly_dissolve\scratch\scratch.gdb\poly_dissolve_selected_features

\\esri-arcsrvdev1\arcgisserver\directories\arcgisjobs\fmh\gp_util_poly_dissolve\scratch\scratch.gdb\poly_dissolved_features PRIM_TRANS_ID # SINGLE_PART DISSOLVE_LINES
esriJobMessageTypeInformative: Start Time: Tue Nov 15 10:58:40 2011
esriJobMessageTypeInformative: Sorting Attributes...
esriJobMessageTypeInformative: Dissolving...
esriJobMessageTypeInformative: Succeeded at Tue Nov 15 10:58:41 2011 (Elapsed Time: 1.00 seconds)
esriJobMessageTypeInformative: Executing (Append): Append \\esri-arcsrvdev1\arcgisserver\directories\arcgisjobs\fmh\gp_util_poly_dissolve\scratch\scratch.gdb\poly_dissolved_features "\\esri-

arcsrvdev1\arcgisserver\directories\arcgisdata\SDE_Default connection to Oracle_ESRI_DEV.sde\SDE.UTIL_POLY_DISSOLVED" TEST # #
esriJobMessageTypeInformative: Start Time: Tue Nov 15 10:58:42 2011


j7da5c5fac7254e3daa6bc06857c7a11b
0 Kudos
MuralidharMoka
Emerging Contributor
The following shows the Geoprocessing task rest definition

Task: poly_dissolve_model
Display Name: poly_dissolve_model

Category:

Help URL: http://geo.dev.fmh.com:6080/arcgis/rest/directories/arcgisoutput/Utilities_Utility_Poly_Dissolve_Mod...

Execution Type: esriExecutionTypeAsynchronous

Parameters:

Parameter: Expression

Data Type: GPString
Display Name Expression
Direction: esriGPParameterDirectionInput
Default Value: PRIM_TRANS_ID = '11ss11'
Parameter Type: esriGPParameterTypeRequired
Category:


Parameter: poly_dissolved_features

Data Type: GPFeatureRecordSetLayer
Display Name poly_dissolved_features
Direction: esriGPParameterDirectionOutput
Default Value:
Geometry Type: esriGeometryPolygon
Spatial Reference: 102100
Fields:
OBJECTID ( type: esriFieldTypeOID , alias: OBJECTID )
PRIM_TRANS_ID ( type: esriFieldTypeString , alias: PRIM_TRANS_ID , length: 50 )
SHAPE_Length ( type: esriFieldTypeDouble , alias: SHAPE_Length )
SHAPE_Area ( type: esriFieldTypeDouble , alias: SHAPE_Area )
Features: None.



Parameter Type: esriGPParameterTypeRequired
Category:
0 Kudos
LakshmananVenkatesan
Frequent Contributor
Give a closer look on information, first time execution displays two warnings..hence there is something wrong in code. Debug the GP tools and see the issue.
0 Kudos
MuralidharMoka
Emerging Contributor
Thanks for looking into this. I dont know what GPTools are. Can you please explain me more.
I am still unable to figure this out.
Thanks
Murali
0 Kudos
LakshmananVenkatesan
Frequent Contributor
I assumed that Geoprocessing call which you make is custom call. i.e. You can created Geoprocessing model and published as Geoprocessing tool (GP Tool) and accessing the same in client application.

I thought  "poly_dissolve_model" is your custom program designed for dissolve operation based on condition. Let me know if my assumption is correct
0 Kudos
MuralidharMoka
Emerging Contributor
I assumed that Geoprocessing call which you make is custom call. i.e. You can created Geoprocessing model and published as Geoprocessing tool (GP Tool) and accessing the same in client application.

I thought  "poly_dissolve_model" is your custom program designed for dissolve operation based on condition. Let me know if my assumption is correct


You are right.The Poly_dissolve_model is the Geoprocessing service we wrote which will merget two graphics and creates a new graphic which we are trying to access. But we dont get the graphic back.

Again simply this is what we are doing
1.We have a FeatureLayer( To this layer we add a two or three graphics with an attribute PRIM_TRANS_ID)
2.We have a  geoprocessing service-GP tool( this will take those graphics and merges it and creates a new graphic )
3.We have an final featurelayer2 (Result layer where we final graphic merged graphic gets created)


Step1: done in ProcessGeoProcessingTask()
Step2: done in DissolveFeature_EndSaveEdits  //Geoprocessing done here
Setp3: geoprocessorTask_JobCompleted       

We have other Geoprocessing services also which we are using and we have problems like.
If the client runs the Geoprocessing service, it works the first time and then it starts failing
2nd, 3rd times and so on.
After some time if we try like after 1hr.It again works for the first times and fails.
When this happens we start our geoprocessing service to trouble shoot, some times it works and some times it doesnt. We are yet unable to identify why geoprocessing services are not working properly. Let us know if our code should take care of any thing once we start or end a Geoprocessing service.

I gave code in txt file.



Thanks
Muralidhar Moka
0 Kudos