示例#1
0
        /// <summary>
        /// 节点转移,从当前节点进入下一节点
        /// </summary>
        /// <param name="WFID"></param>
        /// <param name="InstanceID"></param>
        /// <param name="NodeID"></param>
        /// <param name="NextNodeID"></param>
        public static string NodeTransfer(string InstanceID, string NodeID, string NextNodeID)
        {
            try
            {
                if (CNodeManager.IsNodeThroughEnable(InstanceID, NextNodeID))
                {
                    //记录流转历史
                    if (CDataHelper.ExecuteNonQuery("insert into " + CTableName.FlowChartHistory + "(instance_id,node_id,next_node_id) values('" + InstanceID + "','" + NodeID + "','" + NextNodeID + "')") < 0)
                    {
                        WFGlobal.ErrInfo = CLog.PutDownErrInfo("记录工作流实例流转节点失败,工作流实例ID:" + InstanceID + ",开始节点ID:" + NodeID + ",结束节点ID:" + NextNodeID);
                        return(WFGlobal.ErrInfo);
                    }

                    string NodeType = CNodeManager.GetNodeType(NextNodeID);
                    if (NodeType == CNodeType.SwitchType)
                    {
                        return(GoNextNodesFromSwitchNode(InstanceID, NextNodeID));
                    }
                    else if (NodeType == CNodeType.ProcessType)
                    {
                        RunProcessScript(InstanceID, NextNodeID);
                        return(CNodeManager.GoNextNodesFromOtherNode(InstanceID, NextNodeID));
                    }
                    else if (NodeType == CNodeType.ApproveType || NodeType == CNodeType.StartType)
                    {
                        return(CNodeManager.PutDownNodeApprover(InstanceID, NextNodeID));
                    }
                    else if (NodeType == CNodeType.EndType)
                    {
                        return(CInstanceManager.SetInstanceComplete(InstanceID));
                    }
                }
                return(WFGlobal.success);
            }
            catch (Exception ex)
            {
                WFGlobal.ErrInfo = CLog.PutDownErrInfo("节点流转异常,工作流实例ID:" + InstanceID + ",开始节点ID:" + NodeID + ",结束节点ID:" + NextNodeID);
                return(WFGlobal.ErrInfo);
            }
        }
示例#2
0
 /// <summary>
 /// 获取上一级审批节点
 /// </summary>
 /// <param name="NodeID">当前节点ID</param>
 /// <returns></returns>
 public static string GetUpApprovalNodeID(string NodeID)
 {
     try
     {
         string UpNodeID = null;
         while (true)
         {
             UpNodeID = GetUpNodeID(NodeID);
             string NodeType = CNodeManager.GetNodeType(UpNodeID);
             if (NodeType != CNodeType.SwitchType && NodeType != CNodeType.ProcessType)
             {
                 break;
             }
             NodeID = UpNodeID;
         }
         return(UpNodeID);
     }
     catch (Exception ex)
     {
         CLog.PutDownErrInfo("通过节点ID获取上一个审批节点ID操作异常。节点ID:" + NodeID + ",异常信息:" + ex.Message.ToString());
         throw ex;
     }
 }
示例#3
0
        /// <summary>
        /// 记录节点的审批人
        /// </summary>
        /// <param name="InstanceID"></param>
        /// <param name="NodeID"></param>
        public static string PutDownNodeApprover(string InstanceID, string NodeID)
        {
            try
            {
                string nodetype = CNodeManager.GetNodeType(NodeID);
                if (nodetype == null)
                {
                    WFGlobal.ErrInfo = CLog.PutDownErrInfo("获取节点" + NodeID + "的节点类型失败,工作流实例ID:" + InstanceID);
                    CInstanceManager.SetInstanceError(InstanceID, WFGlobal.ErrInfo);
                    return(WFGlobal.ErrInfo);
                }

                int ApprovalNum = CApprovalManager.GetLastApprovalNum(InstanceID, NodeID);
                //判断是否开始流程
                if (nodetype == CNodeType.StartType)
                {
                    string StartManID = CInstanceManager.GetInstanceStartManID(InstanceID);
                    if (StartManID == null)
                    {
                        WFGlobal.ErrInfo = CLog.PutDownErrInfo("获取流程实例的发起人失败,工作流实例ID:" + InstanceID);
                        CInstanceManager.SetInstanceError(InstanceID, WFGlobal.ErrInfo);
                        return(WFGlobal.ErrInfo);
                    }

                    string ApprovalNote = CApprovalManager.GetApprovalNote(InstanceID, NodeID);

                    string PutDownApproverResult = CApprovalManager.PutDownApprover(InstanceID, NodeID, StartManID, ApprovalNum + 1, ApprovalNote);
                    if (PutDownApproverResult != WFGlobal.success)
                    {
                        return(PutDownApproverResult);
                    }
                }
                //判断流程是否结束
                else if (nodetype != CNodeType.EndType)
                {
                    DataTable dtReceiver   = CApprovalManager.GetApprover(InstanceID, NodeID);
                    string    ApprovalNote = CApprovalManager.GetApprovalNote(InstanceID, NodeID);
                    if (dtReceiver != null)
                    {
                        if (dtReceiver.Rows.Count > 0)
                        {
                            for (int i = 0; i < dtReceiver.Rows.Count; i++)
                            {
                                string ReceiverID            = dtReceiver.Rows[i][WFGlobal.UserID].ToString();
                                string PutDownApproverResult = CApprovalManager.PutDownApprover(InstanceID, NodeID, ReceiverID, ApprovalNum + 1, ApprovalNote);
                                if (PutDownApproverResult != WFGlobal.success)
                                {
                                    return(PutDownApproverResult);
                                }
                            }
                        }
                    }
                }
                return(WFGlobal.success);
            }
            catch (Exception ex)
            {
                WFGlobal.ErrInfo = CLog.PutDownErrInfo("记录节点审批人操作异常。工作流实例ID:" + InstanceID + ",节点ID:" + NodeID + ",异常信息:" + ex.Message.ToString());
                return(WFGlobal.ErrInfo);
            }
        }