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


Guest
2022-04-05T21:26:03Z
I'm am attempting to bypass reporting on tasks that are not active, the status changes occasionally.

I have been able to "Activate" as task using svr.Jobs.Tasks.Activate(tID), however I only want to report on the status, not change it as with: JobObject.Stats.Active, is there a JobObject.Tasks.Stats.Active that I'm just not finding?

Line 28 is where I would like to check the status, if active or not, if not then bypass the print.

svr = clnt.Connect(conn, true);
List<JobClass> jobs = svr.Jobs.GetAll();
or (int i = 0; i < jobs.Count; i++)
	{
		JobClass job = jobs[i];

		if (job.Stats.DateNextExecution.ToString() != "1/1/0001 6:00:00 AM")
		{
		String triggerDesc = "";
		if (job.HasActiveTimeTriggers())
		{
			foreach (var trigger in job.Triggers)
			{
				if (trigger.Active)
					triggerDesc += trigger.Description + ", ";
				Console.WriteLine(trigger.Description);
			}
		}
		if (job.Id == "bebe80d0-0a46-4d63-9746-c416c2d269b6")
		{
			Hydra = svr.Jobs.Get("bebe80d0-0a46-4d63-9746-c416c2d269b6", false, false);
			List<TaskClass> Tasks = Hydra.Tasks;
			for (int j = 0; j < Tasks.Count; j++)
			{
				TaskClass task = Tasks[j];
				var testclass = Tasks[j];
				String tID = task.Id;
				Boolean isActive = svr.Jobs.Tasks.Activate(tID);
				String HtaskName = task.Name;
				Console.WriteLine("Task Name: " + HtaskName);
				if (isActive)
				{
					sw.WriteLine("<tr>");
					sw.WriteLine("<td></td>");
					sw.WriteLine("   <td>Hail HYDRA!</td>");
					sw.WriteLine("   <td> " + task.TaskType.ToString() + ": " + HtaskName + "</td>");
					sw.WriteLine("</tr>");
				}
			}
		}
	}
}
Sponsor
Forum information
Gary_W
2022-04-06T15:34:50Z
You'll want to query the task's stats object's "active" attribute if I'm understanding you correctly. I do a similar thing in powershell, loop through jobs, then loop through tasks:

if ($job.stats.active -eq "True")


So if I understand your code you have the task so:

Boolean isActive = task.stats.active;


Please let me know if I'm right!
Guest
2022-04-06T20:01:27Z
You are correct, thank you. I will make one slight change though in the case of the call: Boolean isActive = task.Stats.Active;
Michael Fjellström
2022-04-07T12:25:01Z
Gary_W
2022-04-07T12:28:18Z
Scroll to Top