Select to view content in your preferred language

ArcGIS .Net SDK 10.2.7 - Call to Geoprocess SubmitJobAsync no returning JobID

623
1
07-12-2019 11:30 AM
DiegoLlamas
Esri Contributor

Hello,

I created a WCF Web Service that uses ArcGIS .NET SDK 10.2.7. In the web service I am calling a secured geoprocessing task.

Before calling the geoprocessing task I’m logging in to the portal using IdentityManager so I have access to the secured geoprocessing task.

However the call to the geoprocessing task SubmitJobAsync is returning a status of New and jobID null. The result should return

a status of Submitted along with a JobID. The geoprocess is created with ArcGIS Server 10.7.

I wasn’t able to find any documentation regarding that case and how to deal with it.

 

Code snippet for login:

public async Task GenerateToken()

       {

            try

            {

                var opt = new GenerateTokenOptions();

                opt.TokenAuthenticationType = TokenAuthenticationType.ArcGISToken;

                //orig

                var cred = await IdentityManager.Current.GenerateCredentialAsync(config.PortalAuthentication.ServiceUri,

                                                                                config.PortalAuthentication.username,

                                                                                config.PortalAuthentication.password,

                                                                                opt);

 

                //test

                //var cred = await IdentityManager.Current.GenerateCredentialAsync(config.PortalAuthentication.ServiceUri,

                //                                                                config.PortalAuthentication.username,

                //                                                                config.PortalAuthentication.password);

 

                IdentityManager.Current.AddCredential(cred);

            }

            catch (ArcGISWebException webExp)

            {

                Debug.WriteLine("Unable to authenticate : " + webExp.Message);

            }

            catch (Exception exception)

            {

                Debug.WriteLine("Unable to authenticate : " + exception.Message);

            }

        }

Snippet for geoprocessing task call:

public async Task<string> CallingMaps(string template, string array, string geo, string ctrl)

        {

            DBConnection connection = new DBConnection();

            string storePath = string.Empty;

            try

            {

                //List<Objects.OrderItemCatastral> allCat

                //var serviceURL = "http://mapas.gmtgis.net/arcgis/rest/services/Geoprocesos/ProductosCartograficos/GPServer";

                //string taskName = "Mapas de Catastro";

                var gp = new Geoprocessor(new Uri(config.MapasCatastral));

                //Set up the parameters

                var parameter = new GPInputParameter();

                var layoutTemplate = new GPString("Layout_Template", template);

                var pageRange = new GPString("Page_Range", array);

                var georef = new GPString("Georef_info", geo);

                var control = new GPString("Control", ctrl);

                parameter.GPParameters.Add(layoutTemplate);

                parameter.GPParameters.Add(pageRange);

                parameter.GPParameters.Add(georef);

                parameter.GPParameters.Add(control);

                //Execute task with the parameters collection defined above

                var result = await gp.SubmitJobAsync(parameter);

                while (result.JobStatus != GPJobStatus.Cancelled && result.JobStatus != GPJobStatus.Deleted && result.JobStatus != GPJobStatus.Succeeded && result.JobStatus != GPJobStatus.TimedOut && result.JobStatus != GPJobStatus.Failed)

                {

                    try

                    {

                        result = await gp.CheckJobStatusAsync(result.JobID);

                        Debug.WriteLine(result.JobStatus +" Catastral ");

                        await Task.Delay(5000);

                    }

                    catch (System.Threading.Tasks.TaskCanceledException)

                    {

                        //connection.LogTransaction(ctrl, "ThreadAbortEsception");

                        Debug.WriteLine("Cancel Exception");

                        connection.UpdateFailedCad(ctrl, array, "false");

                    }

                }

                if (result.JobStatus == GPJobStatus.Succeeded)

                {

                    var outParam = await gp.GetResultDataAsync(result.JobID, "Output_File") as GPDataFile;

                    if (outParam != null && outParam.Uri != null)

                    {

                        //OficialCatUri = outParam.Uri;

                        string fileName = @"\" + template + ".pdf";

                        try

                        {

                            storePath = MakeStoreFolder(ctrl, fileName);

                            string save = LoadUriPdf(outParam.Uri, storePath, fileName);

                            Objects.path = storePath;

                        }

                        catch (Exception e)

                        {

                            //Debug.WriteLine("Error: ", e.ToString());

                            connection.LogTransaction(ctrl, e.Message);

                            Objects.path = "Error";

                        }

                    }

                }

                else

                {

 

                    if (result.JobStatus ==GPJobStatus.Failed){

                        return "failed";

                    }

                    if (result.JobStatus == GPJobStatus.TimedOut)

                    {

                        return "time out";

                    }

                }

            }

            catch (Exception e)

            {

                connection.LogTransaction(ctrl, e.Message +" "+ ctrl);

            }

            return storePath;

        }

 

 

Values returned by result after calling await gp.SubmitJobAsync(parameter):

 

 

However if I call the geoprocessing task from rest endpoint it works and sends the correct output.

 

 

Is there something wrong with the authentication or the code?

Should I deal with status New and no JobID or any ideas on how do I fix this situation?

do i need to migrate to a newer version of the sdk?

 

Regards,

 

Diego Llamas

0 Kudos
1 Reply
MichaelBranscomb
Esri Frequent Contributor

Hi,

 

ArcGIS Runtime components are not currently supported for use in internet-/server-/service- based scenarios. It is a requirement we are monitoring and we hope to be able to support this use case in the future.

 

There are ways of extending ArcGIS Server to implement your behavior - for more info see About extending services—Documentation | ArcGIS Enterprise

 

Regards

 

Mike

0 Kudos