From c5a9db661bc9cf3eddb851967c21e02b178274a3 Mon Sep 17 00:00:00 2001 From: honzapatCZ Date: Sat, 12 Sep 2026 10:47:24 +0200 Subject: [PATCH] qauartz update --- AutoScan.cs | 4 ++-- Models/DateTimeOffsetFrame.cs | 4 ++-- Utils/DateTimeConverter.cs | 2 +- Utils/Extensions.cs | 4 +++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/AutoScan.cs b/AutoScan.cs index b398f16..0ced870 100644 --- a/AutoScan.cs +++ b/AutoScan.cs @@ -30,7 +30,7 @@ public interface ISettings public static class AutoScan { - public static void RegisterJobs(this IServiceCollection collection, IServiceCollectionQuartzConfigurator conf) + public static void RegisterJobs(this IServiceCollection collection, IQuartzBuilder conf) { var jobs = typeof(IRecurringService).Assembly.GetTypes().Where(x => x.IsAssignableTo(typeof(IRecurringService)) && x != typeof(IRecurringService)).ToList(); @@ -46,7 +46,7 @@ public static class AutoScan } Console.WriteLine("Adding job: " + jobKey.Name + " with cron: " + cron); - conf.AddJob(job, jobKey).AddTrigger(x => x.ForJob(jobKey).WithCronSchedule(cron).StartNow()); + conf.AddJob(job, x => x.WithIdentity(jobKey)).AddTrigger(x => x.ForJob(jobKey).WithCronSchedule(cron).StartNow()); } } public static void RegisterServices(this IServiceCollection collection) diff --git a/Models/DateTimeOffsetFrame.cs b/Models/DateTimeOffsetFrame.cs index 3825a99..6e15dea 100644 --- a/Models/DateTimeOffsetFrame.cs +++ b/Models/DateTimeOffsetFrame.cs @@ -28,9 +28,9 @@ public class DateTimeOffsetFrame : IEquatable return e => dateAcessor.Compile()(e) >= frame.FromDate && dateAcessor.Compile()(e) <= frame.ToDate; } - public DateOnlyFrame ToDateOnlyFrame() + public DateOnlyFrame ToDateOnlyFrame(TimeZoneInfo timeZone) { - return new DateOnlyFrame(FromDate.ToDateOnly(), ToDate.ToDateOnly()); + return new DateOnlyFrame(FromDate.ToDateOnly(timeZone), ToDate.ToDateOnly(timeZone)); } public bool Equals(DateTimeOffsetFrame? other) { diff --git a/Utils/DateTimeConverter.cs b/Utils/DateTimeConverter.cs index b6dbb10..6e37413 100644 --- a/Utils/DateTimeConverter.cs +++ b/Utils/DateTimeConverter.cs @@ -8,7 +8,7 @@ namespace NejCommon.Utils { public override DateOnly Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { - return DateOnly.Parse(reader.GetString() ?? string.Empty, CultureInfo.InvariantCulture); + return DateOnly.TryParse(reader.GetString() ?? string.Empty, CultureInfo.InvariantCulture, out var date) ? date : throw new JsonException("Invalid DateOnly format, expected 'yyyy-MM-dd'."); } public override void Write(Utf8JsonWriter writer, DateOnly value, JsonSerializerOptions options) diff --git a/Utils/Extensions.cs b/Utils/Extensions.cs index d555716..890f9e6 100644 --- a/Utils/Extensions.cs +++ b/Utils/Extensions.cs @@ -106,10 +106,12 @@ public static class Extensions [Projectable] public static DateOnly ToDateOnly(this DateTime date) => DateOnly.FromDateTime(date); [Projectable] - public static DateOnly ToDateOnly(this DateTimeOffset date) => DateOnly.FromDateTime(date.DateTime); + public static DateOnly ToDateOnly(this DateTimeOffset date, TimeZoneInfo timeZone) => DateOnly.FromDateTime(date.ToDateTime(timeZone)); [Projectable] public static DateTime ToDateTime(this DateOnly date) => new DateTime(date.Year, date.Month, date.Day); [Projectable] + public static DateTime ToDateTime(this DateTimeOffset date, TimeZoneInfo timeZone) => TimeZoneInfo.ConvertTime(date, timeZone).DateTime; + [Projectable] public static decimal Round(this decimal value, int decimals = 2) => Math.Round(value, decimals); [Projectable] public static decimal Floor(this decimal value, int decimals = 2) => Math.Floor(value * (decimal)Math.Pow(10, decimals)) / (decimal)Math.Pow(10, decimals);