diff --git a/IRaCIS.Core.API/Program.cs b/IRaCIS.Core.API/1Program.cs similarity index 100% rename from IRaCIS.Core.API/Program.cs rename to IRaCIS.Core.API/1Program.cs diff --git a/IRaCIS.Core.API/Startup.cs b/IRaCIS.Core.API/1Startup.cs similarity index 100% rename from IRaCIS.Core.API/Startup.cs rename to IRaCIS.Core.API/1Startup.cs diff --git a/IRaCIS.Core.API/Test.cs b/IRaCIS.Core.API/1Test.cs similarity index 100% rename from IRaCIS.Core.API/Test.cs rename to IRaCIS.Core.API/1Test.cs diff --git a/IRaCIS.Core.API/2Program.cs b/IRaCIS.Core.API/2Program.cs deleted file mode 100644 index e7649cb42..000000000 --- a/IRaCIS.Core.API/2Program.cs +++ /dev/null @@ -1,231 +0,0 @@ -//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.RegisterModule(); -// }) -// .UseWindowsService().UseSerilog(); - - - -//// Add services to the container. - -////本地化 -//builder.Services.AddJsonLocalization(options => options.ResourcesPath = "Resources"); - -//// 异常、参数统一验证过滤器、Json序列化配置、字符串参数绑型统一Trim() -//builder.Services.AddControllers(options => -//{ -// //options.Filters.Add(); -// options.Filters.Add(); -// options.Filters.Add(); -// //options.Filters.Add(); - -// //if (_configuration.GetSection("BasicSystemConfig").GetValue("OpenLoginLimit")) -// //{ -// // options.Filters.Add(); - -// //} - - -//}).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(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(options => -//{ -// options.ForwardedHeaders = -// ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; -//}); -////Dicom影像渲染图片 跨平台 -//builder.Services.AddDicomSetup(); - -//// 实时应用 -//builder.Services.AddSignalR(); - - -//builder.Services.AddSingleton(); - -//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(); - -//// 特殊异常处理 比如 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")/*.RequireCors(t=>t.WithOrigins(new string[] {"null"}).AllowAnyMethod().AllowAnyHeader().AllowCredentials())*/; -////}); - - - -//app.MapControllers(); -//app.MapHub("/UploadHub")/*.RequireCors(t=>t.WithOrigins(new string[] {"null"}).AllowAnyMethod().AllowAnyHeader().AllowCredentials())*/; - - -//app.Run(); - -//测试同步 diff --git a/IRaCIS.Core.API/IRC绯荤粺鏇存柊鏃ュ織.docx b/IRaCIS.Core.API/IRC绯荤粺鏇存柊鏃ュ織.docx deleted file mode 100644 index 467c074a1..000000000 Binary files a/IRaCIS.Core.API/IRC绯荤粺鏇存柊鏃ュ織.docx and /dev/null differ diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.xml b/IRaCIS.Core.API/IRaCIS.Core.API.xml index 5b5c02b0c..fb1288021 100644 --- a/IRaCIS.Core.API/IRaCIS.Core.API.xml +++ b/IRaCIS.Core.API/IRaCIS.Core.API.xml @@ -4,34 +4,6 @@ IRaCIS.Core.API - - - 涓昏澶勭悊 鍓嶇404绛夐敊璇 鍏ㄥ眬涓氬姟寮傚父宸茬粺涓澶勭悊浜嗭紝闈炰笟鍔¢敊璇細鏉ュ埌杩欓噷 - - - - - - - 鍖荤敓鍩烘湰淇℃伅 銆佸伐浣滀俊鎭 涓撲笟淇℃伅銆佸鏍哥姸鎬 - - - - - 鑾峰彇鍖荤敓璇︽儏 - - - - - - - - - - - - 绯荤粺鐢ㄦ埛鐧诲綍鎺ュ彛[New] - 娣诲姞瀹為獙椤圭洰-杩斿洖鏂板Id[AUTH] 鏂拌褰旾d @@ -373,6 +345,27 @@ 搴忓垪鍖栨垚鍛 + + + 鍖荤敓鍩烘湰淇℃伅 銆佸伐浣滀俊鎭 涓撲笟淇℃伅銆佸鏍哥姸鎬 + + + + + 鑾峰彇鍖荤敓璇︽儏 + + + + + + + + + + + + 绯荤粺鐢ㄦ埛鐧诲綍鎺ュ彛[New] + 涓轰簡鍓嶇 涓娈垫椂闂存棤鎿嶄綔锛岄渶瑕侀噸鏂扮櫥闄 @@ -380,6 +373,13 @@ + + + 涓昏澶勭悊 鍓嶇404绛夐敊璇 鍏ㄥ眬涓氬姟寮傚父宸茬粺涓澶勭悊浜嗭紝闈炰笟鍔¢敊璇細鏉ュ埌杩欓噷 + + + + 瀵圭О鍙嗗姞瀵 diff --git a/IRaCIS.Core.API/Progranm.cs b/IRaCIS.Core.API/Progranm.cs new file mode 100644 index 000000000..5116d15fa --- /dev/null +++ b/IRaCIS.Core.API/Progranm.cs @@ -0,0 +1,265 @@ +using System; +using Autofac.Extensions.DependencyInjection; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Configuration; +using Serilog; +using MediatR; +using IRaCIS.Core.Application.MediatR.Handlers; +using System.Threading.Tasks; +using MassTransit; +using MassTransit.NewIdProviders; +using System.IO; +using IRaCIS.Core.Domain.Share; +using IRaCIS.Core.Infra.EFCore; +using IRaCIS.Core.Application.Helper; +using System.Runtime.InteropServices; +using Microsoft.AspNetCore.Builder; +using IRaCIS.Core.API; +using Autofac; +using Microsoft.AspNetCore.Http.Features; +using Microsoft.AspNetCore.SignalR; +using Microsoft.Extensions.DependencyInjection; +using IRaCIS.Core.Application.Filter; +using Microsoft.AspNetCore.HttpOverrides; +using IRaCIS.Application.Services.BackGroundJob; +using LogDashboard; + + + +#region 环境变量设置,以及部署运维平台 + +//以配置文件为准,否则 从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"; +} + +if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) +{ + Log.Logger.Warning($"当前部署平台环境:windows"); +} +else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) +{ + Log.Logger.Warning($"当前部署平台环境:linux"); +} +else +{ + Log.Logger.Warning($"当前部署平台环境:OSX or FreeBSD"); +} + +#endregion + + +NewId.SetProcessIdProvider(new CurrentProcessIdProvider()); + +var builder = WebApplication.CreateBuilder(args); + +builder.Host.UseEnvironment(enviromentName) + .ConfigureAppConfiguration((hostContext, config) => + { + + //Console.WriteLine(hostContext.HostingEnvironment.EnvironmentName); + config.AddJsonFile("appsettings.json", false, true) + .AddJsonFile($"appsettings.{enviromentName}.json", false, true); + }) + .UseServiceProviderFactory(new AutofacServiceProviderFactory()) + .ConfigureContainer(containerBuilder => + { + containerBuilder.RegisterModule(); + }) + .UseWindowsService().UseSerilog(); + + + + +#region 配置服务 +var _configuration = builder.Configuration; + +//健康检查 +builder.Services.AddHealthChecks(); +//本地化 +builder.Services.AddJsonLocalization(options => options.ResourcesPath = "Resources"); + +// 异常、参数统一验证过滤器、Json序列化配置、字符串参数绑型统一Trim() +builder.Services.AddControllers(options => +{ + //options.Filters.Add(); + options.Filters.Add(); + options.Filters.Add(); + options.Filters.Add(); + + if (_configuration.GetSection("BasicSystemConfig").GetValue("OpenLoginLimit")) + { + options.Filters.Add(); + } + +}) + .AddNewtonsoftJsonSetup(); // NewtonsoftJson 序列化 处理 + +builder.Services.AddOptions().Configure(_configuration.GetSection("SystemEmailSendConfig")); +builder.Services.AddOptions().Configure(_configuration.GetSection("BasicSystemConfig")); +builder.Services.AddOptions().Configure(_configuration.GetSection("AliyunOSS")); +builder.Services.AddOptions().Configure(_configuration.GetSection("ObjectStoreService")); + + +//动态WebApi + UnifiedApiResultFilter 省掉控制器代码 +builder.Services.AddDynamicWebApiSetup(); +//AutoMapper +builder.Services.AddAutoMapperSetup(); +//EF ORM QueryWithNoLock +builder.Services.AddEFSetup(_configuration); +//Http 响应压缩 +builder.Services.AddResponseCompressionSetup(); +//Swagger Api 文档 +builder.Services.AddSwaggerSetup(); +//JWT Token 验证 +builder.Services.AddJWTAuthSetup(_configuration); + +// MediatR 进程内消息 事件解耦 从程序集中 注册命令和handler对应关系 +builder.Services.AddMediatR(cfg => cfg.RegisterServicesFromAssemblyContaining()); +// EasyCaching 缓存 +builder.Services.AddEasyCachingSetup(_configuration); + +// hangfire 定时任务框架 有界面,更友好~ +builder.Services.AddhangfireSetup(_configuration); + + +//Serilog 日志可视化 LogDashboard日志 +builder.Services.AddLogDashboardSetup(); + + +builder.Services.AddJsonConfigSetup(_configuration); +//转发头设置 获取真实IP +builder.Services.Configure(options => +{ + options.ForwardedHeaders = + ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; +}); +//Dicom影像渲染图片 跨平台 +builder.Services.AddDicomSetup(); + +// 实时应用 +builder.Services.AddSignalR(); + +builder.Services.AddSingleton(); + + + + + +#region 历史废弃配置 +//builder.Services.AddMemoryCache(); +////上传限制 配置 +//builder.Services.Configure(options => +//{ +// options.MultipartBodyLengthLimit = int.MaxValue; +// options.ValueCountLimit = int.MaxValue; +// options.ValueLengthLimit = int.MaxValue; +//}); +//IP 限流 可设置白名单 或者黑名单 +//services.AddIpPolicyRateLimitSetup(_configuration); +// 用户类型 策略授权 +//services.AddAuthorizationPolicySetup(_configuration); +#endregion + +#endregion + +var app = builder.Build(); +var env = app.Environment; + +#region 配置中间件 + + +// Configure the HTTP request pipeline. + +//本地化 +app.UseLocalization(); + +app.UseForwardedHeaders(); + +//响应压缩 +app.UseResponseCompression(); + +//app.UseCors(t => t.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); + +//不需要 token 访问的静态文件 wwwroot css, JavaScript, and images don't require authentication. +app.UseStaticFiles(); + +app.UseMiddleware(); + +//LogDashboard +app.UseLogDashboard("/LogDashboard"); + +//hangfire +app.UseHangfireConfig(env); + + +////限流 中间件 +//app.UseIpRateLimiting(); + + +if (env.IsDevelopment()) +{ + app.UseDeveloperExceptionPage(); +} +else +{ + //app.UseHsts(); +} + +// 特殊异常处理 比如 404 +app.UseStatusCodePagesWithReExecute("/Error/{0}"); + +SwaggerSetup.Configure(app, env); + + +////serilog 记录请求的用户信息 +app.UseSerilogConfig(env); + +app.UseRouting(); + +app.UseCors(t => t.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); + +//app.UseIRacisHostStaticFileStore(env); + + +app.UseAuthentication(); +app.UseAuthorization(); + + +app.UseEndpoints(endpoints => +{ + endpoints.MapControllers(); + + endpoints.MapHub("/UploadHub"); + + endpoints.MapHealthChecks("/health"); +}); + +// Serilog +SerilogExtension.AddSerilogSetup(enviromentName, app.Services); + +Log.Logger.Warning($"当前环境:{enviromentName}"); + +var hangfireJobService = app.Services.GetRequiredService(); + +await hangfireJobService.InitHangfireJobTaskAsync(); + + +#endregion + +app.Run(); + + + diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index 2606ad5b0..6f2f6718e 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -12,6 +12,7 @@ using Microsoft.Identity.Client; using static IRaCIS.Core.Domain.Share.StaticData; using IRaCIS.Core.Application.ViewModel; using Medallion.Threading; +using EasyCaching.Core; namespace IRaCIS.Application.Services { @@ -26,7 +27,7 @@ namespace IRaCIS.Application.Services private readonly IRepository _userLogRepository; private readonly IDistributedLockProvider _distributedLockProvider; - private readonly IMemoryCache _cache; + private readonly IEasyCachingProvider _cache; private readonly IOptionsMonitor _verifyConfig; @@ -36,7 +37,7 @@ namespace IRaCIS.Application.Services IMailVerificationService mailVerificationService, IRepository verificationCodeRepository, IRepository doctorRepository, - IMemoryCache cache, + IEasyCachingProvider cache, IRepository userTrialRepository, IOptionsMonitor verifyConfig, IRepository userLogRepository @@ -631,7 +632,7 @@ namespace IRaCIS.Application.Services string cacheKey = $"{cachePrefix}{userName}"; // 浠庣紦瀛樹腑鑾峰彇鐧诲綍澶辫触娆℃暟 - int? failCount = _cache.Get(cacheKey); + int? failCount = _cache.Get(cacheKey).Value; if (failCount == null) { diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs index b7c96d35e..21b355e6b 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs @@ -62,12 +62,10 @@ namespace IRaCIS.Application.Services private readonly IRepository _noneDicomStudyFileSystem; private readonly IRepository _readingQuestionTrialRepository; - private readonly IMemoryCache _cache; private readonly ITrialEmailNoticeConfigService _trialEmailNoticeConfigService; public ReadingImageTaskService( - IMapper mapper, IRepository noneDicomStudyRepository, IRepository visitTaskRepository, IRepository TrialRepository, @@ -90,8 +88,7 @@ namespace IRaCIS.Application.Services IRepository userRepository, IEasyCachingProvider provider, IRepository readingCustomTagRepository, - IRepository readingTaskQuestionMarkRepository, - IMemoryCache cache, + IRepository readingTaskQuestionMarkRepository, IRepository readingCriterionDictionaryRepository, IRepository readingTrialCriterionDictionaryRepository, IRepository tumorAssessmentRepository, @@ -107,7 +104,6 @@ namespace IRaCIS.Application.Services IRepository readingQuestionTrialRepository ) { - base._mapper = mapper; this._noneDicomStudyRepository = noneDicomStudyRepository; this._visitTaskRepository = visitTaskRepository; this._trialRepository = TrialRepository; @@ -144,7 +140,6 @@ namespace IRaCIS.Application.Services this._readingQuestionSystem = ReadingQuestionSystem; this._noneDicomStudyFileSystem = noneDicomStudyFileSystem; this._readingQuestionTrialRepository = readingQuestionTrialRepository; - this._cache = cache; this._trialEmailNoticeConfigService = trialEmailNoticeConfigService; }