[Solved] API History Detail For Job and Task - VisualCron - Forum

Community forum

Sharkbait
2015-08-19T15:30:04Z
Hi how can we retrieve the job/task history detail in the AP? I used this post to dig into the log history: http://www.visualcron.co....aspx?g=posts&t=4528  . This was useful but it's missing the history detail. The detail I'm looking for would be something like "task failed with the following exception". You can get this information on the VisualCron interface under job log or task log.

If you can point me to the correct class and class members to get this info that would be great.

Thanks
Support
2015-08-20T09:18:19Z
If you use the Web API you can call this with HTTP Task:

http://localhost:8001/VisualCron/text/Log/Task/List?token={token}&taskId={taskId}&startDate={startDate}&endDate={endDate}

A call with the .NET API looks like this:

            Dim fromDate As New Date(cboDateFromValue.Year, cboDateFromValue.Month, cboDateFromValue.Day, 0, 0, 0)
            Dim toDate As New Date(cboDateToValue.Year, cboDateToValue.Month, cboDateToValue.Day, 23, 59, 59)

            Dim tl As List(Of LogTaskHistoryClass) = objServer.Log.GetTaskHistory(TaskId, fromDate, toDate)

Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Sharkbait
2015-08-22T14:13:34Z
Thanks, unfortunately we are running ver 7.5 and I think the web api is not available until version 7.6.5.

So does this mean the information I'm looking for is not available in the 7.5 API?

Thanks!
Sharkbait
2015-08-24T16:00:04Z
I got the team that runs VisualCron here to upgrade to 7.7. I'll try your suggestion.
Thanks!
ErikC
2015-08-25T06:00:55Z
Originally Posted by: Sharkbait 

Thanks, unfortunately we are running ver 7.5 and I think the web api is not available until version 7.6.5.

So does this mean the information I'm looking for is not available in the 7.5 API?

Thanks!


Hi,

The Web.API and the .NET API are two different thinks. The .NET API is there also in your version. The Web.API is added recently.
So you can do your .NET coding allready.

Regards,
Erik
Uses Visualcron since 2006.
Sharkbait
2015-08-25T18:37:12Z
Originally Posted by: ErikC 

Originally Posted by: Sharkbait 

Thanks, unfortunately we are running ver 7.5 and I think the web api is not available until version 7.6.5.

So does this mean the information I'm looking for is not available in the 7.5 API?

Thanks!


Hi,

The Web.API and the .NET API are two different thinks. The .NET API is there also in your version. The Web.API is added recently.
So you can do your .NET coding allready.

Regards,
Erik


Thanks, the information I need is not available through the API but is available in the web API. See original post above.

Sharkbait
2015-08-25T19:13:45Z
Ok so I checked out the Web API and it looks like the Web API does not provide the exception detail. I expect something like: "Exception in Task: No file(s) copied". The method used an sample results are below...

Method...
http://somedomain.com:80...amp;startDate=2015-08-01  00:00:00&endDate=2015-08-25 23:00:00

Results...
taskid,taskpid,started,exitcode,exitcoderesult,executiontime,executionid,hasstandardoutput,hasstandarderror
4bfc81a3-c388-4b2c-a065-5b4bf8e912be,4064290,8/25/2015 5:48:00 AM,77777,Failure,0.124,3da3113a-068d-4e86-b675-332a5b34c04a,False,True
4bfc81a3-c388-4b2c-a065-5b4bf8e912be,4064342,8/25/2015 5:53:00 AM,77777,Failure,0.097,35592451-dead-4a95-bfc3-053de85a218e,False,True
4bfc81a3-c388-4b2c-a065-5b4bf8e912be,4064388,8/25/2015 5:58:00 AM,77777,Failure,0.108,b867a8e2-6a67-444d-bcd6-171e5763489f,False,True
4bfc81a3-c388-4b2c-a065-5b4bf8e912be,4064447,8/25/2015 6:03:00 AM,0,NotSet,0.192,89d43e0e-bca7-444e-982b-31b91d0fc14f,False,True

