Esempio n. 1
0
        /// <summary>
        /// 修改一个EmployeeReceipt
        /// </summary>
        /// <param name="input">实体</param>
        /// <returns></returns>
        public async Task UpdateCopyFor(UpdateEmployeeReceiptInput 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, "该数据不存在。");
                }
                dbmodel.CopyForType  = input.CopyForType;
                dbmodel.TaskType     = input.TaskType;
                dbmodel.CopyForUsers = input.CopyForUsers;
                await _repository.UpdateAsync(dbmodel);

                if (dbmodel.QrCodeId.HasValue)
                {
                    var qrcodeModel = _qrCodeManager.Get(dbmodel.QrCodeId.Value);
                    if (qrcodeModel.Type == QrCodeType.公文)
                    {
                        qrcodeModel.Type = QrCodeType.档案;
                        _qrCodeManager.UpdateType(qrcodeModel);
                    }
                }
            }
            else
            {
                throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "该数据不存在。");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 修改一个EmployeeReceipt
        /// </summary>
        /// <param name="input">实体</param>
        /// <returns></returns>
        public async Task Update(UpdateEmployeeReceiptInput input)
        {
            if (input.Id != Guid.Empty)
            {
                if (input.DocProperty == ReceiptDocProperty.Electronic && input.FileList.Count() == 0)
                {
                    throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "请上传正文。");
                }
                var dbmodel = await _repository.FirstOrDefaultAsync(x => x.Id == input.Id);

                if (dbmodel == null)
                {
                    throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "该数据不存在。");
                }
                var logModel = new EmployeeReceipt();
                if (input.IsUpdateForChange)
                {
                    logModel = dbmodel.DeepClone <EmployeeReceipt>();
                }
                dbmodel.Opinion         = input.Opinion;
                dbmodel.Title           = input.Title;
                dbmodel.Remark          = input.Remark;
                dbmodel.Rank            = input.Rank;
                dbmodel.IsPrintQrcode   = input.IsPrintQrcode;
                dbmodel.DocReceiveNo    = input.DocReceiveNo;
                dbmodel.DocReceiveDep   = input.DocReceiveDep;
                dbmodel.CopyForType     = input.CopyForType;
                dbmodel.TaskType        = input.TaskType;
                dbmodel.DocType         = input.DocType;
                dbmodel.CopyForUsers    = input.CopyForUsers;
                dbmodel.EmergencyDegree = input.EmergencyDegree;
                await _repository.UpdateAsync(dbmodel);

                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,
                });

                if (input.IsUpdateForChange)
                {
                    var flowModel = _workFlowCacheManager.GetWorkFlowModelFromCache(input.FlowId);
                    if (flowModel == null)
                    {
                        throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "流程不存在");
                    }
                    var files = input.OldFileList.Select(r => new AbpFileChangeDto {
                        FileName = r.FileName, Id = r.Id
                    }).ToList();
                    var newfiles = input.FileList.Select(r => new AbpFileChangeDto {
                        FileName = r.FileName, Id = r.Id
                    }).ToList();
                    var logs = GetChangeModel(logModel, files).GetColumnAllLogs(GetChangeModel(dbmodel, newfiles));
                    await _projectAuditManager.InsertAsync(logs, input.Id.ToString(), flowModel.TitleField.Table);

                    _workFlowTaskManager.CreateNoticeForTask(input.FlowId, input.Id.ToString(), "收文变更", dbmodel.Title);
                }
            }
            else
            {
                throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "该数据不存在。");
            }
        }