static AppConfig() { AppConfig.DefaultDbId = "DEFAULT"; AppConfig.DefaultDbDesc = "系统数据库"; AppConfig.DbMS = DbProviderType.MSSQL; AppConfig.DbServer = string.Empty; AppConfig.TNS_ADMIN = string.Empty; AppConfig.Default_Service_UserId = "SERVICE"; AppConfig.DefaultDbId = ConfigurationManager.AppSettings["DEFAULTDBID"]; AppConfig.DefaultDbDesc = ConfigurationManager.AppSettings["DEFAULTDBDESC"]; AppConfig.DbMS = ConfigurationManager.AppSettings["DBMS"].ToDbProviderType(); AppConfig.DbServer = new NameValueString { NaviteText = ConfigurationManager.AppSettings["DBSERVER"] }.LineText; AppConfig.TNS_ADMIN = ConfigurationManager.AppSettings["TNS_ADMIN"]; AppDbInstance.AddDbInstance(AppConfig.DefaultDbId, new DbConfig(AppConfig.DefaultDbId, AppConfig.DefaultDbDesc, AppConfig.DbMS, AppConfig.DbServer)); }
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); }