var searchName = "example1";
var searchResult = false;
// get the task list from the ZennoPoster
var tasks = ZennoPoster.TasksList;
foreach (var tsk in tasks)
{
// loading Xml documnt with task content
var doc = new System.Xml.XmlDocument();
doc.LoadXml("<Task>" + tsk + "</Task>");
// Search task by name
var nameElement = doc.SelectSingleNode("Task/Name");
if(nameElement == null) continue;
var name = nameElement.InnerText;
// if we found our task
if (name == searchName)
{
// take task id
var idElement = doc.SelectSingleNode("Task/Id");
if (idElement == null) continue;
var id = Guid.Parse(idElement.InnerText);
// take execution settings element
var esElement = doc.SelectSingleNode("Task/ExecutionSettings");
if (esElement == null) continue;
// take limit of threads of the task
var threadsElement = doc.SelectSingleNode("Task/ExecutionSettings/LimitOfThreads");
if (threadsElement == null) continue;
// change the value
threadsElement.InnerText = "5";
// set new settings
ZennoPoster.SetExecutionSettings(id, esElement.InnerXml);
{
// take execution settings element
var esElement1 = doc.SelectSingleNode("Task/ExecutionSettings");
if (esElement1 == null) continue;
// take limit of threads of the task
var threadsElement1 = doc.SelectSingleNode("Task/ExecutionSettings/NumberOfTries");
if (threadsElement1 == null) continue;
// change the value
threadsElement1.InnerText = project.Variables["rowCount"].Value;
// set new settings
ZennoPoster.SetExecutionSettings(id, esElement1.InnerXml);
}
searchResult = true;
break;
}
}
if (!searchResult)
throw new Exception("Task " + searchName + " not found!");