I am trying to get a list of each job execution to monitor execution time over 1-2 weeks and when I call the GetJobHistory method from the Log object I am not getting any results.
I am using the sample client provided. I can connect to the server and the job names etc. all come through. However none of the jobs are coming back with any history. I know the jobs have executed within the 55 hours I am specifying.
Here is the code:
string str;
if (s != null)
{
List<JobClass> allJobs;
allJobs = s.Jobs.GetAll();
AddToLog($"Log from {DateTime.Now.AddHours(-55)} to {DateTime.Now}");
foreach(JobClass j in allJobs)
{
if(j.Stats.Active == true)
{
List<LogJobHistoryClass> j_list = s.Log.GetJobHistory(j.Id, DateTime.Now.AddHours(-55), DateTime.Now, false, true);
if (j_list != null && j_list.Count > 0)
{
foreach (LogJobHistoryClass jhc in j_list)
{
if (jhc.ExitCode != 0)
{
// do something
str = $"Job: {s.Jobs.Get(jhc.JobId).Name} |{jhc.Started}|{jhc.ExecutionTime} | {jhc.ExitCodeResult}";
Console.WriteLine(str);
AddToLog(str) ;
}
}
}
else
{
Console.WriteLine($"Job no History {j.Name} {j.Stats.DateLastExecution}");
AddToLog($"Job no History {j.Name} {j.Stats.DateLastExecution}");
}
}
}
}
Edited by moderator
2018-07-24T08:52:15Z
|
Reason: Not specified