2025-05-22 13:06:49 +08:00
|
|
|
|
using Autofac;
|
|
|
|
|
|
using Autofac.Extensions.DependencyInjection;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using WcsMain;
|
|
|
|
|
|
using WcsMain.Common;
|
|
|
|
|
|
using WcsMain.StartAction;
|
|
|
|
|
|
|
|
|
|
|
|
Console.Title = "WCS<43>豸<EFBFBD><E8B1B8><EFBFBD><EFBFBD>ϵͳ";
|
|
|
|
|
|
Console.OutputEncoding = Encoding.UTF8;
|
|
|
|
|
|
ConsoleLog.DisbleQuickEditMode();
|
|
|
|
|
|
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ز<EFBFBD><D8B2><EFBFBD>
|
|
|
|
|
|
var env = builder.Environment;
|
|
|
|
|
|
LoadingRunningData.Loading(env.IsDevelopment()); // <20><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>˲<EFBFBD><CBB2>豨<EFBFBD><E8B1A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
// Add services to the container.
|
|
|
|
|
|
//builder.Services.Replace(ServiceDescriptor.Transient<IControllerActivator, ServiceBasedControllerActivator>());
|
|
|
|
|
|
builder.Services.AddControllers(options =>
|
|
|
|
|
|
{
|
|
|
|
|
|
//options.Filters.Add<ApiExceptionFilterAttribute>();
|
|
|
|
|
|
}).AddJsonOptions(options =>
|
|
|
|
|
|
{
|
|
|
|
|
|
// <20>ķ<DEB8><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD>ԭʵ<D4AD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
options.JsonSerializerOptions.PropertyNamingPolicy = null;
|
|
|
|
|
|
});
|
|
|
|
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
|
|
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
|
|
|
|
builder.Services.AddSwaggerGen();
|
|
|
|
|
|
builder.Services.AddHostedService<HostService>();
|
|
|
|
|
|
// <20><><EFBFBD>ӿ<EFBFBD><D3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>κ<EFBFBD><CEBA>˷<EFBFBD><CBB7><EFBFBD>
|
|
|
|
|
|
builder.Services.AddCors(options =>
|
|
|
|
|
|
{
|
|
|
|
|
|
options.AddPolicy("any", policyBuilder =>
|
|
|
|
|
|
{
|
|
|
|
|
|
policyBuilder.WithOrigins("*").AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader();
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
builder.WebHost.UseUrls(CommonData.Settings.UseUrls ?? ["http://*:18990"]); // <20><>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD> appSettings.json <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC>ֵ
|
|
|
|
|
|
|
|
|
|
|
|
// ʹ<><CAB9> autoFac <20>滻ע<E6BBBB><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory());
|
|
|
|
|
|
builder.Host.ConfigureContainer<ContainerBuilder>(builder =>
|
|
|
|
|
|
{
|
|
|
|
|
|
builder.RegisterModule<AutofacModule>();
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
|
|
|
|
|
|
// Configure the HTTP request pipeline.
|
|
|
|
|
|
if (app.Environment.IsDevelopment())
|
|
|
|
|
|
{
|
|
|
|
|
|
app.UseSwagger();
|
|
|
|
|
|
app.UseSwaggerUI();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
app.UseCors("any");
|
|
|
|
|
|
|
|
|
|
|
|
app.UseAuthorization();
|
|
|
|
|
|
|
|
|
|
|
|
app.MapControllers();
|
|
|
|
|
|
|
|
|
|
|
|
app.Run();
|