示例#1
0
        private async Task <TaskManagementLogDto> GetChangeModel(TaskManagement model)
        {
            var ret = model.MapTo <TaskManagementLogDto>();

            ret.UserName           = model.UserId == null ? "" : (await UserManager.GetUserByIdAsync(model.UserId.Value)).Name;
            ret.SuperintendentName = model.Superintendent == null ? "" : (await UserManager.GetUserByIdAsync(model.Superintendent.Value)).Name;
            ret.TypeName           = model.Type.GetLocalizedDescription();
            return(ret);
        }
示例#2
0
        /// <summary>
        /// 修改一个TaskManagement
        /// </summary>
        /// <param name="input">实体</param>
        /// <returns></returns>
        public async Task Update(UpdateTaskManagementInput input)
        {
            if (input.InStanceId != Guid.Empty)
            {
                var dbmodel = await _repository.FirstOrDefaultAsync(x => x.Id == input.InStanceId);

                if (dbmodel == null)
                {
                    throw new UserFriendlyException((int)ErrorCode.CodeValErr, "该数据不存在!");
                }
                var logModel = new TaskManagement();
                if (input.IsUpdateForChange)
                {
                    logModel = dbmodel.DeepClone <TaskManagement>();
                }
                dbmodel.Requirement       = input.Requirement;
                dbmodel.SignFileId        = input.SignFileId;
                dbmodel.UserId            = input.UserId;
                dbmodel.Type              = input.Type;
                dbmodel.EndTime           = input.EndTime;
                dbmodel.TaskName          = input.TaskName;
                dbmodel.IsUrgent          = input.IsUrgent;
                dbmodel.Superintendent    = input.Superintendent;
                dbmodel.Explain           = input.Explain;
                dbmodel.PerformanceScore  = input.PerformanceScore;
                dbmodel.SpiritScore       = input.SpiritScore;
                dbmodel.ProjectId         = input.ProjectId;
                dbmodel.TaskStatus        = input.TaskStatus;
                dbmodel.TaskManagementIId = input.TaskManagementIId;
                dbmodel.Number            = input.Number;
                dbmodel.ProjectName       = input.ProjectName;
                if (dbmodel.CreateUserRoleType == CreateUserRoleTypeEnum.BGSZR)
                {
                    dbmodel.TaskCreateUserId = input.TaskCreateUserId;
                }

                await _repository.UpdateAsync(dbmodel);

                if (input.IsUpdateForChange)
                {
                    var flowModel = _workFlowCacheManager.GetWorkFlowModelFromCache(input.FlowId);
                    if (flowModel == null)
                    {
                        throw new UserFriendlyException((int)ErrorCode.CodeValErr, "流程不存在");
                    }
                    var logs = GetChangeModel(logModel).GetColumnAllLogs(GetChangeModel(dbmodel));
                    await _projectAuditManager.InsertAsync(logs, input.InStanceId.ToString(), flowModel.TitleField.Table);
                }
            }
            else
            {
                throw new UserFriendlyException((int)ErrorCode.CodeValErr, "该数据不存在!");
            }
        }
示例#3
0
        public async Task <InitWorkFlowOutput> Create(CreateTaskManagementInput input)
        {
            var newmodel = new TaskManagement()
            {
                Requirement        = input.Requirement,
                SignFileId         = input.SignFileId,
                UserId             = input.UserId,
                Type               = input.Type,
                EndTime            = input.EndTime,
                TaskName           = input.TaskName,
                IsUrgent           = input.IsUrgent,
                Superintendent     = input.Superintendent,
                Explain            = input.Explain,
                PerformanceScore   = input.PerformanceScore,
                SpiritScore        = input.SpiritScore,
                ProjectId          = input.ProjectId,
                TaskStatus         = input.TaskStatus,
                TaskManagementIId  = input.TaskManagementIId,
                Number             = input.Number,
                ProjectName        = input.ProjectName,
                TaskCreateUserId   = input.TaskCreateUserId,
                CreateUserRoleType = GetCreateRoleType(AbpSession.UserId.Value),
            };
            var signFileId = _employeesSignManager.GetSignFileId(input.TaskCreateUserId);

            if (signFileId.HasValue)
            {
                newmodel.SignFileId = signFileId;
            }

            if (newmodel.CreateUserRoleType != CreateUserRoleTypeEnum.BGSZR)
            {
                newmodel.TaskCreateUserId = AbpSession.UserId.Value;
            }
            newmodel.Status = 0;

            await _repository.InsertAsync(newmodel);

            return(new InitWorkFlowOutput()
            {
                InStanceId = newmodel.Id.ToString()
            });
        }