|  |  |  | 
|---|
|  |  |  | using WIDESEAWCS_Core.Helper; | 
|---|
|  |  |  | using WIDESEAWCS_Core.Extensions; | 
|---|
|  |  |  | using WIDESEAWCS_Core.Middlewares; | 
|---|
|  |  |  | using System.Reflection; | 
|---|
|  |  |  | using WIDESEAWCS_Core.Filter; | 
|---|
|  |  |  | using Newtonsoft.Json.Converters; | 
|---|
|  |  |  | using Newtonsoft.Json.Serialization; | 
|---|
|  |  |  | using Newtonsoft.Json; | 
|---|
|  |  |  | using System.Text; | 
|---|
|  |  |  | using Microsoft.AspNetCore.Mvc.Controllers; | 
|---|
|  |  |  | using Microsoft.Extensions.DependencyInjection.Extensions; | 
|---|
|  |  |  | using Microsoft.AspNetCore.Mvc.ModelBinding.Validation; | 
|---|
|  |  |  | using WIDESEAWCS_Core; | 
|---|
|  |  |  | using WIDESEAWCS_Core.BaseServices; | 
|---|
|  |  |  | using Autofac.Extensions.DependencyInjection; | 
|---|
|  |  |  | using Autofac; | 
|---|
|  |  |  | using WIDESEAWCS_WCSServer.Filter; | 
|---|
|  |  |  | using Autofac.Extensions.DependencyInjection; | 
|---|
|  |  |  | using Microsoft.AspNetCore.Mvc.Controllers; | 
|---|
|  |  |  | using Microsoft.AspNetCore.SignalR; | 
|---|
|  |  |  | using Microsoft.Extensions.DependencyInjection.Extensions; | 
|---|
|  |  |  | using Newtonsoft.Json; | 
|---|
|  |  |  | using Newtonsoft.Json.Converters; | 
|---|
|  |  |  | using System.Reflection; | 
|---|
|  |  |  | using System.Text; | 
|---|
|  |  |  | using WIDESEAWCS_Core; | 
|---|
|  |  |  | using WIDESEAWCS_Core.Authorization; | 
|---|
|  |  |  | using WIDESEAWCS_Core.Core; | 
|---|
|  |  |  | using WIDESEAWCS_QuartzJob.Seed; | 
|---|
|  |  |  | using Autofac.Core; | 
|---|
|  |  |  | using WIDESEAWCS_Core.Extensions; | 
|---|
|  |  |  | using WIDESEAWCS_Core.Filter; | 
|---|
|  |  |  | using WIDESEAWCS_Core.Helper; | 
|---|
|  |  |  | using WIDESEAWCS_Core.Middlewares; | 
|---|
|  |  |  | using WIDESEAWCS_QuartzJob.QuartzExtensions; | 
|---|
|  |  |  | using Microsoft.AspNetCore.Builder; | 
|---|
|  |  |  | using Microsoft.AspNetCore.SignalR; | 
|---|
|  |  |  | using WIDESEAWCS_QuartzJob.Seed; | 
|---|
|  |  |  | using WIDESEAWCS_SignalR; | 
|---|
|  |  |  | using WIDESEAWCS_Tasks; | 
|---|
|  |  |  | using WIDESEAWCS_WCSServer.Filter; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var builder = WebApplication.CreateBuilder(args); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (!HslCommunication.Authorization.SetAuthorizationCode("95f1611d-633c-46ea-b03a-38ede1629f74")) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | ConsoleHelper.WriteErrorLine("授权失败!当前程序只能使用24小时!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | ConsoleHelper.WriteSuccessLine("授权成功!"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory()).ConfigureContainer<ContainerBuilder>(builder => | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false); | 
|---|
|  |  |  | }); ; | 
|---|
|  |  |  | builder.Inject().ConfigureApplication(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 2、配置服务 | 
|---|
|  |  |  | builder.Services.AddSingleton(new AppSettings(builder.Configuration));//注册 | 
|---|
|  |  |  | 
|---|
|  |  |  | builder.Services.AddIpPolicyRateLimitSetup(builder.Configuration);//IPLimit限流 启动服务 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | builder.Services.AddScoped<UseServiceDIAttribute>(); | 
|---|
|  |  |  | builder.Services.AddScoped<CommonConveyorLineJob>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | builder.Services.AddSession(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | builder.Services.Replace(ServiceDescriptor.Transient<IControllerActivator, ServiceBasedControllerActivator>()); | 
|---|
|  |  |  | Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var app = builder.Build(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | app.MapHubs(); | 
|---|
|  |  |  | app.MapControllers(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | app.Run(); | 
|---|
|  |  |  | app.Run(); | 
|---|