Exemple #1
0
        public override void Execute()
        {
            Packet p = _typePort.Receive();

            if (p != null)
            {
                var t = p.Content?.ToString();
                if (t != null)
                {
                    if (t.ToUpper() == "OBJECT")
                    {
                        _type = JT.obj;
                    }
                    else if (t.ToUpper() == "ARRAY")
                    {
                        _type = JT.arr;
                    }
                }
                Drop(p);
            }

            p = _inPort.Receive();
            if (p != null)
            {
                var str = p.Content.ToString();
                Drop(p);
                if (str != null)
                {
                    JToken jt;
                    try
                    {
                        switch (_type)
                        {
                        case JT.arr: jt = JArray.Parse(str); break;

                        case JT.obj: jt = JObject.Parse(str); break;

                        default: jt = JToken.Parse(str); break;
                        }
                        _outPort.Send(Create(jt));
                    }
                    catch (System.Exception e)
                    {
                        Console.WriteLine("Exception parsing JSON string. Exception: " + e.Message);
                    }
                }
            }
        }
Exemple #2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult choice = MessageBox.Show("Do you want to delete this Category? It will also delete all connected units", "Delete?", MessageBoxButtons.YesNo);

            if (choice == DialogResult.Yes)
            {
                foreach (JobType JT in Backend.lsJobTypes.ToList())
                {
                    if (JT.getJobTypeCate() == Backend.findCate(getRowID()))
                    {
                        Backend.lsJobTypes.Remove(JT);
                    }
                }
                Backend.lsCategories.Remove(Backend.findCate(getRowID()));
                Populatedgv();
            }
        }
Exemple #3
0
        //关闭进程
        public static void KillProcess(bool stopIndicator)
        {
            TaskCore taskCore = MonitorCore.GetTaskCore();
            string   taskName = taskCore.TaskName;

            //传票结束
            if (stopIndicator && taskCore.IsVoteTask() && !taskName.Equals(TaskCore.TASK_VOTE_PROJECT))
            {
                LogCore.Write($"{taskCore.ProjectName}传票结束!");
                if (taskName.Equals(TaskCore.TASK_VOTE_JIUTIAN))
                {
                    JiuTian.StopAndUpload();
                }
                else if (taskName.Equals(TaskCore.TASK_VOTE_YUANQIU))
                {
                    YuanQiu.StopAndUpload();
                }
                else if (taskName.Equals(TaskCore.TASK_VOTE_JZ))
                {
                    JZ.StopAndUpload();
                }
                else if (taskName.Equals(TaskCore.TASK_VOTE_JT))
                {
                    JT.StopAndUpload();
                }
                else if (taskName.Equals(TaskCore.TASK_VOTE_HY))
                {
                    HY.StopAndUpload();
                }
                else if (taskName.Equals(TaskCore.TASK_VOTE_MM))
                {
                    MM.StopAndUpload();
                }
            }
            Kill();
        }
Exemple #4
0
            public JT Code;     // Join type mask

            public Keyword(byte i, byte chars, JT code)
            {
                I = i;
                Chars = chars;
                Code = code;
            }
