Esempio n. 1
0
        /// <summary>
        /// 添加脚本流节点配置的实例(后期执行脚本流时,按此配置顺序执行相应节点)
        /// </summary>
        /// <param name="scriptID">脚本流ID</param>
        /// <param name="scriptCaseID">脚本流实例ID</param>
        /// <returns></returns>
        public List <long> AddReturnNodeIDList(long scriptID, long scriptCaseID)
        {
            IList <EM_SCRIPT_REF_NODE.Entity> refList = EM_SCRIPT_REF_NODE.Instance.GetNodeListByScriptID(scriptID);
            //用于去重
            Dictionary <long, byte> dic = new Dictionary <long, byte>();

            if (refList != null && refList.Count > 0)
            {
                using (BDBHelper dbHelper = new BDBHelper())
                {
                    //开始事务
                    dbHelper.BeginTrans();
                    foreach (EM_SCRIPT_REF_NODE.Entity refEntity in refList)
                    {
                        try
                        {
                            Entity entity = new Entity();
                            if (Main.KeyFieldIsUseSequence)
                            {
                                entity.ID = GetNextValueFromSeq();
                            }
                            entity.SCRIPT_ID      = scriptID;
                            entity.SCRIPT_CASE_ID = scriptCaseID;
                            entity.PARENT_NODE_ID = refEntity.PARENT_NODE_ID;
                            entity.CURR_NODE_ID   = refEntity.CURR_NODE_ID;
                            entity.REMARK         = refEntity.REMARK;

                            int i = Add(entity);
                            if (i < 0)
                            {
                                dbHelper.RollbackTrans();
                                dic.Clear();
                                break;
                            }
                            if (dic.ContainsKey(entity.CURR_NODE_ID) == false)
                            {
                                dic.Add(entity.CURR_NODE_ID, 1);
                            }
                        }
                        catch (Exception ex)
                        {
                            BLog.Write(BLog.LogLevel.ERROR, "添加脚本流节点配置的实例出错\t" + ex.ToString());
                            //出错回滚
                            dbHelper.RollbackTrans();
                            return(new List <long>());
                        }
                    }
                    //提交事务
                    dbHelper.CommitTrans();
                    dbHelper.Close();
                }
            }

            return(dic.Keys.ToList <long>());
        }
Esempio n. 2
0
        /// <summary>
        /// 添加节点实例列表
        /// </summary>
        /// <param name="scriptCaseID">脚本实例ID</param>
        /// <param name="nodeIDList">脚本相关节点ID列表</param>
        /// <returns>添加成功的节点实例ID列表</returns>
        public List <long> AddCaseReturnList(long scriptCaseID, List <long> nodeIDList)
        {
            List <long> list = new List <long>();

            if (scriptCaseID < 1 || nodeIDList.Count < 1)
            {
                return(list);
            }

            int i      = 0;
            int caseid = 0;

            using (BDBHelper dbHelper = new BDBHelper())
            {
                //开始事务
                dbHelper.BeginTrans();
                foreach (long nodeID in nodeIDList)
                {
                    try
                    {
                        EM_SCRIPT_NODE.Entity ne = EM_SCRIPT_NODE.Instance.GetEntityByKey <EM_SCRIPT_NODE.Entity>(nodeID);
                        Entity entity            = new Entity();
                        if (Main.KeyFieldIsUseSequence)
                        {
                            entity.ID = GetNextValueFromSeq();
                        }
                        entity.SCRIPT_CASE_ID      = scriptCaseID;
                        entity.SCRIPT_NODE_ID      = ne.ID;
                        entity.SCRIPT_NODE_TYPE_ID = ne.SCRIPT_NODE_TYPE_ID;
                        entity.NAME         = ne.NAME;
                        entity.CODE         = ne.CODE;
                        entity.DB_SERVER_ID = ne.DB_SERVER_ID;
                        entity.SCRIPT_MODEL = ne.SCRIPT_MODEL;
                        if (entity.SCRIPT_MODEL == Enums.ScriptModel.CreateTb.GetHashCode())
                        {
                            entity.CONTENT      = ne.CONTENT.ToUpper();
                            entity.E_TABLE_NAME = ne.E_TABLE_NAME.ToUpper();
                        }
                        else
                        {
                            entity.CONTENT      = ne.CONTENT;
                            entity.E_TABLE_NAME = ne.E_TABLE_NAME;
                        }
                        entity.REMARK       = ne.REMARK;
                        entity.C_TABLE_NAME = ne.C_TABLE_NAME;
                        entity.TABLE_TYPE   = ne.TABLE_TYPE;
                        entity.TABLE_MODEL  = ne.TABLE_MODEL;
                        entity.CREATE_TIME  = ne.CREATE_TIME;
                        entity.CREATE_UID   = ne.CREATE_UID;

                        caseid = Add(entity, true);
                        if (caseid > 0)
                        {
                            i++;
                            list.Add(caseid);
                        }
                    }
                    catch (Exception ex)
                    {
                        i = 0;
                        dbHelper.RollbackTrans();
                        list.Clear();

                        break;
                    }
                }

                if (i != nodeIDList.Count)
                {
                    i = 0;
                    dbHelper.RollbackTrans();
                    list.Clear();
                }

                //提交事务
                dbHelper.CommitTrans();
                dbHelper.Close();
            }

            return(list);
        }