From e0bcb4cb20ba6abe531d85d74f0a8eeba49161ba Mon Sep 17 00:00:00 2001 From: MysticBoy Date: Mon, 8 Jun 2020 19:15:39 +0800 Subject: [PATCH] fix title ,namespace ,and more --- .editorconfig | 4 + SilkierQuartz.sln | 1 + sample/AppSettings.cs | 2 +- sample/DemoScheduler.cs | 100 +++++++++--------- sample/InjectProperty.cs | 2 +- sample/Jobs/HelloJob.cs | 2 +- sample/Jobs/HelloJobAuto.cs | 2 +- sample/Jobs/HelloJobSingle.cs | 2 +- sample/Jobs/InjectSampleJob.cs | 2 +- sample/Jobs/InjectSampleJobSingle.cs | 2 +- sample/Pages/Error.cshtml.cs | 2 +- sample/Pages/Index.cshtml.cs | 2 +- sample/Pages/Privacy.cshtml.cs | 2 +- sample/Pages/Shared/_Layout.cshtml | 6 +- sample/Pages/_ViewImports.cshtml | 4 +- sample/Program.cs | 2 +- sample/Startup.cs | 35 ++++-- .../Quartz.Plugins.RecentHistory.csproj | 1 + .../ApplicationBuilderExtensions.cs | 60 ++++++++++- .../IJobRegistratorExtensions.cs | 8 +- .../IServiceCollectionExtensions.cs | 3 +- src/SilkierQuartz/SilkierQuartzOptions.cs | 2 +- 22 files changed, 167 insertions(+), 79 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..dd2b550 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +锘縖*.cs] + +# Default severity for analyzer diagnostics with category 'Style' +dotnet_analyzer_diagnostic.category-Style.severity = none diff --git a/SilkierQuartz.sln b/SilkierQuartz.sln index d7695ab..f3f6849 100644 --- a/SilkierQuartz.sln +++ b/SilkierQuartz.sln @@ -8,6 +8,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F77F2A7C-C844-4DEE-B797-67AB09655FC1}" ProjectSection(SolutionItems) = preProject .dockerignore = .dockerignore + .editorconfig = .editorconfig .gitattributes = .gitattributes .gitignore = .gitignore .travis.yml = .travis.yml diff --git a/sample/AppSettings.cs b/sample/AppSettings.cs index 7cffc38..d522721 100644 --- a/sample/AppSettings.cs +++ b/sample/AppSettings.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -namespace AspNetCore31 +namespace SilkierQuartz.Example { public class AppSettings { diff --git a/sample/DemoScheduler.cs b/sample/DemoScheduler.cs index f149324..963d233 100644 --- a/sample/DemoScheduler.cs +++ b/sample/DemoScheduler.cs @@ -1,19 +1,25 @@ -锘縰sing Quartz; +锘縰sing Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Quartz; using Quartz.Impl; using Quartz.Impl.Matchers; using System; using System.Diagnostics; using System.IO; +using System.Runtime.CompilerServices; using System.Threading.Tasks; namespace SilkierQuartz { public static class DemoScheduler { - public static async Task Create(bool start = true) + /// + /// How to compatible old code to SilkierQuartz + /// + /// + public static void SchedulerJobs(this IApplicationBuilder app) { - var scheduler = await StdSchedulerFactory.GetDefaultScheduler(); - + IScheduler scheduler = app.GetScheduler(); { var jobData = new JobDataMap(); jobData.Put("DateFrom", DateTime.Now); @@ -30,7 +36,7 @@ namespace SilkierQuartz .StartNow() .WithCronSchedule("0 0 8 1/1 * ? *") .Build(); - await scheduler.ScheduleJob(job, trigger); + scheduler.ScheduleJob(job, trigger).Wait(); trigger = TriggerBuilder.Create() .WithIdentity("MonthlySales") @@ -38,8 +44,8 @@ namespace SilkierQuartz .StartNow() .WithCronSchedule("0 0 12 1 1/1 ? *") .Build(); - await scheduler.ScheduleJob(trigger); - await scheduler.PauseTrigger(trigger.Key); + scheduler.ScheduleJob(trigger).Wait(); ; + scheduler.PauseTrigger(trigger.Key).Wait(); ; trigger = TriggerBuilder.Create() .WithIdentity("HourlySales") @@ -47,46 +53,46 @@ namespace SilkierQuartz .StartNow() .WithSimpleSchedule(x => x.WithIntervalInHours(1).RepeatForever()) .Build(); - await scheduler.ScheduleJob(trigger); + scheduler.ScheduleJob(trigger).Wait(); ; } + Task.Run(async () => + { + var job = JobBuilder.Create().WithIdentity("Job1").StoreDurably().Build(); + await scheduler.AddJob(job, false); + job = JobBuilder.Create().WithIdentity("Job2").StoreDurably().Build(); + await scheduler.AddJob(job, false); + job = JobBuilder.Create().WithIdentity("Job3").StoreDurably().Build(); + await scheduler.AddJob(job, false); + job = JobBuilder.Create().WithIdentity("Job4").StoreDurably().Build(); + await scheduler.AddJob(job, false); + job = JobBuilder.Create().WithIdentity("Job5").StoreDurably().Build(); + await scheduler.AddJob(job, false); + job = JobBuilder.Create().WithIdentity("Send SMS", "CRITICAL").StoreDurably().RequestRecovery().Build(); + await scheduler.AddJob(job, false); - { - var job = JobBuilder.Create().WithIdentity("Job1").StoreDurably().Build(); - await scheduler.AddJob(job, false); - job = JobBuilder.Create().WithIdentity("Job2").StoreDurably().Build(); - await scheduler.AddJob(job, false); - job = JobBuilder.Create().WithIdentity("Job3").StoreDurably().Build(); - await scheduler.AddJob(job, false); - job = JobBuilder.Create().WithIdentity("Job4").StoreDurably().Build(); - await scheduler.AddJob(job, false); - job = JobBuilder.Create().WithIdentity("Job5").StoreDurably().Build(); - await scheduler.AddJob(job, false); - job = JobBuilder.Create().WithIdentity("Send SMS", "CRITICAL").StoreDurably().RequestRecovery().Build(); - await scheduler.AddJob(job, false); + var trigger = TriggerBuilder.Create() + .WithIdentity("PushAds (US)") + .ForJob(job.Key) + .UsingJobData("Location", "US") + .StartNow() + .WithCronSchedule("0 0/5 * 1/1 * ? *") + .Build(); + await scheduler.ScheduleJob(trigger); - var trigger = TriggerBuilder.Create() - .WithIdentity("PushAds (US)") - .ForJob(job.Key) - .UsingJobData("Location", "US") - .StartNow() - .WithCronSchedule("0 0/5 * 1/1 * ? *") - .Build(); - await scheduler.ScheduleJob(trigger); - - trigger = TriggerBuilder.Create() - .WithIdentity("PushAds (EU)") - .ForJob(job.Key) - .UsingJobData("Location", "EU") - .StartNow() - .WithCronSchedule("0 0/7 * 1/1 * ? *") - .Build(); - await scheduler.ScheduleJob(trigger); - await scheduler.PauseTriggers(GroupMatcher.GroupEquals("LONGRUNNING")); - - job = JobBuilder.Create().WithIdentity("Send Push", "CRITICAL").StoreDurably().RequestRecovery().Build(); - await scheduler.AddJob(job, false); - } + trigger = TriggerBuilder.Create() + .WithIdentity("PushAds (EU)") + .ForJob(job.Key) + .UsingJobData("Location", "EU") + .StartNow() + .WithCronSchedule("0 0/7 * 1/1 * ? *") + .Build(); + await scheduler.ScheduleJob(trigger); + await scheduler.PauseTriggers(GroupMatcher.GroupEquals("LONGRUNNING")); + job = JobBuilder.Create().WithIdentity("Send Push", "CRITICAL").StoreDurably().RequestRecovery().Build(); + await scheduler.AddJob(job, false); + }); + Task.Run(async () => { var job = JobBuilder.Create() .WithIdentity("Load CSV", "IMPORT") @@ -103,14 +109,12 @@ namespace SilkierQuartz .WithIdentity("CSV_big", "LONGRUNNING") .ForJob(job) .StartNow() - .WithDailyTimeIntervalSchedule(x=>x.OnMondayThroughFriday()) + .WithDailyTimeIntervalSchedule(x => x.OnMondayThroughFriday()) .Build(); await scheduler.ScheduleJob(trigger); - } - if (start) - await scheduler.Start(); + }); + - return scheduler; } public class DummyJob : IJob diff --git a/sample/InjectProperty.cs b/sample/InjectProperty.cs index 1b2ab50..bdd3b28 100644 --- a/sample/InjectProperty.cs +++ b/sample/InjectProperty.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Text; -namespace AspNetCore31 +namespace SilkierQuartz.Example { public class InjectProperty { diff --git a/sample/Jobs/HelloJob.cs b/sample/Jobs/HelloJob.cs index 292bafa..2f4244d 100644 --- a/sample/Jobs/HelloJob.cs +++ b/sample/Jobs/HelloJob.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Text; using System.Threading.Tasks; -namespace AspNetCore31.Jobs +namespace SilkierQuartz.Example.Jobs { public class HelloJob : IJob { diff --git a/sample/Jobs/HelloJobAuto.cs b/sample/Jobs/HelloJobAuto.cs index 07a8924..dece0cc 100644 --- a/sample/Jobs/HelloJobAuto.cs +++ b/sample/Jobs/HelloJobAuto.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.Text; using System.Threading.Tasks; -namespace AspNetCore31.Jobs +namespace SilkierQuartz.Example.Jobs { [SilkierQuartz(5, "this e sq test","_hellojobauto",TriggerGroup = "SilkierQuartz")] diff --git a/sample/Jobs/HelloJobSingle.cs b/sample/Jobs/HelloJobSingle.cs index 5a1ae6b..ded4ba9 100644 --- a/sample/Jobs/HelloJobSingle.cs +++ b/sample/Jobs/HelloJobSingle.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Text; using System.Threading.Tasks; -namespace AspNetCore31.Jobs +namespace SilkierQuartz.Example.Jobs { public class HelloJobSingle : IJob { diff --git a/sample/Jobs/InjectSampleJob.cs b/sample/Jobs/InjectSampleJob.cs index a149c78..7ad5083 100644 --- a/sample/Jobs/InjectSampleJob.cs +++ b/sample/Jobs/InjectSampleJob.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.Text; using System.Threading.Tasks; -namespace AspNetCore31.Jobs +namespace SilkierQuartz.Example.Jobs { public class InjectSampleJob : IJob { diff --git a/sample/Jobs/InjectSampleJobSingle.cs b/sample/Jobs/InjectSampleJobSingle.cs index 8fa752c..8899210 100644 --- a/sample/Jobs/InjectSampleJobSingle.cs +++ b/sample/Jobs/InjectSampleJobSingle.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.Text; using System.Threading.Tasks; -namespace AspNetCore31.Jobs +namespace SilkierQuartz.Example.Jobs { public class InjectSampleJobSingle : IJob { diff --git a/sample/Pages/Error.cshtml.cs b/sample/Pages/Error.cshtml.cs index c1776a4..f9e334a 100644 --- a/sample/Pages/Error.cshtml.cs +++ b/sample/Pages/Error.cshtml.cs @@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; -namespace AspNetCore31.Pages +namespace SilkierQuartz.Example.Pages { [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public class ErrorModel : PageModel diff --git a/sample/Pages/Index.cshtml.cs b/sample/Pages/Index.cshtml.cs index a9b9ad0..2b48b51 100644 --- a/sample/Pages/Index.cshtml.cs +++ b/sample/Pages/Index.cshtml.cs @@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; -namespace AspNetCore31.Pages +namespace SilkierQuartz.Example.Pages { public class IndexModel : PageModel { diff --git a/sample/Pages/Privacy.cshtml.cs b/sample/Pages/Privacy.cshtml.cs index d0b7a34..9a6f096 100644 --- a/sample/Pages/Privacy.cshtml.cs +++ b/sample/Pages/Privacy.cshtml.cs @@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.Extensions.Logging; -namespace AspNetCore31.Pages +namespace SilkierQuartz.Example.Pages { public class PrivacyModel : PageModel { diff --git a/sample/Pages/Shared/_Layout.cshtml b/sample/Pages/Shared/_Layout.cshtml index 660755d..5dd43f1 100644 --- a/sample/Pages/Shared/_Layout.cshtml +++ b/sample/Pages/Shared/_Layout.cshtml @@ -3,7 +3,7 @@ - @ViewData["Title"] - AspNetCore31 + @ViewData["Title"] - SilkierQuartz.Example @@ -11,7 +11,7 @@