Select to view content in your preferred language

Access JobID from .NET class extension

3384
4
05-15-2014 08:36 AM
AllWeatherHeather
Frequent Contributor
I am migrating a 9.3 system to 10.2.2 and part of that is upgrading a number of VB.NET class extensions that we put in place for data validation. Part of what these class extensions do is ensure that users can only edit data from within a JTX job (not generic ArcMap). The logic assumes that if the JobID is greater than 0 then the work is being done from within a valid job.

How can I access the JobID and JobStatus in .NET from Workflow Manager? My existing 9.3 solution isn't working (JobID is always 0)...

Thanks,
Heather
0 Kudos
4 Replies
KevinBedel
Esri Contributor
Hi Heather,

You should be able to retrieve the Job or the JobID from the IJTXExtension interface on the Extension. For example:

IJTXExtension extension = m_application.FindExtensionByName("Workflow Manager") as IJTXExtension;
int jobID = extension.JobID;
IJTXJob job = extension.Job;


From the job, you can get the status. If you are following this approach and always getting 0 as the JobID, you may be trying to retrieve this value before the job has actually been loaded. In that case, you may need to wait for the job to be loaded by registering as a Job Listener, via IJTXExtension2.AttachListener.

Kevin
0 Kudos
AllWeatherHeather
Frequent Contributor
Thanks Kevin!

However, we are still having issues... this is our code:

Dim pEX As IExtension = pApplication.FindExtensionByName("workflow manager")
If Not pApplication.FindExtensionByName("workflow manager") Is Nothing Then
    Dim ext As IExtension = CType(pEX, IExtension)
    Dim pJTXEX As IJTXExtension3 = CType(ext, IJTXExtension3) 'TryCast(pApplication.FindExtensionByName("workflow manager"), IJTXExtension4)
    Dim pJob As IJTXJob2 = CType(pJTXEX.Job, IJTXJob2)


The error messages we receive are attached. This code works with our old JTX 9.3 environment.
Suggestions?

[ATTACH=CONFIG]34833[/ATTACH]
0 Kudos
KevinBedel
Esri Contributor
Hi Heather,

I unable to reproduce that issue with your code in a sample VB.Net ArcMap command. I have attached the project I used in the hope that you will be able to discover some difference between it and your project that may help resolve the issue. If this project does not work for you, I suspect the issue may have something to do with your specific configuration or Workflow Manager repository, and you will probably need to contact Esri Support in order to help resolve the issue.

Thanks,
Kevin
0 Kudos
AllWeatherHeather
Frequent Contributor
Kevin,

Thanks for the code. We are getting the same issue with your code as we were seeing with ours. I have contact Esri Support in Canada to see if they can help us get the configuration sorted out.

Thanks!
0 Kudos