//新建定时发布任务
        protected void scheSure_Btn_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(scheTime_T2.Text) && string.IsNullOrEmpty(scheTime_T.Text))
            {
                return;
            }
            scheTime_T.Text = scheTime_T.Text.Trim();
            DataTable schDT = null;// scheBll.SelByTaskType(M_Content_ScheTask.TaskTypeEnum.Release);

            if (schDT != null && schDT.Rows.Count > 0)
            {
                scheMod             = scheMod.GetModelFromDR(schDT.Rows[0]);
                scheMod.ExecuteTime = DateTime.Now.ToString("yyyy/MM/dd ") + scheTime_T.Text;
                scheBll.Update(scheMod);
            }
            else
            {
                scheMod.TaskName    = "定时发布首页";
                scheMod.TaskContent = "index";
                scheMod.TaskType    = (int)M_Content_ScheTask.TaskTypeEnum.Release;
                scheMod.ExecuteType = (int)M_Content_ScheTask.ExecuteTypeEnum.EveryDay;//暂时无效,原本用来决定是否IsLoop
                scheMod.ExecuteTime = DateTime.Now.ToString("yyyy/MM/dd ") + scheTime_T.Text;
                scheMod.Status      = 0;
                scheBll.Add(scheMod);
            }
            Response.Redirect("SchedTask.aspx");
        }
Exemplo n.º 2
0
    //更新计划任务
    public void UpdateSched(int gid, M_Content_ScheTask.TaskTypeEnum type, string datetext)
    {
        M_Content_ScheTask taskmod = taskBll.SelByGid(GeneralID, type);

        if (!string.IsNullOrEmpty(datetext))
        {
            if (taskmod == null)
            {
                taskmod = new M_Content_ScheTask();
            }
            taskmod.TaskType    = (int)type;
            taskmod.TaskContent = GeneralID.ToString();
            taskmod.ExecuteTime = datetext;
            taskmod.LastTime    = DateTime.Parse(datetext);
            taskmod.Status      = 0;
            if (taskmod.ID > 0)
            {
                taskBll.Update(taskmod);
            }
            else
            {
                taskBll.Add(taskmod);
            }
        }
        else if (taskmod != null)
        {
            taskBll.Delete(taskmod.ID);
        }
    }
Exemplo n.º 3
0
        public void AddSched(int gid, string datetext, M_Content_ScheTask.TaskTypeEnum type)
        {
            M_Content_ScheTask taskmod = new M_Content_ScheTask();

            taskmod.TaskType    = (int)type;
            taskmod.TaskContent = gid.ToString();
            taskmod.ExecuteTime = datetext;
            taskmod.LastTime    = DateTime.Parse(datetext).ToString();
            taskBll.Add(taskmod);
        }
Exemplo n.º 4
0
        //创建任务
        private int AddTask(string content, string title, DateTime etime, ZLEnum.ConStatus status = ZLEnum.ConStatus.Audited)
        {
            M_Content_ScheTask scheModel = new M_Content_ScheTask();

            scheModel.TaskName    = title;
            scheModel.TaskContent = content;                                      //ID
            scheModel.TaskType    = (int)M_Content_ScheTask.TaskTypeEnum.Content; //根据这个调用不同的方法处理TaskContent
            scheModel.ExecuteType = (int)M_Content_ScheTask.ExecuteTypeEnum.JustOnce;
            scheModel.ExecuteTime = etime.ToString();
            scheModel.Remind      = ((int)status).ToString();
            scheModel.AdminID     = adminMod.AdminId;
            scheModel.ID          = scheBll.Add(scheModel);
            TaskCenter.AddTask(scheModel);
            return(scheModel.ID);
        }
