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();
        }
Exemple #2
0
 private void tvCategory_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
 {
     if (e.Label == null)
     {
         if (string.IsNullOrEmpty(SelectNodeViewText))
         {
             //表示没有进行修改
             e.Node.Remove();
         }
         else
         {
             e.CancelEdit = true;
         }
         return;
     }
     if (e.Label.ToString().Trim() == "")
     {
         e.CancelEdit = true;
         return;
     }
     if (dictList.Where(q => q.CategoryName.Value == e.Label.Trim() && q.CategoryName.Value != SelectNodeViewText).FirstOrDefault() != null)
     {
         e.CancelEdit = true;
         WinFormLib.Core.MessageBoxHelper.ShowError("分类已存在!");
         return;
     }
     if (!string.IsNullOrEmpty(SelectNodeViewText))
     {
         Dict dicEntity = dictList.Where(q => q.CategoryName.Value == SelectNodeViewText).FirstOrDefault();
         if (dicEntity != null)
         {
             dicEntity.CategoryName = e.Label.Trim();
         }
     }
     else
     {
         dictList.Add(new Dict()
         {
             CategoryName = CDataItem.Instance(e.Label.Trim()),
             DictItemList = new List <DictItem>()
         });
     }
     SelectNodeViewText = string.Empty;
 }
Exemple #3
0
        private void lsvWord_AfterLabelEdit(object sender, LabelEditEventArgs e)
        {
            if (e.Label == null)
            {
                //表示没有进行修改
                this.lsvWord.Items.Remove(this.lsvWord.Items[e.Item]);
                this.lsvWord.LabelEdit = false;
                return;
            }

            if (e.Label.ToString().Trim() == "")
            {
                e.CancelEdit = true;
                this.lsvWord.Items.Remove(this.lsvWord.Items[e.Item]);
                this.lsvWord.LabelEdit = false;
                return;
            }
            Dict dictEntity = dictList.Where(q => q.CategoryName.Value == SelectNodeText).FirstOrDefault();

            if (dictEntity == null)
            {
                WinFormLib.Core.MessageBoxHelper.ShowError("请先选择字典分类!");
                return;
            }
            if (!string.IsNullOrEmpty(SelectListViewText))
            {
                DictItem dictItemEntity = dictEntity.DictItemList.Where(q => q.DictName.Value == SelectListViewText).FirstOrDefault();
                if (dictItemEntity != null)
                {
                    dictItemEntity.DictName = CDataItem.Instance(e.Label.Trim());
                }
            }
            else
            {
                dictEntity.DictItemList.Add(new DictItem()
                {
                    DictName = CDataItem.Instance(e.Label.Trim())
                });
            }
            SelectListViewText = string.Empty;
        }
Exemple #4
0
        private bool SaveTaskPlan()
        {
            taskPlanEntity.PlanName = CDataItem.Instance(lbTaskPlanName.Value);
            if (string.IsNullOrEmpty(taskPlanEntity.PlanName.Value))
            {
                WinFormLib.Core.MessageBoxHelper.ShowError("任务名称不能为空!");
                return(false);
            }
            taskPlanEntity.PlanItemList = taskPlanItemList;
            if (taskPlanEntity.PlanItemList.Count == 0)
            {
                if (WinFormLib.Core.MessageBoxHelper.ShowQuestion("没有任何任务信息!") != System.Windows.Forms.DialogResult.OK)
                {
                    return(false);
                }
            }
            taskPlanEntity.ExpireCount = 1;
            taskPlanEntity.ExpireFlag  = chkExpireFlag.Checked;
            taskPlanEntity.ExpireTime  = DateTime.MinValue;
            taskPlanEntity.ExpireType  = EnumGloabParas.EnumExpireType.None;
            if (taskPlanEntity.ExpireFlag)
            {
                if (raNumber.Checked)
                {
                    taskPlanEntity.ExpireType  = EnumGloabParas.EnumExpireType.Count;
                    taskPlanEntity.ExpireCount = DMSFrame.TryParse.StrToInt(numExpireCount.Value);
                }
                else
                {
                    taskPlanEntity.ExpireType = EnumGloabParas.EnumExpireType.Time;
                    taskPlanEntity.ExpireTime = dateExpireTime.Value;
                }
            }
            taskPlanEntity.PlanExcuteString = CDataItem.Instance("");
            taskPlanEntity.StartDate        = dateStartDate.Value;
            if (raOneTime.Checked)
            {
                taskPlanEntity.PlanExcuteType = EnumGloabParas.EnumPlanExcuteType.One;
                taskPlanEntity.StartTime      = oneStartTime.Value;
            }
            else if (raDay.Checked)
            {
                taskPlanEntity.PlanExcuteType   = EnumGloabParas.EnumPlanExcuteType.Day;
                taskPlanEntity.StartTime        = dayStartTime.Value;
                taskPlanEntity.PlanExcuteString = dayStartTime1.Value.ToString() + "," + dayStartTime2.Value.ToString();
            }
            else if (raWeekly.Checked)
            {
                taskPlanEntity.PlanExcuteType = EnumGloabParas.EnumPlanExcuteType.Weekly;
                taskPlanEntity.StartTime      = weeklyStartTime.Value;
                string str = "";
                for (int index = 0; index < 7; index++)
                {
                    CheckBox chkWeekly = pnlWeekly.Controls["chkWeekly" + index] as CheckBox;
                    if (chkWeekly != null)
                    {
                        str += chkWeekly.Checked ? ",1" : ",0";
                    }
                }
                taskPlanEntity.PlanExcuteString = str;
            }
            else if (raCustom.Checked)
            {
                taskPlanEntity.PlanExcuteType   = EnumGloabParas.EnumPlanExcuteType.One;
                taskPlanEntity.StartTime        = cusStartTime.Value;
                taskPlanEntity.PlanExcuteString = CDataItem.Instance(cusInterval.Value.ToString());
            }
            taskPlanEntity.Remark = CDataItem.Instance(lbRemark.Value);


            string           errMsg   = string.Empty;
            string           filePath = Program.GetConfigPath(@"plan\" + taskPlanEntity.PlanName.Value + ".xml");
            TaskBasePlanList planList = XmlHelper.LoadFromXml <TaskBasePlanList>(Program.GetConfigPath("plan.xml"), ref errMsg);

            if (!string.IsNullOrEmpty(errMsg))
            {
                WinFormLib.Core.MessageBoxHelper.ShowError(errMsg);
                return(false);
            }
            if (taskPlanEntity.TaskPlanID == 0)
            {
                if (planList.Count > 0)
                {
                    taskPlanEntity.TaskPlanID = planList.Select(q => q.TaskPlanID).Max() + 1;
                }
                else
                {
                    taskPlanEntity.TaskPlanID = 1;
                }
                planList.Add(new TaskBasePlan()
                {
                    TaskPlanID = taskPlanEntity.TaskPlanID, PlanName = taskPlanEntity.PlanName
                });
                XmlHelper.Save2File <TaskBasePlanList>(planList, Program.GetConfigPath("plan.xml"), ref errMsg);
                if (!string.IsNullOrEmpty(errMsg))
                {
                    WinFormLib.Core.MessageBoxHelper.ShowError(errMsg);
                    return(false);
                }
            }

            XmlHelper.Save2File <TaskPlan>(taskPlanEntity, filePath, ref errMsg);
            if (!string.IsNullOrEmpty(errMsg))
            {
                WinFormLib.Core.MessageBoxHelper.ShowError(errMsg);
                return(false);
            }
            WinFormLib.Core.MessageBoxHelper.Show("保存成功!");
            return(true);
        }