Ejemplo n.º 1
0
        /// <summary>
        /// 退回流程至主节点
        /// </summary>
        /// <param name="flowNodeId"></param>
        /// <param name="flowCaseId"></param>
        /// <param name="flowId"></param>
        /// <returns></returns>
        public int ReturnFlowNodeCase(int returnFlowNodeCaseId, int flowCaseId)
        {
            int mainFlowNodeCaseId = 0;

            BF_FLOW_CASE.Entity flowCase     = new BF_FLOW_CASE.Entity();
            BF_FLOW_NODE.Entity mainFlowNode = new BF_FLOW_NODE.Entity();
            try
            {
                flowCase     = BF_FLOW_CASE.Instance.GetEntityByKey <BF_FLOW_CASE.Entity>(flowCaseId);
                mainFlowNode = BF_FLOW_NODE.Instance.GetEntity <BF_FLOW_NODE.Entity>("FLOW_ID=? AND IS_MAIN=1");
                //获得上次主节点流程实例信息
                var mainFlowNodeCaseList = BF_FLOW_NODE_CASE.Instance.GetList <BF_FLOW_NODE_CASE.Entity>("FLOW_NODE_ID=? AND FLOW_CASE_ID=? AND FLOW_ID=?", mainFlowNode.ID, flowCaseId, flowCase.FLOW_ID).OrderByDescending(p => p.ID).ToList();
                if (mainFlowNodeCaseList != null && mainFlowNodeCaseList.Count() > 0)
                {
                    var lastMainFlowNodeCase = mainFlowNodeCaseList[0];
                    mainFlowNodeCaseId = BF_FLOW_NODE_CASE.Instance.GetNextValueFromSeqDef();
                    BF_FLOW_NODE_CASE.Entity mainFlowNodeCase = new BF_FLOW_NODE_CASE.Entity()
                    {
                        ID                     = mainFlowNodeCaseId,
                        DIV_X                  = lastMainFlowNodeCase.DIV_X,
                        DIV_Y                  = lastMainFlowNodeCase.DIV_Y,
                        AUDIT_STATUS           = Convert.ToInt16(CS.Common.Enums.AuditStatus.未审批.GetHashCode()),//未审批
                        CREATE_TIME            = DateTime.Now,
                        CREATE_UID             = SystemSession.UserID,
                        USER_IDS               = flowCase.CREATE_UID.ToString(),
                        FLOW_CASE_ID           = flowCaseId,
                        FLOW_ID                = flowCase.FLOW_ID,
                        FROM_FLOW_NODE_CASE_ID = 0,
                        IS_FINISH              = 0,
                        IS_MAIN                = 1,
                        NAME                   = lastMainFlowNodeCase.NAME,
                        REMARK                 = "被退回至主节点",
                        FINISH_TIME            = DateTime.Now,
                        FLOW_NODE_ID           = mainFlowNode.ID,
                        DEAL_WAY               = mainFlowNode.DEAL_WAY
                    };
                    BF_FLOW_NODE_CASE.Instance.Add(mainFlowNodeCase);
                }
            }
            catch (Exception ex)
            {
                string errMsg = string.Format(@"为流程[{0}]实例[{1}]添加节点[{2}]的实例[3]失败:{4}",
                                              flowCase.FLOW_ID, flowCaseId, mainFlowNode.ID, mainFlowNodeCaseId, ex.Message);
                BLog.Write(BLog.LogLevel.ERROR, errMsg);
                throw ex;
            }
            return(mainFlowNodeCaseId);
        }
