public void Start(string workId, ref bool IsEnd) { try { string userId = string.Empty; var LoginInfo = OperatorProvider.Provider.GetCurrent(); if (LoginInfo != null) { userId = LoginInfo.UserId; } using (var db = new RepositoryBase().BeginTrans()) { WorkEntity workEntity = db.FindEntity <WorkEntity>(m => m.Id == workId); if (workEntity != null && !string.IsNullOrEmpty(workEntity.Id)) { if (workEntity.FlowStatus != (int)WorkStatus.Save) { throw new Exception("当前流程已进行申请,无法重复提交申请!"); } AddStartApproProcess(workId, db); workEntity.Modify(workEntity.Id); workEntity.FlowStatus = (int)WorkStatus.Applying; FlowNodeEntity nextNode = GetPassNextNodeId(workId, workEntity.CurrentNodeId, workEntity.FlowVersionId); if (nextNode == null || string.IsNullOrEmpty(nextNode.Id)) { throw new Exception("当前审批下一流程节点不存在,请联系管理员!"); } bool isEndNode = nextNode.IsEndNode; if (!isEndNode) { bool isNeedSkip = false; string userIds = GetCurrentUserIds(nextNode, userId, out isNeedSkip); string nextNodeId = nextNode.Id; if (isNeedSkip && !nextNode.IsEndNode) { nextNodeId = SkipNode(workId, workEntity.CurrentNodeId, nextNode, workEntity.FlowVersionId, db, out userIds, out isEndNode); } workEntity.CurrentNodeId = nextNodeId; if (!string.IsNullOrEmpty(userIds)) { workEntity.CurrentUsers = userIds; } } if (isEndNode) { IsEnd = true; workEntity.FlowStatus = (int)WorkStatus.Success; AddEndApproProcess(workId, nextNode, db); } AddCcSuccess(workId, nextNode.Id, userId, db); db.Update(workEntity); db.Commit(); } } } catch (Exception ex) { throw ex; } }
public void UpdateForm(string workId, int status, string contents, List <WorkControlEntity> controls, List <WorkFileEntity> files, List <string> RemoveFileIds) { WorkEntity workEntity = new WorkEntity(); if (status == (int)WorkStatus.Save || status == (int)WorkStatus.Applying) { if (workId != null) { workEntity = GetForm(workId); if (workEntity != null && !string.IsNullOrEmpty(workEntity.Id)) { if (workEntity.FlowStatus != (int)WorkStatus.Save) { throw new Exception("该申请已申请,不能修改!"); } workEntity.Modify(workId); workEntity.FlowStatus = (int)WorkStatus.Save; workEntity.Contents = contents; service.UpdateForm(workEntity, controls, files, RemoveFileIds); if (status == (int)WorkStatus.Applying) { try { workFlowApp.Start(workEntity.Id); } catch (Exception ex) { workEntity.FlowStatus = (int)WorkStatus.Save; service.Update(workEntity); throw ex; } } } else { throw new Exception("操作失败!"); } } else { throw new Exception("操作失败!"); } } else { throw new Exception("操作失败,提交状态无效!"); } }
public void ApplyFail(string workId, string desc) { try { using (var db = new RepositoryBase().BeginTrans()) { WorkEntity workEntity = db.FindEntity <WorkEntity>(m => m.Id == workId); if (workEntity != null && !string.IsNullOrEmpty(workEntity.Id)) { workEntity.Modify(workEntity.Id); FlowLineEntity flowLineEntity = new FlowLineEntity(); FlowNodeEntity currentNode = db.FindEntity <FlowNodeEntity>(m => m.Id == workEntity.CurrentNodeId); FlowNodeEntity nextNode = GetNextNodeId(workId, ApprovalStatus.Pass, ref flowLineEntity); if (nextNode != null && !string.IsNullOrEmpty(nextNode.Id)) { workEntity.CurrentNodeId = nextNode.Id; } else { workEntity.CurrentNodeId = string.Empty; } string userIds = GetCurrentUserIds(nextNode); if (!string.IsNullOrEmpty(userIds)) { workEntity.CurrentUsers = userIds; } if (currentNode.RejectType == (int)RejectType.End) { workEntity.FlowStatus = (int)WorkStatus.Fail; AddEndApproProcess(workId, nextNode, db); } else { workEntity.FlowStatus = (int)WorkStatus.Applying; } AddApproProcess(workId, desc, ApprovalStatus.Fail, currentNode, db); db.Update(workEntity); db.Commit(); } } } catch (Exception ex) { throw ex; } }
private void ApplySuccess(string workId, string desc, ref bool IsEnd) { try { string applyUserId = string.Empty; var loguser = OperatorProvider.Provider.GetCurrent(); if (loguser != null) { applyUserId = loguser.UserId; } else { throw new Exception("当前用户信息异常!"); } using (var db = new RepositoryBase().BeginTrans()) { WorkEntity workEntity = db.FindEntity <WorkEntity>(m => m.Id == workId); if (workEntity != null && !string.IsNullOrEmpty(workEntity.Id)) { if (!workEntity.CurrentUsers.Contains(applyUserId)) { throw new Exception("当前用户无权限审核此流程!"); } if (workEntity.FlowStatus != (int)WorkStatus.Applying) { throw new Exception("当前审批状态不能进行审核!"); } workEntity.Modify(workEntity.Id); FlowNodeEntity currentNode = db.FindEntity <FlowNodeEntity>(m => m.Id == workEntity.CurrentNodeId); if (currentNode != null && !string.IsNullOrEmpty(currentNode.Id)) { if (currentNode.StepType == (int)StepType.One) { ApplySuccessOne(workId, desc, db, workEntity, currentNode, ref IsEnd); } else { string[] strUsers = workEntity.CurrentUsers.Split(','); if (strUsers != null && strUsers.Length == 1) { ApplySuccessOne(workId, desc, db, workEntity, currentNode, ref IsEnd); } else { string[] strUsersNew = strUsers?.Where(m => m != applyUserId)?.ToArray(); if (strUsersNew != null && strUsersNew.Length > 0) { workEntity.CurrentUsers = string.Join(",", strUsersNew.ToArray()); AddApproProcess(workId, desc, ApprovalStatus.Pass, currentNode, db); AddCcSuccess(workId, workEntity.CurrentNodeId, applyUserId, db); } } } } else { throw new Exception("获取当前流程节点异常!"); } db.Update(workEntity); db.Commit(); } else { throw new Exception("获取当前流程信息异常!"); } } } catch (Exception ex) { throw ex; } }
private void ApplyFail(string workId, string desc) { try { string applyUserId = string.Empty; var loguser = OperatorProvider.Provider.GetCurrent(); if (loguser != null) { applyUserId = loguser.UserId; } else { throw new Exception("当前用户信息异常!"); } using (var db = new RepositoryBase().BeginTrans()) { WorkEntity workEntity = db.FindEntity <WorkEntity>(m => m.Id == workId); if (workEntity != null && !string.IsNullOrEmpty(workEntity.Id)) { if (!workEntity.CurrentUsers.Contains(applyUserId)) { throw new Exception("当前用户无权限审核此流程!"); } if (workEntity.FlowStatus != (int)WorkStatus.Applying) { throw new Exception("当前审批状态不能进行审核!"); } workEntity.Modify(workEntity.Id); FlowNodeEntity currentNode = db.FindEntity <FlowNodeEntity>(m => m.Id == workEntity.CurrentNodeId); bool isFail = false; FlowNodeEntity lastNode = GetFailNextNodeId(workId, out isFail); if (isFail) { AddApproProcess(workId, desc, ApprovalStatus.Fail, currentNode, db); workEntity.FlowStatus = (int)WorkStatus.Fail; AddEndApproProcess(workId, lastNode, db); } else { if (lastNode != null && !string.IsNullOrEmpty(lastNode.Id)) { workEntity.CurrentNodeId = lastNode.Id; string lastUserId = GetApplyUserByNode(lastNode, workId); bool isNeedSkip = false; string userIds = GetCurrentUserIds(lastNode, lastUserId, out isNeedSkip); if (!string.IsNullOrEmpty(userIds)) { workEntity.CurrentUsers = userIds; } workEntity.FlowStatus = (int)WorkStatus.Applying; AddApproProcess(workId, desc, ApprovalStatus.Fail, currentNode, db); } else { throw new Exception("当前节点驳回配置异常,请联系管理员!"); } } AddCcFail(workId, lastNode.Id, applyUserId, db); db.Update(workEntity); db.Commit(); } else { throw new Exception("获取当前流程信息异常!"); } } } catch (Exception ex) { throw ex; } }