JTX 9.3.1 How to get Job_ID

2797
4
01-16-2011 12:20 AM
MarkMindlin
Occasional Contributor III
We are facing a problem  with JTX and ArcMap. We create a SDE version and start ArcMap from JTX.  It creates specific mxd file (with name JOB_xxxx, where xxxx ??? is current Job_ID number).
Question: How we can get Job_ID programmatically?
First, maybe we could create a command (extension) for ArcMap? JTX has classes connected to Job_ID. How can we create JTX objects from ArcMap?
Second, maybe get Job_ID before mxd file will be created ?
Last, maybe another source (for instance, from JTX tables linked with process ID in Windows), BUT WE CAN'T GET LAST JOB_ID, because we are running a couple of JTX instances?
0 Kudos
4 Replies
BrianDemers
Esri Contributor
Hi... There are a couple of different ways to get the ID of the current job, depending on how you need to do it.

Probably the simplest way would be to pass the job ID as a step argument using the "[JOB:ID]" token; this works well with, say, GP tools or scripts, .bat files, and the like.

With a custom step, the job ID is passed directly into the "Execute" function as an argument, so that's another easy case.

From within ArcMap... if ArcMap was launched using the "JTXDesktopSteps.LaunchArcMap" step, the Workflow Manager extension will know which job opened ArcMap.  I don't know if this is the only/preferred way or even if it will work in all cases, but for example:

IApplication m_application;
IJTXJob3 m_job;

// ...m_application is a handle to the ArcMap application; might be retrieved, passed in, etc...

IExtension ext = m_application.FindExtensionByName("Workflow Manager");
if (ext != null)
{
  // Get handles to the JTX extension and current job, if possible.
  m_jtxExt = ext as IJTXExtension;

  if (m_jtxExt != null)
  {
    m_job = m_jtxExt.Job as IJTXJob3;
  }
}


...and at this point, if everything's successful, "m_job" should be a handle to the job that was active when ArcMap was launched.  From there, you can access its ID, name, etc.

Hopefully that helps.

Brian D.
0 Kudos
MarkMindlin
Occasional Contributor III
Thank you Brain,
Actually, user may have several running JTX instances and every instance has its job_id and ArcMaps.
Question: if in the specific ArcMap we would get exactly job_id from its JTX instance?

Another question is if we can write our own step to launch ArcMap instead of "JTXDesktopSteps.LaunchArcMap" step, the important thing is not to lose AOI option, meaning user can't edit area that out from AOI, or if we should do something additional for AOI?
0 Kudos
BrianDemers
Esri Contributor
Regarding your first question: I checked with a developer, and yes, if you're launching a new ArcMap session each time you run your step (that is, you aren't using the "/useexisting" flag with your step), the IJTXExtension object that you retrieve will report the job information for whichever job launched that particular ArcMap session.  This will be true even if multiple Workflow Manager sessions are open and are each launching ArcMap sessions. 

Regarding writing a custom version of LaunchArcMap: it's certainly possible, though it may be overkill.  I'm not sure I follow your use case, but if you're trying to ensure that the user can't edit features outside of their job's AOI, there's now a system setting (new at 10, I believe) that can be used to enforce this:

  1. Open the Workflow Manager Administrator

  2. Connect to your database

  3. Go to "System" --> "Workflow Manager System Settings"

  4. Click on the "Area of Interest" tab

In that dialog, have a look at the settings for the "AOI Edit Extension".  Perhaps one of those settings will meet your needs...?

Brian D.
0 Kudos
MarkMindlin
Occasional Contributor III
Thank you a lot, Brian.
0 Kudos