修改接口时间
parent
65e478bb35
commit
7bda924bf1
|
@ -0,0 +1,229 @@
|
|||
//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();
|
|
@ -224,7 +224,7 @@ namespace IRaCIS.Api.Controllers
|
|||
|
||||
[HttpGet, Route("ip")]
|
||||
[AllowAnonymous]
|
||||
public IResponseOutput Get([FromServices] IHttpContextAccessor _context, [FromServices] IUserService _userService)
|
||||
public IResponseOutput Get([FromServices] IHttpContextAccessor _context/*, [FromServices] IUserService _userService*/)
|
||||
{
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
@ -243,5 +243,25 @@ namespace IRaCIS.Api.Controllers
|
|||
}
|
||||
|
||||
|
||||
[HttpGet, Route("ip2")]
|
||||
[AllowAnonymous]
|
||||
public IResponseOutput Get2([FromServices] IHttpContextAccessor _context, [FromServices] IRepository _userService)
|
||||
{
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine($"RemoteIpAddress:{_context.HttpContext.Connection.RemoteIpAddress}");
|
||||
|
||||
if (Request.Headers.ContainsKey("X-Real-IP"))
|
||||
{
|
||||
sb.AppendLine($"X-Real-IP:{Request.Headers["X-Real-IP"].ToString()}");
|
||||
}
|
||||
|
||||
if (Request.Headers.ContainsKey("X-Forwarded-For"))
|
||||
{
|
||||
sb.AppendLine($"X-Forwarded-For:{Request.Headers["X-Forwarded-For"].ToString()}");
|
||||
}
|
||||
return ResponseOutput.Ok(sb.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,9 +30,9 @@ namespace IRaCIS.Core.API
|
|||
{
|
||||
|
||||
var index = Array.IndexOf(args, "--env");
|
||||
enviromentName = index > -1
|
||||
? args[index + 1]
|
||||
: "Development";
|
||||
enviromentName = index > -1
|
||||
? args[index + 1]
|
||||
: "Development";
|
||||
}
|
||||
|
||||
//Dicom 浏览
|
||||
|
@ -54,7 +54,7 @@ namespace IRaCIS.Core.API
|
|||
NewId.SetProcessIdProvider(new CurrentProcessIdProvider());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//// Serilog
|
||||
SerilogExtension.AddSerilogSetup(enviromentName, host.Services);
|
||||
|
@ -62,7 +62,7 @@ namespace IRaCIS.Core.API
|
|||
//缓存项目的状态 匿名化数据
|
||||
await InitCache(host);
|
||||
|
||||
|
||||
|
||||
|
||||
host.Run();
|
||||
|
||||
|
@ -152,7 +152,7 @@ namespace IRaCIS.Core.API
|
|||
await _mediator.Send(new AnonymizeCacheRequest());
|
||||
|
||||
await _mediator.Send(new TrialStateCacheRequest());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,11 +86,7 @@ namespace IRaCIS.Core.API
|
|||
|
||||
|
||||
})
|
||||
//.AddDataAnnotationsLocalization(options =>
|
||||
//{
|
||||
// options.DataAnnotationLocalizerProvider = (type, factory) =>
|
||||
// factory.Create(typeof(SharedResource));
|
||||
//})
|
||||
|
||||
.AddNewtonsoftJsonSetup(); // NewtonsoftJson 序列化 处理
|
||||
|
||||
|
||||
|
@ -112,7 +108,7 @@ namespace IRaCIS.Core.API
|
|||
services.AddMediatR(typeof(ConsistencyVerificationHandler).Assembly);
|
||||
// EasyCaching 缓存
|
||||
services.AddEasyCachingSetup();
|
||||
|
||||
|
||||
//services.AddDistributedMemoryCache();
|
||||
|
||||
// hangfire 定时任务框架 有界面,更友好~
|
||||
|
@ -168,7 +164,6 @@ namespace IRaCIS.Core.API
|
|||
|
||||
app.UseForwardedHeaders();
|
||||
|
||||
app.UseCors(t => t.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
|
||||
|
||||
//不需要 token 访问的静态文件 wwwroot css, JavaScript, and images don't require authentication.
|
||||
app.UseStaticFiles();
|
||||
|
@ -181,10 +176,10 @@ namespace IRaCIS.Core.API
|
|||
//hangfire
|
||||
app.UseHangfireConfig(env);
|
||||
|
||||
// //暂时废弃
|
||||
////暂时废弃
|
||||
//app.UseHttpReports();
|
||||
|
||||
//限流 中间件
|
||||
////限流 中间件
|
||||
//app.UseIpRateLimiting();
|
||||
|
||||
//响应压缩
|
||||
|
@ -209,25 +204,30 @@ namespace IRaCIS.Core.API
|
|||
|
||||
|
||||
|
||||
//serilog 记录请求的用户信息
|
||||
////serilog 记录请求的用户信息
|
||||
app.UseSerilogConfig(env);
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
//app.UseCors(t => t.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
|
||||
|
||||
|
||||
app.UseAuthentication();
|
||||
//app.UseJwtBearerQueryString();
|
||||
app.UseAuthorization();
|
||||
|
||||
//文件伺服 必须带Token 访问
|
||||
//app.UseIRacisHostStaticFileStore(env);
|
||||
////文件伺服 必须带Token 访问
|
||||
////app.UseIRacisHostStaticFileStore(env);
|
||||
|
||||
|
||||
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapHub<UploadHub>("/UploadHub" )/*.RequireCors(t=>t.WithOrigins(new string[] {"null"}).AllowAnyMethod().AllowAnyHeader().AllowCredentials())*/;
|
||||
|
||||
|
||||
endpoints.MapControllers();
|
||||
|
||||
endpoints.MapHub<UploadHub>("/UploadHub")/*.RequireCors(t=>t.WithOrigins(new string[] {"null"}).AllowAnyMethod().AllowAnyHeader().AllowCredentials())*/;
|
||||
});
|
||||
|
||||
}
|
||||
|
|
|
@ -11,7 +11,10 @@ using System.Linq;
|
|||
using System.Reflection;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
|
||||
using MediatR;
|
||||
using IRaCIS.Application.Services;
|
||||
using IRaCIS.Application.Interfaces;
|
||||
using AutoMapper;
|
||||
|
||||
namespace IRaCIS.Core.API
|
||||
{
|
||||
|
@ -26,8 +29,12 @@ namespace IRaCIS.Core.API
|
|||
containerBuilder.RegisterGeneric(typeof(Repository<>))
|
||||
.As(typeof(IRepository<>)).InstancePerLifetimeScope();//注册泛型仓储
|
||||
|
||||
containerBuilder.RegisterGeneric(typeof(EFUnitOfWork<>))
|
||||
.As(typeof(IEFUnitOfWork<>)).InstancePerLifetimeScope();//注册仓储
|
||||
containerBuilder.RegisterType<Repository>().As<IRepository>().InstancePerLifetimeScope();
|
||||
|
||||
//containerBuilder.RegisterType<Mapper>().As<IMapper>().InstancePerLifetimeScope();
|
||||
|
||||
//containerBuilder.RegisterGeneric(typeof(EFUnitOfWork<>))
|
||||
// .As(typeof(IEFUnitOfWork<>)).InstancePerLifetimeScope();//注册仓储
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -38,29 +45,30 @@ namespace IRaCIS.Core.API
|
|||
.Where(type => typeof(IDynamicWebApi).IsAssignableFrom(type))
|
||||
.PropertiesAutowired();
|
||||
|
||||
//var controllerBaseType = typeof(ControllerBase);
|
||||
//containerBuilder.RegisterAssemblyTypes(typeof(BaseService).Assembly)
|
||||
// .Where(t => controllerBaseType.IsAssignableFrom(t) && t != controllerBaseType)
|
||||
// .PropertiesAutowired();
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
//containerBuilder.RegisterType<BaseService>().As<IBaseService>().PropertiesAutowired().InstancePerLifetimeScope();
|
||||
//containerBuilder.RegisterType<DictionaryService>().As<IDictionaryService>().InstancePerLifetimeScope();
|
||||
|
||||
|
||||
|
||||
Assembly application = Assembly.LoadFrom(AppDomain.CurrentDomain.BaseDirectory + "IRaCIS.Core.Application.dll");
|
||||
containerBuilder.RegisterAssemblyTypes(application).Where(t => t.FullName.Contains("Service"))
|
||||
.PropertiesAutowired().AsImplementedInterfaces().EnableClassInterceptors();
|
||||
|
||||
Assembly infrastructure = Assembly.Load("IRaCIS.Core.Infra.EFCore");
|
||||
containerBuilder.RegisterAssemblyTypes(infrastructure).AsImplementedInterfaces();
|
||||
//Assembly infrastructure = Assembly.Load("IRaCIS.Core.Infra.EFCore");
|
||||
//containerBuilder.RegisterAssemblyTypes(infrastructure).AsImplementedInterfaces();
|
||||
|
||||
containerBuilder.RegisterType<HttpContextAccessor>().As<IHttpContextAccessor>().SingleInstance();
|
||||
containerBuilder.RegisterType<UserInfo>().As<IUserInfo>().InstancePerLifetimeScope();
|
||||
|
||||
|
||||
//containerBuilder.RegisterType<Dictionary>().InstancePerLifetimeScope();
|
||||
|
||||
|
||||
|
||||
//Autofac 注册拦截器 需要注意的是生成api上服务上的动态代理AOP失效 间接掉用不影响
|
||||
containerBuilder.RegisterType<TrialStatusAutofacAOP>();
|
||||
//containerBuilder.RegisterType<TrialStatusAutofacAOP>();
|
||||
//containerBuilder.RegisterType<UserAddAOP>();
|
||||
//containerBuilder.RegisterType<QANoticeAOP>();
|
||||
//containerBuilder.RegisterType<LogService>().As<ILogService>().SingleInstance();
|
||||
|
|
|
@ -29,7 +29,21 @@ namespace IRaCIS.Core.API
|
|||
|
||||
//options.UseTriggers(triggerOptions => triggerOptions.AddTrigger<SubjectVisitImageDateTrigger>());
|
||||
|
||||
options.UseTriggers(triggerOptions => triggerOptions.AddAssemblyTriggers(typeof(SubjectVisitTrigger).Assembly));
|
||||
//options.UseTriggers(triggerOptions => triggerOptions.AddAssemblyTriggers(typeof(SubjectVisitTrigger).Assembly));
|
||||
|
||||
|
||||
options.UseTriggers(triggerOptions =>
|
||||
{
|
||||
triggerOptions.AddTrigger<AddSubjectTrigger>();
|
||||
triggerOptions.AddTrigger<ChallengeStateTrigger>();
|
||||
triggerOptions.AddTrigger<SubjectStateTrigger>();
|
||||
triggerOptions.AddTrigger<SubjectVisitCheckPassedTrigger>();
|
||||
triggerOptions.AddTrigger<SubjectVisitFinalVisitTrigger>();
|
||||
triggerOptions.AddTrigger<SubjectVisitTrigger>();
|
||||
triggerOptions.AddTrigger<TrialCriterionSignTrigger>();
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -24,7 +24,8 @@ namespace IRaCIS.Core.API
|
|||
|
||||
//options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
|
||||
|
||||
}).AddControllersAsServices()//动态webApi属性注入需要
|
||||
})
|
||||
.AddControllersAsServices()//动态webApi属性注入需要
|
||||
.ConfigureApiBehaviorOptions(o =>
|
||||
{
|
||||
o.SuppressModelStateInvalidFilter = true; //自己写验证
|
||||
|
|
Loading…
Reference in New Issue