How to encapsulate a method which covers the zennoposter method into my DLL file ?

gongyouze

Пользователь
Регистрация
26.06.2014
Сообщения
42
Благодарностей
0
Баллы
6
I have come up with a problem that I want to encapsulate a method into a DLL file, but this method calls the method of zennoposter itself, which causes Microsoft visual studio can recognize this method.


How to encapsulate a method which covers the zennoposter method into my DLL file ?


FOR EXAMPLE A case that needs to call the script in the process of script execution, I need to write a lot of codes. But if I can encapsulate them into

Callscripts ( “Example”, “5”), which can save the time when editing to the most extent. But the Miscrosoft visual studio can recognize ZennoPoster.TasksList;ZennoPoster.SetExecutionSettings;and other methods, so I can’t get to the goal.

C#:
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)
  thrownew Exception("Task " + searchName + " not found!");
 
Последнее редактирование модератором:

darkdiver

Administrator
Команда форума
Регистрация
13.01.2009
Сообщения
2 284
Благодарностей
2 728
Баллы
113
If you want to use ZennoPoster classes in Visual Studio
You should reference
ZennoLab.CommandCenter.dll
ZennoLab.Global.dll
ZennoLab.CommunicationInterfaces.dll
ZennoLab.InterfacesLibrary.dll
ZennoLab.LogLibrary.dll
 

gongyouze

Пользователь
Регистрация
26.06.2014
Сообщения
42
Благодарностей
0
Баллы
6
How do I using these dll files
Like this
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
 

darkdiver

Administrator
Команда форума
Регистрация
13.01.2009
Сообщения
2 284
Благодарностей
2 728
Баллы
113

gongyouze

Пользователь
Регистрация
26.06.2014
Сообщения
42
Благодарностей
0
Баллы
6
Referenced assemblies "ZennoLab.CommandCenter.dll" no strong name
 

gongyouze

Пользователь
Регистрация
26.06.2014
Сообщения
42
Благодарностей
0
Баллы
6
Target Framework

.net framework 3.5 Change became .net framework 4.0
 

gongyouze

Пользователь
Регистрация
26.06.2014
Сообщения
42
Благодарностей
0
Баллы
6

gongyouze

Пользователь
Регистрация
26.06.2014
Сообщения
42
Благодарностей
0
Баллы
6
I do not know why it generated so many DLL files;
And these DLL files can not be added to the C: \ Windows \ assembly
 

gongyouze

Пользователь
Регистрация
26.06.2014
Сообщения
42
Благодарностей
0
Баллы
6

gongyouze

Пользователь
Регистрация
26.06.2014
Сообщения
42
Благодарностей
0
Баллы
6

gongyouze

Пользователь
Регистрация
26.06.2014
Сообщения
42
Благодарностей
0
Баллы
6

gongyouze

Пользователь
Регистрация
26.06.2014
Сообщения
42
Благодарностей
0
Баллы
6

gongyouze

Пользователь
Регистрация
26.06.2014
Сообщения
42
Благодарностей
0
Баллы
6

gongyouze

Пользователь
Регистрация
26.06.2014
Сообщения
42
Благодарностей
0
Баллы
6
compile code of error in action "cs0246" Could not find the type or namespace name“zenno”(Are you missing a using directive or an assembly reference?)
 

gongyouze

Пользователь
Регистрация
26.06.2014
Сообщения
42
Благодарностей
0
Баллы
6
ZennoLab.CommandCenter.dll not join after generation
 

gongyouze

Пользователь
Регистрация
26.06.2014
Сообщения
42
Благодарностей
0
Баллы
6

gongyouze

Пользователь
Регистрация
26.06.2014
Сообщения
42
Благодарностей
0
Баллы
6
This DLL file because strong name issue through the following process

sn -k ZennoLab.CommandCenter.snk
ildasm ZennoLab.CommandCenter.dll /out=ZennoLab.CommandCenter.il
ilasm ZennoLab.CommandCenter.il /dll /resource=ZennoLab.CommandCenter.res /key=ZennoLab.CommandCenter.snk /optimize
sn -v ZennoLab.CommandCenter.dll
 

darkdiver

Administrator
Команда форума
Регистрация
13.01.2009
Сообщения
2 284
Благодарностей
2 728
Баллы
113
you do not need to sign ZennoLab.CommandCenter.dll
you do not need to add them to the GAC.
You just need to copy your dll to the folder ExternalAssemblies of ZennoPoster.exe folder and add it to the project
upload_2014-8-6_16-55-26.png
 
Последнее редактирование:

gongyouze

Пользователь
Регистрация
26.06.2014
Сообщения
42
Благодарностей
0
Баллы
6
ok thanks Problem solved
 

cheekybot

Client
Регистрация
19.09.2014
Сообщения
36
Благодарностей
3
Баллы
8

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