示例#1
0
        private IJobFilterProvider CreateJobFilterProvider()
        {
            var filters = new JobFilterCollection();

            filters.Add(new ConsoleServerFilter(new ConsoleOptions()));
            filters.Add(_otherFilter.Object);
            return(filters);
        }
 static GlobalJobFilters()
 {
     Filters = new JobFilterCollection();
     Filters.Add(new CaptureCultureAttribute());
     Filters.Add(new AutomaticRetryAttribute());
     Filters.Add(new StatisticsHistoryAttribute());
     Filters.Add(new ContinuationsSupportAttribute());
 }
示例#3
0
 static GlobalJobFilters()
 {
     Filters = new JobFilterCollection();
     Filters.Add(new CaptureCultureAttribute());
     Filters.Add(new AutomaticRetryAttribute());
     Filters.Add(new StatisticsHistoryAttribute());
     Filters.Add(new ContinuationsSupportAttribute());
 }
示例#4
0
        private IJobFilterProvider CreateJobFilterProvider(bool followJobRetention = false)
        {
            var filters = new JobFilterCollection();

            filters.Add(new ConsoleServerFilter(new ConsoleOptions()
            {
                FollowJobRetentionPolicy = followJobRetention
            }));
            filters.Add(_otherFilter.Object);
            return(new JobFilterProviderCollection(filters));
        }
        private IJobFilterProvider CreateJobFilterProvider(bool followJobRetention = true)
        {
            var filters = new JobFilterCollection();

            filters.Add(new ConsoleApplyStateFilter(new ConsoleOptions()
            {
                FollowJobRetentionPolicy = followJobRetention
            }), int.MaxValue);
            filters.Add(_otherFilter.Object);
            return(new JobFilterProviderCollection(filters));
        }
 public void AddRejectsNonFilterInstances()
 {
     foreach (var instance in AddRejectsNonFilterInstancesData)
     {
         // Act + Assert
         Assert.Throws <InvalidOperationException>(() => _collection.Add(instance));
     }
 }
示例#7
0
        static GlobalJobFilters()
        {
            // ReSharper disable once UseObjectOrCollectionInitializer
            Filters = new JobFilterCollection();

            // Filters should be added with the `Add` method call: some 
            // of them indirectly use `GlobalJobFilters.Filters` property, 
            // and it is null, when we are using collection initializer.
            Filters.Add(new CaptureCultureAttribute());
            Filters.Add(new AutomaticRetryAttribute());
            Filters.Add(new StatisticsHistoryAttribute());
            Filters.Add(new ContinuationsSupportAttribute());
        }
        static GlobalJobFilters()
        {
            // ReSharper disable once UseObjectOrCollectionInitializer
            Filters = new JobFilterCollection();

            // Filters should be added with the `Add` method call: some
            // of them indirectly use `GlobalJobFilters.Filters` property,
            // and it is null, when we are using collection initializer.
            Filters.Add(new CaptureCultureAttribute());
            Filters.Add(new AutomaticRetryAttribute());
            Filters.Add(new StatisticsHistoryAttribute());
            Filters.Add(new ContinuationsSupportAttribute());
        }
 public static JobFilterCollection AutomaticRetry(this JobFilterCollection source, int attempts = 10, AttemptsExceededAction onAttemptsExceeded = AttemptsExceededAction.Fail, int[] delaysInSeconds = null)
 {
     source.Add(new AutomaticRetryAttribute()
     {
         Attempts           = attempts,
         OnAttemptsExceeded = onAttemptsExceeded,
         DelaysInSeconds    = delaysInSeconds
     });
     return(source);
 }
示例#10
0
        //https://github.com/HangfireIO/Hangfire/blob/a07ad0b9926923db75747d92796c5a9db39c1a87/samples/NetCoreSample/Program.cs
        static Task Main(string[] args)
        {
            //const string connectionString = "Server=(localdb)\\mssqllocaldb;Database=Hangfire;Trusted_Connection=True;MultipleActiveResultSets=true;";
            //const string connectionString = "Data Source=:hangfire.db;";
            //const string connectionString = "Data Source=:memory:;";
            const string connectionString = "";

            var hostBuilder = new HostBuilder()
                              .ConfigureLogging(x => x.AddConsole().SetMinimumLevel(LogLevel.Information))
                              .ConfigureServices((hostContext, services) =>
            {
                services.AddHangfireServer("console", connectionString, null, options => {
                    var jobFilters = new JobFilterCollection();
                    jobFilters.Add(new CaptureCultureAttribute());
                    jobFilters.Add(new AutomaticRetryAttribute());
                    jobFilters.Add(new StatisticsHistoryAttribute());
                    jobFilters.Add(new ContinuationsSupportAttribute());

                    jobFilters.Add(new HangfireLoggerAttribute());
                    jobFilters.Add(new HangfirePreserveOriginalQueueAttribute());

                    options.FilterProvider = new JobFilterProviderCollection(jobFilters, new JobFilterAttributeFilterProvider());
                });

                services.AddHostedService <RecurringJobsService>();
            });

            return(hostBuilder.RunConsoleAsync());
        }
 public static JobFilterCollection DisableConcurrentExecution(this JobFilterCollection source, int timeoutInSeconds = 300)
 {
     source.Add(new DisableConcurrentExecutionAttribute(timeoutInSeconds));
     return(source);
 }