示例#1
0
        public DataRes <bool> DeleteSchedule(int id)
        {
            var res = new DataRes <bool>()
            {
                code = ResCode.Success, data = true
            };

            using (var uow = _uowProvider.CreateUnitOfWork())
            {
                var repository = uow.GetRepository <ResSchedule>();
                //根据任务编号获取任务详情
                var model = repository.Get(id);
                //恢复指定任务
                var result = QuartzHelper.StopScheduleAsync(model);
                if (result.Result.Code == 1000)
                {
                    repository.Remove(model);
                    res.msg = result.Result.Msg;
                    logger.Info($"任务已删除:{model.JobGroup}-{model.JobName},{result.Result.Msg}");
                }
                else
                {
                    res.code = ResCode.Error;
                    res.msg  = result.Result.Msg;
                    logger.Error($"任务停止异常,删除失败:{model.JobGroup}-{model.JobName},{result.Result.Msg}");
                }
            }
            return(res);
        }
示例#2
0
        public DataRes <bool> Stop(int id)
        {
            var res = new DataRes <bool>()
            {
                code = ResCode.Success, data = true
            };

            using (var uow = _uowProvider.CreateUnitOfWork())
            {
                var repository = uow.GetRepository <ResSchedule>();
                //根据任务编号获取任务详情
                var model = repository.Get(id);
                //停止指定任务
                var result = QuartzHelper.StopScheduleAsync(model);
                if (result.Result.Code == 1000)
                {
                    model.JobStatus = 0;
                    model.WriteDate = DateTime.Now;
                    var t10 = repository.Update(model);
                    res.msg = result.Result.Msg;
                    logger.Info($"任务已停止:{model.JobGroup}-{model.JobName},{result.Result.Msg}");
                }
                else
                {
                    res.code = ResCode.Error;
                    res.msg  = result.Result.Msg;
                    logger.Error($"任务停止异常:{model.JobGroup}-{model.JobName},{result.Result.Msg}");
                }
            }
            return(res);
        }