Hi,
Would there be an easy way to only toggle the status of a scheduled task through an automation script?
The goal would be that from a Visual overview or automation script a scheduled task can be disabled or re-enabled.
(There seems to be a Class Library request available Method UpdateTask | DataMiner Docs but it requires to pass along every detail of the scheduled task. Would this be the correct way of doing things?)
Thanks
Hi Robin
looking at the code example and the comments that are provided it seems like a lot of tye arguments are optional. Default behavior if you leave them empty would be to leave them unchanged. The only required parameter is the task id ( argument position [0][0][1]). You can just leave the rest blank and specify the enabled state (argument position [0][0][9]) to be either true or false.
Hope this helps.
Hi Baptiste
I tried the method UpdateTask() with the following parameters:
// Build update data
object[] updateData = new object[]
{
new object[]
{
new string[] // general info
{
schedulerTask.Id.ToString(), // [0] : task ID
null, ////taskName, // [1] : name
null, ////activStartDay, // [2] : start date (YYYY-MM-DD) (leave empty to have start time == current time)
null, ////activStopDay, // [3] : end date (YYYY-MM-DD) (can be left empty)
null, ////startTime, // [4] : start run time (HH:MM)
null, ////taskType, // [5] : task type (daily / monthly / weekly / once)
null, ////runInterval, // [6] : run interval (x minutes / 1,…,31,101,102 / 1,3,5,7 (1=monday, 7=sunday)) (101-112 -> months)
null, ////””, // [7] : # of repeats before final actions are executed
null, ////taskDescription, // [8] : description
input.Enable.ToString().ToUpper(), // [9] : enabled (TRUE/FALSE)
null, ////endTime, // [10] : end run time (HH:MM) (only affects daily tasks)
null ////””, // [11]: minutes interval for weekly/monthly tasks either an enddate or a repeat count should be specified
},
},
new object[] // repeat actions
{
//new string[]
//{
// “automation”, // action type
// scriptName, // name of automation script
// elemLinked, // example of linking element 123/456 to script dummy 1
// paramLinked, // … other options & further linking of dummies to elements can be added
// // elem2Linked,
// “CHECKSETS:FALSE”,
// “DEFER:False”, // run sync
//}
},
new object[] { } // final actions
};
// send update command
int returnValue = dma.Scheduler.UpdateTask(updateData);
This gives me the following error:
An exception occurred:
System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
Server stack trace:
at Interop.SLScheduler.ISchedulerEngine.SetInfo(String userCookie, Int32 eType, Object varData, Object& varResult)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Interop.SLScheduler.ISchedulerEngine.SetInfo(String userCookie, Int32 eType, Object varData, Object& varResult)
at Skyline.DataMiner.Net.Scheduler.SchedulerManager.c__DisplayClass6_0.b__1()
at Skyline.DataMiner.Net.Scheduler.SchedulerManager.RetryOnRemotingException(Action action)
at Skyline.DataMiner.Net.Scheduler.SchedulerManager.HandleSetSchedulerInfoMessage(IConnectionInfo connInfo, SetSchedulerInfoMessage msg)
at Skyline.DataMiner.Net.Scheduler.SchedulerManager.HandleSchedulerRequestMessage(IConnectionInfo connInfo, ISchedulerRequestMessage msg)
at Skyline.DataMiner.Net.Facade.HandleClientRequestMessage(IConnectionInfo connInfo, ClientRequestMessage oneMsg, Boolean canQueue)
at Skyline.DataMiner.Net.Facade.HandleMessageInternal(IConnectionInfo connInfo, DMSMessage oneMsg, Int32 groupID, Int32 groupTotal)
at Skyline.DataMiner.Net.Facade.HandleMessage(IConnectionInfo connInfo, DMSMessage oneMsg, Int32 groupID, Int32 groupTotal)
I also checked the logs on the DMA for the Scheduler and this is wat I got:
2023/03/15 17:47:29.555|SLScheduler.exe 10.3.2301.1186|12012|13120|CBase::UpdateTask|DBG|-1|Task info not found for task 1.
Any clues on how to further debug or who to contact?
Thanks in advance!