private EmployeeProposalLogDto GetChangeModel(EmployeeProposal model) { var ret = model.MapTo <EmployeeProposalLogDto>(); ret.TypeName = model.Type.GetLocalizedDescription(); return(ret); }
public async Task <InitWorkFlowOutput> Create(CreateEmployeeProposalInput input) { var newmodel = new EmployeeProposal() { Title = input.Title, Type = input.Type, Content = input.Content, IsIssue = input.IsIssue, ParticipateUser = input.ParticipateUser }; newmodel.IssueUserId = AbpSession.UserId.Value; await _repository.InsertAsync(newmodel); if (input.FileList != null) { var fileList = new List <AbpFileListInput>(); foreach (var item in input.FileList) { fileList.Add(new AbpFileListInput() { Id = item.Id, Sort = item.Sort }); } await _abpFileRelationAppService.CreateAsync(new CreateFileRelationsInput() { BusinessId = newmodel.Id.ToString(), BusinessType = (int)AbpFileBusinessType.提案附件, Files = fileList }); } return(new InitWorkFlowOutput() { InStanceId = newmodel.Id.ToString() }); }
/// <summary> /// 修改一个EmployeeProposal /// </summary> /// <param name="input">实体</param> /// <returns></returns> public async Task Update(UpdateEmployeeProposalInput 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 EmployeeProposal(); if (input.IsUpdateForChange) { logModel = dbmodel.DeepClone(); } dbmodel.Title = input.Title; dbmodel.Type = input.Type; dbmodel.Content = input.Content; dbmodel.Comment = input.Comment; dbmodel.IsIssue = input.IsIssue; dbmodel.OrgId = input.OrgId; dbmodel.SingleProjectId = input.SingleProjectId; dbmodel.IssueUserId = input.IssueUserId; dbmodel.IssueType = input.IssueType; if (!string.IsNullOrEmpty(input.ParticipateUser)) { dbmodel.ParticipateUser = input.ParticipateUser; } 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); } var fileList = new List <AbpFileListInput>(); if (input.FileList != null) { foreach (var item in input.FileList) { fileList.Add(new AbpFileListInput() { Id = item.Id, Sort = item.Sort }); } } await _abpFileRelationAppService.UpdateAsync(new CreateFileRelationsInput() { BusinessId = input.Id.ToString(), BusinessType = (int)AbpFileBusinessType.提案附件, Files = fileList }); } else { throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "该数据不存在。"); } }