mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 09:46:30 +00:00
7807f5bc90
configure auto-scan folder and create hls files job WIP
27 lines
966 B
C#
27 lines
966 B
C#
using Azaion.Repository.Jobs;
|
|
using Quartz;
|
|
|
|
namespace Azaion.Repository.Extensions
|
|
{
|
|
public static class QuartzJobConfigHelper
|
|
{
|
|
public static IServiceCollectionQuartzConfigurator RegisterJob<T>(this IServiceCollectionQuartzConfigurator q,
|
|
string cron, TimeSpan? startForDebug = null) where T: BaseJob
|
|
{
|
|
var jobName = typeof(T).Name;
|
|
var jobKey = new JobKey(jobName);
|
|
q.AddJob<T>(jobKey);
|
|
q.AddTrigger(t => t.WithIdentity($"{jobName}_TRIGGER")
|
|
.ForJob(jobKey)
|
|
#if DEBUG
|
|
.StartAt(DateTimeOffset.Now.Add(startForDebug ?? TimeSpan.FromHours(10)))
|
|
.WithSimpleSchedule(b => b.WithIntervalInHours(5))
|
|
#else
|
|
.StartAt(DateTimeOffset.Now.AddMinutes(1))
|
|
.WithCronSchedule(cron, builder => builder.InTimeZone(TimeZoneInfo.Utc))
|
|
#endif
|
|
);
|
|
return q;
|
|
}
|
|
}
|
|
} |