Community
Vault Customization
Share your knowledge, ask questions, and explore popular Vault API, Data Standard, and VBA topics related to programming, creating add-ins, or working with the Vault API.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Job Processor vb sample vault pro 2012 not working

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
Anonymous
1239 Views, 9 Replies

Job Processor vb sample vault pro 2012 not working

Anonymous
Not applicable

Did anyone have luck example on the jobprocessor to work?

 

When i submit the job it says status pending and never goes on?

 

job processor error.png

 

0 Likes

Job Processor vb sample vault pro 2012 not working

Did anyone have luck example on the jobprocessor to work?

 

When i submit the job it says status pending and never goes on?

 

job processor error.png

 

9 REPLIES 9
Message 2 of 10
Redmond.D
in reply to: Anonymous

Redmond.D
Autodesk
Autodesk

Are you running JobProcessor.exe?  If so, do you see your job type listed when you go to Administration -> Job Types?



Doug Redmond
Software Engineer
Autodesk, Inc.

0 Likes

Are you running JobProcessor.exe?  If so, do you see your job type listed when you go to Administration -> Job Types?



Doug Redmond
Software Engineer
Autodesk, Inc.

Message 3 of 10
Anonymous
in reply to: Anonymous

Anonymous
Not applicable

on the local computer the jobserver is running? and shows like this

jobserver1.pngjobserver2.pngjobserver3.pngjobserver4.pngjobserver5.pngjobserver6.png

 

on the server the jobserver is running also and shows this.

 

serverjobserver.png

 

i setup a jobserver user "VaultJobServer" that i typed in to the jobserver as the user to run the jobserver?

 

jobserver user.png

 

what do i do wrong?

0 Likes

on the local computer the jobserver is running? and shows like this

jobserver1.pngjobserver2.pngjobserver3.pngjobserver4.pngjobserver5.pngjobserver6.png

 

on the server the jobserver is running also and shows this.

 

serverjobserver.png

 

i setup a jobserver user "VaultJobServer" that i typed in to the jobserver as the user to run the jobserver?

 

jobserver user.png

 

what do i do wrong?

Message 4 of 10
barbara.han
in reply to: Anonymous

barbara.han
Alumni
Alumni
Accepted solution

You might not see the readme.txt file, which has a statement like this:

To Process a job: Go to the Explorer folder under your Vault Client install path. Edit JobProcessor.exe.config in a text or XML editor. Add

<jobHandler class="MyCompany.File.Publish" handler="JobProcessorApiSamples.FolderPublishJobHandler, JobProcessorApiSamples"/>

in the <jobHandlers> section. Save and close.

 

If you did above mentioned, you will see a new job type called "MyCompany.File.Publish" in the job type list, also that job will be handled by JobProcessor.exe when it runs.

 

Hope this helps.

Barbara Han
Developer Technical Services
Autodesk Developer Network
0 Likes

You might not see the readme.txt file, which has a statement like this:

To Process a job: Go to the Explorer folder under your Vault Client install path. Edit JobProcessor.exe.config in a text or XML editor. Add

<jobHandler class="MyCompany.File.Publish" handler="JobProcessorApiSamples.FolderPublishJobHandler, JobProcessorApiSamples"/>

in the <jobHandlers> section. Save and close.

 

If you did above mentioned, you will see a new job type called "MyCompany.File.Publish" in the job type list, also that job will be handled by JobProcessor.exe when it runs.

 

Hope this helps.

Barbara Han
Developer Technical Services
Autodesk Developer Network
Message 5 of 10
Anonymous
in reply to: barbara.han

Anonymous
Not applicable

That did the trick? now the jobs are added to the jobqueue but i have to pause and resume the jobserver to get the jobs running? can you explain why? and another thing is that in the code there is a bytes warning how do i get this right?

 

Jobserver error.pngJobserver code error.png

0 Likes

That did the trick? now the jobs are added to the jobqueue but i have to pause and resume the jobserver to get the jobs running? can you explain why? and another thing is that in the code there is a bytes warning how do i get this right?

 

Jobserver error.pngJobserver code error.png

Message 6 of 10
barbara.han
in reply to: Anonymous

barbara.han
Alumni
Alumni

What you need to do is please follow the instruction explained in the readme file in Job processor sample. The job type is missing in your job type list (see your previous pic), this means that job has no jobhandler so it won't be hanlded.

 

No need to stop/assume job server. I did't say you should do that.

 

that warning you showed in your pic doesn't matter, you can leave it alone.

 

