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 Yi.Framework.WebCore.Utility;
|
|
|
|
|
|
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-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>();
|
|
|
|
|
|
});
|
|
|
|
|
|
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");
|
|
|
|
|
|
|
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-09-18 17:22:47 +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>ҪRedis<69><73><EFBFBD><EFBFBD>
|
2022-04-06 22:22:45 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddSqlsugarServer();
|
2022-09-18 17:22:47 +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();
|
|
|
|
|
|
#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
|
|
|
|
|
|
builder.Services.AddControllers(optios => {
|
2022-04-06 22:22:45 +08:00
|
|
|
|
//optios.Filters.Add<PermissionAttribute>();
|
2021-12-25 14:50:54 +08:00
|
|
|
|
}).AddJsonFileService();
|
|
|
|
|
|
#region
|
2022-04-06 22:22:45 +08:00
|
|
|
|
//Ȩ<><EFBFBD><DEB9><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddSingleton<PermissionAttribute>();
|
|
|
|
|
|
#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
|
|
|
|
|
|
builder.Services.AddRedisService();
|
|
|
|
|
|
#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>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
builder.Services.AddHttpContextAccessor();
|
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();
|
|
|
|
|
|
#region
|
|
|
|
|
|
//Swagger<65><72><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
app.UseSwaggerService();
|
|
|
|
|
|
}
|
|
|
|
|
|
#region
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ץȡ<D7A5><C8A1><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>
|
|
|
|
|
|
#endregion
|
2022-09-13 19:04:41 +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();
|
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();
|
2021-12-25 14:50:54 +08:00
|
|
|
|
#region
|
2022-09-04 18:47:39 +08:00
|
|
|
|
//SignalR<6C><52><EFBFBD><EFBFBD>
|
2021-12-25 14:50:54 +08:00
|
|
|
|
#endregion
|
2022-09-04 18:47:39 +08:00
|
|
|
|
app.MapHub<MainHub>("/hub/main");
|
|
|
|
|
|
|
2021-12-25 14:50:54 +08:00
|
|
|
|
app.UseEndpoints(endpoints =>
|
|
|
|
|
|
{
|
|
|
|
|
|
endpoints.MapControllers();
|
|
|
|
|
|
});
|
2022-09-04 18:47:39 +08:00
|
|
|
|
|
2021-12-25 14:50:54 +08:00
|
|
|
|
app.Run();
|