示例#1
0
        public TenantManager(
            IRepository <Tenant> tenantRepository,
            IRepository <TenantFeatureSetting, long> tenantFeatureRepository,
            EditionManager editionManager,
            ICommonFrameFeatureValueStore featureValueStore,

            IUnitOfWorkManager unitOfWorkManager,
            RoleManager roleManager,
            IUserEmailer userEmailer,
            UserManager userManager,
            INotificationSubscriptionManager notificationSubscriptionManager,
            IAppNotifier appNotifier,

            IDbMigrator dbMigrator,
            ITenantCache tenantCache
            )
            : base(
                tenantRepository,
                tenantFeatureRepository,
                editionManager,
                featureValueStore
                )
        {
            _unitOfWorkManager = unitOfWorkManager;
            _roleManager       = roleManager;
            _userEmailer       = userEmailer;
            _userManager       = userManager;
            _notificationSubscriptionManager = notificationSubscriptionManager;
            _appNotifier = appNotifier;
            _dbMigrator  = dbMigrator;
            _tenantCache = tenantCache;
        }
示例#2
0
        public override void Configure(Container container)
        {
            _logger.Debug("Configuring");

            container.Adapter = _autofacIocAdapter;
            AppSettings       = container.Resolve <IAppSettings>();

            JsConfig.EmitCamelCaseNames = true;

            GlobalHtmlErrorHttpHandler = new RazorHandler("/oops");

            Configuration = container.Resolve <IEkklesiaConfiguration>();

            SetConfig(new HostConfig
            {
                DebugMode  = _hostingEnvironment.IsDevelopment() || Configuration.DebugMode,
                WebHostUrl = _configuration["SiteUrl"]
            });

            Plugins.Add(new RazorFormat());
            Plugins.Add(new ValidationFeature());
            Plugins.Add(new RequestLogsFeature());

            IDbMigrator migrator = container.Resolve <IDbMigrator>();

            migrator.Migrate();
        }
示例#3
0
        private static void ApplyMigration(IDbMigrator migrator, IDbConnection connection)
        {
            var result = migrator.Migrate(connection);

            if (result.MigrationWasApplied)
            {
                connection.Execute(
                    @"INSERT INTO PocketMigrator.AppliedMigrations
             (MigrationScope,
              MigrationVersion,
              Log,
              AppliedDate)
     VALUES
            (@migrationScope, 
             @migrationVersion,
             @log,
             GetDate())",
                    parameters: new Dictionary <string, object>
                {
                    { "@migrationScope", migrator.MigrationScope },
                    { "@migrationVersion", migrator.MigrationVersion.ToString() },
                    {
                        "@log",
                        $"{migrator.GetType().AssemblyQualifiedName}\n\n{result.Log}".Trim()
                    }
                });
            }
        }
示例#4
0
        public override void Configure(Container container)
        {
            _logger.Debug("Configuring");

            container.Adapter = _autofacIocAdapter;
            AppSettings       = container.Resolve <IAppSettings>();

            //Set JSON web services to return idiomatic JSON camelCase properties
            JsConfig.EmitCamelCaseNames = true;

            GlobalHtmlErrorHttpHandler = new RazorHandler("/oops");

            Configuration = container.Resolve <ISoundWordsConfiguration>();

            SetConfig(new HostConfig
            {
                DebugMode  = _hostingEnvironment.IsDevelopment() || Configuration.DebugMode,
                WebHostUrl = _configuration["SITE_URL"]
            });

            ConfigureAuth(container);

            MimeTypes.ExtensionMimeTypes["manifest"] = "text/cache-manifest";
            MimeTypes.ExtensionMimeTypes["appcache"] = "text/cache-manifest";
            MimeTypes.ExtensionMimeTypes["ico"]      = "image/x-icon";
            Config.AllowFileExtensions.Add("manifest");
            Config.AllowFileExtensions.Add("appcache");

            Plugins.Add(new RazorFormat());
            Plugins.Add(new ValidationFeature());
            Plugins.Add(_serverEventsFeature);

            IDbMigrator migrator = container.Resolve <IDbMigrator>();

            migrator.Migrate();

            OrmLiteConfig.InsertFilter += (command, o) =>
            {
                DbEntity entity = o as DbEntity;
                if (entity == null)
                {
                    return;
                }

                entity.CreatedOn  = DateTime.UtcNow;
                entity.ModifiedOn = DateTime.UtcNow;
            };

            OrmLiteConfig.UpdateFilter += (command, o) =>
            {
                DbEntity entity = o as DbEntity;
                if (entity == null)
                {
                    return;
                }

                entity.ModifiedOn = DateTime.UtcNow;
            };
        }
        private void Run(IDbMigrator migration)
        {
            using (var db = Configuration.Current.CommandSchedulerDbContext())
            {
                var results = migration.Migrate(db);

                Console.WriteLine(results.ToLogString());
            }
        }
示例#6
0
 public SqliteRepository(IDbConnection conn, IDbMigrator migrator)
 {
     _connection = conn as SQLiteConnection;
     if (_connection == null)
     {
         Throw.InvalidOperation("Connection provided to SqliteRepository must be of type SQLiteConnection");
     }
     migrator.Migrate();
 }
示例#7
0
 public FeatureRemoteService(
     IDbMigrator dbMigrator,
     ISeedSynchronizer seedSynchronizer,
     IViewDataSynchronizer viewDataSynchronizer,
     ILogger <FeatureRemoteService> logger)
 {
     _dbMigrator           = dbMigrator;
     _seedSynchronizer     = seedSynchronizer;
     _viewDataSynchronizer = viewDataSynchronizer;
     this.Logger           = logger;
 }
