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); }
public int Insert(int instanceID, int todoID, string operationUserCode, int operationType, string comments) { WF_OperationHistory history = new WF_OperationHistory(); Employee emp = empbll.getbyUserCode(operationUserCode); history.InstanceID = instanceID; history.Comments = comments; history.IsDelete = (int)IsDelete.UnDelete; history.OperationTime = DateTime.Now; history.OperationType = operationType; WF_ToDo todo = todobll.getByID(todoID); history.State = (int)State.Enable; if (todo != null) { history.TodoID = todoID; if (todo.ResponseUserCode == operationUserCode) { history.OperationUserCode = operationUserCode; history.OperationUserName = emp.UserName; } else { history.AgentUserCode = operationUserCode; history.AgentUserName = emp.UserName; } } else { history.OperationUserCode = operationUserCode; history.OperationUserName = emp.UserName; history.TodoID = -1; } return(operbll.save(history)); }
public bool update(WF_ToDo entity) { using (IDbConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["wfdb"].ToString())) { conn.Open(); return(conn.Update <WF_ToDo>(entity)); } }
public int save(WF_ToDo entity) { using (IDbConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["wfdb"].ToString())) { conn.Open(); object id = conn.Insert <WF_ToDo>(entity); return((int)id); } }
public bool del(int id) { using (IDbConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["wfdb"].ToString())) { conn.Open(); WF_ToDo todo = conn.Get <WF_ToDo>(id); todo.IsDelete = 1; return(conn.Update <WF_ToDo>(todo)); } }
/// <summary> /// 处理待办 /// </summary> /// <param name="operationType"></param> /// <param name="operationUserCode"></param> /// <param name="todoID"></param> public static void DealTodo(int operationType, string operationUserCode, int todoID) { WF_ToDo todo = todobll.getByID(todoID); todo.DealTime = DateTime.Now; todo.DealUserCode = operationUserCode; todo.OperationType = operationType; todo.UpdateTime = DateTime.Now; todo.UpdateUserCode = operationUserCode; todo.State = (int)TodoState.Done; todobll.update(todo); }
public static Flow getFlowByTodo(int todoid, string currenUserCode) { WF_ToDo todo = todobll.getByID(todoid); WF_Instance instance = instancebll.getByID(todo.InstanceID); WF_Template tmp = tmpbll.getByKey(instance.TmpKey); Flow flo = GetFlowByTmpKey(tmp.key); flo.Tmpkey = instance.TmpKey; flo.FormName = tmp.TmpName; flo.CurrenUserCode = currenUserCode; flo.ApplyUserCode = instance.ApplyUserCode; flo.FormID = instance.FormID; flo.InstanceID = instance.ID; flo.InstanceState = instance.State; flo.TodoID = todoid; flo.WriterUserCode = instance.WriterUserCode; flo.Init(); return(flo); }
public bool update(WF_ToDo entity) { return(dao.update(entity)); }
public int save(WF_ToDo entity) { return(dao.save(entity)); }
/// <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); } }