Пример #1
0
        public taskForm(mainForm mainForm)
        {
            InitializeComponent();
            this.mainForm = mainForm;

            zxtype.Items.Clear();
            zxtype.Items.Add(EnumDescription.GetText(ERunCycle.OnlyOnce));
            zxtype.Items.Add(EnumDescription.GetText(ERunCycle.EveryDay));
            zxtype.Items.Add(EnumDescription.GetText(ERunCycle.EveryWeek));
            zxtype.Items.Add(EnumDescription.GetText(ERunCycle.EveryMonth));
            zxtype.SelectedIndex = 0;
            confgir = new string[] { DateTime.Now.ToString("yyyy-MM-dd"), DateTime.Now.ToString("yyyy-MM-dd"), "0:00:00" };
        }
Пример #2
0
 public void RefreshDataGridView(TaskInfo data)
 {
     if (taskTreeView.SelectedNode.Text == EnumDescription.GetText(data.RunState) || taskTreeView.SelectedNode.Text.Contains("任务"))
     {
         int rowIndex = -1;
         for (int i = 0; i < this.taskDataView.Rows.Count; i++)
         {
             if ((int)taskDataView.Rows[i].Cells[0].Value == data.Id)
             {
                 rowIndex = i;
                 break;
             }
         }
         FillTaksInfo(data, rowIndex);
     }
 }
Пример #3
0
        private void FillTaksInfo(TaskInfo data, int index = -1)
        {
            if (index == -1)
            {
                index = this.taskDataView.Rows.Add();
            }
            int idx = 0;

            this.taskDataView.Rows[index].Cells[idx++].Value = data.Id;
            this.taskDataView.Rows[index].Cells[idx++].Value = data.Title;
            this.taskDataView.Rows[index].Cells[idx++].Value = EnumDescription.GetText(data.RunState);
            this.taskDataView.Rows[index].Cells[idx++].Value = EnumDescription.GetText(data.Type);
            this.taskDataView.Rows[index].Cells[idx++].Value = data.RunMessage.IRunTime != 0 ? data.RunMessage.LastRunningTimeStr : "";
            this.taskDataView.Rows[index].Cells[idx++].Value = data.RunMessage.RunCount;
            this.taskDataView.Rows[index].Cells[idx++].Value = data.RunMessage.ErrorCount;
            this.taskDataView.Rows[index].Cells[idx++].Value = data.Remark;
            this.taskDataView.Rows[index].Tag = data.Id;
        }
Пример #4
0
        public void Set(TaskInfo taskInfo)
        {
            if (taskInfo == null)
            {
                taskInfo = new TaskInfo();
            }
            this.taskInfo = taskInfo;
            if (!string.IsNullOrEmpty(taskInfo.StartDate))
            {
                confgir[0] = taskInfo.StartDate;
            }
            if (!string.IsNullOrEmpty(taskInfo.EndDate))
            {
                confgir[1] = taskInfo.EndDate;
            }
            if (!string.IsNullOrEmpty(taskInfo.RunTime))
            {
                confgir[2] = taskInfo.RunTime;
            }

            #region 填充任务计划选项
            txtBoxWebSiteName.Text = taskInfo.Title;
            zxtype.SelectedIndex   = zxtype.Items.IndexOf(EnumDescription.GetText(taskInfo.Type));
            dateTimePkStart.Value  = Convert.ToDateTime(confgir[2]);
            numBoxEveryDay.Value   = taskInfo.RunDay;
            dateTimePkOne.Value    = Convert.ToDateTime(confgir[0]);
            numBoxEveryWeek.Value  = taskInfo.RunWeek;
            string[] weeks = taskInfo.RunWeekDay.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            if (weeks.Length == 7)
            {
                chkWeek_7.Checked = weeks[0] == "1";
                chkWeek_1.Checked = weeks[1] == "1";
                chkWeek_2.Checked = weeks[2] == "1";
                chkWeek_3.Checked = weeks[3] == "1";
                chkWeek_4.Checked = weeks[4] == "1";
                chkWeek_5.Checked = weeks[5] == "1";
                chkWeek_6.Checked = weeks[6] == "1";
            }
            string[] months = taskInfo.RunMonth.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            if (months.Length == 12)
            {
                chkMonth_1.Checked  = months[0] == "1";
                chkMonth_2.Checked  = months[1] == "1";
                chkMonth_3.Checked  = months[2] == "1";
                chkMonth_4.Checked  = months[3] == "1";
                chkMonth_5.Checked  = months[4] == "1";
                chkMonth_6.Checked  = months[5] == "1";
                chkMonth_7.Checked  = months[6] == "1";
                chkMonth_8.Checked  = months[7] == "1";
                chkMonth_9.Checked  = months[8] == "1";
                chkMonth_10.Checked = months[9] == "1";
                chkMonth_11.Checked = months[10] == "1";
                chkMonth_12.Checked = months[11] == "1";
            }
            rdBoxMonthDate.Checked = taskInfo.RunMonthWeek == -1;
            rdBoxMonthWeek.Checked = !rdBoxMonthDate.Checked;
            if (rdBoxMonthWeek.Checked)
            {
                cbBoxMonthEveryWeek.SelectedIndex = taskInfo.RunMonthWeek;
            }
            txtBoxRemark.Text = taskInfo.Remark;
            IsEndDate         = taskInfo.IsEndDate;
            #endregion

            #region 填充爬虫设置选项
            var spider = taskInfo.SpiderConfig;

            txtBoxWebURL.Text         = spider.ListUrl;
            txtBoxKeyWords.Text       = spider.KeyWords;
            numBoxPageCount.Value     = spider.PageCount;
            numBoxLastDay.Value       = spider.ScanLastDay;
            txtBoxListTag_xpath.Text  = spider.ListTag;
            txtBoxListLink_xpath.Text = spider.ListTitleTag;
            txtBoxListDate_xpath.Text = spider.ListDateTag;
            txtBoxListLinkURL.Text    = spider.ListTitleSpliceUrl;

            txtBoxFirstPageFileName.Text = spider.FirstPageFile;
            txtBoxNextPageFileName.Text  = spider.NextPageFile;
            numBoxStart.Value            = spider.PageStartInx;

            txtBoxContextTag_xpath.Text    = spider.ContextTag;
            txtBoxContextTitle_xpath.Text  = spider.ContextTitleTag;
            txtBoxContextDetail_xpath.Text = spider.ContextDetailTag;
            txtBoxCharset.Text             = spider.Charset;
            #endregion

            runState = taskInfo.RunState;
            //配置过程中,暂停运行
            taskInfo.RunState = ERunState.Stop;
        }