Пример #1
0
        public virtual ActionResult Index()
        {
            var connectionString = ConnectionStringProvider.ConnectionString;
            var schema = ConnectionStringProvider.Schema;

            string error;
            var model = new IndexModel();
            model.CanConnect = Database.TryConnect(connectionString, out error);
            model.ConnectionError = error;
            model.ConnectionString = connectionString;
            model.Schema = schema;

            if (model.CanConnect)
            {
                var required = Database
                    .GetCoreRequiredScripts()
                    .Union(Extensions.SelectMany(x => Database.GetExtensionRequiredScripts(x)))
                    .ToArray();

                var executedAlready = Database
                    .GetCoreExecutedScripts(connectionString, schema)
                    .Union(Extensions.SelectMany(x => Database.GetExtensionExecutedScripts(connectionString, x, schema)))
                    .ToArray();

                model.ScriptsToRun = required.Except(executedAlready).ToArray();
                model.IsInstall = executedAlready.Length > 0;
            }

            return View("Index", model);
        }
Пример #2
0
        public virtual ActionResult Index()
        {
            var connectionString = ConnectionStringProvider.ConnectionString;
            var schema = ConnectionStringProvider.Schema;
            var databaseProviderName = ConnectionStringProvider.DatabaseProvider;
            var databaseProviderList = databaseProviders().ToList();
            var databaseProvider = databaseProviderList.Single(p => p.Metadata.Name.Equals(databaseProviderName, StringComparison.InvariantCultureIgnoreCase));

            string error;
            var model = new IndexModel();
            model.DatabaseProviders = databaseProviderList.Select(p => p.Metadata.Name);
            model.DatabaseProvider = databaseProviderName;
            model.CanConnect = databaseProvider.Value.TryConnect(connectionString, out error);
            model.ConnectionError = error;
            model.ConnectionString = connectionString;
            model.Schema = databaseProvider.Value.SupportSchema ? schema : null;
            model.DatabaseProviderSupportsSchema = databaseProvider.Value.SupportSchema;

            if (model.CanConnect)
            {
                var required = Database
                    .GetCoreRequiredScripts()
                    .Union(Extensions.SelectMany(x => Database.GetExtensionRequiredScripts(x)))
                    .ToArray();

                var connectionFactory = databaseProvider.Value.GetConnectionFactory(connectionString);
                var executedAlready = Database
                    .GetCoreExecutedScripts(connectionFactory)
                    .Union(Extensions.SelectMany(x => Database.GetExtensionExecutedScripts(connectionFactory, x)))
                    .ToArray();

                model.ScriptsToRun = required.Except(executedAlready).ToArray();
                model.IsInstall = executedAlready.Length > 0;
            }

            return View("Index", model);
        }
Пример #3
0
        public virtual ActionResult Index()
        {
            var connectionString = ConnectionStringSettings.ConnectionString;
            var schema = ConnectionStringSettings.Schema;
            var databaseProviderName = ConnectionStringSettings.DatabaseProvider;
            var providerInfo = databaseProvidersInfo();
            var databaseProvider = providerInfo.GetProviderByName(databaseProviderName);

            string error;
            var model = new IndexModel
                            {
                                DatabaseProviders = providerInfo.Keys,
                                DatabaseProvider = databaseProviderName,
                                CanConnect = databaseProvider.TryConnect(connectionString, out error),
                                ConnectionError = error,
                                ConnectionString = connectionString,
                                Schema = databaseProvider.SupportSchema ? schema : null,
                                DatabaseProviderSupportsSchema = databaseProvider.SupportSchema,
                                IsSettingsReadOnly = ConnectionStringSettings.ReadOnlyReason != null,
                                ReadOnlyReason = ConnectionStringSettings.ReadOnlyReason
                            };

            if (model.CanConnect)
            {
                var required = Database
                    .GetCoreRequiredScripts()
                    .Union(Extensions.SelectMany(x => Database.GetExtensionRequiredScripts(x)))
                    .ToArray();

                var connectionFactory = databaseProvider.GetConnectionFactory(connectionString);
                var executedAlready = Database
                    .GetCoreExecutedScripts(connectionFactory)
                    .Union(Extensions.SelectMany(x => Database.GetExtensionExecutedScripts(connectionFactory, x)))
                    .ToArray();

                model.ScriptsToRun = required.Except(executedAlready).ToArray();
                model.IsInstall = executedAlready.Length > 0;
            }

            return View("Index", model);
        }