From ca6b0b19d6f284a7b9782a2f5e41fb1dea59e799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Furkan=20G=C3=BCng=C3=B6r?= Date: Sat, 5 Feb 2022 23:15:20 +0300 Subject: [PATCH 1/9] =?UTF-8?q?=F0=9F=94=A8=20Add=20CronFormat=20property?= =?UTF-8?q?=20to=20the=20ICronConfiguration=20object?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/EasyCronJob.Abstractions/ICronConfiguration.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/EasyCronJob.Abstractions/ICronConfiguration.cs b/src/EasyCronJob.Abstractions/ICronConfiguration.cs index 6dc9e3b..95b6f93 100644 --- a/src/EasyCronJob.Abstractions/ICronConfiguration.cs +++ b/src/EasyCronJob.Abstractions/ICronConfiguration.cs @@ -1,4 +1,5 @@ -using System; +using Cronos; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -23,5 +24,11 @@ public interface ICronConfiguration /// TimeZone Information /// public TimeZoneInfo TimeZoneInfo { get; set; } + + /// + /// Cron Format + /// Default + /// + public CronFormat CronFormat { get; set; } } } From dfd9b95eb28080de56bfa900954416f8ea5991e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Furkan=20G=C3=BCng=C3=B6r?= Date: Sat, 5 Feb 2022 23:16:02 +0300 Subject: [PATCH 2/9] =?UTF-8?q?=F0=9F=94=A8=20Add=20CronFormat=20property?= =?UTF-8?q?=20to=20the=20CronConfiguration=20object.=20This=20property=20s?= =?UTF-8?q?et=20default=20Standart=20value?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/EasyCronJob.Abstractions/CronConfiguration.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/EasyCronJob.Abstractions/CronConfiguration.cs b/src/EasyCronJob.Abstractions/CronConfiguration.cs index 8a4efc0..c07098a 100644 --- a/src/EasyCronJob.Abstractions/CronConfiguration.cs +++ b/src/EasyCronJob.Abstractions/CronConfiguration.cs @@ -1,4 +1,5 @@ -using System; +using Cronos; +using System; namespace EasyCronJob.Abstractions { @@ -17,5 +18,11 @@ public class CronConfiguration : ICronConfiguration /// Represents any time zone in the world. /// public TimeZoneInfo TimeZoneInfo { get; set; } + + /// + /// Cron Format + /// Default + /// + public CronFormat CronFormat { get; set; } = CronFormat.Standard; } } From 50550c282383d902a9579bee79eec59c11093521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Furkan=20G=C3=BCng=C3=B6r?= Date: Sun, 6 Feb 2022 14:40:36 +0300 Subject: [PATCH 3/9] =?UTF-8?q?=F0=9F=94=A8=20Add=20CronFormat=20property?= =?UTF-8?q?=20to=20the=20CronJobService=20ctor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/EasyCronJob.Abstractions/CronJobService.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/EasyCronJob.Abstractions/CronJobService.cs b/src/EasyCronJob.Abstractions/CronJobService.cs index 9feab5a..77cbfdb 100644 --- a/src/EasyCronJob.Abstractions/CronJobService.cs +++ b/src/EasyCronJob.Abstractions/CronJobService.cs @@ -16,11 +16,13 @@ public abstract class CronJobService : IHostedService, IDisposable { private System.Timers.Timer timer; private readonly TimeZoneInfo timeZoneInfo; + private readonly CronFormat cronFormat; private readonly CronExpression cronExpression; - protected CronJobService(string cronExpression, TimeZoneInfo timeZoneInfo) + protected CronJobService(string cronExpression, TimeZoneInfo timeZoneInfo, CronFormat cronFormat = CronFormat.Standard) { this.timeZoneInfo = timeZoneInfo; - this.cronExpression = CronExpression.Parse(cronExpression); + this.cronFormat = cronFormat; + this.cronExpression = CronExpression.Parse(cronExpression, this.cronFormat); } protected virtual async Task ScheduleJob(CancellationToken cancellationToken) From 15f8662269472bb6651e59ef2ba6fd97d24439a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Furkan=20G=C3=BCng=C3=B6r?= Date: Sun, 6 Feb 2022 14:41:33 +0300 Subject: [PATCH 4/9] =?UTF-8?q?=F0=9F=94=A8=20Implement=20cron=20format=20?= =?UTF-8?q?for=20Auto=20Configurer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/EasyCronJob.AutoConfigurer/Startup.cs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/EasyCronJob.AutoConfigurer/Startup.cs b/src/EasyCronJob.AutoConfigurer/Startup.cs index d074c4c..00aec12 100644 --- a/src/EasyCronJob.AutoConfigurer/Startup.cs +++ b/src/EasyCronJob.AutoConfigurer/Startup.cs @@ -1,4 +1,5 @@ -using EasyCronJob.Abstractions; +using Cronos; +using EasyCronJob.Abstractions; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; @@ -43,12 +44,13 @@ private static List FindCronJobServices() /// /// Returns /// - private static Tuple FindServiceParameter(IServiceCollection services, string serviceName) + private static Tuple FindServiceParameter(IServiceCollection services, string serviceName) { var serviceProvider = services.BuildServiceProvider(); var configurationObject = serviceProvider.GetRequiredService(); string cronExpression = configurationObject.GetValue("CronJobs:" + serviceName + ":CronExpression"); string info = configurationObject.GetValue("CronJobs:" + serviceName + ":TimeZoneInfo"); + string cronFormat = configurationObject.GetValue("CronJobs:" + serviceName + ":CronFormat"); TimeZoneInfo timeZoneInfo; switch (info) { @@ -62,7 +64,21 @@ private static Tuple FindServiceParameter(IServiceCollecti timeZoneInfo = TimeZoneInfo.Local; break; } - return new Tuple(cronExpression, timeZoneInfo); + CronFormat format = CronFormat.Standard; + switch (cronFormat) + { + case "Standard": + format = CronFormat.Standard; + break; + case "IncludeSeconds": + format = CronFormat.IncludeSeconds; + break; + default: + format = CronFormat.Standard; + break; + } + + return new Tuple(cronExpression, timeZoneInfo, format); } /// @@ -136,6 +152,7 @@ private static IServiceCollection ConfigureCronServices(IServiceCollection servi { findedService.GetType().GetProperty("CronExpression").SetValue(findedService, cronParameters.Item1); findedService.GetType().GetProperty("TimeZoneInfo").SetValue(findedService, cronParameters.Item2); + findedService.GetType().GetProperty("CronFormat").SetValue(findedService, cronParameters.Item3); } ctorServices.Add(findedService); } From 6e972fb56110acd86712cc1f1db22af3d2a75b27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Furkan=20G=C3=BCng=C3=B6r?= Date: Sun, 6 Feb 2022 14:42:23 +0300 Subject: [PATCH 5/9] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Change=20sample=20jobs?= =?UTF-8?q?=20from=20standart=20cron=20format=20to=20include=20second=20cr?= =?UTF-8?q?on=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EasyCron.Sample/Jobs/ConsoleCronJob.cs | 2 +- samples/EasyCron.Sample/Startup.cs | 26 ++++++++++--------- samples/EasyCron.Sample/appsettings.json | 8 +++--- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/samples/EasyCron.Sample/Jobs/ConsoleCronJob.cs b/samples/EasyCron.Sample/Jobs/ConsoleCronJob.cs index 68274b0..64f8e0f 100644 --- a/samples/EasyCron.Sample/Jobs/ConsoleCronJob.cs +++ b/samples/EasyCron.Sample/Jobs/ConsoleCronJob.cs @@ -13,7 +13,7 @@ public class ConsoleCronJob : CronJobService private readonly ILogger logger; public ConsoleCronJob(ICronConfiguration cronConfiguration, ILogger logger) - : base(cronConfiguration.CronExpression,cronConfiguration.TimeZoneInfo) + : base(cronConfiguration.CronExpression,cronConfiguration.TimeZoneInfo, cronConfiguration.CronFormat) { this.logger = logger; } diff --git a/samples/EasyCron.Sample/Startup.cs b/samples/EasyCron.Sample/Startup.cs index 1f54cf2..3a3b352 100644 --- a/samples/EasyCron.Sample/Startup.cs +++ b/samples/EasyCron.Sample/Startup.cs @@ -36,20 +36,22 @@ public void ConfigureServices(IServiceCollection services) c.SwaggerDoc("v1", new OpenApiInfo { Title = "EasyCron.Sample", Version = "v1" }); }); - services.ApplyResulation(options => - { - options.CronExpression = "* * * * *"; - options.TimeZoneInfo = TimeZoneInfo.Local; - }); - services.ApplyResulation(options => - { - options.CronExpression = "* * * * *"; - options.TimeZoneInfo = TimeZoneInfo.Local; - }); + //services.ApplyResulation(options => + //{ + // options.CronExpression = "*/10 * * * * *"; + // options.TimeZoneInfo = TimeZoneInfo.Local; + // options.CronFormat = Cronos.CronFormat.IncludeSeconds; + //}); + //services.ApplyResulation(options => + //{ + // options.CronExpression = "* * * * *"; + // options.TimeZoneInfo = TimeZoneInfo.Local; + // options.CronFormat = Cronos.CronFormat.Standard; + //}); - //services.InitializeCronServices(); - //services.AutoConfigurer(); + services.InitializeCronServices(); + services.AutoConfigurer(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. diff --git a/samples/EasyCron.Sample/appsettings.json b/samples/EasyCron.Sample/appsettings.json index 1ecbe97..a7aa618 100644 --- a/samples/EasyCron.Sample/appsettings.json +++ b/samples/EasyCron.Sample/appsettings.json @@ -9,12 +9,14 @@ "AllowedHosts": "*", "CronJobs": { "ConsoleCronJob": { - "CronExpression": "* * * * *", - "TimeZoneInfo": "Local" + "CronExpression": "*/10 * * * * *", + "TimeZoneInfo": "Local", + "CronFormat": "IncludeSeconds" }, "MyJob": { "CronExpression": "*/2 * * * *", - "TimeZoneInfo": "Local" + "TimeZoneInfo": "Local", + "CronFormat": "Standard" } } } From 16db13417b0fbbd3315ad23534b0b52644042ea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Furkan=20G=C3=BCng=C3=B6r?= Date: Sun, 6 Feb 2022 14:44:17 +0300 Subject: [PATCH 6/9] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Re-Active=20job=20init?= =?UTF-8?q?ializer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- samples/EasyCron.Sample/Startup.cs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/samples/EasyCron.Sample/Startup.cs b/samples/EasyCron.Sample/Startup.cs index 3a3b352..032363b 100644 --- a/samples/EasyCron.Sample/Startup.cs +++ b/samples/EasyCron.Sample/Startup.cs @@ -36,22 +36,22 @@ public void ConfigureServices(IServiceCollection services) c.SwaggerDoc("v1", new OpenApiInfo { Title = "EasyCron.Sample", Version = "v1" }); }); - //services.ApplyResulation(options => - //{ - // options.CronExpression = "*/10 * * * * *"; - // options.TimeZoneInfo = TimeZoneInfo.Local; - // options.CronFormat = Cronos.CronFormat.IncludeSeconds; - //}); - //services.ApplyResulation(options => - //{ - // options.CronExpression = "* * * * *"; - // options.TimeZoneInfo = TimeZoneInfo.Local; - // options.CronFormat = Cronos.CronFormat.Standard; - //}); + services.ApplyResulation(options => + { + options.CronExpression = "*/10 * * * * *"; + options.TimeZoneInfo = TimeZoneInfo.Local; + options.CronFormat = Cronos.CronFormat.IncludeSeconds; + }); + services.ApplyResulation(options => + { + options.CronExpression = "* * * * *"; + options.TimeZoneInfo = TimeZoneInfo.Local; + options.CronFormat = Cronos.CronFormat.Standard; + }); - services.InitializeCronServices(); - services.AutoConfigurer(); + //services.InitializeCronServices(); + //services.AutoConfigurer(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. From 459f6d911a74ee8aa7ff8d1469846a87da4083ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Furkan=20G=C3=BCng=C3=B6r?= Date: Sun, 6 Feb 2022 14:46:59 +0300 Subject: [PATCH 7/9] =?UTF-8?q?=F0=9F=94=96=20Upgrade=20package=20version?= =?UTF-8?q?=20for=20Abstraction=20Layer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/EasyCronJob.Abstractions/EasyCronJob.Abstractions.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EasyCronJob.Abstractions/EasyCronJob.Abstractions.csproj b/src/EasyCronJob.Abstractions/EasyCronJob.Abstractions.csproj index c82e79a..a2e483d 100644 --- a/src/EasyCronJob.Abstractions/EasyCronJob.Abstractions.csproj +++ b/src/EasyCronJob.Abstractions/EasyCronJob.Abstractions.csproj @@ -4,7 +4,7 @@ net5.0 furkandeveloper furkandeveloper - 2.0.0 + 2.1.0 This library provides abstraction layer for EasyCronJob.Core library. easyCronJob.png https://github.com/furkandeveloper/EasyCronJob From f137adba19bcf84d8d88d264cfd079a54948e32c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Furkan=20G=C3=BCng=C3=B6r?= Date: Sun, 6 Feb 2022 14:47:18 +0300 Subject: [PATCH 8/9] =?UTF-8?q?=F0=9F=94=96=20Upgrade=20package=20version?= =?UTF-8?q?=20for=20AutoConfigurer=20layer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EasyCronJob.AutoConfigurer.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EasyCronJob.AutoConfigurer/EasyCronJob.AutoConfigurer.csproj b/src/EasyCronJob.AutoConfigurer/EasyCronJob.AutoConfigurer.csproj index f12948b..0552f95 100644 --- a/src/EasyCronJob.AutoConfigurer/EasyCronJob.AutoConfigurer.csproj +++ b/src/EasyCronJob.AutoConfigurer/EasyCronJob.AutoConfigurer.csproj @@ -4,7 +4,7 @@ net5.0 furkandeveloper furkandeveloper - 2.0.0 + 2.1.0 This repository provides easy cron job to your application on IHostedService. easyCronJob.png https://github.com/furkandeveloper/EasyCronJob From e8a60c5b9097027a7ce1c2d01701309948d9140b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Furkan=20G=C3=BCng=C3=B6r?= Date: Sun, 6 Feb 2022 14:47:37 +0300 Subject: [PATCH 9/9] =?UTF-8?q?=F0=9F=94=96=20Upgrade=20package=20version?= =?UTF-8?q?=20for=20core=20layer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/EasyCronJob.Core/EasyCronJob.Core.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EasyCronJob.Core/EasyCronJob.Core.csproj b/src/EasyCronJob.Core/EasyCronJob.Core.csproj index 952949f..91f8064 100644 --- a/src/EasyCronJob.Core/EasyCronJob.Core.csproj +++ b/src/EasyCronJob.Core/EasyCronJob.Core.csproj @@ -4,7 +4,7 @@ net5.0 furkandeveloper furkandeveloper - 2.0.0 + 2.1.0 This repository provides easy cron job to your application on IHostedService. easyCronJob.png https://github.com/furkandeveloper/EasyCronJob