public void Configure(IGlobalConfiguration hangfireGlobalConfiguration) { var configuration = global::Apexnet.JobQueue.Configuration.RedisStorage.Instance; var options = ConfigureHangfireRedisStorageOptions(configuration.RedisStorageOptions); hangfireGlobalConfiguration.UseRedisStorage(configuration.ConnectionString, options); }
/// <summary> /// Builds <see cref="RecurringJob"/> automatically by using multiple JSON configuration files. /// To the Hangfire client, alternatively way is to use the class <seealso cref="CronJob"/> to add or update <see cref="RecurringJob"/>. /// </summary> /// <param name="configuration"><see cref="IGlobalConfiguration"/>.</param> /// <param name="jsonFiles">The array of json files.</param> /// <param name="reloadOnChange">Whether the <see cref="RecurringJob"/> should be reloaded if the file changes.</param> /// <returns></returns> public static IGlobalConfiguration UseRecurringJob(this IGlobalConfiguration configuration, string[] jsonFiles, bool reloadOnChange = true) { if (jsonFiles == null) { throw new ArgumentNullException(nameof(jsonFiles)); } CronJob.AddOrUpdate(jsonFiles, reloadOnChange); return(configuration); }
/// <summary> /// Builds <see cref="RecurringJob"/> automatically by using a JSON configuration. /// To the Hangfire client, alternatively way is to use the class <seealso cref="CronJob"/> to add or update <see cref="RecurringJob"/>. /// </summary> /// <param name="configuration"><see cref="IGlobalConfiguration"/>.</param> /// <param name="jsonFile">Json file for <see cref="RecurringJob"/> configuration.</param> /// <param name="reloadOnChange">Whether the <see cref="RecurringJob"/> should be reloaded if the file changes.</param> /// <returns><see cref="IGlobalConfiguration"/></returns> public static IGlobalConfiguration UseRecurringJob(this IGlobalConfiguration configuration, string jsonFile, bool reloadOnChange = true) { if (string.IsNullOrWhiteSpace(jsonFile)) { throw new ArgumentNullException(nameof(jsonFile)); } CronJob.AddOrUpdate(jsonFile, reloadOnChange); return(configuration); }
/// <summary> /// Builds <see cref="RecurringJob"/> automatically within specified interface or class. /// To the Hangfire client, alternatively way is to use the class <seealso cref="CronJob"/> to add or update <see cref="RecurringJob"/>. /// </summary> /// <param name="configuration"><see cref="IGlobalConfiguration"/></param> /// <param name="typesProvider">The provider to get specified interfaces or class.</param> /// <returns><see cref="IGlobalConfiguration"/></returns> public static IGlobalConfiguration UseRecurringJob(this IGlobalConfiguration configuration, Func <IEnumerable <Type> > typesProvider) { if (typesProvider == null) { throw new ArgumentNullException(nameof(typesProvider)); } CronJob.AddOrUpdate(typesProvider); return(configuration); }
public static IGlobalConfiguration <ColouredConsoleLogProvider> UseColouredConsoleLogProvider( this IGlobalConfiguration configuration, LogLevel minLevel) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } return(configuration.UseLogProvider(new ColouredConsoleLogProvider(minLevel))); }
/// <summary> /// Builds <see cref="RecurringJob"/> automatically with <seealso cref="IConfigurationProvider"/>. /// To the Hangfire client, alternatively way is to use the class <seealso cref="CronJob"/> to add or update <see cref="RecurringJob"/>. /// </summary> /// <param name="configuration"><see cref="IGlobalConfiguration"/>.</param> /// <param name="provider"><see cref="IConfigurationProvider"/></param> /// <returns><see cref="IGlobalConfiguration"/>.</returns> public static IGlobalConfiguration UseRecurringJob(this IGlobalConfiguration configuration, IConfigurationProvider provider) { if (provider == null) { throw new ArgumentNullException(nameof(provider)); } CronJob.AddOrUpdate(provider); return(configuration); }
public Expression MapExpression( IGlobalConfiguration configurationProvider, ProfileMap profileMap, MemberMap memberMap, Expression sourceExpression, Expression destExpression ) => Expression.Call( destExpression.Type.GetMethod("Parse", new[] { typeof(string) }), sourceExpression );
public void ConfigureHangfireBuilder(IGlobalConfiguration builder) { if (_Type == DatabaseType.Sqlite) { builder.UseMemoryStorage(); //Sql provider does not support multiple workers } else if (_Type == DatabaseType.Postgres) { builder.UsePostgreSqlStorage(_ConnectionString); } }
public static IGlobalConfiguration <ElmahLogProvider> UseElmahLogProvider( [NotNull] this IGlobalConfiguration configuration, LogLevel minLevel) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } return(configuration.UseLogProvider(new ElmahLogProvider(minLevel))); }
private static void ConfigureHangfire(IServiceProvider provider, IGlobalConfiguration configuration) => configuration .SetDataCompatibilityLevel(CompatibilityLevel.Version_170) .UseDefaultTypeSerializer() .UseRecommendedSerializerSettings() .UseActivator(new ServiceJobActivator(provider.GetService <IServiceScopeFactory>())) .UseFilter(provider.GetService <HangfireJobFilter>()) .UseFilter(new AutomaticRetryAttribute() { Attempts = 0 });
public Expression MapExpression(IGlobalConfiguration configurationProvider, ProfileMap profileMap, MemberMap memberMap, Expression sourceExpression, Expression destExpression) { var destinationType = destExpression.Type; var sourceToString = Call(sourceExpression, ObjectToString); var result = Variable(destinationType, "destinationEnumValue"); var ignoreCase = True; var tryParse = Call(TryParseMethod.MakeGenericMethod(destinationType), sourceToString, ignoreCase, result); return(Block(new[] { result }, Condition(tryParse, result, Convert(sourceExpression, destinationType)))); }
public Expression MapExpression( IGlobalConfiguration configurationProvider, ProfileMap profileMap, MemberMap memberMap, Expression sourceExpression, Expression destExpression ) => Expression.Multiply( Expression.Convert(sourceExpression, typeof(int)), Expression.Constant(1000) );
public static IGlobalConfiguration <RedisStorage> UseRedisStorage( [NotNull] this IGlobalConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } var storage = new RedisStorage(); return(configuration.UseStorage(storage)); }
public static IGlobalConfiguration <RavenStorage> UseEmbeddedRavenStorage(this IGlobalConfiguration configuration, RavenStorageOptions options) { configuration.ThrowIfNull("configuration"); options.ThrowIfNull("options"); Repository.Embedded = true; var storage = new RavenStorage(options); return(configuration.UseStorage(storage)); }
/// <summary> /// Tells the bootstrapper to use PostgreSQL as a job storage /// with the given options, that can be accessed using the specified /// connection string or its name. /// </summary> /// <param name="configuration">Configuration</param> /// <param name="nameOrConnectionString">Connection string or its name</param> /// <param name="options">Advanced options</param> public static PostgreSqlStorage UsePostgreSqlStorage( this IGlobalConfiguration configuration, string nameOrConnectionString, PostgreSqlStorageOptions options) { var storage = new PostgreSqlStorage(nameOrConnectionString, options); configuration.UseStorage(storage); return(storage); }
/// <summary> /// 使用CSRedis 作为hangfire存储 /// </summary> /// <param name="configuration"></param> /// <param name="redisClient"></param> /// <param name="options"></param> /// <returns></returns> public static IGlobalConfiguration <RedisStorage> UseRedisStorage( [NotNull] this IGlobalConfiguration configuration, CSRedis.CSRedisClient redisClient, RedisStorageOptions options = null) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } var storage = new RedisStorage(redisClient, options); return(configuration.UseStorage(storage)); }
public static IGlobalConfiguration <RavenStorage> UseRavenStorage(this IGlobalConfiguration configuration, string connectionString) { configuration.ThrowIfNull("configuration"); connectionString.ThrowIfNull("connectionString"); Repository.ConnectionString = connectionString; var storage = new RavenStorage(); return(configuration.UseStorage(storage)); }
public static IGlobalConfiguration UseRecommendedSerializerSettings( [NotNull] this IGlobalConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } SerializationHelper.SetUserSerializerSettings(SerializationHelper.GetInternalSettings()); return(configuration); }
internal static void Seal(this Features <IRuntimeFeature> features, IGlobalConfiguration configurationProvider) { if (features.Count == 0) { return; } foreach (var feature in features) { feature.Seal(configurationProvider); } }
public RequestLogger( IImplementationsContainer implementationsContainer, IHttpContextAccessor httpContextAccessor, ILogger <RequestLogger> logger, IGlobalConfiguration globalConfiguration) { _implementationsContainer = implementationsContainer; _dbContext = _implementationsContainer.GetLobDbContext <LobToolsDbContext>(httpContextAccessor.HttpContext); _logger = logger; _globalConfiguration = globalConfiguration; }
/// <summary> /// Configure Hangfire to use MongoDB storage /// </summary> /// <param name="configuration">Configuration</param> /// <param name="connectionString">Connection string for Mongo database, for example 'mongodb://*****:*****@host:port'</param> /// <param name="databaseName">Name of database at Mongo server</param> /// <param name="options">Storage options</param> /// <returns></returns> public static MongoStorage UseMongoStorage(this IGlobalConfiguration configuration, string connectionString, string databaseName, MongoStorageOptions options) { var storage = new MongoStorage(connectionString, databaseName, options); configuration.UseStorage(storage); return(storage); }
public static IGlobalConfiguration UseMediator(this IGlobalConfiguration config, IMediator mediator) { config.UseActivator(new MediatorJobActivator(mediator)); JobHelper.SetSerializerSettings(new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Objects, }); return(config); }
/// <summary> /// Configure Hangfire to use MongoDB storage /// </summary> /// <param name="configuration">Configuration</param> /// <param name="mongoClientSettings">Client settings for Mongo</param> /// <param name="databaseName">Name of database at Mongo server</param> /// <param name="options">Storage options</param> /// <returns></returns> public static MongoStorage UseMongoStorage(this IGlobalConfiguration configuration, MongoClientSettings mongoClientSettings, string databaseName, MongoStorageOptions options) { var storage = new MongoStorage(mongoClientSettings, databaseName, options); configuration.UseStorage(storage); return(storage); }
public static IGlobalConfiguration UseMediatR(this IGlobalConfiguration configuration) { var jsonSettings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }; configuration.UseSerializerSettings(jsonSettings); return(configuration); }
/// <summary> /// /// </summary> /// <param name="configuration"></param> /// <returns></returns> /// <exception cref="ArgumentNullException"></exception> public static IGlobalConfiguration <SQLiteStorage> UseSQLiteStorage( [NotNull] this IGlobalConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } var storage = new SQLiteStorage("Hangfire.db", new SQLiteStorageOptions()); return(configuration.UseStorage(storage)); }
public static IGlobalConfiguration UseDashboardExtensions(this IGlobalConfiguration config, [NotNull] params string[] assemblies) { if (assemblies == null) { throw new ArgumentNullException(nameof(assemblies)); } StorageAssemblySingleton.GetInstance().SetCurrentAssembly(assemblies: assemblies.Select(x => Type.GetType(x).Assembly).ToArray()); //PeriodicJobBuilder.GetAllJobs(); CreateManagmentJob(); return(config); }
public static IGlobalConfiguration UseDashboardExtensions(this IGlobalConfiguration config, bool includeReferences = false, [NotNull] params Assembly[] assemblies) { if (assemblies == null) { throw new ArgumentNullException(nameof(assemblies)); } StorageAssemblySingleton.GetInstance().SetCurrentAssembly(includeReferences, assemblies); //PeriodicJobBuilder.GetAllJobs(); CreateManagmentJob(); return(config); }
public static IGlobalConfiguration <EFCoreStorage> UseEFCoreStorage( [NotNull] this IGlobalConfiguration configuration, [NotNull] Action <DbContextOptionsBuilder> optionsAction, [NotNull] EFCoreStorageOptions options) { if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } return(configuration.UseStorage(new EFCoreStorage(optionsAction, options))); }
/// <summary> /// Adds a database creator to the job storage. /// </summary> /// <param name="configuration"> /// The storage configuration to add the database creator to. /// </param> /// <returns> /// A job storage configuration. /// </returns> /// <exception cref="ArgumentNullException"> /// <paramref name="configuration"/> is <see langword="null"/>. /// </exception> public static IGlobalConfiguration <EFCoreStorage> UseDatabaseCreator( [NotNull] this IGlobalConfiguration <EFCoreStorage> configuration) { if (configuration is null) { throw new ArgumentNullException(nameof(configuration)); } configuration.Entry.RegisterDatabaseInitializer( context => context.Database.EnsureCreated()); return(configuration); }
/// <summary> /// These settings is used to serialize user data like arguments or parameters. /// You can use <see cref="SerializationHelper.Serialize{T}(T, SerializationOption)"/> with <see cref="SerializationOption.User"/> option /// to serialize with specified settings /// </summary> public static IGlobalConfiguration UseSerializerSettings( [NotNull] this IGlobalConfiguration configuration, [CanBeNull] JsonSerializerSettings settings) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } SerializationHelper.SetUserSerializerSettings(settings); return(configuration); }
public static IGlobalConfiguration UseTypeSerializer( [NotNull] this IGlobalConfiguration configuration, [CanBeNull] Func <Type, string> typeSerializer) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } TypeHelper.CurrentTypeSerializer = typeSerializer; return(configuration); }
private static void ConfigureHangfire(IGlobalConfiguration config, IContainer container) { config.UseAutofacActivator(container); }
public void Configure(IGlobalConfiguration hangfireGlobalConfiguration) { hangfireGlobalConfiguration.UseMemoryStorage(); }