Select to view content in your preferred language

Getting results from submitJob geoprocessing

2431
2
06-16-2011 10:16 AM
EvanBossett
Emerging Contributor
I have created a Geoprocessing Task using Model Builder.  I published it as a Geoprocessing Service.  I can successfully call geoprocessing services via the expose "submitjob" and the intended action is carried out.  (i am able to linear reference some data in my SDE database and create a new feature class)

However, what I would like to do is have those results be displayed in my Silverlight application.  All the examples from the sample website utilize "execute" operation to display results from the geoprocessing tasks.  However, I only have access to "submit job".

Can anyone share what i must do to display results from "submit job" to my silverlight website?  Or how I create a geoprocessing service that exposes "executetask" so i can utilize the sample code from ESRI examples online?

Please help.

Thank you.
0 Kudos
2 Replies
IgressT
Emerging Contributor
This is what I do

// List of parameters
List<GPParameter> gpParameters = new List<GPParameter>();
gpParameters.Add(new GPString(input1, "input1Value"));
gpParameters.Add(new GPString(input2, "input2Value"));


// Call GP task
Geoprocessor gpTask = new Geoprocessor(gpTaskURL);
// Event raised if job failed
gpTask.Failed += (s1, e1) =>
    {
        // If failed
        MessageBox.Show("Task failed");
    };
// Event raised if job completed
gpTask.JobCompleted += (s2, e2) =>
    {
        Geoprocessor gp = s2 as Geoprocessor;
        gp.GetResultDataCompleted += (s3, e3) =>
            {
                if (e3.Parameter is GPString)
                {
                    // Do something to show in silverlight
                }
                else if (e3.Parameter is GPFeatureRecordSetLayer)
                {
                    // Do something to show in silverlight
                    GPFeatureRecordSetLayer gpresultLayer = e3.Parameter as GPFeatureRecordSetLayer;
                    foreach (Graphic graphic in gpresultLayer.FeatureSet.Features)
                    {
                    }
                }
            };
        // Get the result data
        gp.GetResultDataAsync(e3.JobInfo.JobId, pythonScriptOutputParamterName);
    };
// Submit GP task
gpTask.SubmitJobAsync(gpParameters);


When I write my python script I specify a parameter called pythonScriptOutputParamterName with a datatype with direction as "output" I specify the same name at gp.GetResultDataAsync
0 Kudos
EvanBossett
Emerging Contributor
0 Kudos