Beispiel #1
0
        /// <summary>
        /// id查询任务
        /// </summary>
        /// <param name="sid"></param>
        /// <returns></returns>
        public ScheduleDelayedInfo QueryById(Guid sid)
        {
            var entity = _repositoryFactory.ScheduleDelayeds.FirstOrDefault(m => m.Id == sid);
            ScheduleDelayedInfo info = ObjectMapper <ScheduleDelayedEntity, ScheduleDelayedInfo> .Convert(entity);

            if (info != null)
            {
                info.Executors = _repositoryFactory.ScheduleExecutors.Where(x => x.ScheduleId == sid).Select(x => x.WorkerName).ToList();
            }
            return(info);
        }
Beispiel #2
0
        public ServiceResponseMessage Create([FromForm] ScheduleDelayedInfo task)
        {
            if (!ModelState.IsValid)
            {
                return(ApiResponse(ResultStatus.ParamError, "非法提交参数"));
            }
            ScheduleDelayedEntity entity = ObjectMapper <ScheduleDelayedInfo, ScheduleDelayedEntity> .Convert(task);

            entity.Status         = (int)ScheduleDelayStatus.Created;
            entity.CreateUserName = CurrentUserName;
            var result = _taskService.Add(entity, task.Executors);

            return(result);
        }
Beispiel #3
0
        public ActionResult Create(ScheduleDelayedInfo task)
        {
            if (!ModelState.IsValid)
            {
                return(this.JsonNet(false, "数据验证失败!"));
            }
            ScheduleDelayedEntity entity = ObjectMapper <ScheduleDelayedInfo, ScheduleDelayedEntity> .Convert(task);

            entity.Status         = (int)ScheduleDelayStatus.Created;
            entity.CreateUserName = CurrentAdmin.UserName;
            var result = _taskService.Add(entity, task.Executors);

            if (result.Status == ResultStatus.Success)
            {
                return(this.JsonNet(true, "任务创建成功!", Url.Action("Index")));
            }
            return(this.JsonNet(false, "任务创建失败!"));
        }