示例#8
0
 public TenantAppService(
     TenantManager tenantManager,
     RoleManager roleManager,
     EditionManager editionManager,
     IDbMigrator dbMigrator)
 {
     _tenantManager  = tenantManager;
     _roleManager    = roleManager;
     _editionManager = editionManager;
     _Migrator       = dbMigrator;
 }
        public SqlLocalDbTestEnvironmentBootstrapper(IDbMigrator dbMigrator,
            ITestDatabaseInstaller testDatabaseInstaller, ISqlLocalDbInstance sqlLocalDbInstance)
        {
            if (dbMigrator == null) throw new ArgumentNullException(nameof(dbMigrator));
            if (testDatabaseInstaller == null) throw new ArgumentNullException(nameof(testDatabaseInstaller));
            if (sqlLocalDbInstance == null) throw new ArgumentNullException(nameof(sqlLocalDbInstance));

            _dbMigrator = dbMigrator;
            _testDatabaseInstaller = testDatabaseInstaller;
            _sqlLocalDbInstance = sqlLocalDbInstance;
        }
示例#10
0
        public static void Start()
        {
            MayLilyAppHost appHost = new MayLilyAppHost();

            appHost.Init();

            // Migrate the database schema and seed it with sample data.
            IDbMigrator migrator = appHost.Container.Resolve <IDbMigrator>();

            migrator.MigrateSchema();
            migrator.SeedData();
        }
 private static ITestEnvironmentBootstrapper GetBootstrapper(IDbMigrator dbMigrator, ISqlLocalDbInstance sqlLocalDbInstance)
 {
     // Poor-man's Dependency Injection
     var embeddedTextResourceReader = new EmbeddedTextResourceReader();
     var sqlBatchExtractor = new SqlBatchExtractor();
     var tsqltInstaller = new EmbeddedResourceTsqltInstaller(embeddedTextResourceReader, sqlBatchExtractor);
     var sqlCommandExecutor = new SqlCommandExecutor();
     var databaseDropper = new DatabaseDropper(sqlCommandExecutor);
     var testDatabaseCreator = new TestDatabaseCreator(DatabaseName, databaseDropper, sqlCommandExecutor);
     var testDatabaseInstaller = new TestDatabaseInstaller(tsqltInstaller, testDatabaseCreator);
     return new SqlLocalDbTestEnvironmentBootstrapper(dbMigrator ?? new DefaultDbMigrator(),
         testDatabaseInstaller, sqlLocalDbInstance);
 }
示例#12
0
        public PostgreSqlNotificationRepository(string connectionString, IDbMigrator dbMigrator)
        {
            this.dbMigrator       = dbMigrator;
            this.connectionString = connectionString;

            Policy
            .Handle <Exception>()
            .WaitAndRetryAsync(10, r => TimeSpan.FromSeconds(5), (exeption, timeSpan) =>
            {
                Log.Error("Error connecting to database. Retrying in 10 seconds.");
            })
            .ExecuteAsync(InitializeDatabase)
            .Wait();
        }
 public static ITestEnvironment CreateWithSqlLocalDb(Assembly testAssembly, string testResourcePath, IDbMigrator dbMigrator = null, string sqlLocalDbInstanceName = null)
 {
     var sqlLocalDbInstance = GetSqlLocalDbInstance(sqlLocalDbInstanceName ?? "TsqltNet");
     
     sqlLocalDbInstance.Start();
     Debug.WriteLine("Started local DB instance.");
     Func<string, ITestRunner> testRunnerFactory = connectionString =>
     {
         var sqlTestExecutor = GetSqlTestExecutor();
         var testInstaller = GetTestInstaller(testAssembly, testResourcePath);
         return new SqlTestRunner(sqlTestExecutor, testInstaller, connectionString);
     };
     var bootstrapper = GetBootstrapper(dbMigrator, sqlLocalDbInstance);
     return new BootstrappedTestEnvironment(bootstrapper, testRunnerFactory);
 }
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IDbMigrator migrations)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app
            .UseStaticFiles()
            .UseRouting()
            .UseIdentityServer()
            .UseAuthorization()
            .UseDefaultEndpoints();

            migrations.Migrate();
        }
示例#15
0
        private static MigrationResult ApplyMigration(IDbMigrator migrator, DbContext connection)
        {
            var result = migrator.Migrate(connection);

            if (result.MigrationWasApplied)
            {
                connection.Database.ExecuteSqlCommand(
                    @"INSERT INTO PocketMigrator.AppliedMigrations
             (MigrationScope,
              MigrationVersion,
              Log,
              AppliedDate)
     VALUES
            (@migrationScope, 
             @migrationVersion,
             @log,
             GetDate())",
                    new SqlParameter("@migrationScope", migrator.MigrationScope),
                    new SqlParameter("@migrationVersion", migrator.MigrationVersion.ToString()),
                    new SqlParameter("@log", $"{migrator.GetType().AssemblyQualifiedName}\n\n{result.Log}".Trim()));
            }

            return(result);
        }
示例#16
0
 public UpgradeDatabaseCommandHandler(IDbMigrator dbMigrator, IMessageBus messageBus)
 {
     this.dbMigrator = dbMigrator;
     this.messageBus = messageBus;
 }
        private void Run(IDbMigrator migration)
        {
            using (var db = Configuration.Current.CommandSchedulerDbContext())
            {
                var results = migration.Migrate(db);

                Console.WriteLine(results.ToLogString());
            }
        }