コード例 #1
0
        protected internal static IRuntimeDatabaseConfiguration ConfigurationForDatabase(string databaseName, DatabaseSettingsSerialization.Source source, DatabaseSettingsSerialization.User user)
        {
            if (string.IsNullOrEmpty(databaseName) ||
                (databaseName == Constants.SystemDatabaseLogicalName) ||
                (databaseName == ForSystemDatabase.DatabaseServices.DatabaseConfiguration.DatabaseIdentifier))
            {
                return(null);
            }

            using (var trans = ForSystemDatabase.GetCommitableTransaction()) {
                var eSpaceParams = DBRuntimePlatform.Instance.GetCatalogDetailsByName(trans, databaseName, user);
                if (eSpaceParams == null)
                {
                    return(null);
                }

                var baseConf = RuntimeDatabaseConfigurations.For(
                    CurrentPlatformDatabasesPluginProvider,
                    source,
                    user);

                baseConf.SetParameters(eSpaceParams);
                return(baseConf);
            }
        }
コード例 #2
0
        public static IRuntimeDatabaseConfiguration For(DatabasePluginProvider <IPlatformDatabaseProvider> provider, DatabaseSettingsSerialization.Source source, DatabaseSettingsSerialization.User user)
        {
            var @params = Read(source, user);

            if (@params.Count == 0)
            {
                return(null);
            }

            var providerKey = DatabaseProviderKey.Deserialize(@params[DatabaseConfigurations.ProviderKeyName].ToString());
            var conf        = provider.GetImplementation(providerKey).CreateEmptyRuntimeDatabaseConfiguration();

            RuntimeDatabaseConfigurations.Fill(conf, @params);

            return(conf);
        }
コード例 #3
0
        private static IRuntimeDatabaseConfiguration LoadCatalogConfigurationForCatalogName(string catalogName)
        {
            var details = RuntimePlatformSettings.Catalog.Configuration(catalogName).All;

            if (details == null)
            {
                return(null);
            }

            var conf = RuntimeDatabaseConfigurations.For(
                PlatformDatabasePluginProvider,
                DatabaseSettingsSerialization.Source.Application,
                DatabaseSettingsSerialization.User.Runtime,
                DatabaseSettingsSerialization.DataSpace.Business,
                RuntimeSettingsProvider.Instance);

            conf.SetParameters(details);
            return(conf);
        }
コード例 #4
0
        protected internal static IRuntimeDatabaseConfiguration LoadConfigurationForESpace(int eSpaceId)
        {
            using (var trans = ForSystemDatabase.GetCommitableTransaction()) {
                var details = DBRuntimePlatform.Instance.GetCatalogDetailsByESpaceId(trans, eSpaceId);

                if (details == null)
                {
                    return(null);
                }

                var conf = RuntimeDatabaseConfigurations.For(
                    PlatformDatabasePluginProvider,
                    AccessRequester,
                    DatabaseSettingsSerialization.User.Runtime);

                conf.SetParameters(details);

                return(conf);
            }
        }
コード例 #5
0
        protected static DatabaseAccessProvider <IPlatformDatabaseServices> CreatePlatformDatabaseAccessProvider(
            DatabaseSettingsSerialization.Source source,
            DatabaseSettingsSerialization.User user,
            DatabaseSettingsSerialization.DataSpace dataSpace,
            ISettingsProvider settingsProvider)
        {
            var pluginProvider = PlatformDatabasePluginProvider;

            IRuntimeDatabaseConfiguration conf = RuntimeDatabaseConfigurations.For(pluginProvider, source, user, dataSpace, settingsProvider);

            if (conf == null || conf.ConnectionString.IsEmpty())
            {
                throw new InvalidOperationException("Unable to obtain the connection string. Please run Configuration Tool.");
            }

            var services = pluginProvider.GetImplementation(conf.DatabaseProvider.Key).GetPlatformDatabaseServices(conf);

            return(new DatabaseAccessProvider <IPlatformDatabaseServices>(
                       services,
                       services.TransactionService.CreateTransactionManager()));
        }
コード例 #6
0
        public static IRuntimeDatabaseConfiguration For(
            DatabasePluginProvider <IPlatformDatabaseProvider> provider,
            DatabaseSettingsSerialization.Source source,
            DatabaseSettingsSerialization.User user,
            DatabaseSettingsSerialization.DataSpace dataSpace,
            ISettingsProvider settingsProvider)
        {
            var providerKeySetting = new Setting <string>(BuildSettingName(source, user, dataSpace, DatabaseConfigurations.ProviderKeyName), string.Empty);
            var providerKeyString  = settingsProvider.Get(providerKeySetting);

            if (string.IsNullOrEmpty(providerKeyString))
            {
                return(null);
            }

            var providerKey = DatabaseProviderKey.Deserialize(providerKeyString);
            var conf        = provider.GetImplementation(providerKey).CreateEmptyRuntimeDatabaseConfiguration();

            RuntimeDatabaseConfigurations.Fill(conf, BuildSettingName(source, user, dataSpace, ""), settingsProvider);

            return(conf);
        }
コード例 #7
0
        protected static DatabaseAccessProvider <IPlatformDatabaseServices> CreatePlatformDatabaseAccessProvider(
            DatabaseSettingsSerialization.Source source,
            DatabaseSettingsSerialization.User user)
        {
            var pluginProvider = PlatformDatabasePluginProvider;

            var key = Pair.Create(source, user);
            IRuntimeDatabaseConfiguration conf;

            if (source == DatabaseSettingsSerialization.Source.Application)
            {
                // We don't use GetOrAdd because in Java computeIfAbsent holds a lock
                // while evaluating the factory function which can lead to deadlocks when one thread
                // is initializing the database access for the first time and another is retrieving
                // a setting from the database
                if (!cachedPlatformAccessConfigurations.TryGetValue(key, out conf))
                {
                    var newConf = RuntimeDatabaseConfigurations.For(pluginProvider, source, user);
                    conf = cachedPlatformAccessConfigurations.GetOrAdd(key, newConf);
                }
            }
            else
            {
                // Service Configurations can't be cached becase the underlining settings storage keeps changing as they serve diferent sandboxes
                conf = RuntimeDatabaseConfigurations.For(pluginProvider, source, user);
            }

            if (conf == null || conf.ConnectionString.IsEmpty())
            {
                throw new InvalidOperationException("Unable to obtain the connection string. Please run Configuration Tool.");
            }

            var services = pluginProvider.GetImplementation(conf.ProviderKey()).GetPlatformDatabaseServices(conf);

            services.IntrospectionService.QueryTimeout = IntrospectionQueryTimeout;
            return(new DatabaseAccessProvider <IPlatformDatabaseServices>(
                       services,
                       services.TransactionService.CreateTransactionManager()));
        }