Beispiel #1
0
 /// <summary>
 /// 根据不同的审批意见获取不同的下一级节点
 /// </summary>
 /// <param name="NodeID">当前节点ID</param>
 /// <param name="Apo"></param>
 /// <returns></returns>
 public static string GetNextNodeIDByCurrentNodeID(string NodeID, EApprovalOpinion Apo)
 {
     try
     {
         string WFID = CWFManager.GetWFIDByNodeID(NodeID);
         if (Apo == EApprovalOpinion.意)
         {
             return(CDataHelper.GetData("select next_node_id from " + CTableName.FlowChartLine + " where node_id='" + NodeID + "'"));
         }
         else if (Apo == EApprovalOpinion.意)
         {
             return(CDataHelper.GetData("select [node_id] from " + CTableName.FlowChartNode + " where [flowchart_id]='" + WFID + "' and [nodetype]='" + CNodeType.EndType + "'"));
         }
         else if (Apo == EApprovalOpinion.驳回上级)
         {
             return(GetUpApprovalNodeID(NodeID));
         }
         else
         {
             return(GetStartNodeID(WFID));
         }
     }
     catch (Exception ex)
     {
         CLog.PutDownErrInfo("通过节点ID获取下一个节点ID操作异常。节点ID:" + NodeID + ",异常信息:" + ex.Message.ToString());
         throw ex;
     }
 }
        /// <summary>
        /// 记录新发起的工作流实例
        /// </summary>
        /// <param name="WFName">工作流名称</param>
        /// <param name="WFDataID">工作流实例对应的数据的ID</param>
        /// <param name="OpeManID">操作人</param>
        /// <param name="WFID">工作流ID</param>
        /// <param name="NewInstanceID">新工作流实例ID</param>
        public static string PutDownNewInstance(string WFName, string WFDataID, string OpeManID, string WFID, string NewInstanceID)
        {
            try
            {
                string WFVersion = CWFManager.GetLastVersion(WFName);
                if (WFVersion == null || WFVersion == "")
                {
                    CInstanceManager.SetInstanceError(NewInstanceID, "缺少工作流版本号");
                    WFGlobal.ErrInfo = CLog.PutDownErrInfo("工作流实例" + NewInstanceID + "缺少工作流版本号");
                    return(WFGlobal.ErrInfo);
                }

                if (CDataHelper.ExecuteNonQuery("insert into " + CTableName.FlowChartInstance + "(flowchart_id,flowchart_version,instance_id,cre_date,cre_man,instance_status) values('" + WFID + "','" + WFVersion + "','" + NewInstanceID + "','" + DateTime.Now.ToString() + "','" + OpeManID + "','" + EInstanceStatus.Active.ToString() + "')") < 0)
                {
                    WFGlobal.ErrInfo = CLog.PutDownErrInfo("记录工作流实例信息失败。");
                    return(WFGlobal.ErrInfo);
                }

                if (CDataHelper.ExecuteNonQuery("insert into " + CTableName.FlowChartPars + "(instance_id,keyvalue) values('" + NewInstanceID + "','" + WFDataID + "')") < 0)
                {
                    WFGlobal.ErrInfo = CLog.PutDownErrInfo("记录工作流数据信息失败。");
                    return(WFGlobal.ErrInfo);
                }
                return(WFGlobal.success);
            }
            catch (Exception ex)
            {
                WFGlobal.ErrInfo = CLog.PutDownErrInfo("记录工作流实例操作异常。工作流名称:" + WFName + ",数据ID:" + WFDataID + ",发起人ID:" + OpeManID + ",工作流ID:" + WFID + ",异常信息:" + ex.Message.ToString());
                return(WFGlobal.ErrInfo);
            }
        }
        /// <summary>
        /// 发起流程命令处理
        /// </summary>
        /// <param name="WFName">流程名称</param>
        /// <param name="WFDataID">数据表相对应数据ID</param>
        /// <param name="OpeManID">发起人ID</param>
        private string WFStartDeal(string WFName, string WFDataID, string OpeManID)
        {
            try
            {
                string WFID = CWFManager.GetLastVersionWFID(WFName);

                if (WFID == null || WFID == "")
                {
                    WFGlobal.ErrInfo = CLog.PutDownErrInfo("工作流" + WFName + "不存在。");
                    return(WFGlobal.ErrInfo);
                }

                string StartNodeID = CNodeManager.GetStartNodeID(WFID);
                if (StartNodeID == null || StartNodeID == "")
                {
                    WFGlobal.ErrInfo = CLog.PutDownErrInfo("工作流" + WFID + "没有起始节点。");
                    return(WFGlobal.ErrInfo);
                }

                string NewInstanceID = Guid.NewGuid().ToString();

                //记录工作流实例
                string PutDownInstanceResult = CInstanceManager.PutDownNewInstance(WFName, WFDataID, OpeManID, WFID, NewInstanceID);
                if (PutDownInstanceResult != WFGlobal.success)
                {
                    return(PutDownInstanceResult);
                }

                //将工作流实例的审批人设定为发起人
                string PutDownApproverResult = CApprovalManager.PutDownApprover(NewInstanceID, StartNodeID, OpeManID, 1, "");
                if (PutDownApproverResult != WFGlobal.success)
                {
                    return(PutDownApproverResult);
                }

                //流程流转
                return(WFTransmitDeal(NewInstanceID, StartNodeID, EApprovalOpinion.意, OpeManID, ""));
            }
            catch (Exception ex)
            {
                WFGlobal.ErrInfo = CLog.PutDownErrInfo("发起工作流操作异常。工作流名称:" + WFName + ",发起人ID:" + OpeManID + ",数据ID" + WFDataID + ",异常信息:" + ex.Message.ToString());
                return(WFGlobal.ErrInfo);
            }
        }