How to access 'NextRun' variable of a job using GetJobVariable() - VisualCron - Forum

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 Jithin  
#1 Posted : Thursday, June 8, 2017 11:36:43 AM(UTC)
Jithin

Rank: No customer

Joined: 5/11/2017(UTC)
Posts: 1
India
Location: Thiruvananthapuram, Kerala

I have been trying to access the 'NextRun' variable of a job.
foreach (var job in server.Jobs.GetAll())
{
Response.Write("Task Name : " + job.Name + "<br />Next Run : " + job.GetJobVariable("NextRun") + "<br />");
}
This gives me a NullReference Exception every time. Is there any other work around?

Edited by moderator Friday, June 9, 2017 10:33:02 AM(UTC)  | Reason: Not specified

Offline thomas  
#2 Posted : Thursday, June 8, 2017 1:04:42 PM(UTC)
thomas

Rank: Paid support

Joined: 12/10/2013(UTC)
Posts: 471
Norway

Thanks: 22 times
Was thanked: 181 time(s) in 137 post(s)
This has nothing to do with the api itself. It's Reponse.Write that throws the exception if you have null values in the input. Assign to a variable and you will see

Dim j as string
j = "Task Name : " + job.Name + "<br />Next Run : " + job.GetJobVariable("NextRun") + "<br />"

and the exception comes here is my guess:

Response.Write(j)
Offline Support  
#3 Posted : Friday, June 9, 2017 10:32:49 AM(UTC)
Support

Rank: Official support

Joined: 2/23/2008(UTC)
Posts: 11,258

Thanks: 877 times
Was thanked: 450 time(s) in 427 post(s)
Here is some code from the Client in VB.NET:

Code:
    Public Shared Function GetNextExecutionTime(ByVal j As JobClass) As String
        If j.Stats.Active Then
            If j.Stats.DateNextExecution.Year = Date.MinValue.Year Then
                Return LangAPI.GetWord("Never")
            Else
                If ConnectionAPI.CurrentServer.On Then
                    Return TimeAPI.GetDateAdjustedToTimeZoneString(ConnectionAPI.CurrentServer, j.Stats.DateNextExecution)
                Else
                    Return LangAPI.GetWord("Server off")
                End If
            End If
        Else
            Return LangAPI.GetWord("Inactive")
        End If
    End Function
Henrik
Support
http://www.visualcron.com
Please like VisualCron on facebook!
Offline bweston  
#4 Posted : Friday, June 9, 2017 2:09:14 PM(UTC)
bweston

Rank: Paid support

Joined: 12/14/2012(UTC)
Posts: 79

Thanks: 3 times
Was thanked: 16 time(s) in 13 post(s)
Not sure if this will help, but I do a lot of manipulation of the API from powershell, and GetJobVariable doesn't enter into my determining the next run...I use $job.Stats.DateNextExecution.
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