예제 #1
0
파일: Flow.cs 프로젝트: wangyipeng87/wf
        /// <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);
        }
예제 #2
0
파일: Flow.cs 프로젝트: wangyipeng87/wf
        /// <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);
        }
예제 #3
0
파일: Flow.cs 프로젝트: wangyipeng87/wf
        /// <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);
        }
예제 #4
0
파일: Flow.cs 프로젝트: wangyipeng87/wf
        /// <summary>
        /// 流程启动
        /// </summary>
        /// <param name="vallist">流程实例变量</param>
        /// <param name="applyUserCode">申请人员工编号</param>
        /// <param name="writerUserCode">填表人员工编号</param>
        /// <param name="formID">单据编号</param>
        public void StartFlow(Dictionary <string, string> vallist, string applyUserCode, string writerUserCode, string formID)
        {
            //插入流程实例
            int         instanceID = this.InsertInstance((int)WF.Common.InstanceState.Enable, formID, this.CurrenUserCode, writerUserCode, applyUserCode);
            WF_Template tmp        = tmpbll.getByKey(this.Tmpkey);

            this.InstanceID     = instanceID;
            this.ApplyUserCode  = applyUserCode;
            this.WriterUserCode = writerUserCode;
            this.FormID         = formID;
            this.InstanceState  = (int)WF.Common.InstanceState.Enable;

            //触发启动前事件
            FlowContent flowcontent = new FlowContent();

            flowcontent.CurrenUserCode    = this.CurrenUserCode;
            flowcontent.TmpKey            = this.Tmpkey;
            flowcontent.CurrentInstanceID = instanceID;
            flowcontent.OperationType     = (int)Common.Operation.Start;
            flowcontent.TaskName          = tmp.TmpName;
            flowcontent.InstanceState     = (int)WF.Common.InstanceState.Enable;
            flowcontent.CurrentNodeKey    = "";
            flowcontent.FormID            = formID;
            if (this.beforStartFlow != null)
            {
                this.beforStartFlow(flowcontent);
            }

            //更新流程变量
            FlowVar var = new FlowVar(this.Tmpkey, instanceID);

            //先将流程模板变量copy到流程实例
            var.copyVarByTmpKey(this.CurrenUserCode);
            //更新流程实例的变量
            var.UpdateVal(vallist, this.CurrenUserCode);
            //获取第一个节点
            List <FlowNode> firstNode = this.GetFirstNode();
            //获取当前待办人的编号
            List <string> newtodis   = new List <string>();
            List <string> newnodekey = new List <string>();

            if (firstNode != null && firstNode.Count > 0)
            {
                foreach (FlowNode node in firstNode)
                {
                    NodeReturn noderet = node.Run(flowcontent);
                    if (!noderet.isOver)
                    {
                        newnodekey.Add(node.NodeKey);
                        List <string> userCodeList = noderet.ToDoUserList;
                        //循环遍历插入待办
                        if (userCodeList != null && userCodeList.Count > 0)
                        {
                            foreach (string item in userCodeList)
                            {
                                int todoid = ToDoHandle.InsertTodo(item.Trim(), instanceID, (int)TodoIsShow.Show, -1, flowcontent.TaskName, (int)TodoType.Normal, node, node.NodeKey, CurrenUserCode);
                                newtodis.Add(todoid.ToString());
                            }
                        }
                    }
                }
            }
            operationbll.Insert(instanceID, -1, CurrenUserCode, (int)Common.Operation.Start, "启动流程");
            flowcontent.CurrentNodeKey = string.Join(", ", newnodekey);;
            flowcontent.CurrentTodoID  = string.Join(", ", newtodis);
            //触发启动后事件
            if (this.afterStartFlow != null)
            {
                this.afterStartFlow(flowcontent);
            }
        }
예제 #5
0
파일: Flow.cs 프로젝트: wangyipeng87/wf
        /// <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);
        }