Languages: C#, VB.NET
View on GitHub to download or comment.
See the Client API Examples Introduction for additional information and prerequisites.
This script retrieves scheduled execution times for all jobs on the server.
The script calls GetJobExecutionTimes to calculate the scheduled executions for all jobs on the server for the next 24 hours.
//if the adTempus server is on a different computer, replace "." with the name
using (var session = Scheduler.Connect(".", LoginAuthenticationType.Windows, "", ""))
{
using (var context = session.NewDataContext())
{
var parms=new JobQueryParameters();
//don't look at held jobs
parms.IncludeHeldJobs= IncludeExcludeType.Exclude;
//specify the jobs or groups to get runtimes for.
//If you add WellKnownOIDs.RootGroup, you tell it to look at all jobs on the server.
//you can also specify the OIDs of one or more individual jobs or groups.
parms.TargetObjects.Add(WellKnownOIDs.RootGroup);
//set the date/time as appropriate; this will get all executions for the next 24 hours
//Note: startTime and endTime must be in the local timezone of the adTempus server
var startTime=DateTime.Now;
var endTime=startTime.AddHours(24);
var runtimes=context.GetJobExecutionTimes(parms, startTime, endTime);
foreach(var item in runtimes)
{
Console.WriteLine(item.FullyQualifiedJobName);
foreach(var runtime in item.ExecutionTimes)
{
Console.WriteLine(runtime.ToString("yyyy-MM-dd HH:mm"));
}
}
}
}
'if the adTempus server is on a different computer, replace "." with the name
Using session = Scheduler.Connect(".", LoginAuthenticationType.Windows, "", "")
Using context = session.NewDataContext()
Dim parms = New JobQueryParameters()
'don't look at held jobs
parms.IncludeHeldJobs = IncludeExcludeType.Exclude
'specify the jobs or groups to get runtimes for.
'If you add WellKnownOIDs.RootGroup, you tell it to look at all jobs on the server.
'you can also specify the OIDs of one or more individual jobs or groups.
parms.TargetObjects.Add(WellKnownOIDs.RootGroup)
'set the date/time as appropriate; this will get all executions for the next 24 hours
'Note: startTime and endTime must be in the local timezone of the adTempus server
Dim startTime = DateTime.Now
Dim endTime = startTime.AddHours(24)
Dim runtimes = context.GetJobExecutionTimes(parms, startTime, endTime)
For Each item In runtimes
Console.WriteLine(item.FullyQualifiedJobName)
For Each runtime In item.ExecutionTimes
Console.WriteLine(runtime.ToString("yyyy-MM-dd HH:mm"))
Next
Next
End Using
End Using
View on GitHub to comment.