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