예제 #1
0
 public static void SwitchWaitOrder(string taskChange)
 {
     TaskInfos.Clear();
     IniReadWriter.WriteIniKeys("Command", "TaskChange" + Sort, taskChange, PathShareTask);
     IniReadWriter.WriteIniKeys("Command", "TaskName" + Sort, TaskCore.TASK_SYS_WAIT_ORDER, PathShareTask);
     IniReadWriter.WriteIniKeys("Command", "CustomPath" + Sort, "", PathShareTaskPlus);
 }
예제 #2
0
        //添加黑名单项目
        public void AddVoteProjectNameDroped(bool isAllProject)
        {
            string projectName = IniReadWriter.ReadIniKeys("Command", "ProjectName", ConfigCore.PathShareAutoVote);

            if (isAllProject)
            {
                projectName = projectName.Substring(0, projectName.IndexOf("_"));
            }

            string voteProjectNameDroped =
                IniReadWriter.ReadIniKeys("Command", "voteProjectNameDroped", ConfigCore.PathShareAutoVote);
            int dropVote = 0;

            try
            {
                dropVote = int.Parse(IniReadWriter.ReadIniKeys("Command", "dropVote", ConfigCore.PathShareAutoVote));
            }
            catch (Exception)
            {
            }
            finally
            {
                dropVote++;
            }

            IniReadWriter.WriteIniKeys("Command", "dropVote", dropVote.ToString(), ConfigCore.PathShareAutoVote);
            if (StringUtil.isEmpty(voteProjectNameDroped) || voteProjectNameDroped.IndexOf(projectName) == -1)
            {
                int validDrop;
                try
                {
                    validDrop = int.Parse(IniReadWriter.ReadIniKeys("Command", "validDrop",
                                                                    ConfigCore.PathShareAutoVote));
                }
                catch (Exception)
                {
                    validDrop = 1;
                }

                if (dropVote >= validDrop)
                {
                    voteProjectNameDroped +=
                        StringUtil.isEmpty(voteProjectNameDroped) ? projectName : "|" + projectName;
                    IniReadWriter.WriteIniKeys("Command", "voteProjectNameDroped", voteProjectNameDroped,
                                               ConfigCore.PathShareAutoVote);
                }
            }
        }
예제 #3
0
        //网络异常处理
        public static void NetError(string type)
        {
            String val = IniReadWriter.ReadIniKeys("Command", "Val", PathShareConfig);

            if (StringUtil.isEmpty(val))
            {
                if (type.Equals("exception"))
                {
                    IniReadWriter.WriteIniKeys("Command", "Val", Sort.ToString(), PathShareConfig); //正数 异常
                }
                else
                {
                    IniReadWriter.WriteIniKeys("Command", "Val", (-Sort).ToString(), PathShareConfig); //负数 掉线
                }

                Form1.MainClose();
            }
            else
            {
                Thread.Sleep(2000);
                NetError(type);
            }
        }
예제 #4
0
        //缓存
        public static void Cache()
        {
            TaskCore taskCore = MonitorCore.GetTaskCore();

            if (taskCore.TaskName == null || taskCore.IsSysTask())
            {
                return;
            }

            string path = "";

            if (taskCore.CustomPath.Equals(taskCore.TaskPath))
            {
                path = taskCore.TaskPath;
            }
            else
            {
                path = "Writein";
            }

            string cacheMemory = "TaskName-" + taskCore.TaskName + "`TaskPath-" + path + "`Worker:" + Id;

            IniReadWriter.WriteIniKeys("Command", "CacheMemory" + Sort, cacheMemory, PathShareTaskPlus);
        }
예제 #5
0
 public static void WriteOver()
 {
     IniReadWriter.WriteIniKeys("Command", "OVER", "1", PathShareConfig);
 }
예제 #6
0
 public static void WriteStatistic(string name, string value)
 {
     IniReadWriter.WriteIniKeys(Sort.ToString(), name, value, PathShareStatistic);
 }
