Exemple #1
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);
        }
    }
Exemple #2
0
 protected void EGV_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     switch (e.CommandName)
     {
     case "del2":
         int id = Convert.ToInt32(e.CommandArgument);
         scheBll.Delete(id);
         TaskCenter.RemoveTask(id);
         break;
     }
     MyBind();
 }
Exemple #3
0
        public ContentResult Task_API()
        {
            scheMod = scheBll.SelReturnModel(DataConvert.CLng(ids));
            if (scheMod == null)
            {
                return(Content("任务不存在"));
            }
            switch (action)
            {
            case "del":
            {
                scheBll.Delete(scheMod.ID);
                RecurringJob.RemoveIfExists(scheMod.TaskFlag);
            }
            break;

            case "stop":
            {
                if (scheMod.Status != -1)
                {
                    scheMod.Status = -1;
                    scheBll.Update(scheMod);
                }
                RecurringJob.RemoveIfExists(scheMod.TaskFlag);
            }
            break;

            case "start":
            {
                if (scheMod.Status == -1)
                {
                    scheMod.Status = 0;
                    scheBll.Update(scheMod);
                    HFHelper.AddTask(scheMod);
                }
            }
            break;

            case "execute":
            {
                BackgroundJob.Enqueue <HF_Task_ExecuteSql>(x => x.Execute(scheMod));
            }
            break;
            }
            return(Content(Success.ToString()));
        }