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!
Hi Jan,
This is because a scheduled task is created for each event (START and STOP), more information can be found here.
If you don't want to use the events and just have one scheduled task, you should change your script so that:
var scheduleOnce = new ScheduleOnce(createSchedulerEvent: false);
Hope this helps you further!
Kind regards,
Pieter
thank you very much.
createSchedulerEvent: false works for me. This is exactly what I expected.
best regards
jan