2023-03-31 23:00:15 -07:00
|
|
|
using Hangfire;
|
|
|
|
using Newsbot.Collector.Domain.Consts;
|
|
|
|
using Newsbot.Collector.Domain.Models.Config;
|
|
|
|
using Newsbot.Collector.Services.Jobs;
|
|
|
|
|
|
|
|
namespace Newsbot.Collector.Api;
|
|
|
|
|
2023-04-01 08:53:34 -07:00
|
|
|
public static class BackgroundJobs
|
2023-03-31 23:00:15 -07:00
|
|
|
{
|
|
|
|
public static void SetupRecurringJobs(IConfiguration configuration)
|
|
|
|
{
|
2023-04-01 08:53:34 -07:00
|
|
|
RecurringJob.AddOrUpdate<RssWatcherJob>("RSS", x =>
|
|
|
|
x.InitAndExecute(new RssWatcherJobOptions
|
2023-03-31 23:00:15 -07:00
|
|
|
{
|
2023-04-01 08:53:34 -07:00
|
|
|
ConnectionString = configuration.GetValue<string>(ConfigConst.ConnectionStringDatabase),
|
|
|
|
OpenTelemetry = configuration.GetValue<string>(ConfigConst.ConnectionStringOpenTelemetry),
|
2023-04-01 16:22:44 -07:00
|
|
|
IsEnabled = configuration.GetValue<bool>(ConfigConst.RssIsEnabled)
|
2023-03-31 23:00:15 -07:00
|
|
|
}), "15 0-23 * * *");
|
2023-04-01 08:53:34 -07:00
|
|
|
|
2023-03-31 23:00:15 -07:00
|
|
|
RecurringJob.AddOrUpdate<DiscordNotificationJob>("Discord Alerts", x =>
|
|
|
|
x.InitAndExecute(new DiscordNotificationJobOptions
|
|
|
|
{
|
2023-04-01 08:53:34 -07:00
|
|
|
ConnectionString = configuration.GetValue<string>(ConfigConst.ConnectionStringDatabase),
|
|
|
|
OpenTelemetry = configuration.GetValue<string>(ConfigConst.ConnectionStringOpenTelemetry),
|
|
|
|
IsEnabled = configuration.GetValue<bool>(ConfigConst.DiscordNotificationsEnabled),
|
2023-03-31 23:00:15 -07:00
|
|
|
}), "5/10 * * * *");
|
|
|
|
}
|
|
|
|
}
|