Thanks
ErikC
2015-08-26T07:47:43Z
Hi,

I tried to solve this for you with the use of the API (not the web.api):

DateTime fromDate = new DateTime(2015, 8, 26, 7, 30, 0);
DateTime toDate = new DateTime(2015, 8, 26, 7, 40, 0);
string taskId = "dd066664-8888-111c-9222-dbf3333465e3";

foreach (LogTaskHistoryClass hist in s.Log.GetTaskHistory(taskId, fromDate, toDate))
{
	if (hist.ExitCodeResult == ExitCodeClass.ExitCodeResultT.Failure)
	{
		LogTaskOutputClass output = s.Log.GetTaskOutput(hist.ExecutionId, taskId, hist.TaskPId);
		/// output.StandardError 
		/// output.StandardOutput 
	}
}

What I did here was looking at one specific task between two dates.
When the task failed, I look for the output of that specific task and you can use the output object to get the error of the output of that task.
the hist object has also the date time stamp, you you know when the error happened.

For the the job you can use the 'GetJobHistory' method.

Regards,
Erik
Uses Visualcron since 2006.
Support
2015-08-26T08:12:20Z
Originally Posted by: Sharkbait 

Ok so I checked out the Web API and it looks like the Web API does not provide the exception detail. I expect something like: "Exception in Task: No file(s) copied". The method used an sample results are below...

Method...
http://somedomain.com:80...amp;startDate=2015-08-01  00:00:00&endDate=2015-08-25 23:00:00

Results...
taskid,taskpid,started,exitcode,exitcoderesult,executiontime,executionid,hasstandardoutput,hasstandarderror
4bfc81a3-c388-4b2c-a065-5b4bf8e912be,4064290,8/25/2015 5:48:00 AM,77777,Failure,0.124,3da3113a-068d-4e86-b675-332a5b34c04a,False,True
4bfc81a3-c388-4b2c-a065-5b4bf8e912be,4064342,8/25/2015 5:53:00 AM,77777,Failure,0.097,35592451-dead-4a95-bfc3-053de85a218e,False,True
4bfc81a3-c388-4b2c-a065-5b4bf8e912be,4064388,8/25/2015 5:58:00 AM,77777,Failure,0.108,b867a8e2-6a67-444d-bcd6-171e5763489f,False,True
4bfc81a3-c388-4b2c-a065-5b4bf8e912be,4064447,8/25/2015 6:03:00 AM,0,NotSet,0.192,89d43e0e-bca7-444e-982b-31b91d0fc14f,False,True

Thanks



For the next build we have added Task_Output (historic) method in Web API which takes the Task Id, Task PId and Execution Id as parameter.
Henrik
Support
http://www.visualcron.com 
Please like  VisualCron on facebook!
Sharkbait
2015-08-26T14:55:45Z
Originally Posted by: ErikC 

Hi,

I tried to solve this for you with the use of the API (not the web.api):

DateTime fromDate = new DateTime(2015, 8, 26, 7, 30, 0);
DateTime toDate = new DateTime(2015, 8, 26, 7, 40, 0);
string taskId = "dd066664-8888-111c-9222-dbf3333465e3";

foreach (LogTaskHistoryClass hist in s.Log.GetTaskHistory(taskId, fromDate, toDate))
{
	if (hist.ExitCodeResult == ExitCodeClass.ExitCodeResultT.Failure)
	{
		LogTaskOutputClass output = s.Log.GetTaskOutput(hist.ExecutionId, taskId, hist.TaskPId);
		/// output.StandardError 
		/// output.StandardOutput 
	}
}

What I did here was looking at one specific task between two dates.
When the task failed, I look for the output of that specific task and you can use the output object to get the error of the output of that task.
the hist object has also the date time stamp, you you know when the error happened.

For the the job you can use the 'GetJobHistory' method.

Regards,
Erik



That's what I'm looking for! Thanks Erik!
Scroll to Top