Ejemplo n.º 2
0
        public int AddMainFlowNodeCase(BF_FLOW_NODE.Entity mainNode, int flowCaseId, int flowId)
        {
            int mainFlowNodeCaseId = BF_FLOW_NODE_CASE.Instance.GetNextValueFromSeqDef();

            try
            {
                BF_FLOW_NODE_CASE.Entity mainFlowNodeCase = new BF_FLOW_NODE_CASE.Entity()
                {
                    ID                     = mainFlowNodeCaseId,
                    DIV_X                  = mainNode.DIV_X,
                    DIV_Y                  = mainNode.DIV_Y,
                    AUDIT_STATUS           = Convert.ToInt16(CS.Common.Enums.AuditStatus.通过.GetHashCode()),//默认通过1
                    CREATE_TIME            = DateTime.Now,
                    CREATE_UID             = SystemSession.UserID,
                    USER_IDS               = mainNode.USER_IDS,
                    DPT_IDS                = mainNode.DPT_IDS,
                    ROLE_IDS               = mainNode.ROLE_IDS,
                    FLOW_CASE_ID           = flowCaseId,
                    FLOW_ID                = flowId,
                    FROM_FLOW_NODE_CASE_ID = 0,
                    IS_FINISH              = 1,
                    IS_MAIN                = 1,
                    NAME                   = mainNode.NAME,
                    REMARK                 = "主节点默认通过状态",
                    FINISH_TIME            = DateTime.Now,
                    FLOW_NODE_ID           = mainNode.ID,
                    DEAL_WAY               = mainNode.DEAL_WAY
                };
                BF_FLOW_NODE_CASE.Instance.Add(mainFlowNodeCase);
            }
            catch (Exception ex)
            {
                string errMsg = string.Format(@"为流程[{0}]实例[{1}]添加节点[{2}]的实例[3]失败:{4}",
                                              flowId, flowCaseId, mainNode.ID, mainFlowNodeCaseId, ex.Message);
                BLog.Write(BLog.LogLevel.ERROR, errMsg);
                throw ex;
            }
            return(mainFlowNodeCaseId);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 为当前节点添加下级节点的实例s
        /// 追加流程是否结束的处理
        /// </summary>
        /// <param name="flow"></param>
        /// <param name="currFlowNode"></param>
        /// <param name="flowCaseId"></param>
        /// <returns></returns>
        public bool CreateNextNodesCase(BF_FLOW.Entity flow, BF_FLOW_NODE.Entity currFlowNode, int flowCaseId)
        {
            bool resBool = true;

            try
            {
                //获得流程的所有节点信息
                var allNodeList     = BF_FLOW_NODE.Instance.GetList <BF_FLOW_NODE.Entity>("FLOW_ID=?", flow.ID);
                var allNodeJoinList = BF_FLOW_NODE_JOIN.Instance.GetList <BF_FLOW_NODE_JOIN.Entity>("FLOW_ID=?", flow.ID);

                //已审批通过的节点实例集合
                var allNodeCaseList = BF_FLOW_NODE_CASE.Instance.GetList <BF_FLOW_NODE_CASE.Entity>("FLOW_ID=? AND FLOW_CASE_ID=? AND AUDIT_STATUS=?", flow.ID, flowCaseId, CS.Common.Enums.AuditStatus.通过.GetHashCode());

                //先获得当前节点下个走向节点集合
                var nodeJoinList = allNodeJoinList.Where(p => p.FROM_NODE_ID == currFlowNode.ID).ToList();
                //var nodeJoinList = BF_FLOW_NODE_JOIN.Instance.GetList<BF_FLOW_NODE_JOIN.Entity>("FLOW_ID=? AND FROM_NODE_ID=?", flow.ID, mainNode.ID);
                if (nodeJoinList != null && nodeJoinList.Count > 0)
                {
                    //分别为下级节点添加待办,分别为其创建待处理节点(暂时只考虑具体到人的情况)
                    foreach (var toNode in nodeJoinList)
                    {
                        var curFromNodeIdList = allNodeJoinList.Where(p => p.TO_NODE_ID == toNode.ID).Select(p => p.FROM_NODE_ID).ToList();
                        var ncCount           = allNodeCaseList.Count(p => curFromNodeIdList.Contains(p.FLOW_NODE_ID));
                        if (curFromNodeIdList.Count == ncCount)//from节点数=from节点实例数,添加下级待办
                        {
                            var curToNode     = allNodeList.FirstOrDefault(p => p.ID == toNode.TO_NODE_ID);
                            int curToNodeCase = BF_FLOW_NODE_CASE.Instance.AddFlowNodeCase(curToNode, flowCaseId, flow.ID, toNode.FROM_NODE_ID);
                        }
                    }
                }
                else
                {
                    //验证流程是否结束(末梢节点是否均处理完毕)
                    if (ValidateFlowCaseIsFinish(flow.ID, flowCaseId))
                    {
                        string remark = null;
                        //结束流程
                        var flowCase = BF_FLOW_CASE.Instance.GetEntityByKey <BF_FLOW_CASE.Entity>(flowCaseId);
                        flowCase.IS_ARCHIVE   = 1;
                        flowCase.IS_ENABLE    = 1;
                        flowCase.ARCHIVE_TIME = DateTime.Now;
                        BF_FLOW_CASE.Instance.UpdateByKey(flowCase, flowCaseId);

                        //验证和触发下个流程
                        var flowRefList = BF_FLOW_REF.Instance.GetNextFlow(flow.ID);
                        if (flowRefList != null && flowRefList.Count > 0)
                        {
                            foreach (var flowRef in flowRefList)
                            {
                                CreateFlowCaseAndMainNodeCase(flowRef.FLOW_ID);
                            }
                            remark = string.Format(@"创建了[{0}]个下级流程", flowRefList.Count);
                        }
                        else
                        {
                            remark = "未找到下级走向节点";
                        }

                        #region 加入走向说明
                        Dictionary <string, object> dic = new Dictionary <string, object>();
                        dic.Add("REMARK", remark);//是否流程就结束了呢?
                        BF_FLOW_CASE.Instance.UpdateByKey(dic, flowCaseId);
                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
                string errMsg = string.Format(@"为流程[{0}]实例[{1}]的节点[{2}]添加下级节点实例失败:{3}",
                                              flow.ID, flowCaseId, currFlowNode.ID, ex.Message);
                BLog.Write(BLog.LogLevel.ERROR, errMsg);
                throw new Exception(errMsg);
            }
            return(resBool);
        }