Ejemplo n.º 1
0
        internal static Database GetDatabase(DbConfig dbConfig)
        {
            //return (dbConfig.ProviderType != DbProviderType.MSSQL) ? ((dbConfig.ProviderType != DbProviderType.ORACLE) ? new SqlDatabase(dbConfig.DbId, dbConfig.ProviderType.ToString(), dbConfig.ConnectionString) : new OdacDatabase(dbConfig.DbId, dbConfig.ProviderType.ToString(), dbConfig.ConnectionString)) : new SqlDatabase(dbConfig.DbId, dbConfig.ProviderType.ToString(), dbConfig.ConnectionString);
            Database database = null;

            if (dbConfig.ProviderType != DbProviderType.MSSQL)
            {
                if (dbConfig.ProviderType != DbProviderType.ORACLE)
                {
                    database = new SqlDatabase(dbConfig.DbId, dbConfig.ProviderType.ToString(), dbConfig.ConnectionString);
                }
                else
                {
                    database = new OdacDatabase(dbConfig.DbId, dbConfig.ProviderType.ToString(), dbConfig.ConnectionString);
                }
            }
            else
            {
                database = new SqlDatabase(dbConfig.DbId, dbConfig.ProviderType.ToString(), dbConfig.ConnectionString);
            }

            return(database);
        }
Ejemplo n.º 2
0
        public static Database GetDatabase(string dbId)
        {
            LogicContext current = LogicContext.Current;
            bool         flag    = current == null;

            if (flag)
            {
                throw new Exception("内部错误:当前线程未设置上下文环境!");
            }
            bool flag2 = current.m_databases == null;

            if (flag2)
            {
                current.m_databases = new ListDictionary();
            }
            bool     flag3 = current.m_databases.Contains(dbId);
            Database database;

            if (flag3)
            {
                database = (Database)current.m_databases[dbId];
            }
            else
            {
                DbConfig dbConfig = AppDbInstance.GetDbInstance(dbId);
                bool     flag4    = dbConfig == null;
                if (flag4)
                {
                    DbServer dbServer = DbServerUtils.GetDbServer(dbId);
                    bool     flag5    = dbServer != null;
                    if (flag5)
                    {
                        dbConfig = new DbConfig(dbServer.DbId, dbServer.Desc, dbServer.DbMS, new NameValueString
                        {
                            NaviteText = dbServer.Conn
                        }.LineText);
                    }
                }
                //database = ((dbConfig.ProviderType != DbProviderType.MSSQL) ?
                //                ((dbConfig.ProviderType != DbProviderType.ORACLE) ?
                //                new SqlDatabase(dbConfig.DbId, dbConfig.ProviderType.ToString(), dbConfig.ConnectionString) :
                //                new OdacDatabase(dbConfig.DbId, dbConfig.ProviderType.ToString(), dbConfig.ConnectionString)) :
                // new SqlDatabase(dbConfig.DbId, dbConfig.ProviderType.ToString(), dbConfig.ConnectionString));

                if (dbConfig.ProviderType != DbProviderType.MSSQL)
                {
                    if (dbConfig.ProviderType != DbProviderType.ORACLE)
                    {
                        database = new SqlDatabase(dbConfig.DbId, dbConfig.ProviderType.ToString(), dbConfig.ConnectionString);
                    }
                    else
                    {
                        database = new OdacDatabase(dbConfig.DbId, dbConfig.ProviderType.ToString(), dbConfig.ConnectionString);
                    }
                }
                else
                {
                    database = new SqlDatabase(dbConfig.DbId, dbConfig.ProviderType.ToString(), dbConfig.ConnectionString);
                }


                current.m_databases.Add(dbConfig.DbId, database);
            }
            return(database);
        }