新增rss功能
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
|
||||
|
||||
namespace Yes.Application.Core.HostedServices
|
||||
{
|
||||
public class HangfireJobRegistrationService : BackgroundService
|
||||
{
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly BlogSettings _settings;
|
||||
|
||||
public HangfireJobRegistrationService(
|
||||
IServiceProvider serviceProvider,
|
||||
IOptionsMonitor<BlogSettings> options)
|
||||
{
|
||||
_serviceProvider = serviceProvider;
|
||||
_settings = options.CurrentValue;
|
||||
}
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
using var scope = _serviceProvider.CreateScope();
|
||||
var recurringJobManager = scope.ServiceProvider.GetRequiredService<IRecurringJobManager>();
|
||||
|
||||
var intervalHours = _settings.RssGenerationIntervalHours;
|
||||
|
||||
//recurringJobManager.AddOrUpdate<RssGenerationJob>(
|
||||
// nameof(RssGenerationJob),
|
||||
// x => x.Execute(),
|
||||
// Cron.Hourly(intervalHours)
|
||||
//);
|
||||
|
||||
recurringJobManager.AddOrUpdate<RssGenerationJob>(
|
||||
nameof(RssGenerationJob),
|
||||
x => x.Execute(),
|
||||
Cron.Minutely
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user