예제 #7
0
 public static void WriteAutoVote(string name, string value)
 {
     IniReadWriter.WriteIniKeys("Command", name, value, PathShareAutoVote);
 }
예제 #8
0
 public static void WriteBaseConfig(string name, string value)
 {
     IniReadWriter.WriteIniKeys("Command", name, value, BaseConfig);
 }
예제 #9
0
 public static void WriteTaskName(String task)
 {
     IniReadWriter.WriteIniKeys("Command", "TaskName" + Sort, task,
                                PathShareTask);
 }
예제 #10
0
 public static void SwitchNetTest()
 {
     IniReadWriter.WriteIniKeys("Command", "TaskChange" + Sort, "1", PathShareTask);
     IniReadWriter.WriteIniKeys("Command", "TaskName" + Sort, TaskCore.TASK_SYS_NET_TEST, PathShareTask);
     IniReadWriter.WriteIniKeys("Command", "CustomPath" + Sort, "", PathShareTaskPlus);
 }
예제 #11
0
 public static void ClearCacheMemory()
 {
     IniReadWriter.WriteIniKeys("Command", "CacheMemory" + Sort, "", PathShareTaskPlus);
 }
예제 #12
0
 public static void SetTaskChange(String taskChange)
 {
     IniReadWriter.WriteIniKeys("Command", "TaskChange" + Sort, taskChange, PathShareTask);
 }
