예제 #1
0
        private void SimpleButton1_Click(object sender, EventArgs e)
        {
            int[] selectedRows = GridView_Tasks.GetSelectedRows();
            foreach (int rowHandle in selectedRows)
            {
                if (rowHandle >= 0)
                {
                    String ID     = GridView_Tasks.GetRowCellValue(rowHandle, "PID").ToString();
                    String status = GridView_Tasks.GetRowCellValue(rowHandle, "Task_Status").ToString();

                    if (status == TaskManger.TaskManagerStatus.Running)

                    {
                        XtraMessageBox.Show("Cannot Remove Running Task !", "TaskManger", MessageBoxButtons.OK, MessageBoxIcon.Error); return;
                    }


                    foreach (BackgroundWorker t in TaskList)
                    {
                        if (t.GetHashCode().ToString() == ID)
                        {
                            TaskManger.Running_Process = TaskManger.Running_Process.Replace(t.GetHashCode().ToString(), "");
                            GridView_Tasks.SetRowCellValue(rowHandle, "Task_Status", TaskManger.TaskManagerStatus.Paused);

                            DataRow dxr = DT_TaskManger.Select("PID='" + ID + "'").FirstOrDefault();
                            DT_TaskManger.Rows.Remove(dxr);
                            appHelper.SetTaskMangerDataTable_Control = Login.DT_TaskManger;
                        }
                    }
                }
            }
        }
예제 #2
0
        private void SimpleButton4_Click(object sender, EventArgs e)
        {
            int[] selectedRows = GridView_Tasks.GetSelectedRows();
            foreach (int rowHandle in selectedRows)
            {
                if (rowHandle >= 0)
                {
                    String ID     = GridView_Tasks.GetRowCellValue(rowHandle, "PID").ToString();
                    String status = GridView_Tasks.GetRowCellValue(rowHandle, "Task_Status").ToString();

                    if (status == TaskManger.TaskManagerStatus.Running)
                    {
                        XtraMessageBox.Show("Already Running ! ", "TaskManger", MessageBoxButtons.OK, MessageBoxIcon.Error); return;
                    }

                    if (status == TaskManger.TaskManagerStatus.Failed)
                    { /*XtraMessageBox.Show("an Error shown in this process . please check error log!", "TaskManger", MessageBoxButtons.OK, MessageBoxIcon.Error); return; */
                    }


                    if (status == TaskManger.TaskManagerStatus.Paused)
                    {
                        XtraMessageBox.Show("You Cannot Start A Paused Task , Only Resume", "TaskManger", MessageBoxButtons.OK, MessageBoxIcon.Error); return;
                    }


                    if (status == TaskManger.TaskManagerStatus.Ready)
                    {
                        foreach (BackgroundWorker t in TaskList)
                        {
                            if (t.GetHashCode().ToString() == ID)
                            {
                                TaskManger.Running_Process += t.GetHashCode().ToString() + " ";
                                t.RunWorkerAsync();


                                GridView_Tasks.SetRowCellValue(rowHandle, "Task_Status", TaskManagerStatus.Running);
                            }
                        }
                    }
                }
            }
            appHelper.SetTaskMangerDataTable_Control = DT_TaskManger;
        }
예제 #3
0
        private async void SimpleButton5_Click(object sender, EventArgs e)
        {
            int[] selectedRows = GridView_Tasks.GetSelectedRows();
            foreach (int rowHandle in selectedRows)
            {
                if (rowHandle >= 0)
                {
                    String ID                     = GridView_Tasks.GetRowCellValue(rowHandle, "PID").ToString();
                    String status                 = GridView_Tasks.GetRowCellValue(rowHandle, "Task_Status").ToString();
                    String Scraping_Account       = GridView_Tasks.GetRowCellValue(rowHandle, "Scraping_Account").ToString();
                    String Scraped_Board          = GridView_Tasks.GetRowCellValue(rowHandle, "Scraped_Board").ToString();
                    String Posting_Board          = GridView_Tasks.GetRowCellValue(rowHandle, "Posting_Board").ToString();
                    String acctoken               = GridView_Tasks.GetRowCellValue(rowHandle, "acctoken").ToString();
                    String accPassword            = GridView_Tasks.GetRowCellValue(rowHandle, "accPassword").ToString();
                    String t1delay                = GridView_Tasks.GetRowCellValue(rowHandle, "t1delay").ToString();
                    String t2delay                = GridView_Tasks.GetRowCellValue(rowHandle, "t2delay").ToString();
                    String PostingaccountUsername = GridView_Tasks.GetRowCellValue(rowHandle, "PostingAccountUsername").ToString();



                    if (status.Contains(TaskManger.TaskManagerStatus.Paused) || status.Contains(TaskManger.TaskManagerStatus.Failed))
                    {
                        BackgroundWorker t = new BackgroundWorker();
                        t.WorkerSupportsCancellation = true;
                        string pid = t.GetHashCode().ToString();

                        t.DoWork += new DoWorkEventHandler(delegate(object o, DoWorkEventArgs a)
                        {
                            PinObject pinObject = new PinObject(pid,
                                                                Scraping_Account,
                                                                accPassword,
                                                                acctoken,
                                                                Posting_Board,
                                                                int.Parse(t1delay),
                                                                int.Parse(t2delay),
                                                                PostingaccountUsername

                                                                );



                            pinObject.Resume();
                        });

                        DataRow dxr = DT_TaskManger.Select("PID='" + ID + "'").FirstOrDefault();
                        dxr["PID"] = pid;
                        GridView_Tasks.SetRowCellValue(rowHandle, "PID", pid);
                        ID = pid;



                        appHelper.SetTaskMangerDataTable_Control = DT_TaskManger;
                        GridControl_Tasks.Focus();
                        GridControl_Tasks.Refresh();


                        TaskList.Add(t);
                        //t.RunWorkerAsync();

                        TaskManger.Running_Process += t.GetHashCode().ToString();



                        foreach (BackgroundWorker ts in TaskList)
                        {
                            if (ts.GetHashCode().ToString() == ID)
                            {
                                TaskManger.Running_Process += ts.GetHashCode().ToString() + " ";
                                ts.RunWorkerAsync();


                                GridView_Tasks.SetRowCellValue(rowHandle, "Task_Status", TaskManagerStatus.Running);
                            }
                        }


                        return;
                    }


                    foreach (BackgroundWorker t in TaskList)
                    {
                        if (t.GetHashCode().ToString() == ID)
                        {
                            TaskManger.Running_Process = TaskManger.Running_Process.Replace(t.GetHashCode().ToString(), "");
                            simpleButton5.Enabled      = false;
                        }
                    }
                }
            }

            appHelper.SetTaskMangerDataTable_Control = DT_TaskManger;
        }