• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Vault Customization

    Reply
    Active Contributor kbo
    Active Contributor
    kbo
    Posts: 32
    Registered: 08-18-2010
    Accepted Solution

    Job Processor vb sample vault pro 2012 not working

    191 Views, 9 Replies
    02-01-2012 10:48 AM

    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

     

    Employee
    Posts: 414
    Registered: 12-12-2006

    Re: Job Processor vb sample vault pro 2012 not working

    02-01-2012 11:14 AM in reply to: kbo

    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.
    http://justonesandzeros.typepad.com/

    Active Contributor kbo
    Active Contributor
    kbo
    Posts: 32
    Registered: 08-18-2010

    Re: Job Processor vb sample vault pro 2012 not working

    02-01-2012 02:05 PM in reply to: kbo

    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?

    Employee
    Posts: 22
    Registered: 09-09-2007

    Re: Job Processor vb sample vault pro 2012 not working

    02-01-2012 11:37 PM in reply to: kbo

    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
    Active Contributor kbo
    Active Contributor
    kbo
    Posts: 32
    Registered: 08-18-2010

    Re: Job Processor vb sample vault pro 2012 not working

    02-02-2012 02:02 AM in reply to: barbara.han

    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

    Employee
    Posts: 22
    Registered: 09-09-2007

    Re: Job Processor vb sample vault pro 2012 not working

    02-02-2012 06:34 PM in reply to: kbo

    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
    Active Contributor kbo
    Active Contributor
    kbo
    Posts: 32
    Registered: 08-18-2010

    Re: Job Processor vb sample vault pro 2012 not working

    02-03-2012 01:38 AM in reply to: barbara.han

    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

    Employee
    Posts: 22
    Registered: 09-09-2007

    Re: Job Processor vb sample vault pro 2012 not working

    02-03-2012 01:59 AM in reply to: kbo

    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
    Active Contributor kbo
    Active Contributor
    kbo
    Posts: 32
    Registered: 08-18-2010

    Re: Job Processor vb sample vault pro 2012 not working

    02-03-2012 05:04 AM in reply to: barbara.han

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

     

    jobserver new error.png

    Employee
    Posts: 22
    Registered: 09-09-2007

    Re: Job Processor vb sample vault pro 2012 not working

    02-05-2012 06:40 PM in reply to: kbo

    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