コード例 #1
0
ファイル: frmAddPlanTask.cs プロジェクト: Pinkuburu/NETSpider
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            TaskPlanItem entity = new TaskPlanItem()
            {
                TaskItemType = 0
            };

            if (raSpiderTask.Checked)
            {
                if (dgvTask.SelectedRows.Count > 0)
                {
                    entity.CategroyName = comCategorys.SelectedItem.ToString();
                    entity.TaskID       = TryParse.StrToInt(dgvTask[colTaskID.Index, dgvTask.SelectedRows[0].Index].Value);
                    entity.TaskName     = CDataItem.Instance(dgvTask[colTaskName.Index, dgvTask.SelectedRows[0].Index].Value.ToString());
                    entity.TaskType     = EnumGloabParas.EnumPlanTaskType.Task;
                    entity.TaskArgs     = "";
                }
                else
                {
                    WinFormLib.Core.MessageBoxHelper.ShowError("请选择执行任务!");
                    return;
                }
            }
            else if (raDataTask.Checked)
            {
                if (cbPubDataTable.SelectedItem != null || string.IsNullOrEmpty(cbPubDataTable.Text))
                {
                    entity.CategroyName = CDataItem.Instance("");
                    entity.TaskID       = 0;
                    entity.TaskName     = string.IsNullOrEmpty(cbPubDataTable.Text) ? cbPubDataTable.SelectedItem.ToString() : cbPubDataTable.Text;
                    entity.TaskType     = EnumGloabParas.EnumPlanTaskType.DataBase;
                    entity.TaskArgs     = lbConnectionString.Value;
                    entity.TaskItemType = cbPubDataTable.SelectedItem != null ? 1 : 0;
                }
                else
                {
                    WinFormLib.Core.MessageBoxHelper.ShowError("请设置查询或存储过程");
                    return;
                }
            }
            else if (raOtherTask.Checked)
            {
                entity.CategroyName = CDataItem.Instance("");
                entity.TaskID       = 0;
                entity.TaskName     = lbFileName.Value;
                entity.TaskType     = EnumGloabParas.EnumPlanTaskType.Custom;
                entity.TaskArgs     = lbFileArgs.Value;
                if (string.IsNullOrEmpty(entity.TaskName.Value))
                {
                    WinFormLib.Core.MessageBoxHelper.ShowError("请设置执行程序路径");
                    return;
                }
            }
            this.DialogResult = DialogResult.OK;
            if (e_OnReturnTaskPlanItem != null)
            {
                e_OnReturnTaskPlanItem(entity);
            }
            this.Close();
        }
コード例 #2
0
 void frmAddPlan_e_OnReturnTaskPlanItem(TaskPlanItem planItem)
 {
     planItem.TaskPlanItemID = taskPlanItemList.Count + 1;
     taskPlanItemList.Add(planItem);
     this.dgvTaskPlan.RemoveBind();
     this.dgvTaskPlan.ReBind(TaskPlanItem.GetDataTable(taskPlanItemList), false);
     this.dgvTaskPlan.ClearSelection();
 }
コード例 #3
0
 private void btnRemove_Click(object sender, EventArgs e)
 {
     if (dgvTaskPlan.SelectedRows.Count > 0)
     {
         int taskPlanItemID = DMSFrame.TryParse.StrToInt(dgvTaskPlan[colTaskPlanItemID.Index, dgvTaskPlan.SelectedRows[0].Index].Value);
         if (taskPlanItemID > 0)
         {
             TaskPlanItem entity = taskPlanItemList.Where(q => q.TaskPlanItemID == taskPlanItemID).FirstOrDefault();
             if (entity != null)
             {
                 taskPlanItemList.Remove(entity);
                 this.dgvTaskPlan.RemoveBind();
                 this.dgvTaskPlan.ReBind(TaskPlanItem.GetDataTable(taskPlanItemList), false);
                 this.dgvTaskPlan.ClearSelection();
             }
         }
     }
 }
