Using a Button to Trigger the Creation of a Job for the Job Server

Using a Button to Trigger the Creation of a Job for the Job Server

Anonymous
Not applicable
1,804 Views
12 Replies
Message 1 of 13

Using a Button to Trigger the Creation of a Job for the Job Server

Anonymous
Not applicable

I have several custom jobs for the Job Processor that are currently triggered by lifecycle changes using the Lifecycle Event Editor. I would like to create a toolbar button that will trigger a specific job to be queued for the selected file or Item. I am not terribly familiar with the Vault API so if somebody could let me know if it is even possible and point me in the right direction I would appreciate it.

0 Likes
1,805 Views
12 Replies
Replies (12)
Message 2 of 13

smithmat
Autodesk
Autodesk

Yes, that sounds possible:

Hope that helps,

- Matt

0 Likes
Message 3 of 13

Anonymous
Not applicable

Matt,

 

Thanks for the feedback. I will work on creating a Vault Explorer Extension.

0 Likes
Message 4 of 13

C-Hoppen
Advocate
Advocate

Hello,

same problem to me. I need to trigger a job on click. I used WebServiceManager.JobService.AddJob.

ISelection selection = e.Context.CurrentSelectionSet.First();

JobParam param1 = new JobParam();
param1.Name = "EntityId";
param1.Val = selection.Id.ToString();

JobParam param2 = new JobParam();
param2.Name = "EntityClassId";
param2.Val = "FILE";

VDF.Vault.Currency.Connections.Connection connection = 
         e.Context.Application.Connection;

connection.WebServiceManager.JobService.AddJob(
                    "myJob",
                    "My Job",
                    new JobParam[2] { param1, param1 },
                    1);

The job appears in Vault's Job Server Queue Dialog but it does not appear in the job processor. (Even after Pause/Continue).

 

Looking at the help WebServiceManager.JobService.AddJob is "Not intended for public use"

Is there a better way?

 

And, what vaues are recommended for the last param priority  ? Is 1 high or low?

 

Thanks

Christoph

0 Likes
Message 5 of 13

C-Hoppen
Advocate
Advocate

Additional information: debugging the job shows the following:

After Pause/Continue the OnJobProcessorWake is fired and immediately after that OnJobProcessorSleep in fired.

It never reaches public JobOutcome Execute.

C.

0 Likes
Message 6 of 13

smilinger
Advisor
Advisor

You should use a job type name that the job processor can recognise, it has no idea what type of job is "myJob" and doesn't know how to deal with it.

 

You can either use the built-in job types such as "autodesk.vault.dwf.create.ipt", or write a add-in and register your own job type, such as "myJob".

0 Likes
Message 7 of 13

Markus.Koechl
Autodesk
Autodesk

To complement the reply of @smilinger, I recommend watching the short video on how to create and register custom Jobs: https://youtu.be/7CWGSSzHcBw

And, I'd liked to pick-up the other questions of @C-Hoppen :

- JobService class - public use: The JobServiceBase class is not intended for public use, but you are encouraged using the JobService class for your custom job extensions.

- Job Priority: In theory, priority- 1- jobs will run before priority 2, 3, etc.. In production environments, the theory gets quickly overruled if you run more than one Job Processor, and each of them is designated to run specific jobs and not any. The article in the SDK Help discusses this in detail: "Job Queue Priority."



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 8 of 13

c_hoppen
Advocate
Advocate

"my job" was just a place holder. Of course it's a registered job. It works well when changing revision state of a file. 

0 Likes
Message 9 of 13

c_hoppen
Advocate
Advocate

The job is fired when using WebServiceManager.JobService.AddJob.

As I wrote, inside my job addin main class the OnJobProcessorWake is fired and immediately after that OnJobProcessorSleep in fired.

It never reaches "public JobOutcome Execute".

Why? 

0 Likes
Message 10 of 13

c_hoppen
Advocate
Advocate

What I forgot to tell: "My Job" is the Export Sample from Markus' Github repository (https://github.com/koechlm/Vault-Sample---InventorExportAnySampleJob)

0 Likes
Message 11 of 13

Markus.Koechl
Autodesk
Autodesk

OK, If I got you right - the job works fine in case of a lifecycle transition submitted it. Now, you target a user submission like this: select one or multiple Inventor files and submit the job for these, right?

My latest contribution to the GitHub samples includes a sample to do this for the new iLogic Job submissions. In this extension, you find an Action menu item "Queue iLogic Job..." Queue_iLogic_Job.pngYou could use it as "Create STEP|JT|... export and allow the format as another user option to choose from. 

BTW: the AU class IM468712 will talk through this iLogic Job extension sample.



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 12 of 13

daniel.li89M5L
Participant
Participant

Hi Mr. Koechl ,

 

Hope you are doing well! I am not able to find the Action menu item "Queue iLogic Job" in Vault Professional 2020. Is there another way to make it happen? Thank you!

 

Best Regards,

Daniel

 

0 Likes
Message 13 of 13

Markus.Koechl
Autodesk
Autodesk
The 2020 branch did not include the user interactive job submission; I suggest using the latest codebase (2022).


Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes