示例#1
0
        public async Task <Result> AddTaskAsync(TaskScheduleModel model)
        {
            Result result = new Result();

            if (model == null)
            {
                return(result.SetError("Model 不能为空!"));
            }
            if (string.IsNullOrEmpty(model.JobName))
            {
                return(result.SetError("JobName 不能为空!"));
            }
            if (string.IsNullOrEmpty(model.JobGroup))
            {
                return(result.SetError("JobGroup 不能为空!"));
            }
            if (model.StarRunTime == null)
            {
                model.StarRunTime = DateTime.Now;
            }
            if (model.EndRunTime == null)
            {
                model.EndRunTime = DateTime.MaxValue.AddDays(-1);
            }
            var info = await jobCenter.AddScheduleJobAsync(model);

            if (info.Status != 200)
            {
                return(result.SetError(info.Message));
            }
            base.Add(new TaskSchedule
            {
                Id          = Guid.NewGuid().ToString("N"),
                CreateAuthr = identity.Name,
                CronExpress = model.CronExpress,
                EndRunTime  = model.EndRunTime,
                StarRunTime = model.StarRunTime,
                JobGroup    = model.JobGroup,
                JobName     = model.JobName,
                RunStatus   = model.RunStatus
            }, true);
            return(result);
        }
示例#2
0
 public async Task <IResponseOutput> AddJob([FromBody] ScheduleDto entity)
 {
     return(await _service.AddScheduleJobAsync(entity));
 }