Barbara Han
Developer Technical Services
Autodesk Developer Network
0 Likes

What you need to do is please follow the instruction explained in the readme file in Job processor sample. The job type is missing in your job type list (see your previous pic), this means that job has no jobhandler so it won't be hanlded.

 

No need to stop/assume job server. I did't say you should do that.

 

that warning you showed in your pic doesn't matter, you can leave it alone.

 

Barbara Han
Developer Technical Services
Autodesk Developer Network
Message 7 of 10
Anonymous
in reply to: barbara.han

Anonymous
Not applicable

i Did do what you told me to do - the problem was my virus scanner was bloggin the jobserver to start. when i disconnected the virus scanner it all worked. Thanks to your help

0 Likes

i Did do what you told me to do - the problem was my virus scanner was bloggin the jobserver to start. when i disconnected the virus scanner it all worked. Thanks to your help

Message 8 of 10
barbara.han
in reply to: Anonymous

barbara.han
Alumni
Alumni

Nice. Some time back, I wrote a sample which auto-fires the JobProcessor.exe after the job is posted to job queue, so no need to wait till JobProcessor.exe to run up periodly to deal with your job. I copied the code below, in case it's useful for you:

Replace the QueuePublishJobCommandHandler function in QueuePublishJobCommandExtension.vb file with the following code:

Public Sub QueuePublishJobCommandHandler(s As Object, e As CommandItemEventArgs)

'Create your own job

For Each vaultObj As ISelection In e.Context.CurrentSelectionSet
Dim file As File = m_serviceManager.DocumentService.GetLatestFileByMasterId(vaultObj.Id)
Dim param1 As JobParam = New JobParam
param1.Name = "FileVersionId"
param1.Val = file.Id.ToString()

Dim fileNameParam As New JobParam()
fileNameParam.Name = "FileName"
fileNameParam.Val = vaultObj.Label

Dim mySyncJob As Job = _
m_serviceManager.JobService.AddJob("MyCompany.File.Publish", "property sync job", New JobParam() {param1, fileNameParam}, 1)
Next


' Try to run a new instance of Job Processor
Dim processes() As Process = System.Diagnostics.Process.GetProcessesByName("JobProcessor")
If processes.Count > 0 Then
Dim Pcs As Process
For Each Pcs In processes
Pcs.CloseMainWindow()
Next
End If

Try
Dim mypcs As New Process
mypcs.StartInfo.FileName = "JobProcessor.exe"
mypcs.Start()
Catch ex As Exception

End Try
End Sub

Next, replace the Execute function in FolderPublishJobHandler.vb file with the following code:

Public Function Execute(context As IJobProcessorServices, job As IJob) As JobOutcome Implements IJobHandler.Execute 
Dim fileMasterId As Long = Convert.ToInt64(job.Params("FileVersionId"))
Dim fileName As String = job.Params("FileName")
Try
' Do something here, e.g. PrintFiles

 

' Close the JobProcessor.exe
Dim processes() As Process = System.Diagnostics.Process.GetProcessesByName("JobProcessor")
If processes.Count > 0 Then
Dim Pcs As Process
For Each Pcs In processes
Pcs.CloseMainWindow()
Next
End If

Return JobOutcome.Success
Catch er As Exception
Return JobOutcome.Failure
End Try
End Function

Barbara Han
Developer Technical Services
Autodesk Developer Network
0 Likes

Nice. Some time back, I wrote a sample which auto-fires the JobProcessor.exe after the job is posted to job queue, so no need to wait till JobProcessor.exe to run up periodly to deal with your job. I copied the code below, in case it's useful for you:

Replace the QueuePublishJobCommandHandler function in QueuePublishJobCommandExtension.vb file with the following code:

Public Sub QueuePublishJobCommandHandler(s As Object, e As CommandItemEventArgs)

'Create your own job

For Each vaultObj As ISelection In e.Context.CurrentSelectionSet
Dim file As File = m_serviceManager.DocumentService.GetLatestFileByMasterId(vaultObj.Id)
Dim param1 As JobParam = New JobParam
param1.Name = "FileVersionId"
param1.Val = file.Id.ToString()

Dim fileNameParam As New JobParam()
fileNameParam.Name = "FileName"
fileNameParam.Val = vaultObj.Label

Dim mySyncJob As Job = _
m_serviceManager.JobService.AddJob("MyCompany.File.Publish", "property sync job", New JobParam() {param1, fileNameParam}, 1)
Next


