mirror of
https://github.com/fergalmoran/SilkierQuartz.git
synced 2025-12-22 09:37:56 +00:00
减少 startup 内的 Add和 Use
This commit is contained in:
27
sample/Properties/launchSettings.json
Normal file
27
sample/Properties/launchSettings.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:64450",
|
||||
"sslPort": 0
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"SilkierQuartz.Example": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "http://localhost:5000",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,8 +32,7 @@ namespace AspNetCore31
|
||||
services.AddOptions();
|
||||
services.Configure<AppSettings>(Configuration);
|
||||
services.Configure<InjectProperty>(options => { options.WriteText = "This is inject string"; });
|
||||
services.AddQuartzHostedService()
|
||||
.AddQuartzJob<HelloJob>()
|
||||
services.AddQuartzJob<HelloJob>()
|
||||
.AddQuartzJob<InjectSampleJob>()
|
||||
.AddQuartzJob<HelloJobSingle>()
|
||||
.AddQuartzJob<InjectSampleJobSingle>();
|
||||
|
||||
11
sample/app.config
Normal file
11
sample/app.config
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<section name="quartz" type="System.Configuration.NameValueFileSectionHandler" />
|
||||
</configSections>
|
||||
|
||||
<quartz>
|
||||
<add key="quartz.plugin.recentHistory.type" value="Quartz.Plugins.RecentHistory.ExecutionHistoryPlugin, Quartz.Plugins.RecentHistory" />
|
||||
<add key="quartz.plugin.recentHistory.storeType" value="Quartz.Plugins.RecentHistory.Impl.InProcExecutionHistoryStore, Quartz.Plugins.RecentHistory" />
|
||||
</quartz>
|
||||
</configuration>
|
||||
@@ -1,12 +1,13 @@
|
||||
#if ( NETSTANDARD || NETCOREAPP )
|
||||
|
||||
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Diagnostics;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using SilkierQuartz;
|
||||
using System;
|
||||
using System.Collections.Specialized;
|
||||
using System.Reflection;
|
||||
|
||||
namespace SilkierQuartz
|
||||
@@ -28,20 +29,11 @@ namespace SilkierQuartz
|
||||
await next.Invoke();
|
||||
});
|
||||
|
||||
|
||||
#if NETCOREAPP
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapControllerRoute(nameof(SilkierQuartz), $"{options.VirtualPathRoot}/{{controller=Scheduler}}/{{action=Index}}");
|
||||
});
|
||||
#else
|
||||
app.UseMvc( routes =>
|
||||
{
|
||||
routes.MapRoute(
|
||||
name: nameof( SilkierQuartz ),
|
||||
template: "{controller=Scheduler}/{action=Index}" );
|
||||
} );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
private static void UseFileServer(this IApplicationBuilder app, SilkierQuartzOptions options)
|
||||
@@ -63,23 +55,16 @@ namespace SilkierQuartz
|
||||
app.UseFileServer(fsOptions);
|
||||
}
|
||||
|
||||
#if NETCOREAPP
|
||||
public static void AddSilkierQuartz( this IServiceCollection services )
|
||||
public static void AddSilkierQuartz(this IServiceCollection services, Action<NameValueCollection> stdSchedulerFactoryOptions = null)
|
||||
{
|
||||
services.AddControllers()
|
||||
.AddApplicationPart(Assembly.GetExecutingAssembly())
|
||||
.AddNewtonsoftJson();
|
||||
services.UseQuartzHostedService(stdSchedulerFactoryOptions);
|
||||
|
||||
}
|
||||
#else
|
||||
public static void AddSilkierQuartz( this IServiceCollection services )
|
||||
{
|
||||
services.AddMvcCore()
|
||||
.AddApplicationPart( Assembly.GetExecutingAssembly() )
|
||||
.AddJsonFormatters();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Quartz;
|
||||
using Quartz.Spi;
|
||||
using SilkierQuartz.HostedService;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -9,7 +10,7 @@ using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SilkierQuartz.HostedService
|
||||
namespace SilkierQuartz
|
||||
{
|
||||
public static class IJobRegistratorExtensions
|
||||
{
|
||||
|
||||
@@ -4,12 +4,13 @@ using Microsoft.Extensions.Hosting;
|
||||
using Quartz;
|
||||
using Quartz.Impl;
|
||||
using Quartz.Spi;
|
||||
using SilkierQuartz.HostedService;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Text;
|
||||
|
||||
namespace SilkierQuartz.HostedService
|
||||
namespace SilkierQuartz
|
||||
{
|
||||
public static class IServiceCollectionExtensions
|
||||
{
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
|
||||
{{#footer}}
|
||||
<footer style="text-align:center; margin-top: 3em; padding: .8em 0; background-color: #f8f8f8; font-size: 90%; border-top: 1px solid rgba(34,36,38,.1);">
|
||||
<a href="https://github.com/jlucansky/SilkierQuartz" target="_blank" style="color: #909090"><i class="github icon"></i> SilkierQuartz v{{SilkierQuartzVersion}}</a>
|
||||
<a href="https://github.com/maikebing/SilkierQuartz" target="_blank" style="color: #909090"><i class="github icon"></i> SilkierQuartz v{{SilkierQuartzVersion}}</a>
|
||||
</footer>
|
||||
{{/footer}}
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user