Exemple #5
0
        //任务监控
        public void TaskMonitor()
        {
            //最大超时数
            int overTime = 30;
            //最大流量
            int maxKb = 200;

            try
            {
                overTime = ConfigCore.GetOverTime();
                maxKb    = ConfigCore.GetMaxKb();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            //延时
            int delay = 1000;

            if (ConfigCore.IsAdsl)
            {
                overTime *= 2;
                delay    /= 2;
            }

            //连续在线、离线次数
            int p = 0;
            //计数
            int s = 0;
            //拨号次数
            int  circle   = 0;
            bool isOnline = false;

            do
            {
                DaemonCore.KeepAlive();
                isOnline = Net.IsOnline();
                NetCore.CloseException();
                if (isOnline && !ConfigCore.IsAdsl && IsAutoVote)
                {
                    if (Net.GetNetStatic(ConfigCore.AdslName) > maxKb)
                    {
                        LogCore.Write($"{TaskName}流量大于{maxKb}KB,拉黑!");
                        AutoVote.AddVoteProjectNameDroped(false);
                        SwitchWaitOrder();
                    }
                }

                if (ConfigCore.GetTaskChange().Equals("1"))
                {
                    TaskChangeProcess();
                    return;
                }

                if (IsSysTask())
                {
                    if (ConfigCore.IsAdsl && !isOnline)
                    {
                        LogCore.Write("ADSL待命断网拨号!");
                        NetCore.NetCheck();
                    }

                    p = 0;
                }

                if (IsAutoVote && AutoVote.FailTooMuch)
                {
                    LogCore.Write("连续两分钟成功过低,拉黑!");
                    AutoVote.AddVoteProjectNameDroped(false);
                    SwitchWaitOrder();
                }

                if (TaskName.Equals(TASK_VOTE_JIUTIAN) && p > 0)
                {
                    if (JiuTian.OverCheck(ref s) || JiuTian.RestrictCheck() || JiuTian.IsIdentifyCode() ||
                        JiuTian.VmBanCheck())
                    {
                        SwitchWaitOrder();
                    }
                }
                else if (TaskName.Equals(TASK_VOTE_MM))
                {
                    if (MM.OverCheck() || MM.ExcpCheck() || MM.ErrCheck())
                    {
                        ProgressCore.KillProcess(false);
                        SwitchWaitOrder();
                    }
                }
                else if (TaskName.Equals(TASK_VOTE_YUANQIU))
                {
                    if (YuanQiu.OverCheck())
                    {
                        ProgressCore.KillProcess(false);
                        SwitchWaitOrder();
                    }
                }
                else if (TaskName.Equals(TASK_VOTE_JT))
                {
                    if (JT.OverCheck())
                    {
                        ProgressCore.KillProcess(false);
                        SwitchWaitOrder();
                    }
                }
                else if (TaskName.Equals(TASK_VOTE_ML))
                {
                    //ML到票检测
                }
                else if (TaskName.Equals(TASK_VOTE_DM))
                {
                    //DM到票检测
                }
                else if (TaskName.Equals(TASK_VOTE_JZ))
                {
                    if (JZ.OverCheck())
                    {
                        ProgressCore.KillProcess(false);
                        SwitchWaitOrder();
                    }
                }
                else if (TaskName.Equals(TASK_VOTE_HY))
                {
                    if (HY.OverCheck())
                    {
                        ProgressCore.KillProcess(false);
                        SwitchWaitOrder();
                    }
                }
                else if (TaskName.Equals(TASK_VOTE_OUTDO))
                {
                    //OUTDO到票检测
                }

                if (isOnline)
                {
                    p = p < 0 ? 1 : ++p;
                }
                else
                {
                    circle++;
                    p = p > 0 ? -1 : --p;
                }

                Thread.Sleep(delay);
            } while (p == 0 || (p > 0 && p < overTime) || (p < 0 && p > -overTime));

            overTimeCount++;
            LogCore.Write($"超时{overTimeCount}次!");
            TaskChangeProcess();
        }
Exemple #6
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;
            }
        }
Exemple #7
0
        public void startComponents()
        {
            int XLoc   = 20;
            int YLoc   = btnAddJob.Location.Y + 60;
            int Width  = this.Size.Width - 60;
            int Height = 200;

            clearDataGridControls();
            setControlState();

            if (Backend.bFileLoaded)
            {
                FlowLayoutPanel DGVContain = new FlowLayoutPanel();
                DGVContain.Size                   = new Size(Width, this.Size.Height);
                DGVContain.Location               = new Point(XLoc, YLoc);
                DGVContain.MaximumSize            = DGVContain.Size;
                DGVContain.AutoScroll             = true;
                DGVContain.AutoSize               = true;
                DGVContain.VerticalScroll.Visible = true;
                DGVContain.Anchor                 = (AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom);

                DGVContain.Name = "ContainerforDGV";
                foreach (Categories c in Backend.lsCategories)
                {
                    DataTable table = new DataTable("Jobs");
                    table.Columns.Add("Job ID");
                    table.Columns.Add("Job Name");
                    table.Columns.Add("Job Desc");
                    table.Columns.Add("Job Type");
                    table.Columns.Add("Attachment");
                    Label tableHead = new Label();
                    tableHead.Text      = c.getCategoryName();
                    tableHead.Location  = new Point(XLoc, YLoc);
                    tableHead.Size      = new Size(DGVContain.Size.Width - 20, 20);
                    tableHead.TextAlign = ContentAlignment.MiddleCenter;
                    YLoc = YLoc + 30;
                    DataGridView Cate = new DataGridView();
                    Backend.SetDGV(Cate, c.getCategoryName() + c.getCategoryID().ToString(), c.getColor(), new Point(XLoc, YLoc), new Size(DGVContain.Size.Width - 20, Height));
                    Cate.CellDoubleClick += new DataGridViewCellEventHandler(this.Grid_MouseDoubleClick);

                    foreach (JobType JT in Backend.lsJobTypes)
                    {
                        if (JT.getJobTypeCate() == c)
                        {
                            foreach (Job J in Backend.lsJobs)
                            {
                                if (J.GetJobType() == JT)
                                {
                                    table.Rows.Add(J.getJobID(), J.getJobName(), J.getJobDesc(),
                                                   J.GetJobType().getJobTypeName(), J.getAttachment());
                                }
                            }
                        }
                    }

                    Cate.DataSource = table;
                    DGVContain.Controls.Add(tableHead);
                    DGVContain.Controls.Add(Cate);

                    YLoc = YLoc + Height + 20;
                }
                this.Controls.Add(DGVContain);
            }
        }