提交 345e4eb0 编写于 作者: 麦壳饼's avatar 麦壳饼

Upgrade to .Net Core 3.0

上级 1979d2ff
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
......@@ -20,24 +20,23 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="CrystalQuartz.AspNetCore" Version="6.8.1" />
<PackageReference Include="HslCommunication" Version="6.2.5" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.WindowsServices" Version="2.2.0" />
<PackageReference Include="Quartz" Version="3.0.7" />
<PackageReference Include="QuartzHostedService" Version="0.0.5" />
<PackageReference Include="Quartzmin.SelfHost" Version="1.0.3" />
<PackageReference Include="System.ServiceModel.Duplex" Version="4.5.3" />
<PackageReference Include="System.ServiceModel.Http" Version="4.5.3" />
<PackageReference Include="System.ServiceModel.NetTcp" Version="4.5.3" />
<PackageReference Include="System.ServiceModel.Security" Version="4.5.3" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" />
<PackageReference Include="QuartzHostedServiceEx" Version="0.0.7" />
<PackageReference Include="System.ServiceModel.Duplex" Version="4.6.0" />
<PackageReference Include="System.ServiceModel.Http" Version="4.6.0" />
<PackageReference Include="System.ServiceModel.NetTcp" Version="4.6.0" />
<PackageReference Include="System.ServiceModel.Security" Version="4.6.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.6.0" />
<PackageReference Include="System.IO.Compression" Version="4.3.0" />
<PackageReference Include="System.Memory" Version="4.5.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\IoTSharp.EdgeSdk.MQTT\IoTSharp.EdgeSdk.MQTT.csproj" />
<ProjectReference Include="..\IoTSharp.Extensions.AspNetCore\IoTSharp.Extensions.AspNetCore.csproj" />
<ProjectReference Include="..\IoTSharp.Extensions\IoTSharp.Extensions.csproj" />
</ItemGroup>
......
using IoTSharp.Extensions;
using IoT.Things.ModBus.Services;
using IoTSharp.Extensions;
using IoTSharp.Extensions.AspNetCore;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using QuartzHostedService;
namespace IoT.Things.ModBus
{
......@@ -9,14 +14,27 @@ namespace IoT.Things.ModBus
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().RunAsEnv();
CreateHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseContentRootAsEnv()
.UseStartup<Startup>();
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWindowsServices()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.ConfigureKestrel(serverOptions =>
{
serverOptions.AllowSynchronousIO = true;
});
webBuilder.UseStartup<Startup>();
})
.ConfigureQuartzHost()
.ConfigureServices(services =>
{
services.AddHostedService<ModBusService>();
});
}
}
\ No newline at end of file
using IoT.Things.ModBus.Jobs;
using CrystalQuartz.AspNetCore;
using IoT.Things.ModBus.Jobs;
using IoT.Things.ModBus.Services;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Quartz;
using QuartzHostedService;
using Quartzmin;
using System;
using System.Linq;
using System.Reflection;
......@@ -28,8 +29,7 @@ namespace IoT.Things.ModBus
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddQuartzmin();
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services.AddControllersWithViews();
services.AddOptions();
services.Configure<AppSettings>(Configuration);
......@@ -39,7 +39,7 @@ namespace IoT.Things.ModBus
});
services.AddQuartzHostedService();
services.AddTransient<Slaver>();
services.AddHostedService<ModBusService>();
services.AddSingleton(options =>
{
var mqtt = new IoTSharp.EdgeSdk.MQTT.MQTTClient();
......@@ -49,20 +49,22 @@ namespace IoT.Things.ModBus
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IOptions<AppSettings> options, ISchedulerFactory factory)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IOptions<AppSettings> options, ISchedulerFactory factory)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseQuartzmin(new QuartzminOptions()
app.UseRouting();
app.UseEndpoints(endpoints =>
{
Scheduler = factory.GetScheduler().Result,
ProductName = typeof(Startup).Assembly.GetName().Name,
endpoints.MapControllers();
});
app.UseMvc();
app.UseCrystalQuartz(() => factory.GetScheduler().Result);
}
}
}
\ No newline at end of file
......@@ -4,4 +4,7 @@
相关文章请参考
https://www.cnblogs.com/MysticBoy/p/11110364.html
\ No newline at end of file
https://www.cnblogs.com/MysticBoy/p/11110364.html
由于使用到的HSL组件已经闭源,本项目后期会从本项目中删除
\ No newline at end of file
......@@ -6,6 +6,7 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D5C97089-F896-436D-8E99-27B2E43BC65F}"
ProjectSection(SolutionItems) = preProject
appveyor.yml = appveyor.yml
GitVersion.yml = GitVersion.yml
LICENSE = LICENSE
README.md = README.md
roadmap.md = roadmap.md
......@@ -23,6 +24,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTSharp.Edge.ModBus", "IoT
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTSharp.Extensions", "IoTSharp.Extensions\IoTSharp.Extensions.csproj", "{551E62E3-51DA-4C1D-8DBB-7346A29EE817}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IoTSharp.Extensions.AspNetCore", "IoTSharp.Extensions.AspNetCore\IoTSharp.Extensions.AspNetCore.csproj", "{AC80DA58-F40E-4B3C-8271-A25F65FEB0CB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -163,6 +166,26 @@ Global
{551E62E3-51DA-4C1D-8DBB-7346A29EE817}.Release|x64.Build.0 = Release|Any CPU
{551E62E3-51DA-4C1D-8DBB-7346A29EE817}.Release|x86.ActiveCfg = Release|Any CPU
{551E62E3-51DA-4C1D-8DBB-7346A29EE817}.Release|x86.Build.0 = Release|Any CPU
{AC80DA58-F40E-4B3C-8271-A25F65FEB0CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AC80DA58-F40E-4B3C-8271-A25F65FEB0CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AC80DA58-F40E-4B3C-8271-A25F65FEB0CB}.Debug|ARM.ActiveCfg = Debug|Any CPU
{AC80DA58-F40E-4B3C-8271-A25F65FEB0CB}.Debug|ARM.Build.0 = Debug|Any CPU
{AC80DA58-F40E-4B3C-8271-A25F65FEB0CB}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{AC80DA58-F40E-4B3C-8271-A25F65FEB0CB}.Debug|ARM64.Build.0 = Debug|Any CPU
{AC80DA58-F40E-4B3C-8271-A25F65FEB0CB}.Debug|x64.ActiveCfg = Debug|Any CPU
{AC80DA58-F40E-4B3C-8271-A25F65FEB0CB}.Debug|x64.Build.0 = Debug|Any CPU
{AC80DA58-F40E-4B3C-8271-A25F65FEB0CB}.Debug|x86.ActiveCfg = Debug|Any CPU
{AC80DA58-F40E-4B3C-8271-A25F65FEB0CB}.Debug|x86.Build.0 = Debug|Any CPU
{AC80DA58-F40E-4B3C-8271-A25F65FEB0CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AC80DA58-F40E-4B3C-8271-A25F65FEB0CB}.Release|Any CPU.Build.0 = Release|Any CPU
{AC80DA58-F40E-4B3C-8271-A25F65FEB0CB}.Release|ARM.ActiveCfg = Release|Any CPU
{AC80DA58-F40E-4B3C-8271-A25F65FEB0CB}.Release|ARM.Build.0 = Release|Any CPU
{AC80DA58-F40E-4B3C-8271-A25F65FEB0CB}.Release|ARM64.ActiveCfg = Release|Any CPU
{AC80DA58-F40E-4B3C-8271-A25F65FEB0CB}.Release|ARM64.Build.0 = Release|Any CPU
{AC80DA58-F40E-4B3C-8271-A25F65FEB0CB}.Release|x64.ActiveCfg = Release|Any CPU
{AC80DA58-F40E-4B3C-8271-A25F65FEB0CB}.Release|x64.Build.0 = Release|Any CPU
{AC80DA58-F40E-4B3C-8271-A25F65FEB0CB}.Release|x86.ActiveCfg = Release|Any CPU
{AC80DA58-F40E-4B3C-8271-A25F65FEB0CB}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册