Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for dotnet core 3.1 #26

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 10 additions & 38 deletions Quartzmin.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.2050
# Visual Studio Version 16
VisualStudioVersion = 16.0.29326.143
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Quartzmin", "Source\Quartzmin\Quartzmin.csproj", "{E14F97E0-8B3B-43A2-9820-2F4B94497253}"
EndProject
Expand All @@ -19,7 +19,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetCoreSelfHost", "Source\E
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormSelfHost", "Source\Examples\WinFormSelfHost\WinFormSelfHost.csproj", "{C54F4403-F40A-497C-B3A7-D1F1E1830D52}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNetCoreDocker", "Source\Examples\AspNetCoreDocker\AspNetCoreDocker.csproj", "{68D816F2-21BF-4376-ABF4-70390E4783C5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCoreDocker", "Source\Examples\AspNetCoreDocker\AspNetCoreDocker.csproj", "{68D816F2-21BF-4376-ABF4-70390E4783C5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNetCore3", "Source\Examples\AspNetCore3\AspNetCore3.csproj", "{3B2A3329-3BBB-4C6B-A42A-07EE565A2EB8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -59,6 +61,10 @@ Global
{68D816F2-21BF-4376-ABF4-70390E4783C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{68D816F2-21BF-4376-ABF4-70390E4783C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{68D816F2-21BF-4376-ABF4-70390E4783C5}.Release|Any CPU.Build.0 = Release|Any CPU
{3B2A3329-3BBB-4C6B-A42A-07EE565A2EB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3B2A3329-3BBB-4C6B-A42A-07EE565A2EB8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3B2A3329-3BBB-4C6B-A42A-07EE565A2EB8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3B2A3329-3BBB-4C6B-A42A-07EE565A2EB8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -69,43 +75,9 @@ Global
{7CF90DB9-37C4-4704-910E-BF1DB8AB79F1} = {B669A725-70A9-4E80-BAC7-9765A14CAAA4}
{C54F4403-F40A-497C-B3A7-D1F1E1830D52} = {B669A725-70A9-4E80-BAC7-9765A14CAAA4}
{68D816F2-21BF-4376-ABF4-70390E4783C5} = {B669A725-70A9-4E80-BAC7-9765A14CAAA4}
{3B2A3329-3BBB-4C6B-A42A-07EE565A2EB8} = {B669A725-70A9-4E80-BAC7-9765A14CAAA4}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0357313D-BD09-4C5D-AF0D-439B3BD33B5A}
EndGlobalSection
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 9
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccTeamFoundationServer = http://tfs/defaultcollection
SccLocalPath0 = .
SccProjectUniqueName1 = Source\\Quartzmin\\Quartzmin.csproj
SccProjectName1 = Source/Quartzmin
SccLocalPath1 = Source\\Quartzmin
SccProjectUniqueName2 = Source\\Quartz.Plugins.RecentHistory\\Quartz.Plugins.RecentHistory.csproj
SccProjectName2 = Source/Quartz.Plugins.RecentHistory
SccLocalPath2 = Source\\Quartz.Plugins.RecentHistory
SccProjectUniqueName3 = Source\\Quartzmin.SelfHost\\Quartzmin.SelfHost.csproj
SccProjectName3 = Source/Quartzmin.SelfHost
SccLocalPath3 = Source\\Quartzmin.SelfHost
SccProjectUniqueName4 = Source\\Examples\\NetCoreSelfHost\\NetCoreSelfHost.csproj
SccProjectTopLevelParentUniqueName4 = Quartzmin.sln
SccProjectName4 = Source/Examples/NetCoreSelfHost
SccLocalPath4 = Source\\Examples\\NetCoreSelfHost
SccProjectUniqueName5 = Source\\Examples\\AspNetCoreHost\\AspNetCoreHost.csproj
SccProjectTopLevelParentUniqueName5 = Quartzmin.sln
SccProjectName5 = Source/Examples/AspNetCoreHost
SccLocalPath5 = Source\\Examples\\AspNetCoreHost
SccProjectUniqueName6 = Source\\Examples\\AspNetWebHost\\AspNetWebHost.csproj
SccProjectTopLevelParentUniqueName6 = Quartzmin.sln
SccProjectName6 = Source/Examples/AspNetWebHost
SccLocalPath6 = Source\\Examples\\AspNetWebHost
SccProjectUniqueName7 = Source\\Examples\\WinFormSelfHost\\WinFormSelfHost.csproj
SccProjectTopLevelParentUniqueName7 = Quartzmin.sln
SccProjectName7 = Source/Examples/WinFormSelfHost
SccLocalPath7 = Source\\Examples\\WinFormSelfHost
SccProjectUniqueName8 = Source\\Examples\\AspNetCoreDocker\\AspNetCoreDocker.csproj
SccProjectTopLevelParentUniqueName8 = Quartzmin.sln
SccProjectName8 = Source/Examples/AspNetCoreDocker
SccLocalPath8 = Source\\Examples\\AspNetCoreDocker
EndGlobalSection
EndGlobal
20 changes: 20 additions & 0 deletions Source/Examples/AspNetCore3/AspNetCore3.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\Shared\DemoScheduler.cs" Link="DemoScheduler.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Quartzmin\Quartzmin.csproj" />
</ItemGroup>

</Project>
38 changes: 38 additions & 0 deletions Source/Examples/AspNetCore3/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Quartzmin;

namespace AspNetCore3
{
public class Program
{
public static void Main( string[] args )
{
var scheduler = DemoScheduler.Create().Result;

var host = WebHost.CreateDefaultBuilder( args ).Configure( app =>
{
app.UseQuartzmin( new QuartzminOptions() { Scheduler = scheduler } );

} ).ConfigureServices( services =>
{
services.AddQuartzmin();

} )
.Build();

host.Start();

while ( !scheduler.IsShutdown )
Thread.Sleep( 250 );
}
}
}
9 changes: 9 additions & 0 deletions Source/Examples/AspNetCore3/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}
8 changes: 8 additions & 0 deletions Source/Examples/AspNetCore3/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*"
}
85 changes: 51 additions & 34 deletions Source/Quartzmin/ApplicationBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NETSTANDARD
#if ( NETSTANDARD || NETCOREAPP )

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics;
Expand All @@ -13,65 +13,82 @@ namespace Quartzmin
{
public static class ApplicationBuilderExtensions
{
public static void UseQuartzmin(this IApplicationBuilder app, QuartzminOptions options, Action<Services> configure = null)
public static void UseQuartzmin( this IApplicationBuilder app, QuartzminOptions 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 );

var services = Services.Create(options);
configure?.Invoke(services);
var services = Services.Create( options );
configure?.Invoke( services );

app.Use(async (context, next) =>
{
context.Items[typeof(Services)] = services;
await next.Invoke();
});

app.UseExceptionHandler(errorApp =>
{
errorApp.Run(async context =>
{
var ex = context.Features.Get<IExceptionHandlerFeature>().Error;
context.Response.StatusCode = 500;
context.Response.ContentType = "text/html";
await context.Response.WriteAsync(services.ViewEngine.ErrorPage(ex));
});
});
app.Use( async ( context, next ) =>
{
context.Items[typeof( Services )] = services;
await next.Invoke();
} );

app.UseMvc(routes =>
app.UseExceptionHandler( errorApp =>
{
errorApp.Run( async context =>
{
var ex = context.Features.Get<IExceptionHandlerFeature>().Error;
context.Response.StatusCode = 500;
context.Response.ContentType = "text/html";
await context.Response.WriteAsync( services.ViewEngine.ErrorPage( ex ) );
} );
} );

#if NETCOREAPP
app.UseRouting();
app.UseEndpoints( endpoints =>
{
endpoints.MapControllerRoute( nameof( Quartzmin ), "{controller=Scheduler}/{action=Index}" );
} );
#else
app.UseMvc( routes =>
{
routes.MapRoute(
name: nameof(Quartzmin),
template: "{controller=Scheduler}/{action=Index}");
});
name: nameof( Quartzmin ),
template: "{controller=Scheduler}/{action=Index}" );
} );
#endif
}

private static void UseFileServer(this IApplicationBuilder app, QuartzminOptions options)
private static void UseFileServer( this IApplicationBuilder app, QuartzminOptions options )
{
IFileProvider fs;
if (string.IsNullOrEmpty(options.ContentRootDirectory))
fs = new ManifestEmbeddedFileProvider(Assembly.GetExecutingAssembly(), "Content");
if ( string.IsNullOrEmpty( options.ContentRootDirectory ) )
fs = new ManifestEmbeddedFileProvider( Assembly.GetExecutingAssembly(), "Content" );
else
fs = new PhysicalFileProvider(options.ContentRootDirectory);
fs = new PhysicalFileProvider( options.ContentRootDirectory );

var fsOptions = new FileServerOptions()
{
RequestPath = new PathString("/Content"),
RequestPath = new PathString( "/Content" ),
EnableDefaultFiles = false,
EnableDirectoryBrowsing = false,
FileProvider = fs
};

app.UseFileServer(fsOptions);
app.UseFileServer( fsOptions );
}

public static void AddQuartzmin(this IServiceCollection services)
#if NETCOREAPP
public static void AddQuartzmin( this IServiceCollection services )
{
services.AddControllers()
.AddApplicationPart( Assembly.GetExecutingAssembly() )
.AddNewtonsoftJson();
}
#else
public static void AddQuartzmin( this IServiceCollection services )
{
services.AddMvcCore()
.AddApplicationPart(Assembly.GetExecutingAssembly())
.AddApplicationPart( Assembly.GetExecutingAssembly() )
.AddJsonFormatters();
}
#endif

}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Quartzmin/Controllers/CalendarsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Threading.Tasks;

#region Target-Specific Directives
#if NETSTANDARD
#if ( NETSTANDARD || NETCOREAPP )
using Microsoft.AspNetCore.Mvc;
#endif
#if NETFRAMEWORK
Expand Down
2 changes: 1 addition & 1 deletion Source/Quartzmin/Controllers/ExecutionsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using System.Globalization;

#region Target-Specific Directives
#if NETSTANDARD
#if ( NETSTANDARD || NETCOREAPP )
using Microsoft.AspNetCore.Mvc;
#endif
#if NETFRAMEWORK
Expand Down
2 changes: 1 addition & 1 deletion Source/Quartzmin/Controllers/HistoryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using System.Threading.Tasks;

#region Target-Specific Directives
#if NETSTANDARD
#if ( NETSTANDARD || NETCOREAPP )
using Microsoft.AspNetCore.Mvc;
#endif
#if NETFRAMEWORK
Expand Down
10 changes: 7 additions & 3 deletions Source/Quartzmin/Controllers/JobDataMapController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using System.Threading;

#region Target-Specific Directives
#if NETSTANDARD
#if ( NETSTANDARD || NETCOREAPP )
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Http.Features;
#endif
Expand Down Expand Up @@ -37,8 +37,12 @@ public async Task<IActionResult> ChangeType()
}
catch (JsonSerializationException ex) when (ex.Message.StartsWith("Could not create an instance of type"))
{
return new BadRequestResult() { ReasonPhrase = "Unknown Type Handler" };
}
#if NETCOREAPP
return new BadRequestResult();
#else
return new BadRequestResult() { ReasonPhrase = "Unknown Type Handler" };
#endif
}

