Esempio n. 1
0
        /// <summary>
        /// 创建流程实例及第一个节点待办项
        /// </summary>
        /// <param name="flowId"></param>
        /// <returns></returns>
        public int CreateFlowCaseAndMainNodeCase(int flowId)
        {
            //01.创建流程实例
            int flowCaseId = CreateFlowCase(flowId, 0);
            //02.创建主流程节点实例
            var mainNode           = BF_FLOW_NODE.Instance.GetEntity <BF_FLOW_NODE.Entity>("FLOW_ID=? AND IS_MAIN=1");
            int mainFlowNodeCaseId = BF_FLOW_NODE_CASE.Instance.GetNextValueFromSeqDef();

            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()),
                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              = 0,
                IS_MAIN                = 1,
                NAME                   = mainNode.NAME,
                REMARK                 = "由上级流程自动触发创建",
                FLOW_NODE_ID           = mainNode.ID,
                DEAL_WAY               = mainNode.DEAL_WAY
            };
            BF_FLOW_NODE_CASE.Instance.Add(mainFlowNodeCase);
            return(mainFlowNodeCaseId);
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }