public ActionResult TaskEdit(string TaskGuid) { InitTask(); Ts_Tasks tasks = _taskService.GetTaskByGuid(TaskGuid); return(View("TaskEdit", tasks)); }
public ActionResult TaskAdd() { InitTask(); Ts_Tasks tasks = new Ts_Tasks(); tasks.TimeOut = 30; tasks.RunServerId = _taskService.GetNewRunServerId(); // tasks.ExecMethod = "GET"; return(View("TaskEdit", tasks)); }
public ActionResult SaveTask(Ts_Tasks tasks) { JsonReturnMessages msg = new JsonReturnMessages(); try { msg.IsSuccess = _taskService.SaveTask(tasks); _taskService.RestTask(tasks); } catch (BOException ex) { msg.Msg = ex.Message; } return(Json(msg)); }
public bool SaveTask(Ts_Tasks Tasks) { try { new CronExpression(Tasks.Interval); } catch (Exception ex) { throw new BOException("设置的cron表达式格式不正确"); } if (Tasks.TimeOut <= 0) { throw new BOException("超时时间必需大于0"); } if (!string.IsNullOrEmpty(Tasks.Encoding)) { try { Encoding.GetEncoding(Tasks.Encoding); } catch { throw new BOException("编码输入错误"); } } Tasks.RunServerId = GetNewRunServerId(); if (Tasks.ExecType == (int)ExecTypeEnum.EXE) { Tasks.IsResponseNorm = false; } if (string.IsNullOrEmpty(Tasks.Guid)) { Tasks.CreateUser = MyContext.CurrentUser.UserId; Tasks.Guid = Guid.NewGuid().ToString(); Tasks.InsertTime = DateTime.Now; _ormTasks.Add(Tasks); _ormTaskExec.Add(new Ts_TaskExec() { TaskGuid = Tasks.Guid }); return(true); } int result = _ormTasks.Update(Tasks); log.Info(string.Format("保存任务记录:{0},执行结果:{1},操作用户:{2}", Tasks.ToJson(), result, MyContext.CurrentUser.UserName)); return(result > 0); }
public void RestTask(Ts_Tasks task) { TasksManage.GetInstance().SetTask(new ExecTaskInfo(task, GetTaskExecByGuid(task.Guid))); }