//using Autofac;
//using Autofac.Extensions.DependencyInjection;
//using IRaCIS.Core.API;
//using IRaCIS.Core.Application.Filter;
//using IRaCIS.Core.Application.MediatR.Handlers;
//using LogDashboard;
//using MassTransit;
//using MassTransit.NewIdProviders;
//using MediatR;
//using Microsoft.AspNetCore.Builder;
//using Microsoft.AspNetCore.Http.Features;
//using Microsoft.AspNetCore.HttpOverrides;
//using Microsoft.AspNetCore.SignalR;
//using Microsoft.Extensions.Configuration;
//using Microsoft.Extensions.DependencyInjection;
//using Microsoft.Extensions.Hosting;
//using Serilog;
//using System;

//var builder = WebApplication.CreateBuilder(args);


//    //以配置文件为准，否则 从url中取环境值(服务以命令行传递参数启动，配置文件配置了就不需要传递环境参数)
//    var config = new ConfigurationBuilder()
//                .AddEnvironmentVariables()
//                .Build();

//    var enviromentName = config["ASPNETCORE_ENVIRONMENT"];

//    if (string.IsNullOrWhiteSpace(enviromentName))
//    {

//        var index = Array.IndexOf(args, "--env");
//        enviromentName = index > -1
//            ? args[index + 1]
//            : "Development";
//    }
 

//    NewId.SetProcessIdProvider(new CurrentProcessIdProvider());




//builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory())
//    .ConfigureContainer<ContainerBuilder>(containerBuilder =>
//    {
//        containerBuilder.RegisterModule<AutofacModuleSetup>();
//    })
//    .UseWindowsService().UseSerilog();



//// Add services to the container.

////本地化
//builder.Services.AddJsonLocalization(options => options.ResourcesPath = "Resources");

//// 异常、参数统一验证过滤器、Json序列化配置、字符串参数绑型统一Trim()
//builder.Services.AddControllers(options =>
//{
//    //options.Filters.Add<LogActionFilter>();
//    options.Filters.Add<ModelActionFilter>();
//    options.Filters.Add<ProjectExceptionFilter>();
//    //options.Filters.Add<UnitOfWorkFilter>();

//    //if (_configuration.GetSection("BasicSystemConfig").GetValue<bool>("OpenLoginLimit"))
//    //{
//    //    options.Filters.Add<LimitUserRequestAuthorization>();

//    //}


//}).AddNewtonsoftJsonSetup(); // NewtonsoftJson 序列化  处理

////动态WebApi + UnifiedApiResultFilter  省掉控制器代码
//builder.Services.AddDynamicWebApiSetup();
////AutoMapper
//builder.Services.AddAutoMapperSetup();
////EF ORM  QueryWithNoLock
//builder.Services.AddEFSetup(builder.Configuration);
////Http 响应压缩
//builder.Services.AddResponseCompressionSetup();
////Swagger Api 文档
//builder.Services.AddSwaggerSetup();
////JWT Token 验证
//builder.Services.AddJWTAuthSetup(builder.Configuration);
//// MediatR 进程内消息 事件解耦  从程序集中 注册命令和handler对应关系
//builder.Services.AddMediatR(typeof(ConsistencyVerificationHandler).Assembly);
//// EasyCaching 缓存
//builder.Services.AddEasyCachingSetup();

////services.AddDistributedMemoryCache();

////// hangfire  定时任务框架  有界面，更友好~
//builder.Services.AddhangfireSetup(builder.Configuration);
//////  QuartZ 定时任务框架  使用了hangfire 暂时不用，后续需要可以打开，已经配好
////builder.Services.AddQuartZSetup(_configuration);

//// 保护上传文件
////services.AddStaticFileAuthorizationSetup();


//////HttpReports 暂时废弃
////services.AddHttpReports().AddHttpTransport();
////Serilog 日志可视化 LogDashboard日志
//builder.Services.AddLogDashboardSetup();
////上传限制 配置
//builder.Services.Configure<FormOptions>(options =>
//{
//    options.MultipartBodyLengthLimit = int.MaxValue;
//    options.ValueCountLimit = int.MaxValue;
//    options.ValueLengthLimit = int.MaxValue;
//});
////IP 限流 可设置白名单 或者黑名单
////services.AddIpPolicyRateLimitSetup(_configuration);
////用户类型 策略授权
//builder.Services.AddAuthorizationPolicySetup(builder.Configuration);

//builder.Services.AddJsonConfigSetup(builder.Configuration);

////转发头设置  获取真实IP 
//builder.Services.Configure<ForwardedHeadersOptions>(options =>
//{
//    options.ForwardedHeaders =
//        ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
//});
////Dicom影像渲染图片  跨平台
//builder.Services.AddDicomSetup();

//// 实时应用
//builder.Services.AddSignalR();


//builder.Services.AddSingleton<IUserIdProvider, IRaCISUserIdProvider>();

//builder.Services.AddControllers();
//// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
////builder.Services.AddEndpointsApiExplorer();
////builder.Services.AddSwaggerGen();

////SerilogExtension.AddSerilogSetup(enviromentName, builder.Host.confi);


//var app = builder.Build();

//// Configure the HTTP request pipeline.

////本地化
//app.UseLocalization();

//app.UseForwardedHeaders();


////不需要 token 访问的静态文件  wwwroot css, JavaScript, and images don't require authentication.
//app.UseStaticFiles();

//app.UseIRacisHostStaticFileStore(app.Environment);

////LogDashboard
//app.UseLogDashboard("/LogDashboard");

////hangfire
////app.UseHangfireConfig(app.Environment);

//////暂时废弃
////app.UseHttpReports();

//////限流 中间件
////app.UseIpRateLimiting();

////响应压缩
//app.UseResponseCompression();

//if (app.Environment.IsDevelopment())
//{
//    app.UseDeveloperExceptionPage();
//}
//else
//{

//    //app.UseHsts();
//}

//SwaggerSetup.Configure(app, app.Environment);

//Console.WriteLine("当前环境： " + builder.Environment.EnvironmentName);

////app.UseMiddleware<AuthMiddleware>();

//// 特殊异常处理 比如 404 
//app.UseStatusCodePagesWithReExecute("/Error/{0}");




//////serilog 记录请求的用户信息
//app.UseSerilogConfig(app.Environment);

//app.UseRouting();

//app.UseCors(t => t.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());


//app.UseAuthentication();
////app.UseJwtBearerQueryString();
//app.UseAuthorization();

//////文件伺服  必须带Token 访问
//////app.UseIRacisHostStaticFileStore(env);



////app.UseEndpoints(endpoints =>
////{


////    endpoints.MapControllers();

////    endpoints.MapHub<UploadHub>("/UploadHub")/*.RequireCors(t=>t.WithOrigins(new string[] {"null"}).AllowAnyMethod().AllowAnyHeader().AllowCredentials())*/;
////});



//app.MapControllers();
//app.MapHub<UploadHub>("/UploadHub")/*.RequireCors(t=>t.WithOrigins(new string[] {"null"}).AllowAnyMethod().AllowAnyHeader().AllowCredentials())*/;


//app.Run();

//测试同步