コード例 #4
0
        public frmPlan(string planName)
        {
            InitializeComponent();
            string errMsg  = string.Empty;
            string dirPath = Program.GetConfigPath(@"plan");

            if (!System.IO.Directory.Exists(dirPath))
            {
                System.IO.Directory.CreateDirectory(dirPath);
            }
            if (!string.IsNullOrEmpty(planName))
            {
                string filePath = Program.GetConfigPath(@"plan\" + planName + ".xml");
                taskPlanEntity = XmlHelper.LoadFromXml <TaskPlan>(filePath, ref errMsg);
                if (!string.IsNullOrEmpty(errMsg))
                {
                    WinFormLib.Core.MessageBoxHelper.ShowError(errMsg);
                }
            }
            else
            {
                taskPlanEntity = new TaskPlan();
            }
            lbTaskPlanName.DataViewValue = taskPlanEntity.PlanName.Value;
            lbRemark.DataViewValue       = taskPlanEntity.Remark.Value;
            if (taskPlanEntity.ExpireFlag)
            {
                chkExpireFlag.Checked = true;
                if (taskPlanEntity.ExpireType == EnumGloabParas.EnumExpireType.Count)
                {
                    raNumber.Checked     = true;
                    numExpireCount.Value = taskPlanEntity.ExpireCount;
                }
                else
                {
                    raDateTime.Checked   = true;
                    dateExpireTime.Value = taskPlanEntity.ExpireTime;
                }
            }
            else
            {
                chkExpireFlag.Checked = false;
            }
            dateStartDate.Value = taskPlanEntity.StartDate;
            if (taskPlanEntity.PlanExcuteType == EnumGloabParas.EnumPlanExcuteType.One)
            {
                raOneTime.Checked  = true;
                oneStartTime.Value = taskPlanEntity.StartTime;
            }
            else if (taskPlanEntity.PlanExcuteType == EnumGloabParas.EnumPlanExcuteType.Day)
            {
                raDay.Checked      = true;
                dayStartTime.Value = taskPlanEntity.StartTime;
                string[] str = taskPlanEntity.PlanExcuteString.Value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                if (str.Length == 2)
                {
                    DateTime[] dateTime = Array.ConvertAll <string, DateTime>(str, item => DMSFrame.TryParse.StrToDate(item));
                    dayStartTime1.Value = dateTime[0];
                    dayStartTime2.Value = dateTime[1];
                }
            }
            else if (taskPlanEntity.PlanExcuteType == EnumGloabParas.EnumPlanExcuteType.Weekly)
            {
                raWeekly.Checked      = true;
                weeklyStartTime.Value = taskPlanEntity.StartTime;
                string[] str = taskPlanEntity.PlanExcuteString.Value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                if (str.Length == 7)
                {
                    int index = 0;
                    foreach (var item in str)
                    {
                        CheckBox chkWeekly = pnlWeekly.Controls["chkWeekly" + index] as CheckBox;
                        if (chkWeekly != null)
                        {
                            if (item == "1")
                            {
                                chkWeekly.Checked = true;
                            }
                            else
                            {
                                chkWeekly.Checked = false;
                            }
                        }
                        index++;
                    }
                }
            }
            else if (taskPlanEntity.PlanExcuteType == EnumGloabParas.EnumPlanExcuteType.Custom)
            {
                raCustom.Checked   = true;
                cusStartTime.Value = taskPlanEntity.StartTime;
                cusInterval.Value  = DMSFrame.TryParse.StrToDecimal(taskPlanEntity.PlanExcuteString);
            }
            ShowExcuteTypePanel();
            taskPlanItemList = taskPlanEntity.PlanItemList;
            if (taskPlanItemList.Count > 0)
            {
                //this.dgvTaskPlan.RemoveBind();
                this.dgvTaskPlan.ReBind(TaskPlanItem.GetDataTable(taskPlanItemList), false);
                this.dgvTaskPlan.ClearSelection();
            }
        }