コード例 #1
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            if (DTbCTPN == null || DTbCTPN.Rows.Count == 0)
            {
                MessageBox.Show("Chưa chọn danh sách link cần up bài.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (dtContent == null || dtContent.Rows.Count == 0)
            {
                MessageBox.Show("Chưa có nội dung up.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (calcEditNumThread.EditValue == null || calcEditNumThread.EditValue.ToString() == "0")
            {
                MessageBox.Show("Thiết lập số tiến trình thực hiện.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (calcEditSleep.EditValue == null)
            {
                MessageBox.Show("Thiết lập thời gian up cách nhau giữa mỗi trang.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            btnStop.Enabled           = true;
            btnStart.Enabled          = false;
            btnClose.Enabled          = false;
            btnClearLog.Enabled       = false;
            tabOption.PageEnabled     = false;
            tabMessage.PageEnabled    = false;
            tabSelectLink.PageEnabled = false;
            dtTimeUp.Rows.Clear();
            foreach (DataRow dtR in dtTime.Rows)
            {
                try
                {
                    DataRow newRow = dtTimeUp.NewRow();
                    newRow["Value"] = dtR["Value"];
                    dtTimeUp.Rows.Add(newRow);
                }
                catch { }
            }
            //dtTimeUp = dtTime.Copy();
            isStop        = false;
            dialogWatcher = new FormDialogWatcher(this.Handle);
            dialogWatcher.CloseUnhandledDialogs = true;
            ThreadPostTopic();
        }
コード例 #2
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            if (DTbCTPN == null || DTbCTPN.Rows.Count == 0)
            {
                MessageBox.Show("Chưa chọn danh sách link cần up bài.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (checkEdit1.Checked)
            {
                if (calcEditOption1.EditValue == null || calcEditOption1.EditValue.ToString() == "0")
                {
                    MessageBox.Show("Thiết lập thời gian up bài.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            else if (checkEdit2.Checked)
            {
                if (gridView3.RowCount <= 0)
                {
                    MessageBox.Show("Thiết lập thời gian up bài.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            if (calcEditNumThread.EditValue == null || calcEditNumThread.EditValue.ToString() == "0")
            {
                MessageBox.Show("Thiết lập số tiến trình thực hiện.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (calcEditSleep.EditValue == null)
            {
                MessageBox.Show("Thiết lập thời gian up cách nhau giữa mỗi trang.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            btnStop.Enabled           = true;
            btnStart.Enabled          = false;
            btnClose.Enabled          = false;
            btnClearLog.Enabled       = false;
            tabOption.PageEnabled     = false;
            tabSelectLink.PageEnabled = false;
            dtTimeUp.Rows.Clear();
            foreach (DataRow dtR in dtTime.Rows)
            {
                try
                {
                    DataRow newRow = dtTimeUp.NewRow();
                    newRow["Value"] = dtR["Value"];
                    dtTimeUp.Rows.Add(newRow);
                }
                catch { }
            }
            //dtTimeUp = dtTime.Copy();
            isStop        = false;
            dialogWatcher = new FormDialogWatcher(this.Handle);
            dialogWatcher.CloseUnhandledDialogs = true;
            if (checkEdit1.Checked)
            {
                timer1.Interval = int.Parse(calcEditOption1.Value.ToString()) * 60000;
                timer1.Start();
            }
            else
            {
                foreach (DataRow dtRow in dtTimeUp.Rows)
                {
                    string[] time  = dtRow["Value"].ToString().Split(':');
                    TimeSpan span1 = new TimeSpan(int.Parse(time[0]), int.Parse(time[1]), 0);
                    TimeSpan span2 = new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, 0);
                    if (span1 <= span2)
                    {
                        dtRow["Value"] = DateTime.Now.AddDays(1).ToString("yyyyMMdd") + dtRow["Value"].ToString();
                    }
                    else
                    {
                        dtRow["Value"] = DateTime.Now.ToString("yyyyMMdd") + dtRow["Value"].ToString();
                    }
                }

                timer2.Start();
            }
        }