var dataMapForm = (await formData.GetJobDataMapForm(includeRowIndex: false)).SingleOrDefault(); // expected single row

Expand Down
2 changes: 1 addition & 1 deletion Source/Quartzmin/Controllers/JobsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using System.Threading.Tasks;

#region Target-Specific Directives
#if NETSTANDARD
#if ( NETSTANDARD || NETCOREAPP )
using Microsoft.AspNetCore.Mvc;
#endif
#if NETFRAMEWORK
Expand Down
14 changes: 8 additions & 6 deletions Source/Quartzmin/Controllers/PageControllerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@
using System.Threading;
using System.Threading.Tasks;
using Quartzmin.Models;
using Quartzmin.Helpers;
using Quartz;

namespace Quartzmin.Controllers
{
#region Target-Specific Directives
#region Target-Specific Directives

#if NETSTANDARD
#if ( NETSTANDARD || NETCOREAPP )
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

public abstract partial class PageControllerBase : Microsoft.AspNetCore.Mvc.ControllerBase
public abstract partial class PageControllerBase : Microsoft.AspNetCore.Mvc.ControllerBase
{
private static readonly JsonSerializerSettings _serializerSettings = new JsonSerializerSettings()
{
Expand All @@ -26,7 +27,8 @@ public abstract partial class PageControllerBase : Microsoft.AspNetCore.Mvc.Cont

protected Services Services => (Services) Request.HttpContext.Items[typeof(Services)];
protected string GetRouteData(string key) => RouteData.Values[key].ToString();
protected IActionResult Json(object content) => new JsonResult(content, _serializerSettings);
protected IActionResult Json( object content ) => new JsonResult( content, _serializerSettings );


protected IActionResult NotModified() => new StatusCodeResult(304);

Expand Down Expand Up @@ -83,9 +85,9 @@ protected IEnumerable<string> GetHeader(string key)

}
#endif
#endregion
#endregion

public abstract partial class PageControllerBase
public abstract partial class PageControllerBase
{
protected IScheduler Scheduler => Services.Scheduler;

Expand Down
2 changes: 1 addition & 1 deletion Source/Quartzmin/Controllers/SchedulerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using System.Globalization;

#region Target-Specific Directives
#if NETSTANDARD
#if ( NETSTANDARD || NETCOREAPP )
using Microsoft.AspNetCore.Mvc;
#endif
#if NETFRAMEWORK
Expand Down
Loading