예제 #13
0
        //切换任务
        private void ChangeTask()
        {
            if (TaskChange.Equals("1"))
            {
                overTimeCount = 0;
                ConfigCore.InitWorker("");
                CustomPath = ConfigCore.GetCustomPath();
                if (CustomPath != "")
                {
                    LogCore.Write($"切换任务:{CustomPath}");
                }

                if (IsVoteTask() && IsAutoVote)
                {
                    string projectName = ConfigCore.GetAutoVote("ProjectName");
                    string drop        = "";
                    try
                    {
                        drop = IniReadWriter.ReadIniKeys("Command", "drop", "./handler.ini");
                    }
                    catch (Exception)
                    {
                    }

                    if (drop != projectName)
                    {
                        IniReadWriter.WriteIniKeys("Command", "drop", "", "./handler.ini");
                    }
                }
            }

            if (TaskName.Equals(TASK_SYS_WAIT_ORDER)) //待命
            {
                NetCore.DisConnect();
                TaskName = ConfigCore.GetTaskName();
                if (TaskName.Equals(TASK_SYS_WAIT_ORDER))
                {
                    WaitOrder();
                }
            }
            else if (TaskName.Equals(TASK_SYS_NET_TEST)) //网络TEST
            {
                NetCore.NetCheck();
                if (Net.IsOnline())
                {
                    NetCore.DisConnect();
                    WaitOrder();
                }
            }
            else if (TaskName.Equals(TASK_SYS_SHUTDOWN)) //关机
            {
                WaitOrder();
                Process.Start("shutdown.exe", "-s -t 0");
                Form1.MainClose();
            }
            else if (TaskName.Equals(TASK_SYS_RESTART)) //重启
            {
                string computerRename = ConfigCore.GetComputerRename();
                if (!StringUtil.isEmpty(computerRename))
                {
                    Computer.apiSetComputerNameEx(5, computerRename + "-" + ConfigCore.Sort);
                }

                WaitOrder();
                Process.Start("shutdown.exe", "-r -t 0");
                Form1.MainClose();
            }
            else if (TaskName.Equals(TASK_SYS_UPDATE)) //升级
            {
                WaitOrder();
                Upgrade.Update();
                Form1.MainClose();
            }
            else if (TaskName.Equals(TASK_SYS_CLEAN)) //清理
            {
                WaitOrder();
                FileUtil.DeleteFolder(PathCore.WorkingPath + "\\投票项目");
            }
            else if (IsVoteTask()) //投票
            {
                NetCore.NetCheck();
                if (CustomPath.Equals(""))
                {
                    WaitOrder();
                    TaskChangeProcess();
                    return;
                }

                if (TaskChange.Equals("1"))
                {
                    if (CustomPath.LastIndexOf("\\") + 1 <= CustomPath.Length && CustomPath.Substring(CustomPath.LastIndexOf("\\") + 1) == "vote.exe")
                    {
                        ProgressCore.StartProcess(CustomPath.Substring(0, CustomPath.Length - 9) + @"\启动九天.bat");
                        TaskName = TASK_VOTE_JIUTIAN;
                    }
                    else
                    {
                        IniReadWriter.WriteIniKeys("setsoft", "ghid", ConfigCore.Id, "c:\\gonghao.ini");
                        ProgressCore.StartProcess(CustomPath);
                        TaskName = TASK_VOTE_PROJECT;
                        IntPtr hwnd0, hwnd1, hwnd2, hwnd3, hwnd4;
                        do
                        {
                            hwnd0 = HwndUtil.FindWindow("WTWindow", null);
                            hwnd1 = HwndUtil.FindWindow("TForm1", null);
                            hwnd2 = HwndUtil.FindWindow("ThunderRT6FormDC", null);
                            hwnd3 = HwndUtil.FindWindow("obj_Form", null);
                            hwnd4 = HwndUtil.FindWindow("TMainForm", null);
                            if (hwnd0 != IntPtr.Zero)
                            {
                                string title = HwndUtil.GetControlText(hwnd0);
                                if (title.Length >= 6 && title.Substring(0, 6) == "自动投票工具")
                                {
                                    TaskName = TASK_VOTE_MM;
                                }
                                else if (title.Length >= 8 && title.Substring(0, 8) == "VOTE2016")
                                {
                                    TaskName = TASK_VOTE_ML;
                                }
                                else if (title.IndexOf("自动投票软件") != -1)
                                {
                                    TaskName = TASK_VOTE_HY;
                                }
                            }
                            else if (hwnd1 != IntPtr.Zero)
                            {
                                TaskName = TASK_VOTE_YUANQIU;
                            }
                            else if (hwnd2 != IntPtr.Zero)
                            {
                                TaskName = TASK_VOTE_JT;
                            }
                            else if (hwnd3 != IntPtr.Zero)
                            {
                                TaskName = TASK_VOTE_DM;
                            }
                            else if (hwnd4 != IntPtr.Zero)
                            {
                                TaskName = TASK_VOTE_JZ;
                            }

                            Thread.Sleep(500);
                        } while (TaskName.Trim().Equals(TASK_VOTE_PROJECT));
                    }

                    bool safeWrite = false;
                    Thread.Sleep(ConfigCore.Sort % 10 * 50);
                    do
                    {
                        try
                        {
                            ConfigCore.WriteTaskName(TaskName);
                            Thread.Sleep(200);
                            string taskNameCheck = ConfigCore.GetTaskName();
                            if (StringUtil.isEmpty(taskNameCheck) || !taskNameCheck.Equals(TaskName))
                            {
                                LogCore.Write("TaskName Write Error!");
                                ConfigCore.WriteTaskName(TaskName);
                                throw new Exception();
                            }

                            safeWrite = true;
                        }
                        catch (Exception)
                        {
                            Thread.Sleep(ConfigCore.Sort % 10 * 50);
                        }
                    } while (!safeWrite);
                }

                if (TaskName.Equals(TASK_VOTE_JIUTIAN))
                {
                    if (!TaskChange.Equals("1"))
                    {
                        ProgressCore.StartProcess(CustomPath.Substring(0, CustomPath.Length - 9) + @"\启动九天.bat");
                        Thread.Sleep(500);
                    }

                    JiuTian.Start();
                }
                else
                {
                    if (!TaskChange.Equals("1"))
                    {
                        ProgressCore.StartProcess(CustomPath);
                        Thread.Sleep(500);
                    }

                    if (TaskName.Equals(TASK_VOTE_MM))
                    {
                        MM.Start();
                    }
                    else if (TaskName.Equals(TASK_VOTE_ML))
                    {
                        //ML开始程序
                    }
                    else if (TaskName.Equals(TASK_VOTE_YUANQIU))
                    {
                        YuanQiu.Start();
                    }
                    else if (TaskName.Equals(TASK_VOTE_JT))
                    {
                        JT.start();
                    }
                    else if (TaskName.Equals(TASK_VOTE_DM))
                    {
                        //DM开始程序
                    }
                    else if (TaskName.Equals(TASK_VOTE_JZ))
                    {
                        JZ.start();
                    }
                    else if (TaskName.Equals(TASK_VOTE_HY))
                    {
                        HY.Start();
                    }
                }

                TaskPath = CustomPath;
            }
            else
            {
                TaskName = TASK_SYS_WAIT_ORDER;
            }
        }
