Is there any way to get the Unique ID for a job run that was just started? I would like to start a job and output when each task in the job finishes.
The code below mostly works, but if the job is running twice I will see the ended events from the other runs. I only want to see the events from the run i just started. I think need something like the line that is currently commented out, but I'm not sure how to get the UniqueId.
var job = server.Jobs.Get(ConfigurationManager.AppSettings["JobId"]);
var r = server.Jobs.Run(job, true, true);
server.Processes.TaskProcessEnded += delegate (ref Server server1, VCTaskProcessClass pc)
{
//if (pc.UniqueId == r.UniqueId)
if (pc.JobId == job.Id)
{
var task = server.Jobs.Tasks.Get(pc.TaskId);
Console.WriteLine("Task Ended " + task.Name);
}
};
Edited by moderator
2016-04-27T06:59:54Z
|
Reason: Not specified