var searchName = "имя проекта";
var searchResult = false;
var tasks = ZennoPoster.TasksList;
foreach (var tsk in tasks)
{
var doc = new System.Xml.XmlDocument();
doc.LoadXml("<Task>" + tsk + "</Task>");
var nameElement = doc.SelectSingleNode("Task/Name");
if(nameElement == null) continue;
var name = nameElement.InnerText;
if (name == searchName)
{
var idElement = doc.SelectSingleNode("Task/Id");
if (idElement == null) continue;
var id = Guid.Parse(idElement.InnerText);
var esElement = doc.SelectSingleNode("Task/ExecutionSettings");
if (esElement == null) continue;
// максимум потоков
var threadsElement0 = doc.SelectSingleNode("Task/ExecutionSettings/LimitOfThreads");
if (threadsElement0 == null) continue;
threadsElement0.InnerText = "0";
// сколько делать
var threadsElement1 = doc.SelectSingleNode("Task/ExecutionSettings/NumberOfTries");
if (threadsElement1 == null) continue;
threadsElement1.InnerText = "0";
// старт, стоп
var threadsElement2 = doc.SelectSingleNode("Task/ExecutionSettings/Status");
if (threadsElement2 == null) continue;
threadsElement2.InnerText = "Stop";
ZennoPoster.SetExecutionSettings(id, esElement.InnerXml);
searchResult = true;
System.Threading.Thread.Sleep(5000);
// максимум потоков
threadsElement0.InnerText = project.Variables["Priority"].Value;
// сколько делать
threadsElement1.InnerText = "-1";
System.Threading.Thread.Sleep(5000);
// старт, стоп
threadsElement2.InnerText = "Perform";
ZennoPoster.SetExecutionSettings(id, esElement.InnerXml);
searchResult = true;
break;
}
}
if (!searchResult)
{
project.SendInfoToLog("", "Неправильное имя проекта", true);
return null;
}