| | |
| | | using System.Reflection; |
| | | using System.Text; |
| | | using Autofac; |
| | | using Autofac.Core; |
| | | using Autofac.Extensions.DependencyInjection; |
| | |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Converters; |
| | | using Newtonsoft.Json.Serialization; |
| | | using System.Reflection; |
| | | using System.Text; |
| | | using WIDESEA_Core; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.Authorization; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | |
| | | using WIDESEAWCS_Server.Filter; |
| | | using WIDESEAWCS_Server.HostedService; |
| | | using WIDESEAWCS_Tasks.SocketServer; |
| | | using WIDESEAWCS_RedisService.Extensions; |
| | | using WIDESEAWCS_WCSServer.Filter; |
| | | |
| | | var builder = WebApplication.CreateBuilder(args); |
| | | // 1、配置服务容器 |
| | | // 1�����÷������� |
| | | |
| | | builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory()).ConfigureContainer<ContainerBuilder>(builder => |
| | | { |
| | | builder.RegisterModule(new AutofacModuleRegister());//带有接口层的服务注入 |
| | | builder.RegisterModule(new AutofacModuleRegister());//���нӿڲ�ķ���ע�� |
| | | builder.RegisterModule(new QuartzJobAutofacModuleRegister()); |
| | | builder.RegisterModule<AutofacPropertityModuleReg>();// |
| | | }).ConfigureAppConfiguration((hostingContext, config) => |
| | |
| | | }); |
| | | builder.ConfigureApplication(); |
| | | |
| | | // 2、配置服务 |
| | | builder.Services.AddSingleton(new AppSettings(builder.Configuration));//注册 |
| | | builder.Services.AddAllOptionRegister();//读取配置文件 |
| | | // 2�����÷��� |
| | | builder.Services.AddSingleton(new AppSettings(builder.Configuration));//ע�� |
| | | builder.Services.AddAllOptionRegister();//��ȡ�����ļ� |
| | | |
| | | |
| | | builder.Services.AddMemoryCacheSetup();//缓存 |
| | | builder.Services.AddSqlsugarSetup();//SqlSugar 启动服务 |
| | | builder.Services.AddInitializationHostServiceSetup();//应用初始化服务注入 |
| | | builder.Services.AddHostedService<SeedDataHostedService>();//初始化数据库 |
| | | builder.Services.AddMemoryCacheSetup();//���� |
| | | builder.Services.AddRedisSetup(builder.Configuration);//Redis缓存 |
| | | builder.Services.AddSqlsugarSetup();//SqlSugar �������� |
| | | builder.Services.AddInitializationHostServiceSetup();//Ӧ�ó�ʼ������ע�� |
| | | builder.Services.AddHostedService<SeedDataHostedService>();//��ʼ�����ݿ� |
| | | |
| | | builder.Services.AddDbSetup();//Db 启动服务 |
| | | builder.Services.AddDbSetup();//Db �������� |
| | | |
| | | builder.Services.AddScoped<QuartzJobCreateDataTabel>();//任务调度 注入创建QuartzJob数据库表类 |
| | | builder.Services.AddHostedService<QuartzJobDataTableHostedService>();//任务调度 映射QuartzJob数据库表 |
| | | builder.Services.AddScoped<QuartzJobCreateDataTabel>();//������� ע�봴��QuartzJob���ݿ���� |
| | | builder.Services.AddHostedService<QuartzJobDataTableHostedService>();//������� ӳ��QuartzJob���ݿ�� |
| | | |
| | | builder.Services.AddWebSocketSetup(); |
| | | |
| | |
| | | |
| | | builder.Services.AddSwaggerSetup(); |
| | | |
| | | builder.Services.AddJobSetup();//任务调度 注入反射获取依赖对象 |
| | | builder.Services.AddJobSetup();//������� ע�뷴���ȡ�������� |
| | | |
| | | builder.Services.AddHttpContextSetup(); |
| | | |
| | | builder.Services.AddHostedService<QuartzJobHostedService>();//任务调度 启动服务 |
| | | builder.Services.AddHostedService<QuartzJobHostedService>();//������� �������� |
| | | builder.Services.AddSingleton<TcpSocketServer>(); |
| | | builder.Services.AddHostedService<SocketServerHostedService>(); |
| | | |
| | |
| | | options.Filters.Add(typeof(CustomAuthorizeFilter)); |
| | | }); |
| | | |
| | | builder.Services.AddScoped<HttpClientHelper>(); |
| | | |
| | | builder.Services.AddAuthorizationSetup(); |
| | | |
| | | builder.Services.AddIpPolicyRateLimitSetup(builder.Configuration);//IPLimit限流 启动服务 |
| | | builder.Services.AddIpPolicyRateLimitSetup(builder.Configuration);//IPLimit���� �������� |
| | | |
| | | builder.Services.AddScoped<UseServiceDIAttribute>(); |
| | | |
| | |
| | | |
| | | builder.Services.AddControllers(o => |
| | | { |
| | | o.Filters.Add(typeof(GlobalExceptionsFilter));//全局异常 |
| | | o.Filters.Add(typeof(GlobalExceptionsFilter));//ȫ���쳣 |
| | | }) |
| | | .AddNewtonsoftJson(options => |
| | | { |
| | |
| | | |
| | | var app = builder.Build(); |
| | | |
| | | // 3、配置中间件 |
| | | app.UseMiniProfiler();//性能分析器 |
| | | app.ConfigureApplication();//配置文件 |
| | | app.UseApplicationSetup();//启动配置 |
| | | // 3�������� |
| | | app.UseMiniProfiler();//���ܷ����� |
| | | app.ConfigureApplication();//�����ļ� |
| | | app.UseApplicationSetup();//�������� |
| | | |
| | | app.UseAllServicesMiddle(builder.Services); |
| | | |
| | | app.UseSession(); |
| | | |
| | | app.UseSwaggerAuthorized(); |
| | | app.UseSwaggerMiddle(() => Assembly.GetExecutingAssembly().GetManifestResourceStream("WIDESEAWCS_Server.index.html") ?? throw new Exception("未找到WIDESEAWCS_Server.index.html文件")); |
| | | app.UseSwaggerMiddle(() => Assembly.GetExecutingAssembly().GetManifestResourceStream("WIDESEAWCS_Server.index.html") ?? throw new Exception("δ�ҵ�WIDESEAWCS_Server.index.html�ļ�")); |
| | | |
| | | app.UseIpLimitMiddle(); |
| | | app.UseApiLogMiddleware(); |