public PublicResult SetIsEnableScheduleTask(SetIsEnableScheduleTaskDto dto) { ScheduleTask scheduleTask = null; using (var client = DbFactory.CreateClient()) { scheduleTask = client.Queryable <ScheduleTask>().InSingle(dto.Id); } if (scheduleTask == null) { throw new Exception("没有找到数据"); } if (dto.IsEnable) { if (scheduleTask.Type.IsNullOrEmpty()) { throw new Exception("没有找到对应的Job"); } if (scheduleTask.Cron.IsNullOrEmpty()) { throw new Exception("没有找到对应的CRON表达式"); } var task = _taskScheduleManager.EnableJob(scheduleTask); Task.WaitAll(task); } else { var task = _taskScheduleManager.DisableJob(scheduleTask); Task.WaitAll(task); } return(Ok()); }
public IActionResult SetIsEnable(SetIsEnableScheduleTaskDto dto) { var result = _scheduleTaskService.SetIsEnableScheduleTask(dto); return(Json(result)); }