are there any good examples of creating scheduled tasks from an automation script?
Hi Jeroen,
I found a regression test where this code is used to create a scheduled task.
private void CreateScheduledTask(ElementID elementId)
{
var startTime = DateTime.UtcNow.AddHours(10);
bool isUpdate = false;var generalInfo = new List<String>();
generalInfo.Add(TASKNAME); // Name
generalInfo.Add(startTime.ToString("yyyy-MM-dd")); // Start Date (YYYY-MM-DD)
generalInfo.Add(""); // End Date (YYYY-MM-DD)
generalInfo.Add(startTime.ToString("HH:mm:ss")); // Start Time (HH:MM)
generalInfo.Add("once"); // recurrence: { once, daily, weekly, monthly }
generalInfo.Add(""); // run interval (months, days of week, days of month)
generalInfo.Add("-1"); // number of repeats before final actions are executed
generalInfo.Add($"{RT_NAME}_Description"); // Description
generalInfo.Add("True"); // enabled: true/false
generalInfo.Add(""); // End run time (HH:MM) (only affects daily tasks)
generalInfo.Add(""); // minutes interval for weekly/monthly tasks (either an enddate or a repeat count should be specified)var reportAction = new List<string>()
{
"report", //action type
$"{RT_NAME}_FakeReportTemplate", //report name
RT_NAME, //subject
TO_ADDRESS, //TO
null, null, null,
$"ELEMENT:{elementId.ToString()}:{PARAMETER_FILTER}" // Filter with "<" character
};var array = new String[3][][];
array[0] = new String[1][]; // General Info
array[1] = new String[2][]; // Actions
array[2] = new String[0][]; // Final Actions: there are none
array[0][0] = generalInfo.ToArray();
array[1][0] = reportAction.ToArray();var msg = new SetSchedulerInfoMessage();
msg.What = 1; //1 = CREATE
msg.DataMinerID = _appocalypseHelper.GetHelper.GetDmaId();
msg.Info = Int32.MaxValue;
msg.Ppsa = new PPSA(array);_engine.SendSLNetMessage(msg);
}
Moderator note: This is an internal call and we do not recommend using this, as it is not officially supported and we cannot guarantee that it will still work in the future. As a rule, you should avoid using SLNet calls, as these are subject to change without notice.