public static void AddHangfireWithMongoDb(this IServiceCollection services, Action <HangfireDatabaseSettings> settingsAction)
        {
            var databaseSettings = new HangfireDatabaseSettings();

            settingsAction(databaseSettings);

            services.AddHangfire(config =>
            {
                config.UseMongoStorage(
                    databaseSettings.ConnectionString,
                    new MongoStorageOptions
                {
                    MigrationOptions = new MongoMigrationOptions
                    {
                        BackupStrategy    = new NoneMongoBackupStrategy(),
                        MigrationStrategy = new MigrateMongoMigrationStrategy()
                    }
                });
            });
        }
        public static void AddHangfireWithSqlServer(this IServiceCollection services, Action <HangfireDatabaseSettings> settingsAction)
        {
            var databaseSettings = new HangfireDatabaseSettings();

            settingsAction(databaseSettings);

            services.AddHangfire(config =>
            {
                config.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
                .UseSimpleAssemblyNameTypeSerializer()
                .UseRecommendedSerializerSettings()
                .UseSqlServerStorage(databaseSettings.ConnectionString, new SqlServerStorageOptions
                {
                    SchemaName                   = databaseSettings.Schema ?? "hangfire",
                    CommandBatchMaxTimeout       = TimeSpan.FromMinutes(5),
                    SlidingInvisibilityTimeout   = TimeSpan.FromMinutes(5),
                    QueuePollInterval            = TimeSpan.Zero,
                    UseRecommendedIsolationLevel = true,
                    UsePageLocksOnDequeue        = true,
                    DisableGlobalLocks           = true,
                });
            });
        }