Community forum

Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
View
Go to last post Go to first unread
Offline jptyrus  
#1 Posted : Thursday, August 11, 2011 12:04:37 PM(UTC)
jptyrus
Rank: Member

Joined: 8/1/2011(UTC)
Posts: 12
Location: London

Was thanked: 1 time(s) in 1 post(s)
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?
Offline Support  
#2 Posted : Thursday, August 11, 2011 1:44:48 PM(UTC)
Support
Rank: Administration

Joined: 2/23/2008(UTC)
Posts: 7,723

Thanks: 344 times
Was thanked: 207 time(s) in 198 post(s)
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!
Offline jptyrus  
#3 Posted : Thursday, August 11, 2011 1:49:53 PM(UTC)
jptyrus
Rank: Member

Joined: 8/1/2011(UTC)
Posts: 12
Location: London

Was thanked: 1 time(s) in 1 post(s)
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)

Edited by user Thursday, August 11, 2011 1:50:52 PM(UTC)  | Reason: Not specified

Offline Support  
#4 Posted : Thursday, August 11, 2011 1:52:09 PM(UTC)
Support
Rank: Administration

Joined: 2/23/2008(UTC)
Posts: 7,723

Thanks: 344 times
Was thanked: 207 time(s) in 198 post(s)
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!
Offline jptyrus  
#5 Posted : Thursday, August 11, 2011 1:57:23 PM(UTC)
jptyrus
Rank: Member

Joined: 8/1/2011(UTC)
Posts: 12
Location: London

Was thanked: 1 time(s) in 1 post(s)
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.
Offline Support  
#6 Posted : Thursday, August 11, 2011 2:00:38 PM(UTC)
Support
Rank: Administration

Joined: 2/23/2008(UTC)
Posts: 7,723

Thanks: 344 times
Was thanked: 207 time(s) in 198 post(s)
Yes,

ExitCodes.Load(); // do this once
ExitCodes.GetDescription(TaskProcess.Task.Stats.ExitCode);
Henrik
Support
http://www.visualcron.com

Please like VisualCron on facebook!
Offline jptyrus  
#7 Posted : Thursday, August 11, 2011 2:07:35 PM(UTC)
jptyrus
Rank: Member

Joined: 8/1/2011(UTC)
Posts: 12
Location: London

Was thanked: 1 time(s) in 1 post(s)
That gives me "The operation completed successfully" for most jobs. What does the interface use to get the simple result string "Success"?
Offline Support  
#8 Posted : Thursday, August 11, 2011 2:09:03 PM(UTC)
Support
Rank: Administration

Joined: 2/23/2008(UTC)
Posts: 7,723

Thanks: 344 times
Was thanked: 207 time(s) in 198 post(s)
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!
Offline jptyrus  
#9 Posted : Thursday, August 11, 2011 2:11:17 PM(UTC)
jptyrus
Rank: Member

Joined: 8/1/2011(UTC)
Posts: 12
Location: London

Was thanked: 1 time(s) in 1 post(s)
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?
Offline Support  
#10 Posted : Thursday, August 11, 2011 2:15:05 PM(UTC)
Support
Rank: Administration

Joined: 2/23/2008(UTC)
Posts: 7,723

Thanks: 344 times
Was thanked: 207 time(s) in 198 post(s)
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:

Code:
                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!
Users browsing this topic
Guest
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Scroll to Top