Iterating through the Jobs and reading the Result for each? - VisualCron - Forum

Community forum

jptyrus
2011-08-11T11:04:37Z
Hi,

I'm finding the API quite esoteric at the moment and can't seem to figure out this seemingly simple functionality.

All I want to do is be able to connect to multiple VC servers, iterate through the list of jobs on each and report the last result for each job (either "Success", "Failure", or presumably something like "Running").

I've managed the connection and grabbing the list of jobs, but I can't seem to find where the last result is stored. Where should I be looking?
Support
2011-08-11T12:44:48Z
You can look at jobObject.Stats.Status and display status depending on that enum.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
jptyrus
2011-08-11T12:49:53Z
That doesn't get me what I need though. I want the last result, not the current status of the job.

(i.e. the column that is displayed as "Result" in the interface)
Support
2011-08-11T12:52:09Z
Sorry, I misunderstood you.

What we do is to check jobObject.Stats.ExitCode. If it is 0 it is success.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
jptyrus
2011-08-11T12:57:23Z
Is there any mapping within the API that will translate an ExitCode into a string? I don't want to report a running job as being an error.
Support
2011-08-11T13:00:38Z
Yes,

ExitCodes.Load(); // do this once
ExitCodes.GetDescription(TaskProcess.Task.Stats.ExitCode);
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
jptyrus
2011-08-11T13:07:35Z
That gives me "The operation completed successfully" for most jobs. What does the interface use to get the simple result string "Success"?
Support
2011-08-11T13:09:03Z
That does not exist. On the client side we just use an if/else.

if exitcode == 0
return "success"
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
jptyrus
2011-08-11T13:11:17Z
Ok, thanks.

Does the exitcode actually change when the job is running, or is the "Result" column actually populated from a combination of exitcode and status?
Support
2011-08-11T13:15:05Z
The result of the Job is based on if any error exists in the Tasks. If a Task is non-zero it is inherited back to the Job.

But yes, result is altered during running, like this:

                If j.Stats.Status = JobStatsClass.StatusT.Running Then
                    drow.Result = LangAPI.JobStatusToString(j.Stats.Status)
                Else
                    If j.Stats.DateLastExecution = Date.MinValue Then
                        drow.Result = LangAPI.GetWord("LBL_SUCCESS")
                    Else
                        If j.Stats.ExitCode = 0 Then
                            drow.Result = LangAPI.GetWord("LBL_SUCCESS")
                        Else
                            drow.Result = LangAPI.GetWord("LBL_FAILED")
                        End If
                    End If
                End If

Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Scroll to Top