Exemple #1
0
        /// <summary>
        /// 获取数据库表列表
        /// </summary>
        /// <param name="dbID">数据库ID</param>
        /// <param name="isUsedInImport">是否用于外导表</param>
        /// <returns>表名列表</returns>
        public List <string> GetTableList(int dbID, bool isUsedInImport)
        {
            List <string> list     = new List <string>();
            string        username = "";

            if (dbID < 0)
            {
                return(new List <string>());
            }
            else if (dbID == 0)
            {
                using (BDBHelper dbHelper = new BDBHelper())
                {
                    username = dbHelper.UserName;
                    list     = dbHelper.GetTablesList();
                }
            }
            else
            {
                BF_DATABASE.Entity entity = BF_DATABASE.Instance.GetEntityByKey <BF_DATABASE.Entity>(dbID);

                if (entity == null)
                {
                    throw new Exception("数据库" + dbID + "不存在");
                }
                string dbType = GetDbTypeName(entity.DB_TYPE);
                using (BDBHelper dbHelper = new BDBHelper(dbType, entity.IP, entity.PORT, entity.USER_NAME, entity.PASSWORD, entity.DB_NAME, entity.DB_NAME))
                {
                    username = dbHelper.UserName;
                    list     = dbHelper.GetTablesList();
                }
            }

            if (list == null || list.Count < 1)
            {
                return(new List <string>());
            }
            List <string> l = new List <string>();
            int           i = 0;

            foreach (string t in list)
            {
                string name = t.Replace(username.ToUpper() + ".", "");
                //外导时,排除框架所用的表
                if (isUsedInImport == true && name.StartsWith("BF_"))
                {
                    //continue;
                }
                l.Add(name);
                i++;
                //最多返回200张表
                if (i >= 200 && isUsedInImport == false)
                {
                    break;
                }
            }
            return(l);
        }
Exemple #2
0
        /// <summary>
        /// 获取指定库的全量表集合
        /// </summary>
        /// <param name="dbID"></param>
        /// <returns></returns>
        public List <string> GetAllTableList(int dbID)
        {
            List <string> list     = new List <string>();
            string        username = "";

            if (dbID < 0)
            {
                return(new List <string>());
            }
            else if (dbID == 0)
            {
                using (BDBHelper dbHelper = new BDBHelper())
                {
                    username = dbHelper.UserName;
                    list     = dbHelper.GetTablesList();
                }
            }
            else
            {
                BF_DATABASE.Entity entity = BF_DATABASE.Instance.GetEntityByKey <BF_DATABASE.Entity>(dbID);

                if (entity == null)
                {
                    throw new Exception("数据库" + dbID + "不存在");
                }
                string dbType = GetDbTypeName(entity.DB_TYPE);
                using (BDBHelper dbHelper = new BDBHelper(dbType, entity.IP, entity.PORT, entity.USER_NAME, entity.PASSWORD, entity.DB_NAME, entity.DB_NAME))
                {
                    username = dbHelper.UserName;
                    list     = dbHelper.GetTablesList();
                }
            }

            if (list == null || list.Count < 1)
            {
                return(new List <string>());
            }
            else
            {
                return(list);
            }
        }