Languages: C#, VB.NET

View on GitHub to download or comment.

See the Client API Examples Introduction for additional information and prerequisites.

Samples index

This example uses the adTempus API to terminate all running jobs on the server.

sample.cs
// if the adTempus server is on a different computer, replace "." with the server name
using (var session = Scheduler.Connect(".", LoginAuthenticationType.Windows, "", ""))
{
    using (var context = session.NewDataContext())
    {
        var parms = new InstanceQueryParameters();
        //Add WellKnownOIDs.RootGroup to search the root group and all sub-groups
        parms.TargetObjects.Add(WellKnownOIDs.RootGroup);
        
        //look for all active instances
        parms.Statuses.AddRange(JobStatusHelpers.ActiveStatuses);

        var instances=context.GetJobHistory(parms);
        
        foreach(var instance in instances)
        {
            instance.Terminate(TerminationOptions.None);				
        }
    }
}
sample.vb
Using session = Scheduler.Connect(".", LoginAuthenticationType.Windows, "", "")

    Using context = session.NewDataContext()
        Dim parms = New InstanceQueryParameters()
        parms.TargetObjects.Add(WellKnownOIDs.RootGroup)
        parms.Statuses.AddRange(JobStatusHelpers.ActiveStatuses)
        Dim instances = context.GetJobHistory(parms)

        For Each instance In instances
            instance.Terminate(TerminationOptions.None)
        Next
    End Using
End Using

Comments

View on GitHub to comment.