Table of Contents

Method UpdateTask

Namespace
Skyline.DataMiner.Core.DataMinerSystem.Common
Assembly
Skyline.DataMiner.Core.DataMinerSystem.Common.dll

UpdateTask(object[])

Updates the specified task. Replaces: slScheduler.SetInfo(userCookie, TSI_UPDATE (2), taskData, out response);

public int UpdateTask(object[] updateData)

Parameters

updateData object[]

Array of data as expected by old Interop call.

Returns

int

Returns 0 if successful.

Examples

int taskId = 100;
string taskDescription = "Updated Task description";
DateTime startDate = DateTime.Now.AddDays(5);
DateTime endDate = DateTime.Now.AddDays(10);

string activStartDay = startDate.ToString("yyyy-MM-dd");
string activStopDay = endDate.ToString("yyyy-MM-dd");

string startTime = startDate.ToString("HH:mm:ss");
string endTime = endDate.ToString("HH:mm:ss");

string taskType = "once";   // Task type     (1=once , 2=weekly, 3=monthly, 4=daily)
string runInterval = "1";   // Run interval  (x minutes(daily) / 1,...,31,101,102(mothly)   / 1,3,5,7 (1=monday, 7=sunday)(weekly))

string scriptName = "scriptName";
string elemLinked = "";     //"PROTOCOL:1:123:456",   // example of linking element 123/456 to script dummy 1
string paramLinked = "";

object[] schedulerTaskData = new object[]
{
/*
varData => PPSA

[0][0][*] : general info
	  [0] : task id
	  [1] : name
	  [2] : start date (YYYY-MM-DD)
	  [3] : end date (YYYY-MM-DD)
	  [4] : start run time (HH:MM)
	  [5] : task type
	  [6] : run interval
	  [7] : # of repeats before final actions are executed
	  [8] : description
	  [9] : enabled
	  [10]: End time
	  [11]: minutes interval for weekly/monthly tasks
   [1][*]	  : repeated actions
	  [0] : type
	  ... : extra info
   [2][*]    : final actions
	  [0] : type
	  ... : extra info

result:
	E_FAIL/E_INVALIDARG
	S_OK
*/
	new object[]
	{
		new string[]    // general info
		{
			taskId.ToString(),               // [0] : task ID
			taskName,                        // [1] : name
			activStartDay,                   // [2] : start date (YYYY-MM-DD) (leave empty to have start time == current time)
			activStopDay,                    // [3] : end date (YYYY-MM-DD)      (can be left empty)
			startTime,                       // [4] : start run time (HH:MM)
			taskType,                        // [5] : task type     (daily   / monthly            / weekly /                      once)
			runInterval,                     // [6] : run interval  (x minutes / 1,...,31,101,102   / 1,3,5,7 (1=monday, 7=sunday)) (101-112 -> months)
			"",                              // [7] : # of repeats before final actions are executed
			taskDescription,				 // [8] : description
			"TRUE",                          // [9] : enabled (TRUE/FALSE)
			endTime,                         // [10] : end run time (HH:MM) (only affects daily tasks)       
			""                               // [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
};

int returnValue = scheduler.UpdateTask(schedulerTaskData);

Exceptions

ArgumentNullException

updateData is null.

UpdateTask(IDmsSchedulerTask)

Updates the specified task.

public int UpdateTask(IDmsSchedulerTask task)

Parameters

task IDmsSchedulerTask

The task to be updated.

Returns

int

Returns 0 if successful.

Examples

var dms = protocol.GetDms();
var dma = dms.GetAgent(protocol.DataMinerID);
var scheduler = dma.Scheduler;

// Retrieve an existing task
var existingTask = scheduler.GetTasks().First(t => t.Id == 123);

// Create a builder from the existing task to modify it
IDmsSchedulerTask updatedTask = scheduler.CreateTaskBuilder(existingTask)
    .WithDescription("Updated description")
    .WithIsEnabled(false)
    .Build();

int result = scheduler.UpdateTask(updatedTask);

Exceptions

ArgumentNullException

task is null.