diff --git a/delete-bin-obj-folders.bat b/delete-bin-obj-folders.bat new file mode 100644 index 0000000..cf0d6ef --- /dev/null +++ b/delete-bin-obj-folders.bat @@ -0,0 +1,20 @@ +@ECHO off +cls + +ECHO Deleting all BIN and OBJ folders... +ECHO. + +FOR /d /r . %%d in (bin,obj,LocalNuget) DO ( + IF EXIST "%%d" ( + ECHO %%d | FIND /I "\node_modules\" > Nul && ( + ECHO.Skipping: %%d + ) || ( + ECHO.Deleting: %%d + rd /s/q "%%d" + ) + ) +) + +ECHO. +ECHO.BIN and OBJ folders have been successfully deleted. Press any key to exit. +pause > nul \ No newline at end of file diff --git a/sample/DemoScheduler.cs b/sample/DemoScheduler.cs index ce4ba2c..af1c835 100644 --- a/sample/DemoScheduler.cs +++ b/sample/DemoScheduler.cs @@ -17,9 +17,9 @@ public static class DemoScheduler /// How to compatible old code to SilkierQuartz /// /// - public static void SchedulerJobs(this IApplicationBuilder app) + public static void SchedulerJobs(this IApplicationBuilder app) { - IScheduler scheduler = app.GetScheduler(); + var scheduler = app.GetScheduler(); { var jobData = new JobDataMap(); jobData.Put("DateFrom", DateTime.Now); @@ -127,7 +127,7 @@ public static void SchedulerJobs(this IApplicationBuilder app) } - public class DummyJob : IJob + private class DummyJob : IJob { private static readonly Random Random = new Random(); diff --git a/sample/Jobs/LongRunningJob.cs b/sample/Jobs/LongRunningJob.cs new file mode 100644 index 0000000..6c737b4 --- /dev/null +++ b/sample/Jobs/LongRunningJob.cs @@ -0,0 +1,21 @@ +锘縰sing Quartz; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; + +namespace SilkierQuartz.Example.Jobs +{ + public class LongRunningJob : IJob + { + public async Task Execute(IJobExecutionContext context) + { + Console.WriteLine("Long Started"); + await Task.Delay(30000);//half min + Console.WriteLine("Long Running"); + await Task.Delay(30000);//half min + Console.WriteLine("Long Complete"); + await Task.CompletedTask; + } + } +} diff --git a/sample/Program.cs b/sample/Program.cs index bb2453d..34d0e56 100644 --- a/sample/Program.cs +++ b/sample/Program.cs @@ -18,7 +18,7 @@ public static void Main(string[] args) CreateHostBuilder(args).Build().Run(); } - public static IHostBuilder CreateHostBuilder(string[] args) => + private static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { diff --git a/sample/Startup.cs b/sample/Startup.cs index 1403366..1c3c173 100644 --- a/sample/Startup.cs +++ b/sample/Startup.cs @@ -1,3 +1,4 @@ +using System; using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; @@ -17,7 +18,7 @@ public Startup(IConfiguration configuration) Configuration = configuration; } - public IConfiguration Configuration { get; } + private IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) @@ -59,7 +60,8 @@ public void ConfigureServices(IServiceCollection services) services.AddQuartzJob() .AddQuartzJob() .AddQuartzJob() - .AddQuartzJob(); + .AddQuartzJob() + .AddQuartzJob(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -85,11 +87,11 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) endpoints.MapRazorPages(); }); //How to compatible old code to SilkierQuartz - //将旧的原来的规划Job的代码进行移植兼容的示例 + //灏嗘棫鐨勫師鏉ョ殑瑙勫垝Job鐨勪唬鐮佽繘琛岀Щ妞嶅吋瀹圭殑绀轰緥 // app.SchedulerJobs(); - #region 不使用 SilkierQuartzAttribe 属性的进行注册和使用的IJob,这里通过UseQuartzJob的IJob必须在 ConfigureServices进行AddQuartzJob + #region 涓嶄娇鐢 SilkierQuartzAttribe 灞炴х殑杩涜娉ㄥ唽鍜屼娇鐢ㄧ殑IJob锛岃繖閲岄氳繃UseQuartzJob鐨処Job蹇呴』鍦 ConfigureServices杩涜AddQuartzJob app.UseQuartzJob(TriggerBuilder.Create().WithSimpleSchedule(x => x.WithIntervalInSeconds(1).RepeatForever())) .UseQuartzJob(() => @@ -108,6 +110,17 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) TriggerBuilder.Create() .WithCronSchedule("0 0 2 ? * 7 *"), }); + var runAt = DateTime.Now.AddMinutes(3); + app.UseQuartzJob(new List + { + TriggerBuilder.Create() + .WithSimpleSchedule(x => x.WithIntervalInMinutes(1).RepeatForever()), + TriggerBuilder.Create() + .WithSimpleSchedule(x => x.WithIntervalInMinutes(2).RepeatForever()), + //Add a sample that uses 1-7 for dow + TriggerBuilder.Create() + .WithCronSchedule($"0 {runAt.Minute} {runAt.Hour} ? * {(int)runAt.DayOfWeek} *"), + }); app.UseQuartzJob(() => { diff --git a/sample/example.csproj b/sample/example.csproj index 56d07f2..3d1b569 100644 --- a/sample/example.csproj +++ b/sample/example.csproj @@ -1,7 +1,7 @@ 锘 - net6.0 + net8.0 diff --git a/sample2/DemoScheduler.cs b/sample2/DemoScheduler.cs index ce4ba2c..5b757ee 100644 --- a/sample2/DemoScheduler.cs +++ b/sample2/DemoScheduler.cs @@ -19,7 +19,7 @@ public static class DemoScheduler /// public static void SchedulerJobs(this IApplicationBuilder app) { - IScheduler scheduler = app.GetScheduler(); + var scheduler = app.GetScheduler(); { var jobData = new JobDataMap(); jobData.Put("DateFrom", DateTime.Now); diff --git a/sample2/Jobs/LongRunningJob.cs b/sample2/Jobs/LongRunningJob.cs new file mode 100644 index 0000000..6c737b4 --- /dev/null +++ b/sample2/Jobs/LongRunningJob.cs @@ -0,0 +1,21 @@ +锘縰sing Quartz; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; + +namespace SilkierQuartz.Example.Jobs +{ + public class LongRunningJob : IJob + { + public async Task Execute(IJobExecutionContext context) + { + Console.WriteLine("Long Started"); + await Task.Delay(30000);//half min + Console.WriteLine("Long Running"); + await Task.Delay(30000);//half min + Console.WriteLine("Long Complete"); + await Task.CompletedTask; + } + } +} diff --git a/sample2/Program.cs b/sample2/Program.cs index 1e2a391..3084488 100644 --- a/sample2/Program.cs +++ b/sample2/Program.cs @@ -21,7 +21,7 @@ builder.Services.AddRazorPages(); var services = builder.Services; -var Configuration =builder.Configuration; +var configuration = builder.Configuration; services.AddSilkierQuartz(options => { options.VirtualPathRoot = "/quartz"; @@ -53,12 +53,13 @@ #endif ); services.AddOptions(); -services.Configure(Configuration); +services.Configure(configuration); services.Configure(options => { options.WriteText = "This is inject string"; }); services.AddQuartzJob() .AddQuartzJob() .AddQuartzJob() - .AddQuartzJob(); + .AddQuartzJob() + .AddQuartzJob(); var app = builder.Build(); @@ -84,7 +85,7 @@ app.UseAuthorization(); app.UseSilkierQuartz(); app.MapRazorPages(); -#region 不使用 SilkierQuartzAttribe 属性的进行注册和使用的IJob,这里通过UseQuartzJob的IJob必须在 ConfigureServices进行AddQuartzJob +#region 涓嶄娇鐢 SilkierQuartzAttribe 灞炴х殑杩涜娉ㄥ唽鍜屼娇鐢ㄧ殑IJob锛岃繖閲岄氳繃UseQuartzJob鐨処Job蹇呴』鍦 ConfigureServices杩涜AddQuartzJob app.UseQuartzJob(TriggerBuilder.Create().WithSimpleSchedule(x => x.WithIntervalInSeconds(1).RepeatForever())) .UseQuartzJob(() => @@ -103,6 +104,17 @@ TriggerBuilder.Create() .WithCronSchedule("0 0 2 ? * 7 *"), }); +var runAt = DateTime.Now.AddMinutes(3); +app.UseQuartzJob(new List + { + TriggerBuilder.Create() + .WithSimpleSchedule(x => x.WithIntervalInMinutes(1).RepeatForever()), + TriggerBuilder.Create() + .WithSimpleSchedule(x => x.WithIntervalInMinutes(2).RepeatForever()), + //Add a sample that uses 1-7 for dow + TriggerBuilder.Create() + .WithCronSchedule($"0 {runAt.Minute} {runAt.Hour} ? * {(int)runAt.DayOfWeek} *"), + }); app.UseQuartzJob(() => { @@ -113,4 +125,4 @@ }); #endregion -app.Run(); +app.Run(); \ No newline at end of file diff --git a/sample2/sample2.csproj b/sample2/sample2.csproj index 6e0e75f..269c39c 100644 --- a/sample2/sample2.csproj +++ b/sample2/sample2.csproj @@ -1,23 +1,23 @@ - - net6.0 - enable - enable - aspnet-WebApplication1-A527D1EB-9052-4CB4-84DF-96A390FE8CC1 - + + net8.0 + enable + enable + aspnet-WebApplication1-A527D1EB-9052-4CB4-84DF-96A390FE8CC1 + - - - - - - - + + + + + + + - - - - + + + + diff --git a/src/Quartz.Plugins.RecentHistory/IExecutionHistoryStore.cs b/src/Quartz.Plugins.RecentHistory/IExecutionHistoryStore.cs index 5933207..5379c15 100644 --- a/src/Quartz.Plugins.RecentHistory/IExecutionHistoryStore.cs +++ b/src/Quartz.Plugins.RecentHistory/IExecutionHistoryStore.cs @@ -12,11 +12,11 @@ public class ExecutionHistoryEntry public string SchedulerName { get; set; } public string Job { get; set; } public string Trigger { get; set; } - public DateTime? ScheduledFireTimeUtc { get; set; } - public DateTime ActualFireTimeUtc { get; set; } + public DateTimeOffset? ScheduledFireTimeUtc { get; set; } + public DateTimeOffset ActualFireTimeUtc { get; set; } public bool Recovering { get; set; } public bool Vetoed { get; set; } - public DateTime? FinishedTimeUtc { get; set; } + public DateTimeOffset? FinishedTimeUtc { get; set; } public string ExceptionMessage { get; set; } } diff --git a/src/Quartz.Plugins.RecentHistory/Quartz.Plugins.RecentHistory.csproj b/src/Quartz.Plugins.RecentHistory/Quartz.Plugins.RecentHistory.csproj index 1639ed0..77340fb 100644 --- a/src/Quartz.Plugins.RecentHistory/Quartz.Plugins.RecentHistory.csproj +++ b/src/Quartz.Plugins.RecentHistory/Quartz.Plugins.RecentHistory.csproj @@ -1,40 +1,39 @@ 锘 + + net8.0 + PackageReference + true + true + 1591 - - net6.0 - PackageReference - true - true - 1591 + 8.0.1 + SilkierQuartz + Quartz.NET plugin to persist recent job execution history + Jan Lucansky,Maikebing + https://github.com/jlucansky/SilkierQuartz + This is supporting package for SilkierQuartz + quartz;recent;history + 1.0.0.0 + 1.0.0.0 + LICENSE + Copyright 漏 2018 Jan Lucansky, Copyright 漏 2020 Maikebing + git + https://github.com/jlucansky/SilkierQuartz + SilkierQuartz.Plugins.RecentHistory + true + - 1.0.3 - SilkierQuartz - Quartz.NET plugin to persist recent job execution history - Jan Lucansky,Maikebing - https://github.com/jlucansky/SilkierQuartz - This is supporting package for SilkierQuartz - quartz;recent;history - 1.0.0.0 - 1.0.0.0 - LICENSE - Copyright 漏 2018 Jan Lucansky, Copyright 漏 2020 Maikebing - git - https://github.com/jlucansky/SilkierQuartz - SilkierQuartz.Plugins.RecentHistory - true - + + + + - - - - + + + - - - - - - - + + + diff --git a/src/SilkierQuartz/Controllers/CalendarsController.cs b/src/SilkierQuartz/Controllers/CalendarsController.cs index 1fd60d1..d616002 100644 --- a/src/SilkierQuartz/Controllers/CalendarsController.cs +++ b/src/SilkierQuartz/Controllers/CalendarsController.cs @@ -20,7 +20,7 @@ public async Task Index() var list = new List(); - foreach (string name in calendarNames) + foreach (var name in calendarNames) { var cal = await Scheduler.GetCalendar(name); list.Add(new CalendarListItem() { Name = name, Description = cal.Description, Type = cal.GetType() }); @@ -73,7 +73,7 @@ public async Task Save([FromBody] CalendarViewModel[] chain, bool if (chain.Length == 0 || string.IsNullOrEmpty(chain[0].Name)) result.Errors.Add(ValidationError.EmptyField(nameof(CalendarViewModel.Name))); - for (int i = 0; i < chain.Length; i++) + for (var i = 0; i < chain.Length; i++) { RemoveLastEmpty(chain[i].Days); RemoveLastEmpty(chain[i].Dates); @@ -86,7 +86,7 @@ public async Task Save([FromBody] CalendarViewModel[] chain, bool if (result.Success) { - string name = chain[0].Name; + var name = chain[0].Name; ICalendar existing = null; @@ -94,9 +94,9 @@ public async Task Save([FromBody] CalendarViewModel[] chain, bool existing = await Scheduler.GetCalendar(name); ICalendar root = null, current = null; - for (int i = 0; i < chain.Length; i++) + for (var i = 0; i < chain.Length; i++) { - ICalendar newCal = chain[i].Type.Equals("custom") ? existing : chain[i].BuildCalendar(); + var newCal = chain[i].Type.Equals("custom") ? existing : chain[i].BuildCalendar(); if (newCal == null) break; diff --git a/src/SilkierQuartz/Controllers/HistoryController.cs b/src/SilkierQuartz/Controllers/HistoryController.cs index 30f177a..181de0f 100644 --- a/src/SilkierQuartz/Controllers/HistoryController.cs +++ b/src/SilkierQuartz/Controllers/HistoryController.cs @@ -21,7 +21,7 @@ public async Task Index() if (store == null) return View(null); - IEnumerable history = await store.FilterLast(100); + var history = await store.FilterLast(100); var list = new List(); diff --git a/src/SilkierQuartz/Controllers/JobDataMapController.cs b/src/SilkierQuartz/Controllers/JobDataMapController.cs index a7d6e2b..b335575 100644 --- a/src/SilkierQuartz/Controllers/JobDataMapController.cs +++ b/src/SilkierQuartz/Controllers/JobDataMapController.cs @@ -31,10 +31,10 @@ public async Task ChangeType() var dataMapForm = (await formData.GetJobDataMapForm(includeRowIndex: false)).SingleOrDefault(); // expected single row - object oldValue = selectedType.ConvertFrom(dataMapForm); + var oldValue = selectedType.ConvertFrom(dataMapForm); // phase 1: direct conversion - object newValue = targetType.ConvertFrom(oldValue); + var newValue = targetType.ConvertFrom(oldValue); if (oldValue != null && newValue == null) // if phase 1 failed { @@ -54,12 +54,12 @@ public IActionResult TypeHandlersScript() if (etag.Equals(GetETag())) return NotModified(); - StringBuilder execStubBuilder = new StringBuilder(); + var execStubBuilder = new StringBuilder(); execStubBuilder.AppendLine(); foreach (var func in new[] { "init" }) execStubBuilder.AppendLine(string.Format("if (f === '{0}' && {0} !== 'undefined') {{ {0}.call(this); }}", func)); - string execStub = execStubBuilder.ToString(); + var execStub = execStubBuilder.ToString(); var js = Services.TypeHandlers.GetScripts().ToDictionary(x => x.Key, x => new JRaw("function(f) {" + x.Value + execStub + "}")); diff --git a/src/SilkierQuartz/Controllers/PageControllerBase.cs b/src/SilkierQuartz/Controllers/PageControllerBase.cs index ba10666..8a7af45 100644 --- a/src/SilkierQuartz/Controllers/PageControllerBase.cs +++ b/src/SilkierQuartz/Controllers/PageControllerBase.cs @@ -79,7 +79,7 @@ protected IActionResult View(object model) protected IActionResult View(string viewName, object model) { - string content = Services.ViewEngine.Render($"{GetRouteData("controller")}/{viewName}.hbs", new Page(this, model)); + var content = Services.ViewEngine.Render($"{GetRouteData("controller")}/{viewName}.hbs", new Page(this, model)); return Html(content); } @@ -94,7 +94,7 @@ protected IActionResult Html(string html) protected string GetETag() { - IEnumerable values = GetHeader("If-None-Match"); + var values = GetHeader("If-None-Match"); if (values == null) return null; else diff --git a/src/SilkierQuartz/Controllers/SchedulerController.cs b/src/SilkierQuartz/Controllers/SchedulerController.cs index cbd937b..4486c08 100644 --- a/src/SilkierQuartz/Controllers/SchedulerController.cs +++ b/src/SilkierQuartz/Controllers/SchedulerController.cs @@ -52,7 +52,7 @@ public async Task Index() } int? failedJobs = null; - int executedJobs = metadata.NumberOfJobsExecuted; + var executedJobs = metadata.NumberOfJobsExecuted; if (histStore != null) { diff --git a/src/SilkierQuartz/Controllers/TriggersController.cs b/src/SilkierQuartz/Controllers/TriggersController.cs index 238918c..6bcd592 100644 --- a/src/SilkierQuartz/Controllers/TriggersController.cs +++ b/src/SilkierQuartz/Controllers/TriggersController.cs @@ -245,7 +245,7 @@ public async Task Cron() if (string.IsNullOrEmpty(cron)) return Json(new { Description = "", Next = new object[0] }); - string desc = "Invalid format."; + var desc = "Invalid format."; try { @@ -254,13 +254,13 @@ public async Task Cron() catch { } - List nextDates = new List(); + var nextDates = new List(); try { var qce = new CronExpression(cron); - DateTime dt = DateTime.Now; - for (int i = 0; i < 10; i++) + var dt = DateTime.Now; + for (var i = 0; i < 10; i++) { var next = qce.GetNextValidTimeAfter(dt); if (next == null) diff --git a/src/SilkierQuartz/Extensions.cs b/src/SilkierQuartz/Extensions.cs index 79e1a8c..532f153 100644 --- a/src/SilkierQuartz/Extensions.cs +++ b/src/SilkierQuartz/Extensions.cs @@ -36,6 +36,16 @@ public static string ToDefaultFormat(this DateTime date) CultureInfo.InvariantCulture); } + public static string ToDefaultFormat(this DateTimeOffset date) + { + return DateTimeSettings.UseLocalTime + ? date.ToLocalTime() + .ToString(DateTimeSettings.DefaultDateFormat + " " + DateTimeSettings.DefaultTimeFormat, + CultureInfo.InvariantCulture) + : date.ToString(DateTimeSettings.DefaultDateFormat + " " + DateTimeSettings.DefaultTimeFormat, + CultureInfo.InvariantCulture); + } + public static Dictionary ToDictionary(this IEnumerable timeZoneInfos) { return timeZoneInfos.ToDictionary(x => x.Id, x => @@ -58,7 +68,7 @@ public static IEnumerable Flatten(this ICalendar root) public static string ETag(this DateTime dateTime) { - long etagHash = dateTime.ToFileTimeUtc(); + var etagHash = dateTime.ToFileTimeUtc(); return '\"' + Convert.ToString(etagHash, 16) + '\"'; } @@ -130,16 +140,16 @@ public static string RemoveAssemblyDetails(this Type type) { // https://github.com/JamesNK/Newtonsoft.Json/blob/master/Src/Newtonsoft.Json/Utilities/ReflectionUtils.cs - string fullyQualifiedTypeName = type.AssemblyQualifiedName; + var fullyQualifiedTypeName = type.AssemblyQualifiedName; - StringBuilder builder = new StringBuilder(); + var builder = new StringBuilder(); // loop through the type name and filter out qualified assembly details from nested type names - bool writingAssemblyName = false; - bool skippingAssemblyDetails = false; - for (int i = 0; i < fullyQualifiedTypeName.Length; i++) + var writingAssemblyName = false; + var skippingAssemblyDetails = false; + for (var i = 0; i < fullyQualifiedTypeName.Length; i++) { - char current = fullyQualifiedTypeName[i]; + var current = fullyQualifiedTypeName[i]; switch (current) { case '[': @@ -180,7 +190,7 @@ public static string RemoveAssemblyDetails(this Type type) private static List GetJobDataMapModelCore(object jobOrTrigger, Services services) { - List list = new List(); + var list = new List(); // TODO: doplnit parametre z template na zaklade jobKey; value najprv skonvertovat na ocakavany typ zo sablony @@ -228,7 +238,7 @@ private static List GetJobDataMapModelCore(object jobOrTrigger, if (model.SelectedType == null) // if there is no suitable TypeHandler, create dynamic one { - Type t = model.Value.GetType(); + var t = model.Value.GetType(); string strValue; var m = t.GetMethod(nameof(ToString), BindingFlags.Instance | BindingFlags.Public, null, CallingConventions.Any, new Type[0], null); @@ -336,7 +346,7 @@ public TimespanPart(string singular) public static string GetScheduleDescription(this IDailyTimeIntervalTrigger trigger) { - string result = GetScheduleDescription(trigger.RepeatInterval, trigger.RepeatIntervalUnit, trigger.RepeatCount); + var result = GetScheduleDescription(trigger.RepeatInterval, trigger.RepeatIntervalUnit, trigger.RepeatCount); result += " from " + trigger.StartTimeOfDay.ToShortFormat() + " to " + trigger.EndTimeOfDay.ToShortFormat(); if (trigger.DaysOfWeek.Count < 7) @@ -356,7 +366,7 @@ public static string GetScheduleDescription(this IDailyTimeIntervalTrigger trigg public static string GetScheduleDescription(this ISimpleTrigger trigger) { - string result = "Repeat "; + var result = "Repeat "; if (trigger.RepeatCount > 0) result += trigger.RepeatCount + " times "; result += "every "; @@ -382,12 +392,12 @@ public static string GetScheduleDescription(this ISimpleTrigger trigger) public static string GetScheduleDescription(int repeatInterval, IntervalUnit repeatIntervalUnit, int repeatCount = 0) { - string result = "Repeat "; + var result = "Repeat "; if (repeatCount > 0) result += repeatCount + " times "; result += "every "; - string unitStr = repeatIntervalUnit.ToString().ToLower(); + var unitStr = repeatIntervalUnit.ToString().ToLower(); if (repeatInterval == 1) result += unitStr; @@ -433,8 +443,8 @@ public static Histogram ToHistogram(this IEnumerable entr foreach (var entry in entries) { TimeSpan? duration = null; - string cssClass = ""; - string state = "Finished"; + var cssClass = ""; + var state = "Finished"; if (entry.FinishedTimeUtc != null) duration = entry.FinishedTimeUtc - entry.ActualFireTimeUtc; diff --git a/src/SilkierQuartz/Helpers/CronExpressionDescriptor/ExpressionDescriptor.cs b/src/SilkierQuartz/Helpers/CronExpressionDescriptor/ExpressionDescriptor.cs index 86e08cf..76166ee 100644 --- a/src/SilkierQuartz/Helpers/CronExpressionDescriptor/ExpressionDescriptor.cs +++ b/src/SilkierQuartz/Helpers/CronExpressionDescriptor/ExpressionDescriptor.cs @@ -71,13 +71,13 @@ public ExpressionDescriptor(string expression, Options options) /// The cron expression description public string GetDescription(DescriptionTypeEnum type) { - string description = string.Empty; + var description = string.Empty; try { if (!m_parsed) { - ExpressionParser parser = new ExpressionParser(m_expression, m_options); + var parser = new ExpressionParser(m_expression, m_options); m_expressionParts = parser.Parse(); m_parsed = true; } @@ -144,11 +144,11 @@ protected string GetFullDescription() try { - string timeSegment = GetTimeOfDayDescription(); - string dayOfMonthDesc = GetDayOfMonthDescription(); - string monthDesc = GetMonthDescription(); - string dayOfWeekDesc = GetDayOfWeekDescription(); - string yearDesc = GetYearDescription(); + var timeSegment = GetTimeOfDayDescription(); + var dayOfMonthDesc = GetDayOfMonthDescription(); + var monthDesc = GetMonthDescription(); + var dayOfWeekDesc = GetDayOfWeekDescription(); + var yearDesc = GetYearDescription(); description = string.Format("{0}{1}{2}{3}{4}", timeSegment, @@ -178,11 +178,11 @@ protected string GetFullDescription() /// The TIMEOFDAY description protected string GetTimeOfDayDescription() { - string secondsExpression = m_expressionParts[0]; - string minuteExpression = m_expressionParts[1]; - string hourExpression = m_expressionParts[2]; + var secondsExpression = m_expressionParts[0]; + var minuteExpression = m_expressionParts[1]; + var hourExpression = m_expressionParts[2]; - StringBuilder description = new StringBuilder(); + var description = new StringBuilder(); //handle special cases first if (minuteExpression.IndexOfAny(m_specialCharacters) == -1 @@ -197,7 +197,7 @@ protected string GetTimeOfDayDescription() && hourExpression.IndexOfAny(m_specialCharacters) == -1) { //minute range in single hour (i.e. 0-10 11) - string[] minuteParts = minuteExpression.Split('-'); + var minuteParts = minuteExpression.Split('-'); description.Append(string.Format(GetString("EveryMinuteBetweenX0AndX1"), FormatTime(hourExpression, minuteParts[0]), FormatTime(hourExpression, minuteParts[1]))); @@ -207,9 +207,9 @@ protected string GetTimeOfDayDescription() && minuteExpression.IndexOfAny(m_specialCharacters) == -1) { //hours list with single minute (o.e. 30 6,14,16) - string[] hourParts = hourExpression.Split(','); + var hourParts = hourExpression.Split(','); description.Append(GetString("At")); - for (int i = 0; i < hourParts.Length; i++) + for (var i = 0; i < hourParts.Length; i++) { description.Append(" ").Append(FormatTime(hourParts[i], minuteExpression)); @@ -227,9 +227,9 @@ protected string GetTimeOfDayDescription() else { //default time description - string secondsDescription = GetSecondsDescription(); - string minutesDescription = GetMinutesDescription(); - string hoursDescription = GetHoursDescription(); + var secondsDescription = GetSecondsDescription(); + var minutesDescription = GetMinutesDescription(); + var hoursDescription = GetHoursDescription(); description.Append(secondsDescription); @@ -258,7 +258,7 @@ protected string GetTimeOfDayDescription() /// The SECONDS description protected string GetSecondsDescription() { - string description = GetSegmentDescription( + var description = GetSegmentDescription( m_expressionParts[0], GetString("EverySecond"), (s => s), @@ -266,7 +266,7 @@ protected string GetSecondsDescription() (s => GetString("SecondsX0ThroughX1PastTheMinute")), (s => { - int i = 0; + var i = 0; if (int.TryParse(s, out i)) { return s == "0" @@ -293,7 +293,7 @@ protected string GetSecondsDescription() /// The MINUTE description protected string GetMinutesDescription() { - string description = GetSegmentDescription( + var description = GetSegmentDescription( expression: m_expressionParts[1], allDescription: GetString("EveryMinute"), getSingleItemDescription: (s => s), @@ -301,7 +301,7 @@ protected string GetMinutesDescription() getBetweenDescriptionFormat: (s => GetString("MinutesX0ThroughX1PastTheHour")), getDescriptionFormat: (s => { - int i = 0; + var i = 0; if (int.TryParse(s, out i)) { return s == "0" @@ -327,8 +327,8 @@ protected string GetMinutesDescription() /// The HOUR description protected string GetHoursDescription() { - string expression = m_expressionParts[2]; - string description = GetSegmentDescription(expression, + var expression = m_expressionParts[2]; + var description = GetSegmentDescription(expression, GetString("EveryHour"), (s => FormatTime(s, "0")), (s => string.Format(GetString("EveryX0Hours"), s)), @@ -363,7 +363,7 @@ protected string GetDayOfWeekDescription() GetString("ComaEveryDay"), (s => { - string exp = s.Contains("#") + var exp = s.Contains("#") ? s.Remove(s.IndexOf("#")) : s.Contains("L") ? s.Replace("L", string.Empty) @@ -378,7 +378,7 @@ protected string GetDayOfWeekDescription() string format = null; if (s.Contains("#")) { - string dayOfWeekOfMonthNumber = s.Substring(s.IndexOf("#") + 1); + var dayOfWeekOfMonthNumber = s.Substring(s.IndexOf("#") + 1); string dayOfWeekOfMonthDescription = null; switch (dayOfWeekOfMonthNumber) { @@ -427,7 +427,7 @@ protected string GetDayOfWeekDescription() /// The MONTH description protected string GetMonthDescription() { - string description = GetSegmentDescription( + var description = GetSegmentDescription( m_expressionParts[4], string.Empty, (s => new DateTime(DateTime.Now.Year, Convert.ToInt32(s), 1).ToString("MMMM", m_culture)), @@ -447,7 +447,7 @@ protected string GetMonthDescription() protected string GetDayOfMonthDescription() { string description = null; - string expression = m_expressionParts[3]; + var expression = m_expressionParts[3]; switch (expression) { @@ -459,13 +459,13 @@ protected string GetDayOfMonthDescription() description = GetString("ComaOnTheLastWeekdayOfTheMonth"); break; default: - Regex weekDayNumberMatches = new Regex("(\\d{1,2}W)|(W\\d{1,2})"); + var weekDayNumberMatches = new Regex("(\\d{1,2}W)|(W\\d{1,2})"); if (weekDayNumberMatches.IsMatch(expression)) { - Match m = weekDayNumberMatches.Match(expression); - int dayNumber = Int32.Parse(m.Value.Replace("W", "")); + var m = weekDayNumberMatches.Match(expression); + var dayNumber = Int32.Parse(m.Value.Replace("W", "")); - string dayString = dayNumber == 1 ? GetString("FirstWeekday") : + var dayString = dayNumber == 1 ? GetString("FirstWeekday") : String.Format(GetString("WeekdayNearestDayX0"), dayNumber); description = String.Format(GetString("ComaOnTheX0OfTheMonth"), dayString); @@ -474,11 +474,11 @@ protected string GetDayOfMonthDescription() else { // Handle "last day offset" (i.e. L-5: "5 days before the last day of the month") - Regex lastDayOffSetMatches = new Regex("L-(\\d{1,2})"); + var lastDayOffSetMatches = new Regex("L-(\\d{1,2})"); if (lastDayOffSetMatches.IsMatch(expression)) { - Match m = lastDayOffSetMatches.Match(expression); - string offSetDays = m.Groups[1].Value; + var m = lastDayOffSetMatches.Match(expression); + var offSetDays = m.Groups[1].Value; description = String.Format(GetString("CommaDaysBeforeTheLastDayOfTheMonth"), offSetDays); break; } @@ -506,7 +506,7 @@ protected string GetDayOfMonthDescription() /// The YEAR description private string GetYearDescription() { - string description = GetSegmentDescription(m_expressionParts[6], + var description = GetSegmentDescription(m_expressionParts[6], string.Empty, (s => Regex.IsMatch(s, @"^\d+$") ? new DateTime(Convert.ToInt32(s), 1, 1).ToString("yyyy") : s), @@ -563,13 +563,13 @@ Func getRangeFormat } else if (expression.Contains("/")) { - string[] segments = expression.Split('/'); + var segments = expression.Split('/'); description = string.Format(getIntervalDescriptionFormat(segments[1]), getSingleItemDescription(segments[1])); //interval contains 'between' piece (i.e. 2-59/3 ) if (segments[0].Contains("-")) { - string betweenSegmentDescription = GenerateBetweenSegmentDescription(segments[0], getBetweenDescriptionFormat, getSingleItemDescription); + var betweenSegmentDescription = GenerateBetweenSegmentDescription(segments[0], getBetweenDescriptionFormat, getSingleItemDescription); if (!betweenSegmentDescription.StartsWith(", ")) { @@ -580,7 +580,7 @@ Func getRangeFormat } else if (segments[0].IndexOfAny(new char[] { '*', ',' }) == -1) { - string rangeItemDescription = string.Format(getDescriptionFormat(segments[0]), getSingleItemDescription(segments[0])); + var rangeItemDescription = string.Format(getDescriptionFormat(segments[0]), getSingleItemDescription(segments[0])); //remove any leading comma rangeItemDescription = rangeItemDescription.Replace(", ", ""); @@ -589,10 +589,10 @@ Func getRangeFormat } else if (expression.Contains(",")) { - string[] segments = expression.Split(','); + var segments = expression.Split(','); - string descriptionContent = string.Empty; - for (int i = 0; i < segments.Length; i++) + var descriptionContent = string.Empty; + for (var i = 0; i < segments.Length; i++) { if (i > 0 && segments.Length > 2) { @@ -611,7 +611,7 @@ Func getRangeFormat if (segments[i].Contains("-")) { - string betweenSegmentDescription = GenerateBetweenSegmentDescription(segments[i], getRangeFormat, getSingleItemDescription); + var betweenSegmentDescription = GenerateBetweenSegmentDescription(segments[i], getRangeFormat, getSingleItemDescription); //remove any leading comma betweenSegmentDescription = betweenSegmentDescription.Replace(", ", ""); @@ -643,10 +643,10 @@ Func getRangeFormat /// The between segment description protected string GenerateBetweenSegmentDescription(string betweenExpression, Func getBetweenDescriptionFormat, Func getSingleItemDescription) { - string description = string.Empty; - string[] betweenSegments = betweenExpression.Split('-'); - string betweenSegment1Description = getSingleItemDescription(betweenSegments[0]); - string betweenSegment2Description = getSingleItemDescription(betweenSegments[1]); + var description = string.Empty; + var betweenSegments = betweenExpression.Split('-'); + var betweenSegment1Description = getSingleItemDescription(betweenSegments[0]); + var betweenSegment2Description = getSingleItemDescription(betweenSegments[1]); betweenSegment2Description = betweenSegment2Description.Replace(":00", ":59"); var betweenDescriptionFormat = getBetweenDescriptionFormat(betweenExpression); description += string.Format(betweenDescriptionFormat, betweenSegment1Description, betweenSegment2Description); @@ -674,9 +674,9 @@ protected string FormatTime(string hourExpression, string minuteExpression) /// Formatted time description protected string FormatTime(string hourExpression, string minuteExpression, string secondExpression) { - int hour = Convert.ToInt32(hourExpression); + var hour = Convert.ToInt32(hourExpression); - string period = string.Empty; + var period = string.Empty; if (!m_use24HourTimeFormat) { period = GetString((hour >= 12) ? "PMPeriod" : "AMPeriod"); @@ -696,8 +696,8 @@ protected string FormatTime(string hourExpression, string minuteExpression, stri } } - string minute = Convert.ToInt32(minuteExpression).ToString(); - string second = string.Empty; + var minute = Convert.ToInt32(minuteExpression).ToString(); + var second = string.Empty; if (!string.IsNullOrEmpty(secondExpression)) { second = string.Concat(":", Convert.ToInt32(secondExpression).ToString().PadLeft(2, '0')); @@ -755,7 +755,7 @@ public static string GetDescription(string expression) /// The cron expression description public static string GetDescription(string expression, Options options) { - ExpressionDescriptor descripter = new ExpressionDescriptor(expression, options); + var descripter = new ExpressionDescriptor(expression, options); return descripter.GetDescription(DescriptionTypeEnum.FULL); } #endregion diff --git a/src/SilkierQuartz/Helpers/CronExpressionDescriptor/ExpressionParser.cs b/src/SilkierQuartz/Helpers/CronExpressionDescriptor/ExpressionParser.cs index 645053d..dc0f5cd 100644 --- a/src/SilkierQuartz/Helpers/CronExpressionDescriptor/ExpressionParser.cs +++ b/src/SilkierQuartz/Helpers/CronExpressionDescriptor/ExpressionParser.cs @@ -47,7 +47,7 @@ public ExpressionParser(string expression, Options options) public string[] Parse() { // Initialize all elements of parsed array to empty strings - string[] parsed = new string[7].Select(el => "").ToArray(); + var parsed = new string[7].Select(el => "").ToArray(); if (string.IsNullOrEmpty(m_expression)) { @@ -59,7 +59,7 @@ public string[] Parse() } else { - string[] expressionPartsTemp = m_expression.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + var expressionPartsTemp = m_expression.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (expressionPartsTemp.Length < 5) { @@ -73,7 +73,7 @@ public string[] Parse() else if (expressionPartsTemp.Length == 6) { //If last element ends with 4 digits, a year element has been supplied and no seconds element - Regex yearRegex = new Regex("\\d{4}$"); + var yearRegex = new Regex("\\d{4}$"); if (yearRegex.IsMatch(expressionPartsTemp[5])) { Array.Copy(expressionPartsTemp, 0, parsed, 1, 6); @@ -164,19 +164,19 @@ private void NormalizeExpression(string[] expressionParts) } // Convert SUN-SAT format to 0-6 format - for (int i = 0; i <= 6; i++) + for (var i = 0; i <= 6; i++) { - DayOfWeek currentDay = (DayOfWeek)i; - string currentDayOfWeekDescription = currentDay.ToString().Substring(0, 3).ToUpperInvariant(); + var currentDay = (DayOfWeek)i; + var currentDayOfWeekDescription = currentDay.ToString().Substring(0, 3).ToUpperInvariant(); expressionParts[5] = Regex.Replace(expressionParts[5], currentDayOfWeekDescription, i.ToString(), RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); } // Convert JAN-DEC format to 1-12 format - for (int i = 1; i <= 12; i++) + for (var i = 1; i <= 12; i++) { - DateTime currentMonth = new DateTime(DateTime.Now.Year, i, 1); - string currentMonthDescription = currentMonth.ToString("MMM", m_en_culture).ToUpperInvariant(); + var currentMonth = new DateTime(DateTime.Now.Year, i, 1); + var currentMonthDescription = currentMonth.ToString("MMM", m_en_culture).ToUpperInvariant(); expressionParts[4] = Regex.Replace(expressionParts[4], currentMonthDescription, i.ToString(), RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); } @@ -187,7 +187,7 @@ private void NormalizeExpression(string[] expressionParts) } // Loop through all parts and apply global normalization - for (int i = 0; i < expressionParts.Length; i++) + for (var i = 0; i < expressionParts.Length; i++) { // convert all '*/1' to '*' if (expressionParts[i] == "*/1") @@ -217,7 +217,7 @@ private void NormalizeExpression(string[] expressionParts) if (stepRangeThrough != null) { - string[] parts = expressionParts[i].Split('/'); + var parts = expressionParts[i].Split('/'); expressionParts[i] = string.Format("{0}-{1}/{2}", parts[0], stepRangeThrough, parts[1]); } } @@ -226,8 +226,8 @@ private void NormalizeExpression(string[] expressionParts) private static string DecreaseDaysOfWeek(string dayOfWeekExpressionPart) { - char[] dowChars = dayOfWeekExpressionPart.ToCharArray(); - for (int i = 0; i < dowChars.Length; i++) + var dowChars = dayOfWeekExpressionPart.ToCharArray(); + for (var i = 0; i < dowChars.Length; i++) { int charNumeric; if ((i == 0 || dowChars[i - 1] != '#' && dowChars[i - 1] != '/') diff --git a/src/SilkierQuartz/Helpers/HandlebarsHelpers.cs b/src/SilkierQuartz/Helpers/HandlebarsHelpers.cs index 6ca5dd1..e27e527 100644 --- a/src/SilkierQuartz/Helpers/HandlebarsHelpers.cs +++ b/src/SilkierQuartz/Helpers/HandlebarsHelpers.cs @@ -32,7 +32,7 @@ public static void Register(Services services, SilkierQuartzAuthenticationOption void RegisterInternal() { - IHandlebars h = _services.Handlebars; + var h = _services.Handlebars; h.RegisterHelper("Upper", (o, c, a) => o.Write(a[0].ToString().ToUpper())); h.RegisterHelper("Lower", (o, c, a) => o.Write(a[0].ToString().ToLower())); @@ -74,7 +74,7 @@ string BaseUrl { get { - string url = _services.Options.VirtualPathRoot; + var url = _services.Options.VirtualPathRoot; if (!url.EndsWith("/")) url += "/"; return url; @@ -135,12 +135,12 @@ void MenuItemActionLink(TextWriter output, dynamic context, params object[] argu return; } - string classes = "item"; + var classes = "item"; if (dict["controller"].Equals(context.ControllerName)) classes += " active"; - string url = BaseUrl + dict["controller"]; - string title = HtmlEncode(dict.GetValue("title", dict["controller"])); + var url = BaseUrl + dict["controller"]; + var title = HtmlEncode(dict.GetValue("title", dict["controller"])); output.WriteSafeString($@"{title}"); } @@ -152,7 +152,7 @@ void ActionUrl(TextWriter output, dynamic context, params object[] arguments) IDictionary routeValues = null; string controller = null; - string action = (arguments[0] as Page)?.ActionName ?? (string)arguments[0]; + var action = (arguments[0] as Page)?.ActionName ?? (string)arguments[0]; if (arguments.Length >= 2) // [actionName, controllerName/routeValues ] { @@ -171,7 +171,7 @@ void ActionUrl(TextWriter output, dynamic context, params object[] arguments) if (controller == null) controller = context.ControllerName; - string url = BaseUrl + controller; + var url = BaseUrl + controller; if (!string.IsNullOrEmpty(action)) url += "/" + action; diff --git a/src/SilkierQuartz/Helpers/JobDataMapRequest.cs b/src/SilkierQuartz/Helpers/JobDataMapRequest.cs index 1ca98c6..e12fd1c 100644 --- a/src/SilkierQuartz/Helpers/JobDataMapRequest.cs +++ b/src/SilkierQuartz/Helpers/JobDataMapRequest.cs @@ -15,10 +15,10 @@ public static Task[]> GetJobDataMapForm(this IEnumera foreach (var item in formData) { - string g = GetJobDataMapFieldGroup(item.Key); + var g = GetJobDataMapFieldGroup(item.Key); if (g != null) { - string field = item.Key.Substring(0, item.Key.Length - g.Length - 1); + var field = item.Key.Substring(0, item.Key.Length - g.Length - 1); if (!map.ContainsKey(g)) map[g] = new Dictionary(); map[g][field] = item.Value; @@ -54,7 +54,7 @@ public static Task>> GetFormData(this HttpRequ foreach (var key in request.Form.Keys) { - foreach (string strValue in request.Form[key]) + foreach (var strValue in request.Form[key]) result.Add(new KeyValuePair(key, strValue)); } foreach (var file in request.Form.Files) diff --git a/src/SilkierQuartz/HostedService/IJobRegistratorExtensions.cs b/src/SilkierQuartz/HostedService/IJobRegistratorExtensions.cs index 159fda3..6dfbe39 100644 --- a/src/SilkierQuartz/HostedService/IJobRegistratorExtensions.cs +++ b/src/SilkierQuartz/HostedService/IJobRegistratorExtensions.cs @@ -176,7 +176,7 @@ public static IJobRegistrator RegiserJob( var jobDetail = JobBuilder.Create().Build(); - List triggers = new List(triggerBuilders.Count()); + var triggers = new List(triggerBuilders.Count()); foreach (var triggerBuilder in triggerBuilders) { triggers.Add(triggerBuilder.ForJob(jobDetail).Build()); diff --git a/src/SilkierQuartz/HostedService/QuartzHostedService.cs b/src/SilkierQuartz/HostedService/QuartzHostedService.cs index 05ec49b..367beab 100644 --- a/src/SilkierQuartz/HostedService/QuartzHostedService.cs +++ b/src/SilkierQuartz/HostedService/QuartzHostedService.cs @@ -43,7 +43,7 @@ public async Task StartAsync(CancellationToken cancellationToken) foreach (var scheduleJob in _scheduleJobs) { - bool isNewJob = true; + var isNewJob = true; foreach (var trigger in scheduleJob.Triggers) { diff --git a/src/SilkierQuartz/Models/CalendarViewModel.cs b/src/SilkierQuartz/Models/CalendarViewModel.cs index 9347c8d..fa10b2c 100644 --- a/src/SilkierQuartz/Models/CalendarViewModel.cs +++ b/src/SilkierQuartz/Models/CalendarViewModel.cs @@ -93,9 +93,9 @@ public ICalendar BuildCalendar() }, Validator = (model, errors) => { - for (int i = 0; i < model.Days.Count; i++) + for (var i = 0; i < model.Days.Count; i++) { - if (DateTime.TryParseExact(model.Days[i], "MMMM d", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime _) == false) + if (DateTime.TryParseExact(model.Days[i], "MMMM d", CultureInfo.InvariantCulture, DateTimeStyles.None, out var _) == false) errors.Add(new ValidationError() { Field = nameof(model.Days), Reason = "Invalid format.", FieldIndex = i }); } } @@ -159,9 +159,9 @@ public ICalendar BuildCalendar() }, Validator = (model, errors) => { - for (int i = 0; i < model.Dates.Count; i++) + for (var i = 0; i < model.Dates.Count; i++) { - if (DateTime.TryParseExact(model.Dates[i], DateTimeSettings.DefaultDateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime _) == false) + if (DateTime.TryParseExact(model.Dates[i], DateTimeSettings.DefaultDateFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out var _) == false) errors.Add(new ValidationError() { Field = nameof(model.Dates), Reason = "Invalid format.", FieldIndex = i }); } } @@ -171,7 +171,7 @@ public ICalendar BuildCalendar() Builder = model => { var cal = new MonthlyCalendar() { TimeZone = model.ResolveTimeZone(), Description = model.Description }; - for (int i = 0; i < model.DaysExcluded.Length; i++) + for (var i = 0; i < model.DaysExcluded.Length; i++) cal.SetDayExcluded(i + 1, model.DaysExcluded[i]); return cal; }, @@ -186,7 +186,7 @@ public ICalendar BuildCalendar() Builder = model => { var cal = new WeeklyCalendar() { TimeZone = model.ResolveTimeZone(), Description = model.Description }; - for (int i = 0; i < model.DaysExcluded.Length; i++) + for (var i = 0; i < model.DaysExcluded.Length; i++) cal.SetDayExcluded((DayOfWeek)i, model.DaysExcluded[i]); return cal; }, diff --git a/src/SilkierQuartz/Models/Histogram.cs b/src/SilkierQuartz/Models/Histogram.cs index bea9e3a..05ac0e0 100644 --- a/src/SilkierQuartz/Models/Histogram.cs +++ b/src/SilkierQuartz/Models/Histogram.cs @@ -33,8 +33,8 @@ public void AddBar(double value, string tooltip, string cssClass) internal void Layout() { - double max = Bars.Max(x => x.Value); - int i = 0; + var max = Bars.Max(x => x.Value); + var i = 0; foreach (var b in Bars) { b.ComputedLeft = i * BarWidth; @@ -48,7 +48,7 @@ public static Histogram CreateEmpty() { var hst = new Histogram(); - for (int i = 0; i < 10; i++) + for (var i = 0; i < 10; i++) { hst.Bars.Add(new Bar() { diff --git a/src/SilkierQuartz/SilkierQuartz.csproj b/src/SilkierQuartz/SilkierQuartz.csproj index 326917b..2e636cd 100644 --- a/src/SilkierQuartz/SilkierQuartz.csproj +++ b/src/SilkierQuartz/SilkierQuartz.csproj @@ -1,14 +1,13 @@ 锘 - - net6.0 + net8.0 PackageReference true true 1591 true - 5.0.1 + 8.0.1 SilkierQuartz Web management tool for Quartz.NET Jan Lucansky, Yanhong Ma, mukmyash @@ -16,10 +15,10 @@ Powerful, easy to use web management tool for Quartz.NET quartz;web;ui - 1.0.5.0 - 1.0.5.0 + 1.0.8.1 + 1.0.8.1 LICENSE - Copyright 漏 2020 Jan Lucansky, Yanhong Ma, mukmyash + Copyright 漏 2024 Jan Lucansky, Yanhong Ma, mukmyash git https://github.com/maikebing/SilkierQuartz false @@ -50,6 +49,14 @@ True + + True + + + + True + + False @@ -61,6 +68,15 @@ False + + + False + + + + False + + @@ -68,8 +84,18 @@ - - + + + + + + + + + + + + diff --git a/src/SilkierQuartz/TypeHandlers/Attributes.cs b/src/SilkierQuartz/TypeHandlers/Attributes.cs index 01f62c9..0a7a8eb 100644 --- a/src/SilkierQuartz/TypeHandlers/Attributes.cs +++ b/src/SilkierQuartz/TypeHandlers/Attributes.cs @@ -48,7 +48,7 @@ public EmbeddedTypeHandlerResourcesAttribute(string name) protected string GetManifestResourceString(string name) { - string fullName = $"{Namespace}.{name}"; + var fullName = $"{Namespace}.{name}"; using (var stream = Assembly.GetManifestResourceStream(fullName)) { if (stream == null) diff --git a/src/SilkierQuartz/TypeHandlers/DateTimeHandler.cs b/src/SilkierQuartz/TypeHandlers/DateTimeHandler.cs index e24bb20..41080c6 100644 --- a/src/SilkierQuartz/TypeHandlers/DateTimeHandler.cs +++ b/src/SilkierQuartz/TypeHandlers/DateTimeHandler.cs @@ -30,7 +30,7 @@ public override bool CanHandle(object value) { if (value is DateTime dt) { - bool missingTime = dt.TimeOfDay.Ticks == 0; + var missingTime = dt.TimeOfDay.Ticks == 0; if (IgnoreTimeComponent == missingTime || IsUtc) return (IsUtc == (dt.Kind == DateTimeKind.Utc)); diff --git a/src/SilkierQuartz/ViewFileSystemFactory.cs b/src/SilkierQuartz/ViewFileSystemFactory.cs index a7c4f0a..d76859b 100644 --- a/src/SilkierQuartz/ViewFileSystemFactory.cs +++ b/src/SilkierQuartz/ViewFileSystemFactory.cs @@ -59,11 +59,11 @@ private class EmbeddedFileSystem : ViewEngineFileSystem private EmbeddedFileProvider fs = new EmbeddedFileProvider(Assembly.GetExecutingAssembly(), "SilkierQuartz.Views"); public override string GetFileContent(string filename) { - string result = string.Empty; + var result = string.Empty; var fi = fs.GetFileInfo(GetFullPath(filename)); using (var stream =fi.CreateReadStream()) { - using (StreamReader reader = new StreamReader(stream)) + using (var reader = new StreamReader(stream)) { result = reader.ReadToEnd(); } diff --git a/test/QuartzHostedServiceUnitTest.cs b/test/QuartzHostedServiceUnitTest.cs index 00d42c2..3b48c49 100644 --- a/test/QuartzHostedServiceUnitTest.cs +++ b/test/QuartzHostedServiceUnitTest.cs @@ -15,15 +15,15 @@ public class QuartzHostedServiceUnitTest [Fact(DisplayName = "Install JobFactory (For DI)")] public async void IServiceCollectionExtensions_Register_HostedService() { - IServiceProvider serviceProvider = A.Fake(); + var serviceProvider = A.Fake(); A.CallTo(() => serviceProvider.GetService(typeof(IEnumerable))).Returns(null); - ISchedulerFactory schedulerFactory = A.Fake(); - IScheduler scheduler = A.Fake(); + var schedulerFactory = A.Fake(); + var scheduler = A.Fake(); A.CallTo(() => schedulerFactory.GetScheduler(A.Ignored)) .Returns(Task.FromResult(scheduler)); - IJobFactory jobFactory = A.Fake(); + var jobFactory = A.Fake(); var testClass = new QuartzHostedService(serviceProvider, schedulerFactory, jobFactory); await testClass.StartAsync(CancellationToken.None); @@ -46,16 +46,16 @@ public async void IServiceCollectionExtensions_Register_RegisterJob() scheduleJobc.Add(new ScheduleJob(jobDetail2, new List() { A.Fake() })); scheduleJobc.Add(new ScheduleJob(jobDetail3, new List() { A.Fake() })); - IServiceProvider serviceProvider = A.Fake(); + var serviceProvider = A.Fake(); A.CallTo(() => serviceProvider.GetService(typeof(IEnumerable))).Returns(scheduleJobc); - ISchedulerFactory schedulerFactory = A.Fake(); - IScheduler scheduler = A.Fake(); + var schedulerFactory = A.Fake(); + var scheduler = A.Fake(); A.CallTo(() => schedulerFactory.GetScheduler(A.Ignored)) .Returns(Task.FromResult(scheduler)); - IJobFactory jobFactory = A.Fake(); + var jobFactory = A.Fake(); var testClass = new QuartzHostedService(serviceProvider, schedulerFactory, jobFactory); await testClass.StartAsync(CancellationToken.None); @@ -80,16 +80,16 @@ public async void IServiceCollectionExtensions_Register_RegisterJob_ITrigger() var trigger3 = A.Fake(); scheduleJobc.Add(new ScheduleJob(jobDetail1, new List() { trigger1, trigger2, trigger3 })); - IServiceProvider serviceProvider = A.Fake(); + var serviceProvider = A.Fake(); A.CallTo(() => serviceProvider.GetService(typeof(IEnumerable))).Returns(scheduleJobc); - ISchedulerFactory schedulerFactory = A.Fake(); - IScheduler scheduler = A.Fake(); + var schedulerFactory = A.Fake(); + var scheduler = A.Fake(); A.CallTo(() => schedulerFactory.GetScheduler(A.Ignored)) .Returns(Task.FromResult(scheduler)); - IJobFactory jobFactory = A.Fake(); + var jobFactory = A.Fake(); var testClass = new QuartzHostedService(serviceProvider, schedulerFactory, jobFactory); await testClass.StartAsync(CancellationToken.None); diff --git a/test/SilkierQuartz.Test.csproj b/test/SilkierQuartz.Test.csproj index 339feaa..752f9a3 100644 --- a/test/SilkierQuartz.Test.csproj +++ b/test/SilkierQuartz.Test.csproj @@ -1,16 +1,16 @@ 锘 - net6.0 + net8.0 false - - - - + + + + all