Hi,
I have a simple script that enumerates all scheduler tasks. For each task it just prints out various properties. I found that while some properties return correct values (such as task name, id, description), other properties (such as LastRunTime, NextRunTime, LastRunResult) return empty string.
Would appreciate if someone could do a test on their end and see if there's a bug in the library.
Here's the code if it helps:
IDms myDms = protocol.GetDms();
IDma myDma = myDms.GetAgent(protocol.DataMinerID);
IDmsScheduler scheduler = myDma.Scheduler;List<IDmsSchedulerTask> schedulerTasks = new List<IDmsSchedulerTask>(scheduler.GetTasks());
foreach (IDmsSchedulerTask task in schedulerTasks) {
protocol.Log($"TaskId:{task.Id} | TaskName:{task.TaskName} | Next Run time:{task.NextRunTime} | Last Run Time: {task.LastRunTime} | Last Run Result: {task.LastRunResult}");
}
Thanks.
Hi,
when calling the GetTasks method, the class library performs an SLNet call behind the scenes which retrieves info about the scheduled tasks. However, SLNet does not set the mentioned properties and therefore the class library also does not return a value for these.
To obtain information about the next run time, last run time and last run time result, you could execute the GetStatus method as follows:
IDms myDms = protocol.GetDms();
IDma myDma = myDms.GetAgent(protocol.DataMinerID);
IDmsScheduler scheduler = myDma.Scheduler;
var tasksStatus = scheduler.GetStatus() as Object[];
foreach (var taskStatus in tasksStatus)
{
var taskStatusInfo = (string[]) taskStatus;
string name = taskStatusInfo[0];
string status = taskStatusInfo[1]; // Running/Pending/Finished
string lastResult = taskStatusInfo[2];
string nextRunTime = taskStatusInfo[3]; // "YYYY-MM-DD HH:MM:SS"
string lastRunTime = taskStatusInfo[4]; // "YYYY-MM-DD HH:MM:SS"
string lastRunTimeCode = taskStatusInfo[5]; // "0" - undefined, "1" - OK, "2" - Warning, "3" - Failed string
}
We'll create a task to investigate if we can extend the GetTasks method so it also has values for the mentioned properties.