예제 #14
0
        //添加黑名单项目
        public static void AddVoteProjectNameDroped(bool isAllProject)
        {
            string projectName = ConfigCore.GetAutoVote("ProjectName");
            //一机器只允许拉黑投票一次
            string   drop     = IniReadWriter.ReadIniKeys("Command", "drop", "./handler.ini");
            TaskInfo taskInfo = TaskInfos.Get();

            if ((taskInfo != null && taskInfo.ProjectName != projectName) || drop == projectName)
            {
                return;
            }

            IniReadWriter.WriteIniKeys("Command", "drop", projectName, "./handler.ini");
            string voteProjectNameDroped = ConfigCore.GetAutoVote("voteProjectNameDroped");
            int    dropVote = 0;

            try
            {
                dropVote = int.Parse(ConfigCore.GetAutoVote("dropVote"));
            }
            catch (Exception)
            {
            }
            finally
            {
                dropVote++;
            }

            if (isAllProject)
            {
                if (projectName.IndexOf("_") > 0)
                {
                    projectName = projectName.Substring(0, projectName.IndexOf("_"));
                }
            }

            ConfigCore.WriteAutoVote("dropVote", dropVote.ToString());
            if (StringUtil.isEmpty(voteProjectNameDroped) || voteProjectNameDroped.IndexOf(projectName) == -1)
            {
                int    validDrop = 1;
                double blackRate = 1;
                try
                {
                    validDrop = int.Parse(ConfigCore.GetAutoVote("validDrop"));
                }
                catch { }
                try
                {
                    blackRate = int.Parse(ConfigCore.GetAutoVote("blackRate"));
                }
                catch { }
                if (dropVote >= validDrop)
                {
                    IniReadWriter.WriteIniKeys("Command", "drop", "", "./handler.ini");
                    LogCore.Write($"{projectName}拉黑{blackRate * 20}分钟");
                    voteProjectNameDroped +=
                        StringUtil.isEmpty(voteProjectNameDroped) ? projectName : "|" + projectName;
                    ConfigCore.WriteAutoVote("voteProjectNameDroped", voteProjectNameDroped);
                }
            }
        }
예제 #15
0
 //改变延时
 private void textBox2_TextChanged(object sender, EventArgs e)
 {
     IniReadWriter.WriteIniKeys("Command", "yanchi", textBox2.Text, ConfigCore.BaseConfig);
 }
예제 #16
0
 //改变延时
 private void textBox3_TextChanged(object sender, EventArgs e)
 {
     IniReadWriter.WriteIniKeys("Command", "gongxiang", textBox3.Text, ConfigCore.BaseConfig);
     ConfigCore.InitPathShare();
     IniReadWriter.WriteIniKeys("Command", "gongxiang", textBox3.Text, ConfigCore.PathShareConfig);
 }