Exemplo n.º 5
0
        public IActionResult TaskAdd_Submit()
        {
            if (Mid > 0)
            {
                scheMod = scheBll.GetModel(Mid);
            }
            scheMod.TaskName = RequestEx["TaskName_T"];
            //scheMod.ExecuteTime = ExecuteTime_T1.Text;
            scheMod.Interval = DataConvert.CLng(RequestEx["Interval_T"]);
            string taskContent = RequestEx["TaskContent_T"].Trim();

            if (taskContent.StartsWith("/"))//任务内容为脚本路径时
            {
                if (!System.IO.File.Exists(function.VToP(taskContent)))
                {
                    return(WriteErr("脚本不存在"));
                }
                else
                {
                    scheMod.TaskContent = taskContent;
                }
            }
            else
            {
                scheMod.TaskContent = taskContent;
            }
            scheMod.Remind = RequestEx["Remind_T"];
            //任务类型不允许修改
            if (Mid <= 0)
            {
                scheMod.TaskType = DataConvert.CLng(Request.Form["taskType_rad"]);
            }
            scheMod.ExecuteType = DataConvert.CLng(Request.Form["executeType_rad"]);
            scheMod.Status      = DataConvert.CLng(Request.Form["status_rad"]);
            if (scheMod.ExecuteType == (int)M_Content_ScheTask.ExecuteTypeEnum.Interval)
            {
                if (scheMod.Interval <= 0)
                {
                    return(WriteErr("未指定正确的间隔时间"));
                }
            }
            else if (scheMod.ExecuteType == (int)M_Content_ScheTask.ExecuteTypeEnum.JustOnce)
            {
                scheMod.ExecuteTime = RequestEx["ExecuteTime_T1"];
                if (DataConvert.CDate(scheMod.ExecuteTime) < DateTime.Now)
                {
                    return(WriteErr("执行时间无效"));
                }
            }
            else if (scheMod.ExecuteType == (int)M_Content_ScheTask.ExecuteTypeEnum.EveryDay)
            {
                scheMod.ExecuteTime = RequestEx["ExecuteTime_T2"];
            }
            else if (scheMod.ExecuteType == (int)M_Content_ScheTask.ExecuteTypeEnum.EveryMonth)
            {
                scheMod.ExecuteTime = RequestEx["ExecuteTime_T1"];
            }
            if (Mid > 0)
            {
                scheBll.Update(scheMod);
            }
            else
            {
                scheMod.CDate   = DateTime.Now;
                scheMod.AdminID = adminMod.AdminId;
                scheMod.ID      = scheBll.Add(scheMod);
            }
            HFHelper.AddTask(scheMod);
            return(WriteOK("操作成功", "TaskList"));
        }
 protected void Save_Btn_Click(object sender, EventArgs e)
 {
     if (Mid > 0)
     {
         scheMod = scheBll.GetModel(Mid);
     }
     scheMod.TaskName = TaskName_T.Text;
     //scheMod.ExecuteTime = ExecuteTime_T1.Text;
     scheMod.Interval = DataConvert.CLng(Interval_T.Text);
     if (TaskContent_T.Text.StartsWith("/"))//任务内容为脚本路径时
     {
         if (!File.Exists(function.VToP(TaskContent_T.Text)))
         {
             function.WriteErrMsg("脚本不存在");
         }
         else
         {
             scheMod.TaskContent = TaskContent_T.Text;
         }
     }
     else
     {
         scheMod.TaskContent = TaskContent_T.Text;
     }
     scheMod.Remind = Remind_T.Text;
     //任务类型不允许修改
     if (Mid <= 0)
     {
         scheMod.TaskType = DataConvert.CLng(Request.Form["taskType_rad"]);
     }
     scheMod.ExecuteType = DataConvert.CLng(Request.Form["executeType_rad"]);
     scheMod.Status      = DataConvert.CLng(Request.Form["status_rad"]);
     if (scheMod.ExecuteType == (int)M_Content_ScheTask.ExecuteTypeEnum.Interval)
     {
         if (scheMod.Interval <= 0)
         {
             function.WriteErrMsg("未指定正确的间隔时间");
         }
     }
     else if (scheMod.ExecuteType == (int)M_Content_ScheTask.ExecuteTypeEnum.JustOnce)
     {
         scheMod.ExecuteTime = ExecuteTime_T1.Text;
         if (DataConvert.CDate(scheMod.ExecuteTime) < DateTime.Now)
         {
             function.WriteErrMsg("执行时间无效");
         }
     }
     else if (scheMod.ExecuteType == (int)M_Content_ScheTask.ExecuteTypeEnum.EveryDay)
     {
         scheMod.ExecuteTime = ExecuteTime_T2.Text;
     }
     else if (scheMod.ExecuteType == (int)M_Content_ScheTask.ExecuteTypeEnum.EveryMonth)
     {
         scheMod.ExecuteTime = ExecuteTime_T1.Text;
     }
     if (Mid > 0)
     {
         scheBll.Update(scheMod);
     }
     else
     {
         M_AdminInfo adminMod = B_Admin.GetLogin();
         scheMod.CDate   = DateTime.Now;
         scheMod.AdminID = adminMod.AdminId;
         scheMod.ID      = scheBll.Add(scheMod);
     }
     TaskCenter.AddTask(scheMod);
     function.WriteSuccessMsg("操作成功", "Default.aspx");
 }