Geoprocessor object won't execute

2808
11
07-15-2013 10:50 AM
ReneeCammarere
Occasional Contributor
I've tried several different approaches to getting the simple geoprocessing package that I created to execute from my C# project . . .

        ESRI.ArcGIS.Client.Tasks.Geoprocessor _localGPService = null;
        string gpkPath = ConfigurationManager.AppSettings["EsriRuntimeGeoPackageLocation"];
        string geoObjectPath = ConfigurationManager.AppSettings["EsriRuntimeGeoProcessorObject"];
    LocalGeoprocessingService.GetServiceAsync(gpkPath, GPServiceType.Execute, (gpService) =>
    {
        if (gpService.Error != null)
        {
         MessageBox.Show(gpService.Error.Message);
        }
        _localGPService = new ESRI.ArcGIS.Client.Tasks.Geoprocessor(gpService.UrlGeoprocessingService + geoObjectPath);
        DataContext = this;
    });
    List<ESRI.ArcGIS.Client.Tasks.GPParameter> parameters = new List<ESRI.ArcGIS.Client.Tasks.GPParameter>();
    _localGPService.ExecuteAsync(parameters);

I've also tried the following . . .

private LocalGeoprocessingService _localGPService = null;
    string gpkPath = ConfigurationManager.AppSettings["EsriRuntimeGeoPackageLocation"];
    _localGPService = new LocalGeoprocessingService(gpkPath, GPServiceType.Execute);

    _localGPService.StartAsync((callback) =>
    {
        if (callback.Error == null)
        {
            CoverButton.IsEnabled = true;
        }
        else
        {
            MessageBox.Show("Error starting gp service");
        }
    });
    string geoObjectPath = ConfigurationManager.AppSettings["EsriRuntimeGeoProcessorObject"];
    ESRI.ArcGIS.Client.Tasks.Geoprocessor gp = new ESRI.ArcGIS.Client.Tasks.Geoprocessor(_localGPService.UrlGeoprocessingService + geoObjectPath);
   List<ESRI.ArcGIS.Client.Tasks.GPParameter> parameters = new List<ESRI.ArcGIS.Client.Tasks.GPParameter>();
   gp.ExecuteAsync(parameters);

When it gets to the last line (execute), I don't get an error, but it also doesn't do anything. I've been tracing through the code, and the geoprocessor object does get created and invoked with a URL, so I don't know why it does nothing. Tracing through, it appears as if everything is OK. The tool that the gpk was created from runs OK when I execute it in ArcMap.  There are no input or output parameters in the model (tool).  
Any ideas as to what might cause this? I just don't know what to look for anymore. Thanks!
0 Kudos
11 Replies
SachinKanaujia
Occasional Contributor III
I hope you have created the geoprocessing package correctly by selecting the ArcGIS Runtime Support and then creating the package. You can try to first run everything in a synchronous mode and later switch to Async. What is the expected result from this tool? Is it expected to create any output somewhere?

As a side note :- Enabling logging on your local server can also be helpful sometimes
0 Kudos
ReneeCammarere
Occasional Contributor
@sachin  I did check the box for ArcGIS Runtime.  This is a simple test (I was not able to get my original tool to run).  I created a simple model using Modelbuilder, that just uses the CopyFeatures tool to make a copy of a polygon.  There are no inputs or output parameters.  It runs successfully in ArcMap.

By the way, I'm not sure what you meant by "Enabling logging on your local server can also be helpful sometimes"
0 Kudos
ReneeCammarere
Occasional Contributor
I did re-write the code executing in a non-asynchronous manner, but it didn't make any difference.  This is what the changes in the code look like from what I showed previously . . .
private LocalGeoprocessingService _localGPService = null;
string gpkPath = ConfigurationManager.AppSettings["EsriRuntimeGeoPackageLocation"];
_localGPService = new LocalGeoprocessingService(gpkPath, GPServiceType.Execute);
  _localGPService.Start();

Inside routine that executes the geoprocessor object . . .

string geoObjectPath = ConfigurationManager.AppSettings["EsriRuntimeGeoProcessorObject"];
ESRI.ArcGIS.Client.Tasks.Geoprocessor gp = new ESRI.ArcGIS.Client.Tasks.Geoprocessor(_localGPService.UrlGeoprocessingService + geoObjectPath);

//Create a new List of type GPParameter to hold the parameters for the service
List<ESRI.ArcGIS.Client.Tasks.GPParameter> parameters = new List<ESRI.ArcGIS.Client.Tasks.GPParameter>();
gp.Execute(parameters);
0 Kudos
SachinKanaujia
Occasional Contributor III
Under ArcGIS Runtime there should be a Local Server Utility where you can enable logging. This should provide you a but more detail about whats going on.

