示例#1
0
        public string TrainLeaveFlowActive(Guid instanceId)
        {
            var subInstaceId = "";
            var train        = _trainRepository.GetAll().FirstOrDefault(x => x.Id == instanceId);

            if (train != null)
            {
                var model = new TrainLeave();
                model.Id      = Guid.NewGuid();
                model.UserId  = AbpSession.UserId.Value;
                model.TrainId = instanceId;
                _repository.Insert(model);
                subInstaceId = model.Id.ToString();
            }
            else
            {
                throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "获取培训数据异常");
            }
            return(subInstaceId);
        }
示例#2
0
        public async Task <InitWorkFlowOutput> Create(CreateTrainLeaveInput input)
        {
            var newmodel = new TrainLeave()
            {
                UserId    = AbpSession.UserId.Value,
                TrainId   = input.TrainId,
                LevelType = input.LevelType,
                Reason    = input.Reason,
                StartTime = input.StartTime,
                EndTime   = input.EndTime,
                Day       = input.Day
            };

            newmodel.Status = 0;
            await _repository.InsertAsync(newmodel);

            return(new InitWorkFlowOutput()
            {
                InStanceId = newmodel.Id.ToString()
            });
        }
示例#3
0
        /// <summary>
        /// 修改一个TrainLeave
        /// </summary>
        /// <param name="input">实体</param>
        /// <returns></returns>
        public async Task Update(UpdateTrainLeaveInput input)
        {
            if (input.Id != Guid.Empty)
            {
                var dbmodel = await _repository.FirstOrDefaultAsync(x => x.Id == input.Id);

                if (dbmodel == null)
                {
                    throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "该数据不存在!");
                }
                var logModel = new TrainLeave();
                if (input.IsUpdateForChange)
                {
                    logModel = dbmodel.DeepClone <TrainLeave>();
                }
                dbmodel.LevelType = input.LevelType;
                dbmodel.Reason    = input.Reason;
                dbmodel.StartTime = input.StartTime;
                dbmodel.EndTime   = input.EndTime;
                dbmodel.Day       = input.Day;

                await _repository.UpdateAsync(dbmodel);

                if (input.IsUpdateForChange)
                {
                    var flowModel = _workFlowCacheManager.GetWorkFlowModelFromCache(input.FlowId);
                    if (flowModel == null)
                    {
                        throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "流程不存在");
                    }
                    var logs = GetChangeModel(logModel).GetColumnAllLogs(GetChangeModel(dbmodel));
                    await _projectAuditManager.InsertAsync(logs, input.Id.ToString(), flowModel.TitleField.Table);
                }
            }
            else
            {
                throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "该数据不存在!");
            }
        }
示例#4
0
        private TrainLeaveLogDto GetChangeModel(TrainLeave model)
        {
            var ret = model.MapTo <TrainLeaveLogDto>();

            return(ret);
        }