/// <summary> /// 驳回 /// </summary> /// <param name="vallist"></param> /// <param name="todoID"></param> /// <param name="operationUserCode"></param> /// <param name="operationType"></param> /// <param name="common"></param> /// <param name="flowcontent"></param> /// <param name="node"></param> /// <param name="toNodeKey"></param> private void Reject(Dictionary <string, string> vallist, int todoID, string operationUserCode, Operation operationType, string common, FlowContent flowcontent, FlowNode node, string toNodeKey) { ToDoHandle.DealTodo((int)operationType, operationUserCode, todoID); FlowVar var = new FlowVar(flowcontent.TmpKey, flowcontent.CurrentInstanceID); var.UpdateVal(vallist, this.CurrenUserCode); List <WF_ToDo> undolist = todobll.getList(flowcontent.CurrentInstanceID, node.NodeKey, (int)TodoState.UnDo); if (undolist != null && undolist.Count > 0) { foreach (WF_ToDo item in undolist) { ToDoHandle.DeleteTodo((int)operationType, operationUserCode, item.ID); } } WF_TemplateNode tmpnode = nodebll.getByNodeKey(flowcontent.TmpKey, node.NodeKey); if (tmpnode.IsGoBack == 0) { throw new Exception("改节点禁止退回"); } if (tmpnode.GoBackType == "every") { if (string.IsNullOrWhiteSpace(toNodeKey)) { throw new Exception("请选择需要退回到哪一个节点"); } } else { toNodeKey = tmpnode.GoBackType; } FlowNode toNode = NodeFactory.getFlowNode(flowcontent.TmpKey, toNodeKey, this.endFlow); NodeReturn ret = toNode.Run(flowcontent); //获取当前待办人的编号 List <string> newtodis = new List <string>(); List <string> newnodekey = new List <string>(); if (!ret.isOver) { List <string> userCodeList = ret.ToDoUserList; //循环遍历插入待办 if (userCodeList != null && userCodeList.Count > 0) { foreach (string user in userCodeList) { int todoid = ToDoHandle.InsertTodo(user.Trim(), flowcontent.CurrentInstanceID, (int)TodoIsShow.Show, -1, flowcontent.TaskName, (int)TodoType.Normal, toNode, toNode.NodeKey, CurrenUserCode); newtodis.Add(todoid.ToString()); } } flowcontent.CurrentTodoID = string.Join(", ", newtodis); flowcontent.CurrentNodeKey = toNodeKey; } operationbll.Insert(flowcontent.CurrentInstanceID, todoID, CurrenUserCode, (int)operationType, common); }
/// <summary> /// 加签 /// </summary> /// <param name="vallist"></param> /// <param name="befortodoID"></param> /// <param name="operationUserCode"></param> /// <param name="operationType"></param> /// <param name="common"></param> /// <param name="flowcontent"></param> /// <param name="node"></param> /// <param name="toNodeKey"></param> private void Add(Dictionary <string, string> vallist, int befortodoID, string operationUserCode, Operation operationType, string common, FlowContent flowcontent, FlowNode node, string todoUserCode) { ToDoHandle.DealTodo((int)operationType, operationUserCode, befortodoID); FlowVar var = new FlowVar(flowcontent.TmpKey, flowcontent.CurrentInstanceID); var.UpdateVal(vallist, this.CurrenUserCode); //获取当前待办人的编号 List <string> newtodis = new List <string>(); List <string> newnodekey = new List <string>(); int todoid = ToDoHandle.InsertTodo(todoUserCode.Trim(), flowcontent.CurrentInstanceID, (int)TodoIsShow.Show, befortodoID, flowcontent.TaskName, (int)TodoType.Add, node, node.NodeKey, CurrenUserCode); newtodis.Add(todoid.ToString()); flowcontent.CurrentTodoID = string.Join(", ", newtodis); flowcontent.CurrentNodeKey = node.NodeKey; operationbll.Insert(flowcontent.CurrentInstanceID, befortodoID, CurrenUserCode, (int)operationType, common); //插入转签历史记录 WF_Sign sign = new WF_Sign(); sign.AfterToDoID = todoid; sign.beforeToDoID = befortodoID; sign.IsDelete = (int)IsDelete.UnDelete; sign.State = (int)State.Enable; sign.OperationTime = DateTime.Now; sign.OperationUserCode = operationUserCode; Employee emp = empbll.getbyUserCode(operationUserCode); if (emp != null) { sign.OperationUserName = emp.UserName; } signbll.save(sign); }
/// <summary> /// 跳转 /// </summary> /// <param name="vallist"></param> /// <param name="todoID"></param> /// <param name="operationUserCode"></param> /// <param name="operationType"></param> /// <param name="common"></param> /// <param name="flowcontent"></param> /// <param name="node"></param> private void GoTo(Dictionary <string, string> vallist, int todoID, string operationUserCode, Operation operationType, string common, FlowContent flowcontent, FlowNode node, string toNodeKey) { ToDoHandle.DealTodo((int)operationType, operationUserCode, todoID); FlowVar var = new FlowVar(flowcontent.TmpKey, flowcontent.CurrentInstanceID); var.UpdateVal(vallist, this.CurrenUserCode); List <WF_ToDo> undolist = todobll.getList(flowcontent.CurrentInstanceID, node.NodeKey, (int)TodoState.UnDo); if (undolist != null && undolist.Count > 0) { foreach (WF_ToDo item in undolist) { ToDoHandle.DeleteTodo((int)operationType, operationUserCode, item.ID); } } FlowNode toNode = NodeFactory.getFlowNode(flowcontent.TmpKey, toNodeKey, this.endFlow); NodeReturn ret = toNode.Run(flowcontent); //获取当前待办人的编号 List <string> newtodis = new List <string>(); List <string> newnodekey = new List <string>(); if (!ret.isOver) { List <string> userCodeList = ret.ToDoUserList; //循环遍历插入待办 if (userCodeList != null && userCodeList.Count > 0) { foreach (string user in userCodeList) { int todoid = ToDoHandle.InsertTodo(user.Trim(), flowcontent.CurrentInstanceID, (int)TodoIsShow.Show, -1, flowcontent.TaskName, (int)TodoType.Normal, toNode, toNode.NodeKey, CurrenUserCode); newtodis.Add(todoid.ToString()); } } flowcontent.CurrentTodoID = string.Join(", ", newtodis); flowcontent.CurrentNodeKey = toNodeKey; } operationbll.Insert(flowcontent.CurrentInstanceID, todoID, CurrenUserCode, (int)operationType, common); }
/// <summary> /// 同意转签类型 /// </summary> /// <param name="vallist"></param> /// <param name="todoID"></param> /// <param name="operationUserCode"></param> /// <param name="operationType"></param> /// <param name="common"></param> /// <param name="flowcontent"></param> /// <param name="node"></param> private void ApplyTransfer(Dictionary <string, string> vallist, int todoID, string operationUserCode, Operation operationType, string common, FlowContent flowcontent, FlowNode node) { //NodeReturn ret = node.Run(flowcontent); WF_ToDo preTodo = todobll.getPreTransferTodo(todoID); if (preTodo != null) { //int newtodiid = ToDoHandle.Reopen(preTodo.ResponseUserCode, preTodo.InstanceID, preTodo.IsShow, preTodo.PrevID, preTodo.ToDoName, preTodo.TodoType, node, preTodo.Nodekey, operationUserCode); //flowcontent.CurrentTodoID = string.Join(", ", newtodiid); if (preTodo.TodoType == (int)TodoType.Normal) { FlowNode befornode = NodeFactory.getFlowNode(flowcontent.TmpKey, preTodo.Nodekey, this.endFlow); NodeReturn ret = befornode.Run(flowcontent); //获取当前待办人的编号 List <string> newtodis = new List <string>(); List <string> newnodekey = new List <string>(); if (ret.isOver) { List <FlowNode> nextNode = befornode.GetNextNode(flowcontent); if (nextNode != null && nextNode.Count > 0) { foreach (FlowNode nxitem in nextNode) { NodeReturn noderet = nxitem.Run(flowcontent); if (!noderet.isOver) { newnodekey.Add(nxitem.NodeKey); List <string> userCodeList = noderet.ToDoUserList; //循环遍历插入待办 if (userCodeList != null && userCodeList.Count > 0) { foreach (string user in userCodeList) { int todoid = ToDoHandle.InsertTodo(user.Trim(), flowcontent.CurrentInstanceID, (int)TodoIsShow.Show, -1, flowcontent.TaskName, (int)TodoType.Normal, nxitem, nxitem.NodeKey, CurrenUserCode); newtodis.Add(todoid.ToString()); } } } } } flowcontent.CurrentNodeKey = string.Join(", ", newnodekey); flowcontent.CurrentTodoID = string.Join(", ", newtodis); } else { List <string> userCodeList = ret.ToDoUserList; //循环遍历插入待办 if (userCodeList != null && userCodeList.Count > 0) { foreach (string user in userCodeList) { int todoid = ToDoHandle.InsertTodo(user.Trim(), flowcontent.CurrentInstanceID, (int)TodoIsShow.Show, -1, flowcontent.TaskName, (int)TodoType.Normal, befornode, befornode.NodeKey, CurrenUserCode); newtodis.Add(todoid.ToString()); } } newnodekey.Add(befornode.NodeKey); flowcontent.CurrentNodeKey = string.Join(", ", newnodekey); flowcontent.CurrentTodoID = string.Join(", ", newtodis); } } if (preTodo.TodoType == (int)TodoType.Add) { WF_ToDo beforTodo = todobll.getPreAddTodo(todoID); while (beforTodo.TodoType == (int)TodoType.Add) { beforTodo = todobll.getPreAddTodo(beforTodo.ID); } FlowNode befornode = NodeFactory.getFlowNode(flowcontent.TmpKey, beforTodo.Nodekey, this.endFlow); int newtodiid = ToDoHandle.Reopen(beforTodo.ResponseUserCode, beforTodo.InstanceID, beforTodo.IsShow, beforTodo.PrevID, beforTodo.ToDoName, beforTodo.TodoType, befornode, beforTodo.Nodekey, operationUserCode); flowcontent.CurrentTodoID = string.Join(", ", newtodiid); } if (preTodo.TodoType == (int)TodoType.Redirect) { ApplyTransfer(vallist, preTodo.ID, operationUserCode, operationType, common, flowcontent, node); } } }
/// <summary> /// 同意 /// </summary> /// <param name="vallist"></param> /// <param name="todoID"></param> /// <param name="operationUserCode"></param> /// <param name="operationType"></param> /// <param name="common"></param> /// <param name="flowcontent"></param> /// <param name="node"></param> private void Apply(Dictionary <string, string> vallist, int todoID, string operationUserCode, Operation operationType, string common, FlowContent flowcontent, FlowNode node) { ToDoHandle.DealTodo((int)operationType, operationUserCode, todoID); FlowVar var = new FlowVar(flowcontent.TmpKey, flowcontent.CurrentInstanceID); var.UpdateVal(vallist, this.CurrenUserCode); WF_ToDo todo = todobll.getByID(todoID); // 加签类型 if (todo.TodoType == (int)TodoType.Add) { WF_ToDo nextodo = todobll.getPreAddTodo(todoID); int newtodiid = ToDoHandle.Reopen(nextodo.ResponseUserCode, nextodo.InstanceID, nextodo.IsShow, nextodo.PrevID, nextodo.ToDoName, nextodo.TodoType, node, nextodo.Nodekey, operationUserCode); flowcontent.CurrentTodoID = string.Join(", ", newtodiid); } //todo 转签处理,如果找到最近一个加签类型,然后生成加签待办,如果不是从加签转过来的,就直接到下一个节点 if (todo.TodoType == (int)TodoType.Redirect) { ApplyTransfer(vallist, todoID, operationUserCode, operationType, common, flowcontent, node); } // 一般同意 转签类型 if (todo.TodoType == (int)TodoType.Normal) { NodeReturn ret = node.Run(flowcontent); //获取当前待办人的编号 List <string> newtodis = new List <string>(); List <string> newnodekey = new List <string>(); if (ret.isOver) { List <FlowNode> nextNode = node.GetNextNode(flowcontent); if (nextNode != null && nextNode.Count > 0) { foreach (FlowNode nxitem in nextNode) { NodeReturn noderet = nxitem.Run(flowcontent); if (!noderet.isOver) { newnodekey.Add(nxitem.NodeKey); List <string> userCodeList = noderet.ToDoUserList; //循环遍历插入待办 if (userCodeList != null && userCodeList.Count > 0) { foreach (string user in userCodeList) { int todoid = ToDoHandle.InsertTodo(user.Trim(), flowcontent.CurrentInstanceID, (int)TodoIsShow.Show, -1, flowcontent.TaskName, (int)TodoType.Normal, nxitem, nxitem.NodeKey, CurrenUserCode); newtodis.Add(todoid.ToString()); } } } } } flowcontent.CurrentNodeKey = string.Join(", ", newnodekey); flowcontent.CurrentTodoID = string.Join(", ", newtodis); } else { List <string> userCodeList = ret.ToDoUserList; //循环遍历插入待办 if (userCodeList != null && userCodeList.Count > 0) { foreach (string user in userCodeList) { int todoid = ToDoHandle.InsertTodo(user.Trim(), flowcontent.CurrentInstanceID, (int)TodoIsShow.Show, -1, flowcontent.TaskName, (int)TodoType.Normal, node, node.NodeKey, CurrenUserCode); newtodis.Add(todoid.ToString()); } } newnodekey.Add(node.NodeKey); flowcontent.CurrentNodeKey = string.Join(", ", newnodekey); flowcontent.CurrentTodoID = string.Join(", ", newtodis); } } operationbll.Insert(flowcontent.CurrentInstanceID, todoID, CurrenUserCode, (int)operationType, common); }
/// <summary> /// 待办处理操作 /// </summary> /// <param name="vallist">流程实例变量</param> /// <param name="todoID">待办id</param> /// <param name="operationUserCode">操作人工号 </param> /// <param name="operationType">操作类型</param> public void Operation(Dictionary <string, string> vallist, int todoID, string operationUserCode, Operation operationType, string common = null, string toNodeKey = null, string todoUserCode = null) { //禁止流程启动 if (operationType == Common.Operation.Start) { throw new Exception("不能执行流程启动操作"); } WF_ToDo todo = todobll.getByID(todoID); WF_Instance instance = instancebll.getByID(todo.InstanceID); if (instance.State != (int)Common.InstanceState.Enable) { throw new Exception("当前流程实例状态不是启用状态"); } if (todo.ResponseUserCode != operationUserCode) { List <WF_Agent> agentlist = agentBll.getAgentByOrg(todo.ResponseUserCode); if (agentlist == null || agentlist.Count == 0 || agentlist.Where(p => p.AgentUserCode == operationUserCode).Count() == 0) { throw new Exception("当前操作人不是待办责任人,也不是待办责任人的代理人"); } } if (todo.State != (int)Common.TodoState.UnDo) { throw new Exception("当前待办已经被处理了"); } FlowContent flowcontent = new FlowContent(); flowcontent.CurrenUserCode = operationUserCode; flowcontent.TmpKey = this.Tmpkey; flowcontent.CurrentInstanceID = todo.InstanceID; flowcontent.OperationType = (int)Common.Operation.Start; flowcontent.TaskName = todo.ToDoName; flowcontent.InstanceState = instance.State; flowcontent.CurrentNodeKey = todo.Nodekey; flowcontent.OperationType = (int)operationType; flowcontent.CurrentTodoID = todo.ID.ToString(); flowcontent.FormID = instance.FormID; if (this.beforOperation != null) { this.beforOperation(flowcontent); } FlowNode node = NodeFactory.getFlowNode(instance.TmpKey, todo.Nodekey, this.endFlow); // 处理 同意 if (operationType == Common.Operation.Agree) { this.Apply(vallist, todoID, operationUserCode, operationType, common, flowcontent, node); } //todo 处理 撤回 //if (operationType == Common.Operation.CallBack) //{ //this.Apply(vallist, todoID, operationUserCode, operationType, common, flowcontent, node); //} // 处理 流程跳转 if (operationType == Common.Operation.GoTo) { this.GoTo(vallist, todoID, operationUserCode, operationType, common, flowcontent, node, toNodeKey); } //todo 处理 传阅 //if (operationType == Common.Operation.Read) //{ // this.Apply(vallist, todoID, operationUserCode, operationType, common, flowcontent, node); //} // 处理 驳回 if (operationType == Common.Operation.Reject) { this.Reject(vallist, todoID, operationUserCode, operationType, common, flowcontent, node, toNodeKey); } // 处理 转签 if (operationType == Common.Operation.Redirect) { this.Redirect(vallist, todoID, operationUserCode, operationType, common, flowcontent, node, todoUserCode); } // 处理 加签 if (operationType == Common.Operation.Add) { this.Add(vallist, todoID, operationUserCode, operationType, common, flowcontent, node, todoUserCode); } if (this.afterOperation != null) { this.afterOperation(flowcontent); } }
public static int Reopen(string todoUserCode, int instanceID, int isShow, int prevID, string taskName, int todotype, FlowNode node, string nodeKey, string currenUserCode) { WF_ToDo todo = new WF_ToDo(); WF_Instance instance = instanceBll.getByID(instanceID); WF_TemplateNode tmpNode = nodebll.getByNodeKey(instance.TmpKey, nodeKey); //todo 插入批号 todo.Batch = -1; todo.CreateTime = DateTime.Now; todo.CreateUserCode = currenUserCode; todo.InstanceID = instanceID; todo.IsDelete = 0; todo.IsShow = isShow; todo.Nodekey = nodeKey; todo.PrevID = prevID; todo.ResponseUserCode = todoUserCode; todo.State = (int)TodoState.UnDo; todo.ToDoName = taskName; todo.TodoType = todotype; todo.UpdateTime = DateTime.Now; todo.UpdateUserCode = currenUserCode; todo.URL = tmpNode.URL; int todoid = todobll.save(todo); return(todoid); }