Hi,
For our use case we want to create a scheduled task which runs a simple Automation Script (sleep for 3 seconds) every x amount of minutes. To do this we use the following code:
private readonly IDmsScheduler _scheduler;
public void ScheduleReferenceAutomationScriptRuns(string scriptName, int repetitionIntervalInMinutes = 1)
{
var action = DmsSchedulerActionBuilders.CreateScriptAction()
.WithScriptName(scriptName)
.Build();
var builder = _scheduler.CreateTaskBuilder()
.WithActions(new List<IDmsSchedulerAction> { action })
.WithTaskName($"{TaskNamePrefix} Interval {scriptName}")
.WithDescription($"Runs the script every {repetitionIntervalInMinutes} minutes every day")
.WithRepetitionType(DmsSchedulerRepetitionType.Daily)
.WithRepetitionIntervalInMinutes(repetitionIntervalInMinutes.ToString())
.WithIsEnabled(true);
var task = builder.Build();
_scheduler.CreateTask(task);
}
This creates the scheduled task with seemingly no issues but after the task gets triggered for the first time and the automation script completes. The task gets disabled.
Creating a similar Scheduled Task manually does not have the same behaviour.
If you need more information, please let me know.
Kind regards,
Hi Julien,
Could you try and add the following line to the builder. ".WithRepetitions(-1)" (see docs). This should tell the task to run infinitely instead of a set amount of repetitions or until the defined end date is reached, which in your case means indefinitely as there is no endtime defined. It seems the taskbuilder defaults the repetition value to 0 which causes only 1 runtime, whilst the cube UI sends an empty string if the box is not checked, resulting in a value of -1, which is treated as infinite runtimes..
If this does not help, it may be useful to compare the manually created task with the task created by the builder to see what other setting differ and adapt the builder from there. If you post it as a comment I may be able to offer some advise.
Feel free to reach out to techSupport to further look into this.
Kind regards,