Please note that VisualCron support is not actively monitoring this community forum. Please use our contact page for contacting the VisualCron support directly.


Ken Gould
2018-04-26T21:28:22Z
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}");
}

}

}
}
Sponsor
Forum information
Support
2018-04-27T17:17:10Z
How long time does it take in the Client?
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Ken Gould
2018-04-27T17:20:48Z
I did see it timeout (~30 seconds) a couple of times when in debug at the GetJobHistory call and my development computer, but when I run it on a box that VisualCron is installed on it came back empty very quickly (< 10 seconds)
wam
2018-07-13T21:18:33Z
I have the same issue.

This worked FINE on 8.2.8.

It appears to be broken now on 8.3.5.

I believe this broke at some point between 8.3.5 early beta and 8.3.5 final release.

Henrik,

The same driver program I wrote for you for our memory leak issue has an ExportToCsv command which tries to export all job history and task history. Neither of these are working now. Hope that helps as it is 100% reproducible on both our dev and prod servers.
wam
2018-07-13T21:39:43Z
The API appears to be broke. Attached is a screenshot showing there are 48,363 history rows in dev.

VisualCronSettingsLogDatabaseSettungsTab.png

If helpful, I notice that this is what is returned in Visual Studio debugger when I dump in the Immediate Window the server.Log.DBSettings object:

server.Log.DBSettings
{VisualCron.LogDBSettingsClass}
    LogAuditDateEnd: {1/1/0001 12:00:00 AM}
    LogAuditDateStart: {1/1/0001 12:00:00 AM}
    LogAuditKeepForXDays: true
    LogAuditKeepForXDaysCount: 14
    LogAuditKeepMaximumRows: true
    LogAuditMaximumRowCount: 2000
    LogGeneralDateEnd: {1/1/0001 12:00:00 AM}
    LogGeneralDateStart: {1/1/0001 12:00:00 AM}
    LogGeneralKeepForXDays: true
    LogGeneralKeepForXDaysCount: 14
    LogGeneralKeepMaximumRows: false
    LogGeneralMaximumRowCount: 50000
    LogJobDateEnd: {1/1/0001 12:00:00 AM}
    LogJobDateStart: {1/1/0001 12:00:00 AM}
    LogJobKeepForXDays: true
    LogJobKeepForXDaysCount: 14
    LogJobKeepMaximumRows: false
    LogJobMaximumRowCount: 10000
    LogTaskDateEnd: {1/1/0001 12:00:00 AM}
    LogTaskDateStart: {1/1/0001 12:00:00 AM}
    LogTaskKeepForXDays: true
    LogTaskKeepForXDaysCount: 14
    LogTaskKeepMaximumRows: false
    LogTaskMaximumRowCount: 10000
    LogToDB: true


I even tried to force the settings to see if somehow the settings being DateTime.MinValue and KeepMaximumRows = false were causing problems, but still I get zero rows back:


           var settings = server.Settings;
            settings.LogDB.LogTaskDateEnd = DateTime.MaxValue;
            settings.LogDB.LogJobDateEnd = DateTime.MaxValue;
            settings.LogDB.LogAuditDateEnd = DateTime.MaxValue;
            settings.LogDB.LogJobKeepMaximumRows = true;
            settings.LogDB.LogTaskKeepMaximumRows = true;
            settings.LogDB.LogAuditKeepMaximumRows = true;
            server.UpdateServerSettings(settings);
Support
2018-07-16T08:49:34Z
Originally Posted by: wam 

The API appears to be broke. Attached is a screenshot showing there are 48,363 history rows in dev.



The screenshot shows 48,363 of General log. It is not related to Job log or Audit log. In the screenshot you have very few of the others. I suggest keeping General log to a mininum and focus on Job, Task and Audit log as General log you always have on file.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
wam
2018-07-18T19:38:50Z
Hi Henrik,

All of the logs are empty from the API... I understand I was referring to the General log in the screenshot, but when i dump any of the logs, its all zero rows.

This definitely worked at some point. We were on 8.2.8 without issues. On 8.3.5 it is broke.


        private List<JobHistory> SelectJobHistory(Server server, bool failedOnly)
        {
            var jobs = GetAllJobs(server).Select(j => new
            {
                JobId = j.Id,
                JobName = j.Name
            });
            var jobLogsToWrite = new List<JobHistory>();

            foreach (var job in jobs)
            {
                var jobLog = server.Log.GetJobHistory(
                    job.JobId,
                    DateTime.Today.AddDays(-7),
                    DateTime.Today,
                    failedOnly)
                    .Select(jh => new JobHistory
                    {
                        JobId = job.JobId,
                        JobName = job.JobName,
                        ExecutionId = jh.ExecutionId,
                        ExecutionTime = jh.ExecutionTime,
                        ExitCode = jh.ExitCode,
                        ExitCodeResult = jh.ExitCodeResult.ToString(),
                        Started = jh.Started,
                    }).ToList();

                jobLogsToWrite.AddRange(jobLog);
            }

            return jobLogsToWrite;
        }

        private List<JobClass> GetAllJobs(Server server)
        {
            return server.Jobs.GetAll()
                .OrderBy(x => x.Group)
                .ThenBy(x => x.Name)
                .ToList();
        }
wam
2018-07-18T22:25:13Z
Hmm... it is working now.

I suspect there is some kind of bug in how VIsualCron loads the job log...

Maybe when I first ran Log.GetJobHistory, no jobs had ran.

Either way, it now works after we restarted the test server. NO IDEA WHY.

I do think there is a bug here.
Support
2018-07-24T08:52:02Z
Originally Posted by: wam 

Hmm... it is working now.

I suspect there is some kind of bug in how VIsualCron loads the job log...

Maybe when I first ran Log.GetJobHistory, no jobs had ran.

Either way, it now works after we restarted the test server. NO IDEA WHY.

I do think there is a bug here.



Ok, please keep us updated if you can reproduce this.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Similar Topics
Users browsing this topic
Scroll to Top