Exemplo n.º 1
0
        internal IXapDbSettings GetDatabaseSettings(IXapDbContext dbContext)
        {
            string dbKey = string.Empty;

            try {
                dbKey = GetDbKey(dbContext.DbEnvironment, dbContext.DbConnectionName);
                IXapDbSettings dbSettings = _dbSettings.GetItem(dbKey);
                if (dbSettings == null)
                {
                    dbSettings                  = new DbSettings(dbContext);
                    dbSettings.DbKey            = dbKey;
                    dbSettings.CommandTimeout   = GetCommandTimeout(dbKey);
                    dbSettings.ConnectionString = GetConnectionString(dbKey);
                    dbSettings.DbHost           = GetDbHost(dbKey);
                    dbSettings.DbName           = GetDbName(dbKey);
                    dbSettings.DataProvider     = GetDataProvider(dbKey);
                    dbSettings.SqlLocation      = GetSqlLocation(dbKey);
                    dbSettings.MinPoolSize      = GetMinPoolSize(dbKey);
                    dbSettings.MaxPoolSize      = GetMaxPoolSize(dbKey);
                    dbSettings.PasswordProvider = GetPasswordProvider(dbKey);
                    dbSettings.Build();

                    _dbSettings.AddItem(dbSettings.DbKey, dbSettings);
                }
                return(dbSettings);
            } catch (Exception ex) {
                XapLogger.Instance.Error($"Error retrieving database settings for {dbContext.DbEnvironment}:{dbContext.DbConnectionName}");
                XapLogger.Instance.Write(ex.Message);
                throw;
            }
        }
Exemplo n.º 2
0
 internal DbSettings(IXapDbContext dbContext)
 {
     _dbContext = dbContext;
 }