/// <summary> /// /// </summary> /// <param name="dto"></param> /// <returns></returns> public PublicResult ExecuteScheduleTask(ExecuteScheduleTaskDto dto) { using (var client = DbFactory.CreateClient()) { var scheduleTask = client.Queryable <ScheduleTask>().InSingle(dto.Id); if (scheduleTask == null) { throw new Exception("找不到数据"); } if (!scheduleTask.IsEnable) { throw new Exception("需先开启任务,才能执行"); } var task = _taskScheduleManager.TriggerJob(scheduleTask); Task.WaitAll(task); } return(Ok()); }
public IActionResult Execute(ExecuteScheduleTaskDto dto) { var result = _scheduleTaskService.ExecuteScheduleTask(dto); return(Json(result)); }