private void AuditWorkflow(AuditOperation op) { if (!string.IsNullOrEmpty(txtAuditDescription.Text)) { var audit = new FlowAuditRecord { Id = 0, FlowId = ArchiveFlow.FlowId, AuditUserId = AuthenticateStatus.CurrentUser.UserId, AuditTime = DateTime.Now, Operation = op, AuditDescription = txtAuditDescription.Text }; flowContext.AuditArchiveWorkflow(audit, obj => { if (Utility.Utility.CheckInvokeOperation(obj)) { if (obj.Value > 0) { MessageBox.Show("操作成功!"); } else { MessageBox.Show("审核操作失败!错误码:" + obj.Value); } } }, null); } else { CustomMessageBox.Show("请输入审核意见"); txtAuditDescription.Focus(); } }
//保存存档工作流 public ArchiveWorkflow SaveWorkflow(ArchiveWorkflow flow) { if (flow != null && !string.IsNullOrEmpty(flow.FlowTitle) && flow.Files != null && flow.Files.Count > 0) { flow.SubmitTime = DateTime.Now; FlowAuditRecord record = null; if (flow.Status == AuditStatus.Submitted) { record = new FlowAuditRecord { Id = 0, FlowId = flow.FlowId, AuditUserId = flow.SubmitUserId, AuditTime = DateTime.Now, AuditDescription = flow.SubmitDescription }; var wf = GetWorkflowInfo(flow.FlowType); if (wf != null && wf.AuditSteps != null && wf.AuditSteps.Count > 0) { flow.Status = AuditStatus.Auditing; flow.CurrentStep = wf.AuditSteps.OrderBy(o => o.AuditIndex).First().StepId; } } int n = flow.FlowId > 0 ? SqlHelper.Update(flow) : SqlHelper.Insert(flow); if (n > 0) { if (record != null) { record.FlowId = flow.FlowId; SqlHelper.Insert(record); } var docService = new DocumentDomainService(); var rootFolder = docService.GetFolder(flow.FolderId); foreach (var file in flow.Files) { file.FlowId = flow.FlowId; file.DocumentId = file.DocumentInfo.Identity; if (file.DocumentInfo.Status == DocumentStatus.Deleted) { int tmpFolderId = file.DocumentInfo.FolderId; file.DocumentInfo.FolderId = (rootFolder != null && rootFolder.Identity > 0) ? flow.FolderId : 0; docService.CheckAndCreateFolder(file.DocumentInfo); if (tmpFolderId != file.DocumentInfo.FolderId) { SqlHelper.Update(file.DocumentInfo); } } n = file.Id > 0 ? SqlHelper.Update(file) : SqlHelper.Insert(file); } docService.Dispose(); return(flow); } } return(null); }
//审计存档工作流 public int AuditArchiveWorkflow(FlowAuditRecord auditRecord) { if (auditRecord == null || auditRecord.FlowId < 1) { return(-2); } var awf = GetArchiveWorkflow(auditRecord.FlowId); if (awf == null || awf.FlowId != auditRecord.FlowId) { return(-3); } var twf = GetWorkflowInfo(awf.FlowType); WorkflowAuditStep curStep = null, nextStep = null; foreach (var step in twf.AuditSteps) { if (step.StepId == awf.CurrentStep) { curStep = step; continue; } if (curStep != null) { nextStep = step; break; } } if (curStep == null) { return(-4); } SqlHelper.Insert(auditRecord); if (curStep.AuditType == AuditType.JointCheckup) { var records = GetFlowAuditRecords(awf.FlowId); foreach (var user in GetStepJointCheckupUsers(curStep.StepId)) { JointCheckupUser user1 = user; if (!records.Exists(o => user1.UserId == o.AuditUserId)) { nextStep = curStep; break; } } } switch (auditRecord.Operation) { case AuditOperation.Audit: case AuditOperation.Final: case AuditOperation.JointCheck: if (nextStep != null && nextStep != curStep) { awf.CurrentStep = nextStep.StepId; awf.Status = AuditStatus.Auditing; } else if (nextStep == null) { awf.Status = AuditStatus.Audited; foreach (var file in awf.Files) { if (file.DocumentInfo != null) { file.DocumentInfo.Status = DocumentStatus.FinalVersion; SqlHelper.Update(file.DocumentInfo); } } } break; case AuditOperation.Return: awf.Status = AuditStatus.Returned; foreach (var file in awf.Files) { if (file.DocumentInfo != null) { file.DocumentInfo.Status = DocumentStatus.Hide; SqlHelper.Update(file.DocumentInfo); } } break; case AuditOperation.Reject: awf.CurrentStep = twf.AuditSteps.OrderBy(o => o.AuditIndex).First().StepId; awf.Status = AuditStatus.Rejected; break; } return(SqlHelper.Update(awf)); }