' Try to run a new instance of Job Processor
Dim processes() As Process = System.Diagnostics.Process.GetProcessesByName("JobProcessor")
If processes.Count > 0 Then
Dim Pcs As Process
For Each Pcs In processes
Pcs.CloseMainWindow()
Next
End If

Try
Dim mypcs As New Process
mypcs.StartInfo.FileName = "JobProcessor.exe"
mypcs.Start()
Catch ex As Exception

End Try
End Sub

Next, replace the Execute function in FolderPublishJobHandler.vb file with the following code:

Public Function Execute(context As IJobProcessorServices, job As IJob) As JobOutcome Implements IJobHandler.Execute 
Dim fileMasterId As Long = Convert.ToInt64(job.Params("FileVersionId"))
Dim fileName As String = job.Params("FileName")
Try
' Do something here, e.g. PrintFiles

 

' Close the JobProcessor.exe
Dim processes() As Process = System.Diagnostics.Process.GetProcessesByName("JobProcessor")
If processes.Count > 0 Then
Dim Pcs As Process
For Each Pcs In processes
Pcs.CloseMainWindow()
Next
End If

Return JobOutcome.Success
Catch er As Exception
Return JobOutcome.Failure
End Try
End Function

Barbara Han
Developer Technical Services
Autodesk Developer Network
Message 9 of 10
Anonymous
in reply to: barbara.han

Anonymous
Not applicable

I tried your code but it gives me 2 new errors? what do i do about them?

 

jobserver new error.png

0 Likes

I tried your code but it gives me 2 new errors? what do i do about them?

 

jobserver new error.png

Message 10 of 10
barbara.han
in reply to: Anonymous

barbara.han
Alumni
Alumni

Please just use the SDK code for adding job to the queue. My code sample was wrote for previous version.

 

The key code is to fire JobProcessor tafter the custom job is added to queue. Here is the code that really matter:

 

Public Sub QueuePublishJobCommandHandler(s As Object, e As CommandItemEventArgs)
' TODO: You can add custom job here...

' Try to run a new instance of Job Processor
Dim processes() As Process = System.Diagnostics.Process.GetProcessesByName("JobProcessor")
If processes.Count > 0 Then
Dim Pcs As Process
For Each Pcs In processes
Pcs.CloseMainWindow()
Next
End If

Try
Dim mypcs As New Process
mypcs.StartInfo.FileName = "JobProcessor.exe"
mypcs.Start()
Catch ex As Exception

End Try
End Sub

FolderPublishJobHandler.vb file:

Public Function Execute(context As IJobProcessorServices, job As IJob) As JobOutcome Implements IJobHandler.Execute 

Try
' Handle the custom job here...

 

' Close JobProcessor if needed:
Dim processes() As Process = System.Diagnostics.Process.GetProcessesByName("JobProcessor")
If processes.Count > 0 Then
Dim Pcs As Process
For Each Pcs In processes
Pcs.CloseMainWindow()
Next
End If

Return JobOutcome.Success
Catch er As Exception
Return JobOutcome.Failure
End Try
End Function

Barbara Han
Developer Technical Services
Autodesk Developer Network
0 Likes

Please just use the SDK code for adding job to the queue. My code sample was wrote for previous version.

 

The key code is to fire JobProcessor tafter the custom job is added to queue. Here is the code that really matter:

 

Public Sub QueuePublishJobCommandHandler(s As Object, e As CommandItemEventArgs)
' TODO: You can add custom job here...

' Try to run a new instance of Job Processor
Dim processes() As Process = System.Diagnostics.Process.GetProcessesByName("JobProcessor")
If processes.Count > 0 Then
Dim Pcs As Process
For Each Pcs In processes
Pcs.CloseMainWindow()
Next
End If

Try
Dim mypcs As New Process
mypcs.StartInfo.FileName = "JobProcessor.exe"
mypcs.Start()
Catch ex As Exception

End Try
End Sub

FolderPublishJobHandler.vb file:

Public Function Execute(context As IJobProcessorServices, job As IJob) As JobOutcome Implements IJobHandler.Execute 

Try
' Handle the custom job here...

 

' Close JobProcessor if needed:
Dim processes() As Process = System.Diagnostics.Process.GetProcessesByName("JobProcessor")
If processes.Count > 0 Then
Dim Pcs As Process
For Each Pcs In processes
Pcs.CloseMainWindow()
Next
End If

Return JobOutcome.Success
Catch er As Exception
Return JobOutcome.Failure
End Try
End Function

Barbara Han
Developer Technical Services
Autodesk Developer Network

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report