Beispiel #1
0
        static void Main(string[] args)
        {
            MsSqlConfiguration databaseConfiguration =
                MsSqlConfiguration.MsSql2008.ShowSql().ConnectionString(x => x.Is(ConnectionStrings.Get()));
             
            DatabaseDeployer dd = null;
            ISessionFactory sessionFactory = new SessionFactoryBuilder(new MappingScheme(), databaseConfiguration)
                .Build(cfg => { dd = new DatabaseDeployer(cfg); });

            dd.Drop();
            Console.WriteLine("");
            Console.WriteLine("Database dropped.");
            Thread.Sleep(1000);

            dd.Create();
            Console.WriteLine("");
            Console.WriteLine("Database created.");

            ISession session = sessionFactory.OpenSession();
            using (ITransaction tx = session.BeginTransaction())
            {
                dd.Seed(new List<IDataSeeder>
                            {
                                //add data seeders here.
                                new UserSeeder(session)
                            });
                tx.Commit();
            }
            session.Close();
            sessionFactory.Close();
            Console.WriteLine("");
            Console.WriteLine("Seed data added.");
            Thread.Sleep(2000);
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            IHost            host             = CreateHostBuilder(args).Build();
            DatabaseDeployer databaseDeployer = (DatabaseDeployer)host.Services.GetService(typeof(DatabaseDeployer));

            databaseDeployer.DeployAsync().Wait();
            host.Run();
        }
        private void DeployDatabase(IConfigurationRoot configuration)
        {
            _connectionString = configuration.GetConnectionString("DefaultConnection");
            _databaseDeployer = new DatabaseDeployer(_connectionString, "Sql\\Schema.sql", "Sql\\Procedures.sql");
            bool isDBCreated = _databaseDeployer.ExecuteReader("IF (OBJECT_ID ('dbo.GetBalance', 'P') IS NULL) SELECT 0 ELSE SELECT 1;", IsDatabaseCreated);

            if (!isDBCreated)
            {
                _databaseDeployer.DeployAsync().Wait();
            }
        }
Beispiel #4
0
        public void SetUp()
        {
            var connectionFactory = TestUtilities.GetIntegrationConnectionFactory();
            var logger            = TestUtilities.GetMockLogger();
            var databaseDeployer  = new DatabaseDeployer(new DatabaseMigratorFactory(connectionFactory),
                                                         new ExceptionMigrationResultHandler(logger.Object));
            var serverRepository     = new ServerRepository(connectionFactory);
            var refreshServerService = new RefreshServerService(logger.Object, new ResourceServerRepository(connectionFactory));
            var administrationInstallationRepository = new AdministrationInstallationRepository(connectionFactory);

            this.administrationInstallationService = new AdministrationInstallationService(databaseDeployer, serverRepository, refreshServerService, administrationInstallationRepository);
        }
        public void SetUp()
        {
            var connectionFactory = TestUtilities.GetIntegrationConnectionFactory();
            var sql           = new SqlServerRepository(connectionFactory);
            var hashConverter = new LegacyHashConversionService();
            var tabService    = new TabService(new TabRepository(connectionFactory), new RelativityOneService(sql.ConfigurationRepository));

            this.textLogger = new TextLogger();
            var dbDeployer = new DatabaseDeployer(
                new DatabaseMigratorFactory(connectionFactory),
                new ErrorOnlyMigrationResultHandler(this.textLogger));

            this.applicationInstallationService =
                new ApplicationInstallationService(connectionFactory, sql, hashConverter, tabService, dbDeployer, this.textLogger);
        }
        static void Main(string[] args)
        {
            MsSqlConfiguration databaseConfiguration = MsSqlConfiguration.MsSql2008.ShowSql().ConnectionString(x => x.FromConnectionStringWithKey("Rainfall"));

            DatabaseDeployer dd = null;
            ISessionFactory sessionFactory = new SessionFactoryBuilder(new MappingScheme(), databaseConfiguration)
                .Build(cfg => { dd = new DatabaseDeployer(cfg); });

            using (var sess = sessionFactory.OpenSession())
            {
                using (IDbCommand cmd = sess.Connection.CreateCommand())
                {
                    cmd.ExecuteSqlFile("dropForeignKeys.sql");
                    cmd.ExecuteSqlFile("dropPrimaryKeys.sql");
                    cmd.ExecuteSqlFile("dropTables.sql");
                }
            }

            Console.WriteLine("");
            Console.WriteLine("Database dropped.");
            //Thread.Sleep(1000);

            dd.Create();
            Console.WriteLine("");
            Console.WriteLine("Database created.");

            ISession session = sessionFactory.OpenSession();
            using (ITransaction tx = session.BeginTransaction())
            {
                dd.Seed(new List<IDataSeeder>
                            {
                                //add data seeders here.
                                //new SeedAlamanacDays(session)
                                new SeedCity(session)
                            });
                tx.Commit();
            }
            session.Close();
            sessionFactory.Close();
            Console.WriteLine("");
            Console.WriteLine("Seed data added.");
            //Thread.Sleep(2000);
        }
        private static IServiceProvider GetServiceProvider()
        {
            IConfigurationRoot config = new ConfigurationBuilder()
                                        .AddJsonFile("appsettings.json")
                                        .Build();
            string connectionStr = config.GetConnectionString("DefaultConnection");

            DatabaseDeployer databaseDeployer = new DatabaseDeployer(connectionStr, "Sql\\Schema.sql", "Sql\\Procedures.sql", "Sql\\Initialization.sql");

            databaseDeployer.DeployAsync().Wait();
            SchoolManagerDb schoolManagerDb = new SchoolManagerDb(connectionStr);
            StudentService  studentService  = new StudentService(schoolManagerDb);

            ServiceCollection services = new ServiceCollection();

            services.AddSingleton <ISchoolManagerDb>(x => schoolManagerDb);
            services.AddSingleton <IStudentService>(x => studentService);

            return(services.BuildServiceProvider());
        }
