How to control tasks in ZP from Visual Studio C# application?

  • Автор темы Автор темы cheekybot
  • Дата начала Дата начала

cheekybot

Client
Регистрация
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

Код:
Развернуть Свернуть Копировать
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!");
    }
  }
}

3c9926323d.png
 
Последнее редактирование:
var tasks = ZennoPoster.TasksList.ToList();
 
Still running into the same problem

4c6ad3a70e.png


I changed to an easier task to test and show what I mean:

Here is Visual Studio

3d4618cd58.png


Here is Code Creator

7ecd08c1ac.png
 
I think it's restricted in nondeveloper license. You should run it only in template through zennoposter.
I've tried the same and got the same error message.
Instance instance = new Instance("127.0.0.1", 40505, "server") raise the same error;
And what will support say ?
 
I opened a ticket with support, waiting to hear from them now..

Thanks for helping me check out the issue :)
 
This method should work in ZennoPoster, when you run your project there. Not from VS.
 
Would love to know too. In general, ZP would be worth 5x its value to me if I could get external VS applications and ZP to play together without using hackish methods.

Right now I'm stuck with the following tedious way of communication between VS and ZP:
1. Convert .NET 4.5 object to 4.0
2. Serialize object to json
3. Save json object in a textfile in the folder the ZP task manager watches
4. Read the textfile from ZP
5. Deserialize json object to .NET 4.0 object
6. After the work is done, serialize to json once again
7. Send object in a POST request to an end point which my VS application listens to


Would LOVE if ZP simply could be included as a library and controlled directly from other VS projects (as well as being upgraded to .NET 4.5).
 
May be if you buy develeper licence you could realize your intention. Anyway by now you can rewrite your application into libriary for zennoposter and run it in c# macros.
 
ZP can be laggy sometimes.. I want to control ZP when it's minimized and have tabs/windows for my own code outside of ZP.

If I have to click play on a ZP task just to access my application that controls ZP.. no point having an all-in-one application..

Shouldn't have to buy developer license to have external VS access. There's already a commission if you sell your project without dev license. ZP should already have security there if they want to make max profit..

Maybe @darkdiver can share some info to help? I saw in this thread he mentions using ZP classes in VS.. http://zennolab.com/discussion/thre...ter-method-into-my-dll-file.14921/#post-90388
 
It's located on the wiki here https://wiki.zennolab.com/doku.php?id=en:devlicense:general

Problem is, for $200 per 6 months is a lot to have a .exe if you don't want to sell it. Forces you to sell projects even if you just want for personal use..

Thanks for the link. Personally I will gladly pay $200 in order to be able to export to .exe files in ZP (even though I ain't gonna sell the bots - just the increased stability and time saved would make it worth it).

However I see that I'll have to upload projects etc. If I but the developer license, will I be able to run my projects in .exe format and pass arguments to the file at startup? (Question to the ZP staff)
 
I rather buy more pro licenses and have freedom to use VS too. It's my only problem.. but I like your work around so I will try that instead.

ZP almost perfect platform :(. Example: I just worry if the PC gets reset, no way to auto restart or remote restart the listener task. Same thing for all tasks... dead in water. Unless someone has an idea?
 
Thanks for the link. Personally I will gladly pay $200 in order to be able to export to .exe files in ZP (even though I ain't gonna sell the bots - just the increased stability and time saved would make it worth it).

However I see that I'll have to upload projects etc. If I but the developer license, will I be able to run my projects in .exe format and pass arguments to the file at startup? (Question to the ZP staff)
exe bots will be avialable later. It's in todo list for developer licenses.
 

Кто просматривает тему: (Всего: 0, Пользователи: 0, Гости: 0)