You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
3.6 KiB
C#

using Autofac;
using Autofac.Extensions.DependencyInjection;
using DS.Module.AutofacModule;
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.Module.Core.ServiceExtensions;
using DS.Module.DjyRulesEngine;
using DS.Module.Jwt;
using DS.Module.MQ;
using DS.Module.MultiLanguage;
using DS.Module.PrintModule;
using DS.Module.RedisModule;
using DS.Module.SqlSugar;
using DS.Module.Swagger;
using DS.Module.UserModule;
using DS.WMS.Core;
using NLog.Web;
using Swashbuckle.AspNetCore.SwaggerUI;
using DS.Module.QuartzModuleInstall;
8 months ago
var builder = WebApplication.CreateBuilder(args);
var environment = builder.Environment.EnvironmentName;
Console.WriteLine("<22><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:" + environment);
//ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
builder.Configuration
// .SetBasePath(builder.Environment.ContentRootPath)
.AddJsonFile(path: "appsettings.json", optional: false, reloadOnChange: true)
// .AddJsonFile(path: $"appsettings.{environment}.json", optional: true, reloadOnChange: true)
.Build();
builder.Configuration.AddEnvironmentVariables();
builder.Logging.AddNLog("nlog.config");
8 months ago
// Add services to the container.
//Autofacע<63><D7A2>
builder.Host
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureContainer<ContainerBuilder>(builder => { builder.RegisterModule(new AutofacModuleRegister()); });
builder.Services.AddAppWebInstal();
builder.Services.AddCorsInstall();
builder.Services.AddUserModuleInstall(); //<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
builder.Services.AddRedisModuleInstall();//redis
builder.Services.AddSqlSugarInstall();
builder.Services.AddSwaggerInstall();
builder.Services.AddJwtInstall();
builder.Services.AddSaasDbInstall();//<2F>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD>
builder.Services.AddMultiLanguageInstall();//<2F><><EFBFBD><EFBFBD><EFBFBD>Է<EFBFBD><D4B7><EFBFBD>
builder.Services.AddDjyModuleInstall();//Djy<6A><79><EFBFBD><EFBFBD>
builder.Services.AddRuleEngineModuleInstall();//Djy<6A><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2 months ago
//builder.Services.AddHangfireModuleInstall();//Hangfire<72><65><EFBFBD><EFBFBD>
//builder.Services.AddHangfireOPInstall();//Hangfire<72><65><EFBFBD><EFBFBD>
builder.Services.AddMQModuleInstall();//MQ
// builder.Services.AddEndpointsApiExplorer();
// builder.Services.AddSwaggerGen();
8 months ago
//builder.Services.AddCrawlerModuleInstall();//<2F><><EFBFBD>ٷ<EFBFBD><D9B7><EFBFBD>
// ʹ<><CAB9><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD> Quartz <20><><EFBFBD><EFBFBD>// <20><><EFBFBD><EFBFBD> Quartz <20><><EFBFBD><EFBFBD>
builder.Services.AddOpQuartzModuleInstall();
8 months ago
var app = builder.Build();
8 months ago
// Configure the HTTP request pipeline.
// if (app.Environment.IsDevelopment())
// {
// app.UseSwagger();
// app.UseSwaggerUI();
// }
//swagger
// app.UseSwagger();
var documentName = AppSetting.app(new string[] { "SwaggerDoc", "ContactName" });
app
.UseSwagger(c => { c.RouteTemplate = "{documentName}/swagger.json"; })
.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/" + documentName + "/swagger.json",
AppSetting.app(new string[] { "SwaggerDoc", "ContactName" }));
c.DocExpansion(DocExpansion.None);//DocExpansion<6F><6E><EFBFBD><EFBFBD>ΪNone<6E><65><EFBFBD>۵<EFBFBD><DBB5><EFBFBD><EFBFBD>з<EFBFBD><D0B7><EFBFBD>
c.DefaultModelExpandDepth(-1);//-1 <20>ɲ<EFBFBD><C9B2><EFBFBD>ʾModels
});
//<2F><><EFBFBD><EFBFBD>
var policyName = AppSetting.app(new string[] { "Cors", "PolicyName" });
if (!policyName.IsNullOrEmpty())
8 months ago
{
app.UseCors(policyName); //<2F><><EFBFBD>ӿ<EFBFBD><D3BF><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD>
8 months ago
}
//app.UseHangfireMiddleware();
3 months ago
app.UseRouting();
app.UseStaticFiles();
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><D0BC><EFBFBD>
app.UseMiddleware<MultiLanguageMiddleware>();
// //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD>м<EFBFBD><D0BC><EFBFBD>
// app.UseMiddleware<OperationLogMiddleware>();
app.UseObjectMapping();
// <20>ȿ<EFBFBD><C8BF><EFBFBD><EFBFBD><EFBFBD>֤
app.UseAuthentication();
// Ȼ<><C8BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȩ<EFBFBD>м<EFBFBD><D0BC><EFBFBD>
app.UseAuthorization();
app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
5 months ago
//await ServiceLocator.Instance.GetService<ISysCommonCacheService>().LoadCommonCache();
//app.UseHangfireServer();
//JobMiddleware.RegisterJob<IWSLReportJobService>(j => j.GeneratReportAsync(), Cron.Daily(23, 59));
2 months ago
app.Run();