|  |  |  | 
|---|
|  |  |  | using WIDESEA_Core.Core; | 
|---|
|  |  |  | using Autofac.Core; | 
|---|
|  |  |  | using Microsoft.AspNetCore.Builder; | 
|---|
|  |  |  | using WIDESEA_Core.HostedService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var builder = WebApplication.CreateBuilder(args); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory()).ConfigureContainer<ContainerBuilder>(builder => | 
|---|
|  |  |  | { | 
|---|
|  |  |  | builder.RegisterModule(new AutofacModuleRegister());//å¸¦ææ¥å£å±çæå¡æ³¨å
¥ | 
|---|
|  |  |  | builder.RegisterModule<AutofacModuleRegister>();//å¸¦ææ¥å£å±çæå¡æ³¨å
¥ | 
|---|
|  |  |  | builder.RegisterModule<AutofacPropertityModuleReg>();// | 
|---|
|  |  |  | }).ConfigureAppConfiguration((hostingContext, config) => | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | }); ; | 
|---|
|  |  |  | builder.ConfigureApplication(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //App.ExpDateTime = DateTime.Parse("2025-05-31 00:00:00"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 2ãé
ç½®æå¡ | 
|---|
|  |  |  | builder.Services.AddSingleton(new AppSettings(builder.Configuration));//注å | 
|---|
|  |  |  | builder.Services.AddAllOptionRegister();//读åé
ç½®æä»¶ | 
|---|
|  |  |  | builder.Services.AddMemoryCacheSetup();//ç¼å | 
|---|
|  |  |  | builder.Services.AddWebSocketSetup(); | 
|---|
|  |  |  | builder.Services.AddSqlsugarSetup();//SqlSugar å¯å¨æå¡ | 
|---|
|  |  |  | //builder.Services.AddInitializationHostServiceSetup();//åºç¨åå§åæå¡æ³¨å
¥ | 
|---|
|  |  |  | builder.Services.AddDbSetup();//Db å¯å¨æå¡ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //builder.Services.AddInitializationHostServiceSetup();//åºç¨åå§åæå¡æ³¨å
¥ | 
|---|
|  |  |  | builder.Services.AddHostedService<PermissionDataHostService>();//åºç¨åå§åæå¡æ³¨å
¥ | 
|---|
|  |  |  | builder.Services.AddAutoMapperSetup(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | builder.Services.AddCorsSetup(); | 
|---|
|  |  |  | 
|---|
|  |  |  | builder.Services.AddMvc(options => | 
|---|
|  |  |  | { | 
|---|
|  |  |  | options.Filters.Add(typeof(ApiAuthorizeFilter)); | 
|---|
|  |  |  | options.Filters.Add(typeof(ActionExecuteFilter)); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | builder.Services.AddAuthorizationSetup(); | 
|---|
|  |  |  | 
|---|
|  |  |  | app.UseMiniProfiler();//æ§è½åæå¨ | 
|---|
|  |  |  | app.ConfigureApplication();//é
ç½®æä»¶ | 
|---|
|  |  |  | app.UseApplicationSetup();//å¯å¨é
ç½® | 
|---|
|  |  |  |  | 
|---|
|  |  |  | app.UseAllServicesMiddle(builder.Services); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | app.UseSession(); | 
|---|
|  |  |  | //if (app.Environment.IsDevelopment()) | 
|---|
|  |  |  | if (app.Environment.IsProduction()) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //todo | 
|---|
|  |  |  | //app.UseSwaggerAuthorized(); | 
|---|
|  |  |  | app.UseSwaggerMiddle(() => Assembly.GetExecutingAssembly().GetManifestResourceStream("WIDESEA_WMSServer.index.html")); | 
|---|
|  |  |  | app.UseSwaggerAuthorized(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }//夿æ¯å¦éè¦æå¼swagger | 
|---|
|  |  |  |  | 
|---|
|  |  |  | app.UseSwaggerMiddle(() => Assembly.GetExecutingAssembly().GetManifestResourceStream("WIDESEA_WMSServer.index.html") ?? throw new Exception("WIDESEA_WMSServer.index.htmlæä»¶")); | 
|---|
|  |  |  | app.UseIpLimitMiddle(); | 
|---|
|  |  |  | app.UseApiLogMiddleware(); | 
|---|
|  |  |  | //todo | 
|---|
|  |  |  | //app.UseRecordAccessLogsMiddle(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | app.UseCors(AppSettings.app(new string[] { "Cors", "PolicyName" })); | 
|---|
|  |  |  | app.UseCors(AppSettings.Get(new string[] { "Cors", "PolicyName" })); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | DefaultFilesOptions defaultFilesOptions = new DefaultFilesOptions(); | 
|---|
|  |  |  | defaultFilesOptions.DefaultFileNames.Clear(); | 
|---|