Hi Dojo,
I am trying to create an automation script that creates a scheduled task. The goal is to have this task trigger another script with a specific parameter. This task should run only once at a specific date and time.
I have based my code on the documentation here: https://docs.dataminer.services/develop/devguide/ClassLibrary/ClassLibraryScheduler.html
And I referenced the API types here: https://docs.dataminer.services/develop/api/types/Skyline.DataMiner.Core.Scheduler.Automation.Scheduler.html
Here is the code I am using:
C#
var scheduler = new Scheduler(engine.GetUserConnection(), t => t != null);
var scheduleOnce = new ScheduleOnce(createSchedulerEvent: true);
var startTime = DateTime.Now.AddMinutes(1);
var endTime = startTime.AddMinutes(1);
var paramsList = new List<AutomationScriptInputParameter>
{
new AutomationScriptInputParameter(1, "Zacinam"),
};
var scriptAction = new AutomationScriptAction("GIE", checkSets: true, runAsync: false, paramsList, Array.Empty<Skyline.DataMiner.Net.Messages.AutomationProtocolInfo>());
var task = new Skyline.DataMiner.Core.Scheduler.Automation.SchedulerTask("TestScheduledRun", "Run Just Once", startTime, endTime, scheduleOnce, scriptAction);
scheduler.CreateOrUpdateSchedulerTask(task);
The Issue: I expected this to create a single task in the Scheduler named "TestScheduledRun". However, it creates two separate tasks:
GIE - TestScheduledRun - START(runs atstartTime)GIE - TestScheduledRun - STOP(runs atendTime)
My Question: How can I create a single task that executes only once at the defined time, without generating the secondary STOP task?
Any advice is appreciated. Thanks!
Hello Jan
Based on the documentation that you added, can you check if you can clear the 'schedulerTask.ISchedulerFinalAction' property. This action triggers when the end time is reached
A second option I'm considering is whether you could create the task without an endtime. Since you are trying to create a task that only executes once, there is no need for an endtime.
If both option do not work, you could create the tasks in an alternative way with the IDmsScheduler , which I believe does not have the same behaviour, even when adding endtime.