2022-09-15 18:40:24 +08:00
|
|
|
|
global using System;
|
2021-12-25 14:50:54 +08:00
|
|
|
|
using Autofac.Extensions.DependencyInjection;
|
|
|
|
|
|
using Yi.Framework.WebCore.BuilderExtend;
|
|
|
|
|
|
using Yi.Framework.Core;
|
|
|
|
|
|
using Yi.Framework.WebCore.MiddlewareExtend;
|
|
|
|
|
|
using Autofac;
|
2022-04-02 17:44:50 +08:00
|
|
|
|
using Yi.Framework.Common.Models;
|
2022-04-03 23:21:53 +08:00
|
|
|
|
using Yi.Framework.Language;
|
|
|
|
|
|
using Microsoft.Extensions.Localization;
|
2022-04-06 22:22:45 +08:00
|
|
|
|
using Yi.Framework.WebCore.AttributeExtend;
|
2022-09-04 18:47:39 +08:00
|
|
|
|
using Yi.Framework.WebCore.SignalRHub;
|
2022-09-17 18:09:18 +08:00
|
|
|
|
using Hei.Captcha;
|
2022-09-18 17:22:47 +08:00
|
|
|
|
using Yi.Framework.WebCore;
|
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2022-09-19 17:25:43 +08:00
|
|
|
|
using Yi.Framework.WebCore.DbExtend;
|
2022-10-03 17:04:59 +08:00
|
|
|
|
using IPTools.Core;
|
2022-11-07 01:31:37 +08:00
|
|
|
|
using Yi.Framework.WebCore.LogExtend;
|
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
|
|
|
|
using Microsoft.AspNetCore.Mvc.Controllers;
|
|
|
|
|
|
using Yi.Framework.WebCore.AutoFacExtend;
|
2022-11-27 15:05:27 +08:00
|
|
|
|
using Hangfire;
|
|
|
|
|
|
using Hangfire.MemoryStorage;
|
2022-09-15 17:09:30 +08:00
|
|
|
|
|
2021-12-25 14:50:54 +08:00
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
2022-04-03 23:21:53 +08:00
|
|
|
|
builder.Configuration.AddCommandLine(args);
|
|
|
|
|
|
builder.WebHost.UseUrls(builder.Configuration.GetValue<string>("StartUrl"));
|
2021-12-25 14:50:54 +08:00
|
|
|
|
builder.Host.ConfigureAppConfiguration((hostBuilderContext, configurationBuilder) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
configurationBuilder.AddCommandLine(args);
|
|
|
|
|
|
configurationBuilder.AddJsonFileService();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//Apollo<6C><6F><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
configurationBuilder.AddApolloService("Yi");
|
|
|
|
|
|
});
|
|
|
|
|
|
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
|
|
|
|
|
|
builder.Host.ConfigureContainer<ContainerBuilder>(containerBuilder =>
|
|
|
|
|
|
{
|
|
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>Module<6C><65><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
containerBuilder.RegisterModule<CustomAutofacModule>();
|
2022-10-09 17:32:44 +08:00
|
|
|
|
#region
|
2022-11-07 01:31:37 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>ģ<EFBFBD><C4A3>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
//containerBuilder.RegisterModule<PropertiesAutowiredModule>();
|
|
|
|
|
|
#region
|
2022-10-09 17:32:44 +08:00
|
|
|
|
//ʹ<><CAB9>AppService<63><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŵĽ<C5B5><C4BD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>,<2C>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>ø<EFBFBD><C3B8>ַ<EFBFBD>ʽ<EFBFBD>Զ<EFBFBD>ע<EFBFBD><D7A2>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
containerBuilder.AddAutoIocService("Yi.Framework.Repository", "Yi.Framework.Service");
|
2021-12-25 14:50:54 +08:00
|
|
|
|
});
|
2022-11-07 01:31:37 +08:00
|
|
|
|
////<2F><><EFBFBD><EFBFBD>ע<EFBFBD>룬<EFBFBD><EBA3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>mvcģ<63><C4A3>ת<EFBFBD>Ӹ<EFBFBD>ioc
|
|
|
|
|
|
//builder.Services.Replace(ServiceDescriptor.Transient<IControllerActivator, ServiceBasedControllerActivator>());
|
|
|
|
|
|
|
2021-12-25 14:50:54 +08:00
|
|
|
|
builder.Host.ConfigureLogging(loggingBuilder =>
|
|
|
|
|
|
{
|
|
|
|
|
|
loggingBuilder.AddFilter("System", Microsoft.Extensions.Logging.LogLevel.Warning);
|
|
|
|
|
|
loggingBuilder.AddFilter("Microsoft", Microsoft.Extensions.Logging.LogLevel.Warning);
|
2022-04-03 23:21:53 +08:00
|
|
|
|
loggingBuilder.AddLog4Net("./Config/Log4net.config");
|
2022-11-07 01:31:37 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>־
|
|
|
|
|
|
//loggingBuilder.AddCustomLogger();
|
2021-12-25 14:50:54 +08:00
|
|
|
|
});
|
|
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
//builder.Host.ConfigureWebHostDefaults(webBuilder =>
|
|
|
|
|
|
// {
|
|
|
|
|
|
// //webBuilder.UseStartup<Startup>();
|
|
|
|
|
|
// });
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
//-----------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
#region
|
|
|
|
|
|
//Ioc<6F><63><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddIocService(builder.Configuration);
|
|
|
|
|
|
#region
|
2022-11-04 23:23:54 +08:00
|
|
|
|
//Sqlsugar<61><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>,<2C>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD><EFBFBD><DEB9>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><DFBB><EFBFBD>
|
2022-04-06 22:22:45 +08:00
|
|
|
|
#endregion
|
2022-11-04 23:23:54 +08:00
|
|
|
|
builder.Services.AddSqlsugarServer(DbFiterExtend.Data);
|
2022-04-06 22:22:45 +08:00
|
|
|
|
#region
|
2021-12-25 14:50:54 +08:00
|
|
|
|
//Quartz<74><7A><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddQuartzService();
|
2022-11-27 15:05:27 +08:00
|
|
|
|
builder.Services.AddHangfire(option =>
|
|
|
|
|
|
{
|
|
|
|
|
|
option.SetDataCompatibilityLevel(CompatibilityLevel.Version_170);//ȫ<><C8AB><EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD><C3BC>ݰ汾<DDB0><E6B1BE><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>
|
|
|
|
|
|
option.UseColouredConsoleLogProvider();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־
|
|
|
|
|
|
option.UseSimpleAssemblyNameTypeSerializer();//ʹ<>ü<C3BC><F2B5A5B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
option.UseRecommendedSerializerSettings();//ʹ<><CAB9><EFBFBD>Ƽ<EFBFBD><C6BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
option.UseMemoryStorage();
|
|
|
|
|
|
});
|
|
|
|
|
|
builder.Services.AddHangfireServer();
|
2021-12-25 14:50:54 +08:00
|
|
|
|
#region
|
2022-04-12 22:12:11 +08:00
|
|
|
|
//AutoMapperע<72><D7A2>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddAutoMapperService();
|
|
|
|
|
|
#region
|
2021-12-25 14:50:54 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>+<2B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
2022-11-27 15:05:27 +08:00
|
|
|
|
builder.Services.AddControllers(optios =>
|
|
|
|
|
|
{
|
2022-09-29 17:02:34 +08:00
|
|
|
|
//ע<><D7A2>ȫ<EFBFBD><C8AB>
|
|
|
|
|
|
optios.Filters.Add<GlobalLogAttribute>();
|
2021-12-25 14:50:54 +08:00
|
|
|
|
}).AddJsonFileService();
|
|
|
|
|
|
#region
|
2022-04-06 22:22:45 +08:00
|
|
|
|
//Ȩ<><EFBFBD><DEB9><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
2022-09-29 17:02:34 +08:00
|
|
|
|
//Ȩ<><C8A8>
|
2022-04-06 22:22:45 +08:00
|
|
|
|
builder.Services.AddSingleton<PermissionAttribute>();
|
2022-09-29 17:02:34 +08:00
|
|
|
|
//<2F><>־
|
|
|
|
|
|
builder.Services.AddSingleton<GlobalLogAttribute>();
|
2022-04-06 22:22:45 +08:00
|
|
|
|
#region
|
2021-12-25 14:50:54 +08:00
|
|
|
|
//Swagger<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddSwaggerService<Program>();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddCorsService();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//Jwt<77><74>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddJwtService();
|
|
|
|
|
|
#region
|
2022-01-11 16:40:15 +08:00
|
|
|
|
//<2F><>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddAuthorizationService();
|
|
|
|
|
|
#region
|
2021-12-25 14:50:54 +08:00
|
|
|
|
//Redis<69><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
2022-10-26 20:01:18 +08:00
|
|
|
|
builder.Services.AddCacheService();
|
2021-12-25 14:50:54 +08:00
|
|
|
|
#region
|
|
|
|
|
|
//RabbitMQ<4D><51><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddRabbitMQService();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//ElasticSeach<63><68><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddElasticSeachService();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddSMSService();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//CAP<41><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
2022-04-06 22:22:45 +08:00
|
|
|
|
builder.Services.AddCAPService();
|
2022-04-03 23:21:53 +08:00
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD>ʻ<EFBFBD><CABB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddLocalizerService();
|
2022-09-04 18:47:39 +08:00
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>signalR
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddSignalR();
|
2022-09-18 17:22:47 +08:00
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֤<EFBFBD><D6A4>
|
|
|
|
|
|
#endregion
|
2022-09-17 18:09:18 +08:00
|
|
|
|
builder.Services.AddHeiCaptcha();
|
2022-09-18 17:22:47 +08:00
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>Http<74><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2022-09-26 16:15:51 +08:00
|
|
|
|
#endregion
|
2022-09-18 17:22:47 +08:00
|
|
|
|
builder.Services.AddHttpContextAccessor();
|
2022-10-17 01:10:31 +08:00
|
|
|
|
#region
|
2022-10-19 14:34:53 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>System.Drawing<6E><67>linu<6E><75>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>֧<EFBFBD><D6A7>
|
2022-10-17 01:10:31 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddSingleton<ThumbnailSharpInvoer>();
|
2022-10-18 09:01:16 +08:00
|
|
|
|
|
|
|
|
|
|
#region
|
|
|
|
|
|
//ȫ<><C8AB><EFBFBD><EFBFBD><EFBFBD>ó<EFBFBD>ʼ<EFBFBD><CABC>ֵ
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
GobalModel.SqlLogEnable = Appsettings.appBool("SqlLog_Enable");
|
2022-10-28 14:25:59 +08:00
|
|
|
|
GobalModel.LoginCodeEnable = Appsettings.appBool("LoginCode_Enable");
|
2021-12-25 14:50:54 +08:00
|
|
|
|
//-----------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
var app = builder.Build();
|
2022-04-02 17:44:50 +08:00
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
ServiceLocator.Instance = app.Services;
|
2021-12-25 14:50:54 +08:00
|
|
|
|
//if (app.Environment.IsDevelopment())
|
|
|
|
|
|
{
|
|
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ҳ<EFBFBD><D2B3>ע<EFBFBD><D7A2>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
app.UseDeveloperExceptionPage();
|
|
|
|
|
|
app.UseSwaggerService();
|
|
|
|
|
|
}
|
|
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ץȡ<D7A5><C8A1><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
|
|
|
|
|
#endregion
|
2022-09-27 16:22:34 +08:00
|
|
|
|
app.UseErrorHandlingService();
|
2022-09-17 18:09:18 +08:00
|
|
|
|
|
2021-12-25 14:50:54 +08:00
|
|
|
|
#region
|
|
|
|
|
|
//<2F><>̬<EFBFBD>ļ<EFBFBD>ע<EFBFBD><D7A2>
|
|
|
|
|
|
#endregion
|
2022-04-06 22:22:45 +08:00
|
|
|
|
app.UseStaticFiles();
|
2022-04-03 23:21:53 +08:00
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>Թ<EFBFBD><D4B9>ʻ<EFBFBD>ע<EFBFBD><D7A2>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
app.UseLocalizerService();
|
2022-10-01 23:53:43 +08:00
|
|
|
|
|
|
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>body
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
app.UseHttpBodyService();
|
2021-12-25 14:50:54 +08:00
|
|
|
|
#region
|
|
|
|
|
|
//HttpsRedirectionע<6E><D7A2>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//·<><C2B7>ע<EFBFBD><D7A2>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
app.UseRouting();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
app.UseCorsService();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
|
|
|
|
|
#endregion
|
2022-04-12 22:12:11 +08:00
|
|
|
|
app.UseHealthCheckService();
|
2021-12-25 14:50:54 +08:00
|
|
|
|
#region
|
|
|
|
|
|
//<2F><>Ȩע<C8A8><D7A2>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
app.UseAuthentication();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//<2F><>Ȩע<C8A8><D7A2>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
app.UseAuthorization();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//Consul<75><6C><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
app.UseConsulService();
|
2022-09-19 17:25:43 +08:00
|
|
|
|
|
|
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
app.UseDbSeedInitService();
|
2021-12-25 14:50:54 +08:00
|
|
|
|
#region
|
|
|
|
|
|
//redis<69><73><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
|
|
|
|
|
#endregion
|
2022-04-06 22:22:45 +08:00
|
|
|
|
app.UseRedisSeedInitService();
|
2022-09-04 18:47:39 +08:00
|
|
|
|
|
2022-11-27 15:05:27 +08:00
|
|
|
|
app.UseHangfireDashboard();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-12-25 14:50:54 +08:00
|
|
|
|
app.UseEndpoints(endpoints =>
|
|
|
|
|
|
{
|
2022-10-03 17:04:59 +08:00
|
|
|
|
#region
|
|
|
|
|
|
//SignalR<6C><52><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
endpoints.MapHub<MainHub>("/api/hub/main");
|
2021-12-25 14:50:54 +08:00
|
|
|
|
endpoints.MapControllers();
|
2022-11-27 15:05:27 +08:00
|
|
|
|
endpoints.MapHangfireDashboard();
|
2021-12-25 14:50:54 +08:00
|
|
|
|
});
|
2022-09-04 18:47:39 +08:00
|
|
|
|
|
2022-11-02 08:48:01 +08:00
|
|
|
|
//<><D7BC><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><D3B6>⻧
|
2021-12-25 14:50:54 +08:00
|
|
|
|
app.Run();
|