Exemple #1
0
        public ConfigurationMiddleware(
            RequestDelegate next,
            IDictionary <string, object> properties)
        {
            var injected = properties?.ContainsKey("HangfireConfiguration") ?? false;

            if (injected)
            {
                _configuration = (HangfireConfiguration)properties["HangfireConfiguration"];
            }
            else
            {
                _configuration = new HangfireConfiguration();
                if (properties?.ContainsKey("HangfireConfigurationOptions") ?? false)
                {
                    _configuration.UseOptions((ConfigurationOptions)properties["HangfireConfigurationOptions"]);
                }
            }

            _options = _configuration.Options().ConfigurationOptions();

            _configurationApi = _configuration.ConfigurationApi();
            if (_options.PrepareSchemaIfNecessary)
            {
                using (var c = _options.ConnectionString.CreateConnection())
                    HangfireConfigurationSchemaInstaller.Install(c);
            }
        }
Exemple #2
0
        public void ShouldUpgradeFrom0ToLatest()
        {
            using var c = SelectDialect <DbConnection>(() => new SqlConnection(ConnectionString), () => new NpgsqlConnection(ConnectionString));
            HangfireConfigurationSchemaInstaller.Install(c);

            Assert.AreEqual(HangfireConfigurationSchemaInstaller.SchemaVersion, version());
        }
 private static void installSchema(DbConnection connection, int?schemaVersion)
 {
     if (schemaVersion is > 0)
     {
         HangfireConfigurationSchemaInstaller.Install(connection, schemaVersion.Value);
     }
     else
     {
         HangfireConfigurationSchemaInstaller.Install(connection);
     }
 }
 private void install(int?schemaVersion = null)
 {
     using var c = new SqlConnection(ConnectionStrings.SqlServer);
     if (schemaVersion.HasValue)
     {
         HangfireConfigurationSchemaInstaller.Install(c, schemaVersion.Value);
     }
     else
     {
         HangfireConfigurationSchemaInstaller.Install(c);
     }
 }