- Регистрация
- 19.09.2014
- Сообщения
- 36
- Благодарностей
- 3
- Баллы
- 8
I'm creating an application in Visual Studio to read and write data to a database for ZP to work with and want to have quick view of running tasks.
I borrowed some code from another thread to test and added references to the DLLs that darkdiver mentioned in from this thread but AddTries() doesn't change any values in ZP and "var tasks = new List<string>(ZennoPoster.TasksList);" always returns null.
I'm still new to C#... can anyone point out what I'm missing for this to work?
ZennoLab.CommandCenter.dll
ZennoLab.Global.dll
ZennoLab.CommunicationInterfaces.dll
ZennoLab.InterfacesLibrary.dll
ZennoLab.LogLibrary.dll
I borrowed some code from another thread to test and added references to the DLLs that darkdiver mentioned in from this thread but AddTries() doesn't change any values in ZP and "var tasks = new List<string>(ZennoPoster.TasksList);" always returns null.
I'm still new to C#... can anyone point out what I'm missing for this to work?
ZennoLab.CommandCenter.dll
ZennoLab.Global.dll
ZennoLab.CommunicationInterfaces.dll
ZennoLab.InterfacesLibrary.dll
ZennoLab.LogLibrary.dll
Код:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ZennoLab.CommandCenter;
using ZennoLab.InterfacesLibrary;
using ZennoLab.InterfacesLibrary.ProjectModel;
using ZennoLab.InterfacesLibrary.ProjectModel.Collections;
using ZennoLab.InterfacesLibrary.ProjectModel.Enums;
using Global.ZennoExtensions;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var searchName = "Test";
var searchResult = false;
// get the task list from the ZennoPoster
var tasks = new List<string>(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 = "10";
// 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 = "1";
// set new settings
ZennoPoster.SetExecutionSettings(id, esElement1.InnerXml);
}
searchResult = true;
break;
}
}
if (!searchResult)
throw new Exception("Task " + searchName + " not found!");
}
}
}
Последнее редактирование: