|
|
using Autofac;
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
using SlnMesnac.Config;
|
|
|
using SlnMesnac.Ioc;
|
|
|
using SlnMesnac.Extensions;
|
|
|
using SlnMesnac.Serilog;
|
|
|
using SlnMesnac.Quartz;
|
|
|
|
|
|
#region << 版 本 注 释 >>
|
|
|
/*--------------------------------------------------------------------
|
|
|
* 版权所有 (c) 2024 WenJY 保留所有权利。
|
|
|
* CLR版本:4.0.30319.42000
|
|
|
* 机器名称:T14-GEN3-7895
|
|
|
* 命名空间:ConsoleApp
|
|
|
* 唯一标识:57e1b754-83fd-42ef-ad93-2693dcbebacf
|
|
|
*
|
|
|
* 创建者:WenJY
|
|
|
* 电子邮箱:
|
|
|
* 创建时间:2024-11-08 10:04:52
|
|
|
* 版本:V1.0.0
|
|
|
* 描述:
|
|
|
*
|
|
|
*--------------------------------------------------------------------
|
|
|
* 修改人:
|
|
|
* 时间:
|
|
|
* 修改说明:
|
|
|
*
|
|
|
* 版本:V1.0.0
|
|
|
*--------------------------------------------------------------------*/
|
|
|
#endregion << 版 本 注 释 >>
|
|
|
namespace ConsoleApp
|
|
|
{
|
|
|
public class Startup
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// This method gets called by the runtime. Use this method to add services to the container.
|
|
|
/// </summary>
|
|
|
/// <param name="services"></param>
|
|
|
[Obsolete]
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
|
{
|
|
|
services.AddControllers();
|
|
|
|
|
|
//注册AppConfig
|
|
|
services.AddSingleton<AppConfig>(provider =>
|
|
|
{
|
|
|
var configuration = provider.GetService<IConfiguration>();
|
|
|
return configuration.GetSection("AppConfig").Get<AppConfig>();
|
|
|
|
|
|
});
|
|
|
|
|
|
//注册ORM
|
|
|
services.AddSqlSugarSetup();
|
|
|
|
|
|
//注册PLC工厂
|
|
|
//services.AddPlcFactorySetup();
|
|
|
|
|
|
//注册httpClient
|
|
|
//services.AddHostedService<AirPorthttpClient>();
|
|
|
|
|
|
//注册TCPServer
|
|
|
//services.AddHostedService<TcpServer>();
|
|
|
|
|
|
//注册RFID工厂
|
|
|
//services.AddRfidFactorySetup();
|
|
|
|
|
|
//注册任务调度
|
|
|
services.AddQuartzSetUp();
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// AutoFac自动注入
|
|
|
/// </summary>
|
|
|
/// <param name="builder"></param>
|
|
|
public void ConfigureContainer(ContainerBuilder builder)
|
|
|
{
|
|
|
DependencyConfigurator.Configure(builder);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
|
/// </summary>
|
|
|
/// <param name="app"></param>
|
|
|
/// <param name="env"></param>
|
|
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|
|
{
|
|
|
if (env.IsDevelopment())
|
|
|
{
|
|
|
app.UseDeveloperExceptionPage();
|
|
|
}
|
|
|
|
|
|
//启用Serilog中间件
|
|
|
app.UseSerilogExtensions();
|
|
|
|
|
|
//app.UseTouchSocketExtensions();
|
|
|
|
|
|
app.UseRouting();
|
|
|
|
|
|
app.UseAuthorization();
|
|
|
|
|
|
app.UseEndpoints(endpoints =>
|
|
|
{
|
|
|
endpoints.MapControllers();
|
|
|
});
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|