rediffusion
11/7/2017 - 5:18 PM

Объявляем функции (эмуляция работы)

D:\ZP_teaching_materials\ZennoPoster\Kurs_sibbora\Sibbora-Видеоуроки\2. ZennoPro Advanced Course\0. Подкурсы\3. Работа с базами данных\

Добавить в папку C:\Program Files (x86)\ZennoLab\RU\ZennoPoster Standard\5.11.3.0\Progs\ExternalAssemblies\ - MySQL.Data.dll

Статические блоки: Ссылки из GAC - MySql.Data OwnCodeUsings

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.IO;
using System.Text.RegularExpressions;
using ZennoLab.CommandCenter;
using ZennoLab.InterfacesLibrary;
using ZennoLab.InterfacesLibrary.ProjectModel;
using ZennoLab.InterfacesLibrary.ProjectModel.Collections;
using ZennoLab.InterfacesLibrary.ProjectModel.Enums;
using ZennoLab.Macros;
using Global.ZennoExtensions;
using ZennoLab.Emulation;

namespace ZennoLab.OwnCode
{
    /// <summary>
	/// A simple class of the common code
	/// </summary>
	public class CommonCode
	{
		/// <summary>
		/// Lock this object to mark part of code for single thread execution
		/// </summary>
		public static object SyncObject = new object();

		// Insert your code here
	}
}
//функция-эмулятор постинга
project.Context["fnPost"] = (Func<string, string, string, string>)((strWhere, strText, strImageFile) => {
    string strExecutionResult = String.Empty;
	Random rndFunc = new Random();	
	Thread.Sleep(rndFunc.Next(500, 1500)); //случайная пауза от 1,5 до 5 секунд ("выполняем")
	int intResult = rndFunc.Next(0, 100); //генерируем случайный "результат выполнения"
	if (intResult<85) {
		strExecutionResult = String.Format("ok: успешно запостили в {0}", strWhere);
	}else if (intResult<95){
		strExecutionResult = "err: ошибка размещения поста: аккаунт заблокирован";
	}else{
		project.SendErrorToLog("эмулируем ошибку в коде для id " + project.Variables["str_current_profile"].Value, true);
		throw new Exception("где-то в коде допустили ошибку");
	}
	return strExecutionResult;
});

//функция-эмулятор лайка
project.Context["fnLike"] = (Func<string, string>)((strWhat) => {
	string strExecutionResult = String.Empty;
	Random rndFunc = new Random();
	Thread.Sleep(rndFunc.Next(500, 1500)); //случайная пауза от 1,5 до 5 секунд ("выполняем")
	int intResult = rndFunc.Next(0, 100); //генерируем случайный "результат выполнения"
	if (intResult<85) {
		strExecutionResult = String.Format("ok: успешно лайкнули {0}", strWhat);
	}else if (intResult<95){
		strExecutionResult = "err: ошибка лайка: аккаунт заблокирован";
	}else{
		project.SendErrorToLog("эмулируем ошибку в коде для id " + project.Variables["str_current_profile"].Value, true);
		throw new Exception("где-то в коде допустили ошибку");
	}
	return strExecutionResult;
});

//функция-эмулятор инвайта
project.Context["fnInvite"] = (Func<string, string>)((strWho) => {
	string strExecutionResult = String.Empty;
	Random rndFunc = new Random();
	Thread.Sleep(rndFunc.Next(500, 1500)); //случайная пауза от 1,5 до 5 секунд ("выполняем")
	int intResult = rndFunc.Next(0, 100); //генерируем случайный "результат выполнения"
	if (intResult<85) {
		strExecutionResult = String.Format("ok: успешно пригласили {0}", strWho);
	}else if (intResult<95){
		strExecutionResult = "err: ошибка приглашения: аккаунт заблокирован";
	}else{
		project.SendErrorToLog("эмулируем ошибку в коде для id " + project.Variables["str_current_profile"].Value, true);
		throw new Exception("где-то в коде допустили ошибку");
	}
	return strExecutionResult;
});