Since there are no input/output parameters can you check if the defaults for the input and output of the copy feature is defined correctly? Its strange that its not giving you any errors. Would you mind sharing the script?

-S
0 Kudos
ReneeCammarere
Occasional Contributor
I'll see if I can attach the gpk unpacked and the tool.  There's really nothing to the tool.  I created it using ModelBuilder (picture attached).  Therefore in order to attach it as a script, I had to export the model to a Python script.  That is what I've attached, rather than the Modelbuilder model.
0 Kudos
SachinKanaujia
Occasional Contributor III
In an ArcMap you can always take the input from the dataset added to ArcMap. In the geoprocessing environment, you need to either provide the complete path to the input data or else use input parameters to pass GPRecordset for features. For now you need to change your script to provide the complete path to the file. Example, I need to copy xyz.shp. I assume you already had the scratch.gdb setup. You would need to create your gpk again. I hope this helps !!!

# Import arcpy module
import arcpy


# Local variables:
TestPolygon = "C:\\Projects\\TestPolygon\xyz.shp"
TestPolygonCopy = "C:\\Projects\\Geospatial-Developmental\\TestNoGUI\\TestNoGUI\\Scratch.gdb\\TestPolygonCopy"

# Process: Copy Features
arcpy.CopyFeatures_management(TestPolygon, TestPolygonCopy, "", "0", "0", "0")
0 Kudos
ReneeCammarere
Occasional Contributor
I did change the model to include the complete input path.  When I created the model before in ArcMap using Modelbuilder, I dragged the feature class and placed it into the model.  I guess it didn't grab the full path name, just the name of the layer in ArcMap.  I re-created the gpk from this result and tried the code again, but still got the same result.  Thanks for your help.  I'll just have to keep at it.
0 Kudos
ReneeCammarere
Occasional Contributor
When I trace through, and check the URL from the Local Geoprocessor object, this is the result when I click on "Execute Task (POST)
"{"results":[],"messages":[{"type":"esriJobMessageTypeInformative","description":"Executing (SimpleCopyFeatures2): SimpleCopyFeatures2"},{"type":"esriJobMessageTypeInformative","description":"Start Time: Fri Jul 19 15:43:11 2013"},{"type":"esriJobMessageTypeInformative","description":"Executing (SimpleCopyFeatures2): SimpleCopyFeatures2"},{"type":"esriJobMessageTypeInformative","description":"Start Time: Fri Jul 19 15:43:11 2013"},{"type":"esriJobMessageTypeInformative","description":"Executing (SimpleCopyFeatures2): SimpleCopyFeatures2"},{"type":"esriJobMessageTypeInformative","description":"Start Time: Fri Jul 19 15:43:12 2013"},{"type":"esriJobMessageTypeInformative","description":"Executing (Copy Features): CopyFeatures C:\\Users\\RENEEC~1\\AppData\\Local\\ARCGIS~1\\Documents\\ArcGIS\\Packages\\simplecopyfeatures2\\v101\\scratch.gdb\\TestPolygon \"C:\\Users\\Renee Cammarere\\AppData\\Local\\Temp\\arcgisruntime_5528\\simplecopyfeatures2\\jobs\\_\\j275d94165d9d4f9fa161bfabe2581d55\\scratch\\scratch.gdb\\TestPolygonCopy\" # 0 0 0"},{"type":"esriJobMessageTypeInformative","description":"Start Time: Fri Jul 19 15:43:12 2013"},{"type":"esriJobMessageTypeInformative","description":"Succeeded at Fri Jul 19 15:43:13 2013 (Elapsed Time: 1.00 seconds)"},{"type":"esriJobMessageTypeInformative","description":"Succeeded at Fri Jul 19 15:43:13 2013 (Elapsed Time: 1.00 seconds)"},{"type":"esriJobMessageTypeInformative","description":"Succeeded at Fri Jul 19 15:43:13 2013 (Elapsed Time: 2.00 seconds)"},{"type":"esriJobMessageTypeInformative","description":"Succeeded at Fri Jul 19 15:43:13 2013 (Elapsed Time: 2.00 seconds)"}]}"

It appears that the output is being created (TestPolygonCopy), but it doesn't show up.
0 Kudos
SachinKanaujia
Occasional Contributor III
Look at the input and output locations printed. Instead of using temp gp package locations its better you use some like a C:\ for your input and output.
0 Kudos