Beispiel #1
0
        public void limit_2_999_999()
        {
            project.Variables["action"].Value = "check_limit";
            string query = "SELECT  `day_limit`  FROM `si_" + project.Variables["site"].Value + "` where `id`='" + project.Variables["id_profile"].Value + "';";

            query = ZennoPoster.Db.ExecuteQuery(query, null, ZennoLab.InterfacesLibrary.Enums.Db.DbProvider.MySqlClient, project.Variables["DB_set"].Value, " ", "\r\n");
            int l = int.Parse(query);

            if (l == 0)
            {
                project.SendInfoToLog("Достигнут суточный лимит", true);
                project.Variables["alert"].Value = "limit";
                string text = "<u>Достигнут суточный лимит на 2-999-999.ru</u>";
                string url  = project.Variables["url_for_notifications"].Value + project.Variables["user_id"].Value + "&msg=" + text;
                ZennoPoster.HttpGet(
                    url,           //url
                    "",            //proxy
                    "utf-8",       //charset
                    ZennoLab.InterfacesLibrary.Enums.Http.ResponceType.HeaderOnly
                    );
                query = "UPDATE `DB_users` SET `connects`=`connects`-1 WHERE  `value`='" + project.Variables["DB_set"].Value + "';\r\nupdate `si_" + project.Variables["site"].Value + "` set `run`='0' where `id`='" + project.Variables["id_profile"].Value + "';\r\nUPDATE  `objects` set `" + project.Variables["site"].Value + "`=1 where `id`='" + project.Variables["id"].Value + "';";
                ZennoPoster.Db.ExecuteQuery(query, null, ZennoLab.InterfacesLibrary.Enums.Db.DbProvider.MySqlClient, project.Variables["DB_set"].Value, " ", "\r\n");
                throw new Exception("достигнут суточный лимит");
            }
        }
 public static void WaitRun(IZennoPosterProjectModel project,string TaskName)
 {
     int nt = GetNumberOfTries(TaskName);
   string status = GetStatus(TaskName);
   while( nt >0 )
   {    
     if(((ZennoLab.InterfacesLibrary.ProjectModel.Collections.IContextExt)project.Context).IsInterrupted) return; // Прерывание в ZP
     if(Global.Variables.IsProjectMaker && !Global.Variables.IsDebugMode) return; // Прерывание в PM
     
       Thread.Sleep(3000);
     
       nt = TaskHelper.GetNumberOfTries(TaskName);
     status = GetStatus(TaskName);
     
     switch (status)
     {
       case "Perform":
         break;
       case "Complite": nt = 0;
         break;
       case "Stop": nt = 0;
         break;
       case "Schedule":
         break;
       case "WaitPerform":
         break;
     }
     
       project.SendInfoToLog("Ожидаем завершения "+TaskName,true);   
   }
 }
Beispiel #3
0
 public void proxy()
 {
     if (project.Variables["proxy_type"].Value == "nosok")
     {
         project.SendInfoToLog("Запуск парсера носков", true);
         string text = System.IO.File.ReadAllText(project.Directory + @"/proxy/nosok.xml");
         text = Macros.TextProcessing.Replace(text, @"(?<=url</Name><Value>).*?(?=</Value>)", project.Variables["nosok_url"].Value, "Regex", "All");
         text = Macros.TextProcessing.Replace(text, @"(?<=wait</Name><Value>).*?(?=</Value>)", project.Variables["nosok_time_update"].Value, "Regex", "All");
         System.IO.File.WriteAllText(project.Directory + @"/proxy/nosok.xml", text);
         System.Threading.Thread.Sleep(5 * 1000);
         startInfo.FileName = string.Format(project.Directory + @"/proxy/nosok_run.bat");
         Process.Start(startInfo);
     }
     else
     {
         project.SendInfoToLog("Запуск tor", true);
         startInfo.FileName = string.Format(project.Directory + @"/proxy/2. stop.bat");
         Process.Start(startInfo);
         System.Threading.Thread.Sleep(10 * 1000);
         var List = project.Lists["temp"];
         foreach (string File in Directory.GetDirectories(project.Directory + @"/proxy/data"))
         {
             List.Add(File);
         }
         for (int rc = 0; rc < List.Count; rc++)
         {
             string dir = List[rc];
             Directory.Delete(dir, true);
         }
         System.Threading.Thread.Sleep(5 * 1000);
         startInfo.FileName = string.Format(project.Directory + @"/proxy/data/tor.exe");
         Process.Start(startInfo);
         System.Threading.Thread.Sleep(5 * 1000);
         startInfo.FileName = string.Format(project.Directory + @"/proxy/1. launch.vbs - Shortcut.lnk");
         Process.Start(startInfo);
     }
 }
        /// <summary>
        /// Отправка сообщения в лог (ZP/PM или в консоль)
        /// </summary>
        /// <param name="msg">сообщение</param>
        /// <param name="log_type">тип сообщения</param>
        private static void SendToLog(string msg, LogType log_type = LogType.LogInfo)
        {
            if (project != null)
            {
                switch (log_type)
                {
                case LogType.LogInfo:
                    project.SendInfoToLog(msg, show_in_poster);
                    break;

                case LogType.LogWarning:
                    project.SendWarningToLog(msg, show_in_poster);
                    break;

                case LogType.LogError:
                    project.SendErrorToLog(msg, show_in_poster);
                    break;
                }
            }
            else
            {
                ConsoleColor previous_bgcolor = Console.BackgroundColor;
                ConsoleColor previous_fgcolor = Console.ForegroundColor;
                switch (log_type)
                {
                case LogType.LogInfo:
                    Console.BackgroundColor = ConsoleColor.Black;
                    Console.ForegroundColor = ConsoleColor.White;
                    break;

                case LogType.LogWarning:
                    Console.BackgroundColor = ConsoleColor.Black;
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    break;

                case LogType.LogError:
                    Console.BackgroundColor = ConsoleColor.Black;
                    Console.ForegroundColor = ConsoleColor.Red;
                    break;
                }

                Console.WriteLine(msg);

                Console.BackgroundColor = previous_bgcolor;
                Console.ForegroundColor = previous_fgcolor;
            }
        }
Beispiel #5
0
 public static IZennoPosterProjectModel Info(this IZennoPosterProjectModel project, string message, bool showInPoster = true)
 {
     project.SendInfoToLog(message, showInPoster);
     return(project);
 }
Beispiel #6
0
        public int ExecuteCode(Instance instance, IZennoPosterProjectModel project)
        {
            project.SendInfoToLog("Test");

            return(0);
        }