2023-03-31 23:00:15 -07:00
|
|
|
using Hangfire;
|
|
|
|
using Newsbot.Collector.Domain.Consts;
|
2023-04-10 22:59:13 -07:00
|
|
|
using Newsbot.Collector.Domain.Models.Config;
|
2023-03-31 23:00:15 -07:00
|
|
|
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-08 09:30:59 -07:00
|
|
|
RecurringJob.AddOrUpdate<RssWatcherJob>("RSS", x =>
|
2023-04-01 08:53:34 -07:00
|
|
|
x.InitAndExecute(new RssWatcherJobOptions
|
2023-04-08 09:30:59 -07:00
|
|
|
{
|
|
|
|
ConnectionString = configuration.GetValue<string>(ConfigConst.ConnectionStringDatabase),
|
|
|
|
OpenTelemetry = configuration.GetValue<string>(ConfigConst.ConnectionStringOpenTelemetry),
|
|
|
|
IsEnabled = configuration.GetValue<bool>(ConfigConst.RssIsEnabled)
|
|
|
|
}), "15 0-23 * * *");
|
|
|
|
|
|
|
|
RecurringJob.AddOrUpdate<YoutubeWatcherJob>("Youtube", x => x.InitAndExecute(new YoutubeWatcherJobOptions
|
2023-03-31 23:00:15 -07:00
|
|
|
{
|
2023-04-08 09:30:59 -07:00
|
|
|
DatabaseConnectionString = configuration.GetValue<string>(ConfigConst.ConnectionStringDatabase),
|
|
|
|
OpenTelemetryConnectionString = configuration.GetValue<string>(ConfigConst.ConnectionStringOpenTelemetry),
|
|
|
|
IsEnabled = configuration.GetValue<bool>(ConfigConst.YoutubeIsEnable)
|
|
|
|
}), "20 0-23 * * *");
|
|
|
|
|
2023-04-10 22:59:13 -07:00
|
|
|
RecurringJob.AddOrUpdate<CodeProjectWatcherJob>("CodeProjects", x =>
|
|
|
|
x.InitAndExecute(new CodeProjectWatcherJobOptions
|
|
|
|
{
|
|
|
|
ConnectionStrings = configuration.GetSection(ConfigConst.SectionConnectionStrings)
|
|
|
|
.Get<ConfigSectionConnectionStrings>(),
|
|
|
|
FeaturePullCommits = true,
|
|
|
|
FeaturePullReleases = true
|
|
|
|
}), "25 0-23 * * *");
|
|
|
|
|
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),
|
2023-04-08 09:30:59 -07:00
|
|
|
IsEnabled = configuration.GetValue<bool>(ConfigConst.DiscordNotificationsEnabled)
|
2023-03-31 23:00:15 -07:00
|
|
|
}), "5/10 * * * *");
|
|
|
|
}
|
|
|
|
}
|