fix title ,namespace ,and more

This commit is contained in:
MysticBoy
2020-06-08 19:15:39 +08:00
parent fbf9f79a3d
commit e0bcb4cb20
22 changed files with 167 additions and 79 deletions

4
.editorconfig Normal file
View File

@@ -0,0 +1,4 @@
[*.cs]
# Default severity for analyzer diagnostics with category 'Style'
dotnet_analyzer_diagnostic.category-Style.severity = none

View File

@@ -8,6 +8,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F77F2A7C-C844-4DEE-B797-67AB09655FC1}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F77F2A7C-C844-4DEE-B797-67AB09655FC1}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
.dockerignore = .dockerignore .dockerignore = .dockerignore
.editorconfig = .editorconfig
.gitattributes = .gitattributes .gitattributes = .gitattributes
.gitignore = .gitignore .gitignore = .gitignore
.travis.yml = .travis.yml .travis.yml = .travis.yml

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace AspNetCore31 namespace SilkierQuartz.Example
{ {
public class AppSettings public class AppSettings
{ {

View File

@@ -1,19 +1,25 @@
using Quartz; using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Quartz;
using Quartz.Impl; using Quartz.Impl;
using Quartz.Impl.Matchers; using Quartz.Impl.Matchers;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Runtime.CompilerServices;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace SilkierQuartz namespace SilkierQuartz
{ {
public static class DemoScheduler public static class DemoScheduler
{ {
public static async Task<IScheduler> Create(bool start = true) /// <summary>
/// How to compatible old code to SilkierQuartz
/// </summary>
/// <param name="app"></param>
public static void SchedulerJobs(this IApplicationBuilder app)
{ {
var scheduler = await StdSchedulerFactory.GetDefaultScheduler(); IScheduler scheduler = app.GetScheduler();
{ {
var jobData = new JobDataMap(); var jobData = new JobDataMap();
jobData.Put("DateFrom", DateTime.Now); jobData.Put("DateFrom", DateTime.Now);
@@ -30,7 +36,7 @@ namespace SilkierQuartz
.StartNow() .StartNow()
.WithCronSchedule("0 0 8 1/1 * ? *") .WithCronSchedule("0 0 8 1/1 * ? *")
.Build(); .Build();
await scheduler.ScheduleJob(job, trigger); scheduler.ScheduleJob(job, trigger).Wait();
trigger = TriggerBuilder.Create() trigger = TriggerBuilder.Create()
.WithIdentity("MonthlySales") .WithIdentity("MonthlySales")
@@ -38,8 +44,8 @@ namespace SilkierQuartz
.StartNow() .StartNow()
.WithCronSchedule("0 0 12 1 1/1 ? *") .WithCronSchedule("0 0 12 1 1/1 ? *")
.Build(); .Build();
await scheduler.ScheduleJob(trigger); scheduler.ScheduleJob(trigger).Wait(); ;
await scheduler.PauseTrigger(trigger.Key); scheduler.PauseTrigger(trigger.Key).Wait(); ;
trigger = TriggerBuilder.Create() trigger = TriggerBuilder.Create()
.WithIdentity("HourlySales") .WithIdentity("HourlySales")
@@ -47,9 +53,9 @@ namespace SilkierQuartz
.StartNow() .StartNow()
.WithSimpleSchedule(x => x.WithIntervalInHours(1).RepeatForever()) .WithSimpleSchedule(x => x.WithIntervalInHours(1).RepeatForever())
.Build(); .Build();
await scheduler.ScheduleJob(trigger); scheduler.ScheduleJob(trigger).Wait(); ;
} }
Task.Run(async () =>
{ {
var job = JobBuilder.Create<DummyJob>().WithIdentity("Job1").StoreDurably().Build(); var job = JobBuilder.Create<DummyJob>().WithIdentity("Job1").StoreDurably().Build();
await scheduler.AddJob(job, false); await scheduler.AddJob(job, false);
@@ -85,8 +91,8 @@ namespace SilkierQuartz
job = JobBuilder.Create<DummyJob>().WithIdentity("Send Push", "CRITICAL").StoreDurably().RequestRecovery().Build(); job = JobBuilder.Create<DummyJob>().WithIdentity("Send Push", "CRITICAL").StoreDurably().RequestRecovery().Build();
await scheduler.AddJob(job, false); await scheduler.AddJob(job, false);
} });
Task.Run(async () =>
{ {
var job = JobBuilder.Create<DisallowConcurrentJob>() var job = JobBuilder.Create<DisallowConcurrentJob>()
.WithIdentity("Load CSV", "IMPORT") .WithIdentity("Load CSV", "IMPORT")
@@ -103,14 +109,12 @@ namespace SilkierQuartz
.WithIdentity("CSV_big", "LONGRUNNING") .WithIdentity("CSV_big", "LONGRUNNING")
.ForJob(job) .ForJob(job)
.StartNow() .StartNow()
.WithDailyTimeIntervalSchedule(x=>x.OnMondayThroughFriday()) .WithDailyTimeIntervalSchedule(x => x.OnMondayThroughFriday())
.Build(); .Build();
await scheduler.ScheduleJob(trigger); await scheduler.ScheduleJob(trigger);
} });
if (start)
await scheduler.Start();
return scheduler;
} }
public class DummyJob : IJob public class DummyJob : IJob

View File

@@ -2,7 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
namespace AspNetCore31 namespace SilkierQuartz.Example
{ {
public class InjectProperty public class InjectProperty
{ {

View File

@@ -4,7 +4,7 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace AspNetCore31.Jobs namespace SilkierQuartz.Example.Jobs
{ {
public class HelloJob : IJob public class HelloJob : IJob
{ {

View File

@@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace AspNetCore31.Jobs namespace SilkierQuartz.Example.Jobs
{ {
[SilkierQuartz(5, "this e sq test","_hellojobauto",TriggerGroup = "SilkierQuartz")] [SilkierQuartz(5, "this e sq test","_hellojobauto",TriggerGroup = "SilkierQuartz")]

View File

@@ -4,7 +4,7 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace AspNetCore31.Jobs namespace SilkierQuartz.Example.Jobs
{ {
public class HelloJobSingle : IJob public class HelloJobSingle : IJob
{ {

View File

@@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace AspNetCore31.Jobs namespace SilkierQuartz.Example.Jobs
{ {
public class InjectSampleJob : IJob public class InjectSampleJob : IJob
{ {

View File

@@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace AspNetCore31.Jobs namespace SilkierQuartz.Example.Jobs
{ {
public class InjectSampleJobSingle : IJob public class InjectSampleJobSingle : IJob
{ {

View File

@@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace AspNetCore31.Pages namespace SilkierQuartz.Example.Pages
{ {
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public class ErrorModel : PageModel public class ErrorModel : PageModel

View File

@@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace AspNetCore31.Pages namespace SilkierQuartz.Example.Pages
{ {
public class IndexModel : PageModel public class IndexModel : PageModel
{ {

View File

@@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace AspNetCore31.Pages namespace SilkierQuartz.Example.Pages
{ {
public class PrivacyModel : PageModel public class PrivacyModel : PageModel
{ {

View File

@@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - AspNetCore31</title> <title>@ViewData["Title"] - SilkierQuartz.Example</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" /> <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" /> <link rel="stylesheet" href="~/css/site.css" />
</head> </head>
@@ -11,7 +11,7 @@
<header> <header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3"> <nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container"> <div class="container">
<a class="navbar-brand" asp-area="" asp-page="/Index">AspNetCore31</a> <a class="navbar-brand" asp-area="" asp-page="/Index">SilkierQuartz.Example</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent" <button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation"> aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
@@ -40,7 +40,7 @@
<footer class="border-top footer text-muted"> <footer class="border-top footer text-muted">
<div class="container"> <div class="container">
&copy; 2020 - AspNetCore31 - <a asp-area="" asp-page="/Privacy">Privacy</a> &copy; 2020 - SilkierQuartz.Example - <a asp-area="" asp-page="/Privacy">Privacy</a>
</div> </div>
</footer> </footer>

View File

@@ -1,3 +1,3 @@
@using AspNetCore31 @using SilkierQuartz.Example
@namespace AspNetCore31.Pages @namespace SilkierQuartz.Example.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

View File

@@ -9,7 +9,7 @@ using Microsoft.Extensions.Logging;
using SilkierQuartz; using SilkierQuartz;
using SilkierQuartz.HostedService; using SilkierQuartz.HostedService;
namespace AspNetCore31 namespace SilkierQuartz.Example
{ {
public class Program public class Program
{ {

View File

@@ -2,7 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using AspNetCore31.Jobs; using SilkierQuartz.Example.Jobs;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
@@ -10,10 +10,8 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Quartz; using Quartz;
using SilkierQuartz;
using SilkierQuartz.HostedService;
namespace AspNetCore31 namespace SilkierQuartz.Example
{ {
public class Startup public class Startup
{ {
@@ -32,14 +30,16 @@ namespace AspNetCore31
services.AddOptions(); services.AddOptions();
services.Configure<AppSettings>(Configuration); services.Configure<AppSettings>(Configuration);
services.Configure<InjectProperty>(options => { options.WriteText = "This is inject string"; }); services.Configure<InjectProperty>(options => { options.WriteText = "This is inject string"; });
#pragma warning disable CS0618 // <20><><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD>Ա<EFBFBD>ѹ<EFBFBD>ʱ
services.AddQuartzJob<HelloJob>() services.AddQuartzJob<HelloJob>()
.AddQuartzJob<InjectSampleJob>() .AddQuartzJob<InjectSampleJob>()
.AddQuartzJob<HelloJobSingle>() .AddQuartzJob<HelloJobSingle>()
.AddQuartzJob<InjectSampleJobSingle>(); .AddQuartzJob<InjectSampleJobSingle>();
#pragma warning restore CS0618 // <20><><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD>Ա<EFBFBD>ѹ<EFBFBD>ʱ
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IOptions<AppSettings> settings, ISchedulerFactory factory) public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{ {
if (env.IsDevelopment()) if (env.IsDevelopment())
{ {
@@ -49,17 +49,31 @@ namespace AspNetCore31
{ {
app.UseExceptionHandler("/Error"); app.UseExceptionHandler("/Error");
} }
var scheduler = DemoScheduler.Create().Result;
app.UseStaticFiles(); app.UseStaticFiles();
app.UseRouting(); app.UseRouting();
app.UseAuthorization(); app.UseAuthorization();
app.UseSilkierQuartz(new SilkierQuartzOptions() { Scheduler = scheduler, VirtualPathRoot = "/SilkierQuartz" , UseLocalTime =true, DefaultDateFormat="yyyy-MM-dd", DefaultTimeFormat="HH:mm:ss" }); app.UseSilkierQuartz(
new SilkierQuartzOptions()
{
VirtualPathRoot = "/SilkierQuartz",
UseLocalTime = true,
DefaultDateFormat = "yyyy-MM-dd",
DefaultTimeFormat = "HH:mm:ss"
}
);
app.UseEndpoints(endpoints => app.UseEndpoints(endpoints =>
{ {
endpoints.MapRazorPages(); endpoints.MapRazorPages();
}); });
//How to compatible old code to SilkierQuartz
//<2F><><EFBFBD>ɵ<EFBFBD>ԭ<EFBFBD><D4AD><EFBFBD>Ĺ滮Job<6F>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD>ݵ<EFBFBD>ʾ<EFBFBD><CABE>
app.SchedulerJobs();
#region <EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD> SilkierQuartzAttribe <EFBFBD><EFBFBD><EFBFBD>ԵĽ<EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>õ<EFBFBD>IJob<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD>UseQuartzJob<EFBFBD><EFBFBD>IJob<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ConfigureServices<EFBFBD><EFBFBD><EFBFBD><EFBFBD>AddQuartzJob
#pragma warning disable CS0618 // <20><><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD>Ա<EFBFBD>ѹ<EFBFBD>ʱ
app.UseQuartzJob<HelloJobSingle>(TriggerBuilder.Create().WithSimpleSchedule(x => x.WithIntervalInSeconds(1).RepeatForever())) app.UseQuartzJob<HelloJobSingle>(TriggerBuilder.Create().WithSimpleSchedule(x => x.WithIntervalInSeconds(1).RepeatForever()))
.UseQuartzJob<InjectSampleJobSingle>(() => .UseQuartzJob<InjectSampleJobSingle>(() =>
{ {
@@ -82,7 +96,8 @@ namespace AspNetCore31
.WithSimpleSchedule(x => x.WithIntervalInSeconds(10).RepeatForever())); .WithSimpleSchedule(x => x.WithIntervalInSeconds(10).RepeatForever()));
return result; return result;
}); });
#pragma warning restore CS0618 // <20><><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD>Ա<EFBFBD>ѹ<EFBFBD>ʱ
#endregion
} }
} }
} }

View File

@@ -25,6 +25,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<None Include="..\..\.editorconfig" Link=".editorconfig" />
<None Include="..\..\LICENSE" Pack="true" PackagePath="" /> <None Include="..\..\LICENSE" Pack="true" PackagePath="" />
</ItemGroup> </ItemGroup>

View File

@@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.FileProviders;
using Quartz; using Quartz;
using Quartz.Impl;
using SilkierQuartz; using SilkierQuartz;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -18,12 +19,65 @@ namespace SilkierQuartz
{ {
public static class ApplicationBuilderExtensions public static class ApplicationBuilderExtensions
{ {
/// <summary>
/// Returns a client-usable handle to a Quartz.IScheduler.
/// </summary>
/// <param name="app"></param>
/// <returns></returns>
public static IScheduler GetScheduler(this IApplicationBuilder app)
{
return app.ApplicationServices.GetRequiredService<ISchedulerFactory>().GetScheduler().Result;
}
/// <summary>
/// Returns a handle to the Scheduler with the given name, if it exists.
/// </summary>
/// <param name="app"></param>
/// <param name="schedName"></param>
/// <returns></returns>
public static IScheduler GetScheduler(this IApplicationBuilder app,string schedName)
{
return app.ApplicationServices.GetRequiredService<ISchedulerFactory>().GetScheduler(schedName ).Result;
}
/// <summary>
/// Returns handles to all known Schedulers (made by any SchedulerFactory within this app domain.
/// </summary>
/// <param name="app"></param>
/// <returns></returns>
public static IReadOnlyList<IScheduler> GetAllSchedulers(this IApplicationBuilder app)
{
return app.ApplicationServices.GetRequiredService<ISchedulerFactory>().GetAllSchedulers().Result;
}
[Obsolete("We recommend UseSilkierQuartz")]
public static void UseQuartzmin(this IApplicationBuilder app, SilkierQuartzOptions options, Action<Services> configure = null)
=> app.UseSilkierQuartz(options, configure);
/// <summary>
/// Use SilkierQuartz and automatically discover IJob subclasses with SilkierQuartzAttribute
/// </summary>
/// <param name="app"></param>
/// <param name="options"></param>
/// <param name="configure"></param>
public static void UseSilkierQuartz(this IApplicationBuilder app, SilkierQuartzOptions options, Action<Services> configure = null) public static void UseSilkierQuartz(this IApplicationBuilder app, SilkierQuartzOptions options, Action<Services> configure = null)
{ {
options = options ?? throw new ArgumentNullException(nameof(options)); options = options ?? throw new ArgumentNullException(nameof(options));
app.UseFileServer(options); app.UseFileServer(options);
if (options.Scheduler == null)
{
try
{
options.Scheduler = app.ApplicationServices.GetRequiredService<ISchedulerFactory>()?.GetScheduler().Result;
}
catch (Exception)
{
options.Scheduler = null;
}
if (options.Scheduler==null)
{
options.Scheduler = StdSchedulerFactory.GetDefaultScheduler().Result;
}
}
var services = Services.Create(options); var services = Services.Create(options);
configure?.Invoke(services); configure?.Invoke(services);
@@ -101,6 +155,10 @@ namespace SilkierQuartz
app.UseFileServer(fsOptions); app.UseFileServer(fsOptions);
} }
[Obsolete("We recommend AddSilkierQuartz")]
public static void AddQuartzmin(this IServiceCollection services, Action<NameValueCollection> stdSchedulerFactoryOptions = null)
=> services.AddSilkierQuartz(stdSchedulerFactoryOptions);
public static void AddSilkierQuartz(this IServiceCollection services, Action<NameValueCollection> stdSchedulerFactoryOptions = null,Func<List<Assembly>> jobsasmlist=null) public static void AddSilkierQuartz(this IServiceCollection services, Action<NameValueCollection> stdSchedulerFactoryOptions = null,Func<List<Assembly>> jobsasmlist=null)
{ {

View File

@@ -68,6 +68,8 @@ namespace SilkierQuartz
services.AddSingleton<IScheduleJob>(provider => new ScheduleJob(detail, new List<ITrigger>())); services.AddSingleton<IScheduleJob>(provider => new ScheduleJob(detail, new List<ITrigger>()));
return services; return services;
} }
[Obsolete("We recommend SilkierQuartzAttribute")]
public static IServiceCollection AddQuartzJob<TJob>(this IServiceCollection services) where TJob : class public static IServiceCollection AddQuartzJob<TJob>(this IServiceCollection services) where TJob : class
{ {
services.AddTransient<TJob>(); services.AddTransient<TJob>();
@@ -97,7 +99,7 @@ namespace SilkierQuartz
} }
return app; return app;
} }
[Obsolete("We recommend SilkierQuartzAttribute")]
public static IApplicationBuilder UseQuartzJob<TJob>( public static IApplicationBuilder UseQuartzJob<TJob>(
this IApplicationBuilder app, this IApplicationBuilder app,
TriggerBuilder triggerBuilder) TriggerBuilder triggerBuilder)
@@ -105,7 +107,7 @@ namespace SilkierQuartz
{ {
return app.UseQuartzJob<TJob>(new TriggerBuilder[] { triggerBuilder }); return app.UseQuartzJob<TJob>(new TriggerBuilder[] { triggerBuilder });
} }
[Obsolete("We recommend SilkierQuartzAttribute")]
public static IApplicationBuilder UseQuartzJob<TJob>( public static IApplicationBuilder UseQuartzJob<TJob>(
this IApplicationBuilder app, this IApplicationBuilder app,
Func<IEnumerable<TriggerBuilder>> triggerBuilders_func) Func<IEnumerable<TriggerBuilder>> triggerBuilders_func)
@@ -113,6 +115,7 @@ namespace SilkierQuartz
{ {
return app.UseQuartzJob<TJob>(triggerBuilders_func()); return app.UseQuartzJob<TJob>(triggerBuilders_func());
} }
[Obsolete("We recommend SilkierQuartzAttribute")]
public static IApplicationBuilder UseQuartzJob<TJob>( public static IApplicationBuilder UseQuartzJob<TJob>(
this IApplicationBuilder app, this IApplicationBuilder app,
IEnumerable<TriggerBuilder> triggerBuilders) IEnumerable<TriggerBuilder> triggerBuilders)
@@ -120,6 +123,7 @@ namespace SilkierQuartz
{ {
return app.UseQuartzJob(typeof(TJob), triggerBuilders); return app.UseQuartzJob(typeof(TJob), triggerBuilders);
} }
[Obsolete("We recommend SilkierQuartzAttribute")]
public static IApplicationBuilder UseQuartzJob( public static IApplicationBuilder UseQuartzJob(
this IApplicationBuilder app, Type t, this IApplicationBuilder app, Type t,
TriggerBuilder triggerBuilder) TriggerBuilder triggerBuilder)

View File

@@ -26,7 +26,8 @@ namespace SilkierQuartz
_quartzHostedServiceIsAdded = true; _quartzHostedServiceIsAdded = true;
return builder.ConfigureServices(services => services.AddHostedService<QuartzHostedService>()); return builder.ConfigureServices(services => services.AddHostedService<QuartzHostedService>());
} }
[Obsolete("We recommend ConfigureSilkierQuartzHost")]
public static IHostBuilder ConfigureQuartzHost(this IHostBuilder builder) => builder.ConfigureSilkierQuartzHost();
public static IJobRegistrator UseQuartzHostedService(this IServiceCollection services, public static IJobRegistrator UseQuartzHostedService(this IServiceCollection services,
Action<NameValueCollection> stdSchedulerFactoryOptions) Action<NameValueCollection> stdSchedulerFactoryOptions)

View File

@@ -1,4 +1,5 @@
using Quartz; using Quartz;
using Quartz.Impl;
using SilkierQuartz.TypeHandlers; using SilkierQuartz.TypeHandlers;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@@ -53,7 +54,6 @@ namespace SilkierQuartz
public SilkierQuartzOptions() public SilkierQuartzOptions()
{ {
DefaultSelectedType = new StringHandler() { Name = "String" }; DefaultSelectedType = new StringHandler() { Name = "String" };
// order of StandardTypes is important due to TypeHandlerBase.CanHandle evaluation // order of StandardTypes is important due to TypeHandlerBase.CanHandle evaluation
StandardTypes.Add(new FileHandler() { Name = "File", DisplayName = "Binary Data" }); StandardTypes.Add(new FileHandler() { Name = "File", DisplayName = "Binary Data" });
StandardTypes.Add(new BooleanHandler() { Name = "Boolean" }); StandardTypes.Add(new BooleanHandler() { Name = "Boolean" });