Changing Parameters of Existing Task

Below is the example of using the SetScheduler operation to change task parameters. The request contains moniker of scheduled tasks container and a pattern indicating whether tasks properties must be changed. A task with a new execution period is also sent.

SOAP request:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SetScheduler xmlns="http://www.fsight.ru/PP.SOM.Som">
<tScheduler xmlns="">
  <id>S1!M!6445</id>
  </tScheduler>
<tArg xmlns="">
<pattern>
  <obInst>true</obInst>
  <tasks>Change</tasks>
<task>
  <properties>true</properties>
  </task>
  </pattern>
<meta>
<tasks>
<its>
<it>
  <k>6449</k>
  <id>RUN_MODULE</id>
  <type>Unknown</type>
<properties>
<period>
  <type>Daily</type>
  <startDateTime>2000-01-01T00:00:00</startDateTime>
  <stopDateTime>2010-01-01T00:00:00</stopDateTime>
  </period>
  <active>false</active>
  </properties>
  </it>
  </its>
  </tasks>
  </meta>
  </tArg>
  </SetScheduler>
  </s:Body>
  </s:Envelope>

SOAP response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<SetSchedulerResult xmlns="http://www.fsight.ru/PP.SOM.Som" xmlns:q1="http://www.fsight.ru/PP.SOM.Som" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<id xmlns="">
  <id>S1!M!6445</id>
  </id>
  </SetSchedulerResult>
  </soapenv:Body>
  </soapenv:Envelope>

JSON request:

{
"SetScheduler" :
{
"tScheduler" :
{
"id" : "S1!M!6445"
},
"tArg" :
{
"pattern" :
{
"obInst" : "true",
"tasks" : "Change",
"task" :
{
"properties" : "true"
}
},
"meta" :
{
"tasks" :
{
"its" :
{
"it" :
[
{
"k" : "6449",
"id" : "RUN_MODULE",
"type" : "Unknown",
"properties" :
{
"period" :
{
"type" : "Daily",
"startDateTime" : "2000-01-01T00:00:00",
"stopDateTime" : "2010-01-01T00:00:00"
},
"active" : "false"
}
}
]
}
}
}
}
}
}

JSON response:

{
"SetSchedulerResult" :
{
"id" :
{
"id" : "S1!M!6445"
}
}
}
public static SetSchedulerResult ChangeTaskProperty(SchedulerId moniker, SchedulerTask task)
{
var somClient = new SomPortTypeClient(); // Proxy object for operation execution
//Operation execution parameters
var tSet = new SetScheduler()
{
tScheduler = moniker,
tArg = new SetSchedulerArg()
{
//Pattern that indicates whether tasks should be changed
pattern = new SchedulerMdPattern
{
tasks = ListOperation.Change,
task = new SchedulerTaskPattern()
{
properties = true
}
},
meta = new SchedulerMd()
{
tasks = new SchedulerTasks()
{
its = new SchedulerTask[]
{
new SchedulerTask()
{
id = task.id,
k = task.k,
//Updated task properties
properties = new SchedulerTaskProperties()
{
active = false,
period = new SchedulerTaskPeriod()
{
type = SchedulerTaskPeriodType.Daily,
startDateTime = DateTime.Parse("01.01.2000"),
stopDateTime = DateTime.Parse("01.01.2010")
}
}
}
}
}
}
}
};
//Start task scheduler
var tResult = somClient.SetScheduler(tSet);
return tResult;
}

See also:

SetScheduler