Beispiel #8
0
        }                                                                        // Only used for 'AdminScriptsInstalled'
        #endregion

        public AdministrationInstall()
        {
            //register the prerender event
            this.PreRender += Page_PreRender;
            var logger = new TextLogger();

            _pageModel = new AdministrationInstallationModel();

            var connectionFactory = new HelperConnectionFactory(ConnectionHelper.Helper());

            this.sqlServerRepository = new SqlServerRepository(connectionFactory);
            _serverRepository        = new ServerRepository(connectionFactory);
            var databaseDeployer = new DatabaseDeployer(
                new DatabaseMigratorFactory(connectionFactory),
                new ExceptionMigrationResultHandler(logger));
            var administrationInstallationRepository = new AdministrationInstallationRepository(connectionFactory);
            var refreshServerService = new RefreshServerService(logger, new ResourceServerRepository(connectionFactory));

            _service     = new AdministrationInstallationService(databaseDeployer, _serverRepository, refreshServerService, administrationInstallationRepository);
            _authService = new AuthenticationServiceFactory().GetService();
        }
        public override Response Execute()
        {
            // Initialize application install service -- TODO -- use DI to create kernel and get correct implementation
            if (this.parallelizationInstallationService == null)
            {
                // Build up application installation service
                var logger                         = new TextLogger();
                var connectionFactory              = new HelperConnectionFactory(this.Helper);
                var sqlRepo                        = new SqlServerRepository(connectionFactory);
                var hashConverter                  = new LegacyHashConversionService();
                var tabRepository                  = new TabRepository(connectionFactory);
                var relativityOneService           = new RelativityOneService(sqlRepo.ConfigurationRepository);
                var tabService                     = new TabService(tabRepository, relativityOneService);
                var databaseMigratorFactory        = new DatabaseMigratorFactory(connectionFactory);
                var databaseDeployer               = new DatabaseDeployer(databaseMigratorFactory, new ErrorOnlyMigrationResultHandler(logger));
                var applicationInstallationService = new ApplicationInstallationService(connectionFactory, sqlRepo, hashConverter, tabService, databaseDeployer, logger);

                var toggleProvider         = new PdbSqlToggleProvider(connectionFactory);
                var forceDeparallelization = toggleProvider.IsEnabled <DatabaseDeploymentDeparallelizationToggle>();
                if (forceDeparallelization)
                {
                    // Build up the service that checks for version
                    var versionCheckService = new VersionCheckService(new PdbVersionRepository(connectionFactory), logger);
                    this.parallelizationInstallationService = new SingletonDatabaseInstallationService(applicationInstallationService, versionCheckService, new TimeService(), logger);
                }
                else
                {
                    // Build up the service that actually runs the install process
                    this.parallelizationInstallationService = new DefaultDatabaseInstallationService(applicationInstallationService);
                }
            }

            // Install the application
            var appInstallResponse = this.parallelizationInstallationService.InstallApplication(this.Helper.GetActiveCaseID()).GetAwaiter().GetResult();

            // Return response
            return(new Response {
                Message = appInstallResponse.Message, Success = appInstallResponse.Success
            });
        }