/// <summary> /// 外部调用执行任务 /// </summary> /// <param name="taskInfo"></param> /// <param name="callbackFunc">线程结束后回调</param> /// <param name="saveToDB">是否需要保持到数据库</param> public bool Run(TaskInfo taskInfo, Action callbackFunc, bool saveToDB = true) { if (!backgroundWorker.IsBusy) { TaskInfo = taskInfo; this.htmlWeb.OverrideEncoding = Encoding.GetEncoding(taskInfo.SpiderConfig.Charset.Split('/')[0]); this.callbackFunc = callbackFunc; this.saveToDB = saveToDB; if (string.IsNullOrEmpty(Description)) { Description = taskInfo.Title; } oldRunState = taskInfo.RunState; taskInfo.RunState = ERunState.Running; backgroundWorker.RunWorkerAsync(); return(true); } else { ReportInfo("已经在运行状态中..."); return(false); } }
void SetMoveState() { isSprinting = player.GetAxis("Sprint") != 0f; if (isSprinting) { RunState = ERunState.SPRINTING; } else { RunState = ERunState.RUNNING; } }
private void ToIdle() { RState = ERunState.Idle; CRunTimer.Stop(); CGoButton.Text = "Go"; CProgress.Value = 0; CCycleTime.Enabled = true; CStepSize.Enabled = true; CStepDirection.Enabled = true; CDryRun.Enabled = true; CFrames.Enabled = true; CaptureCount = 0; CaptureCountTarget = 0; }
private void ToRunning() { CGoButton.Text = "Stop"; CProgress.Value = 0; CProgress.Maximum = (int)CFrames.Value; CRunTimer.Interval = (int)CCycleTime.Value; CCycleTime.Enabled = false; CStepSize.Enabled = false; CStepDirection.Enabled = false; CDryRun.Enabled = false; CFrames.Enabled = false; CaptureCount = 0; CaptureCountTarget = (int)CFrames.Value; RState = ERunState.Running; CRunTimer.Start(); }
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; }