From 68d72fce53bc74043bf926b9fef94a785d65c457 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 11 Oct 2023 13:16:57 +0800 Subject: [PATCH 01/34] =?UTF-8?q?=E5=BC=95=E5=85=A5=20EasyCaching=20redis?= =?UTF-8?q?=20=E5=87=86=E5=A4=87=E5=B7=A5=E4=BD=9C=E5=AE=8C=E6=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/IRaCIS.Core.API.csproj | 4 ++-- IRaCIS.Core.API/Startup.cs | 3 ++- .../_ServiceExtensions/EasyCachingSetup.cs | 11 +++++++++- IRaCIS.Core.API/appsettings.json | 20 +++++++++++++++++++ .../IRaCIS.Core.Application.csproj | 3 ++- 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.csproj b/IRaCIS.Core.API/IRaCIS.Core.API.csproj index a823da33e..de81ce373 100644 --- a/IRaCIS.Core.API/IRaCIS.Core.API.csproj +++ b/IRaCIS.Core.API/IRaCIS.Core.API.csproj @@ -70,8 +70,8 @@ - - + + diff --git a/IRaCIS.Core.API/Startup.cs b/IRaCIS.Core.API/Startup.cs index b095f6b07..aee2d0eef 100644 --- a/IRaCIS.Core.API/Startup.cs +++ b/IRaCIS.Core.API/Startup.cs @@ -29,6 +29,7 @@ using IRaCIS.Core.Application.Helper; using Microsoft.AspNetCore.Http; using Autofac.Core; using DocumentFormat.OpenXml.InkML; +using EasyCaching.Core; namespace IRaCIS.Core.API { @@ -114,7 +115,7 @@ namespace IRaCIS.Core.API // MediatR 进程内消息 事件解耦 从程序集中 注册命令和handler对应关系 services.AddMediatR(typeof(ConsistencyVerificationHandler).Assembly); // EasyCaching 缓存 - services.AddEasyCachingSetup(); + services.AddEasyCachingSetup(_configuration); //services.AddDistributedMemoryCache(); diff --git a/IRaCIS.Core.API/_ServiceExtensions/EasyCachingSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/EasyCachingSetup.cs index 7d7a28c6a..63be01d92 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/EasyCachingSetup.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/EasyCachingSetup.cs @@ -1,17 +1,26 @@ 锘縰sing EasyCaching.Core; +using EasyCaching.Core.Configurations; using EasyCaching.Interceptor.Castle; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; namespace IRaCIS.Core.API { public static class EasyCachingSetup { - public static void AddEasyCachingSetup(this IServiceCollection services) + public static void AddEasyCachingSetup(this IServiceCollection services, IConfiguration configuration) { services.AddEasyCaching(options => { options.UseInMemory(); + + //options.UseRedis(configuration, EasyCachingConstValue.DefaultRedisName).WithMessagePack(EasyCachingConstValue.DefaultRedisName); + + }); + + //services.ConfigureCastleInterceptor(options => options.CacheProviderName = EasyCachingConstValue.DefaultRedisName); + services.ConfigureCastleInterceptor(options => options.CacheProviderName = EasyCachingConstValue.DefaultInMemoryName); } } diff --git a/IRaCIS.Core.API/appsettings.json b/IRaCIS.Core.API/appsettings.json index a773c1174..dee559b4c 100644 --- a/IRaCIS.Core.API/appsettings.json +++ b/IRaCIS.Core.API/appsettings.json @@ -57,6 +57,26 @@ "EnableReadDeepClone": true, "EnableWriteDeepClone": false } + }, + "redis": { + "MaxRdSecond": 120, + "EnableLogging": false, + "LockMs": 5000, + "SleepMs": 300, + "dbconfig": { + "Password": "xc@123456", + "IsSsl": false, + "SslHost": null, + "ConnectionTimeout": 5000, + "AllowAdmin": true, + "Endpoints": [ + { + "Host": "47.117.164.182", + "Port": 6379 + } + ], + "Database": 0 + } } }, "IRaCISImageStore": { diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj index bf608d946..4ce2acb70 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj @@ -65,9 +65,10 @@ + + - From 7544e0c2e91bdc5e990c16390445c1e263d2b361 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 11 Oct 2023 16:29:57 +0800 Subject: [PATCH 02/34] =?UTF-8?q?=E5=BC=95=E5=85=A5=E5=88=86=E5=B8=83?= =?UTF-8?q?=E5=BC=8F=E7=BB=84=E4=BB=B6=20redis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Application/IRaCIS.Core.Application.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj index 4ce2acb70..15f4a5eb9 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj @@ -65,6 +65,8 @@ + + From 1afe020e83554f9470ebee76b50d7f1de9d2e623 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 11 Oct 2023 17:38:34 +0800 Subject: [PATCH 03/34] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E9=94=81=20?= =?UTF-8?q?=20sqlserver=20=E6=B5=8B=E8=AF=95=2003?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs | 13 +++++++- IRaCIS.Core.Application/TestService.cs | 31 +++++++++++++++++-- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs index 2f2890712..6c679d676 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs @@ -1,8 +1,12 @@ -锘縰sing IRaCIS.Core.Application.Triggers; +锘縰sing Hangfire.SqlServer; +using IRaCIS.Core.Application.Triggers; using IRaCIS.Core.Infra.EFCore; +using Medallion.Threading; +using Medallion.Threading.SqlServer; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using StackExchange.Redis; namespace IRaCIS.Core.API { @@ -52,6 +56,13 @@ namespace IRaCIS.Core.API }); + //娉ㄦ剰鍖哄垎 easy caching 涔熸湁 IDistributedLockProvider + services.AddSingleton(sp => + { + //var connection = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); + + return new SqlDistributedSynchronizationProvider(configuration.GetSection("ConnectionStrings:RemoteNew").Value); + }); //services.AddAssemblyTriggers(typeof(SubjectVisitImageDateTrigger).Assembly); } diff --git a/IRaCIS.Core.Application/TestService.cs b/IRaCIS.Core.Application/TestService.cs index aea881b0c..e2705a9b9 100644 --- a/IRaCIS.Core.Application/TestService.cs +++ b/IRaCIS.Core.Application/TestService.cs @@ -1,8 +1,10 @@ -锘縰sing IRaCIS.Core.Application.Service; +锘縰sing DocumentFormat.OpenXml.Office2010.Excel; +using IRaCIS.Core.Application.Service; using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Infrastructure; using MassTransit; +using Medallion.Threading; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; @@ -10,6 +12,7 @@ using Microsoft.Extensions.Caching.Distributed; using Microsoft.Extensions.Options; using MiniExcelLibs; using System.Linq.Expressions; +using System.Reflection.Metadata; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; @@ -20,6 +23,8 @@ namespace IRaCIS.Application.Services [ApiExplorerSettings(GroupName = "Institution")] public class TestService : BaseService { + + public static int IntValue = 100; private readonly IRepository _dicRepository; private readonly IRepository _trialRepository; @@ -30,10 +35,11 @@ namespace IRaCIS.Application.Services private readonly IOptionsMonitor _basicConfig; private readonly IRepository _visitTaskRepositoryy; + private readonly IDistributedLockProvider _distributedLockProvider; public TestService(IRepository dicRepository, IRepository trialRepository/*, IDistributedCache cache*/ - , IOptionsMonitor systemEmailConfig, IOptionsMonitor basicConfig, IRepository visitTaskRepository) + , IOptionsMonitor systemEmailConfig, IOptionsMonitor basicConfig, IRepository visitTaskRepository, IDistributedLockProvider distributedLockProvider) { _visitTaskRepositoryy = visitTaskRepository; @@ -42,10 +48,31 @@ namespace IRaCIS.Application.Services _dicRepository = dicRepository; _trialRepository = trialRepository; + + _distributedLockProvider= distributedLockProvider; //_cache = cache; } + + [AllowAnonymous] + public async Task TestDistributedLock( ) + { + Console.WriteLine($"鎴戣繘鏉ヤ簡褰撳墠鍊兼槸锛" + IntValue); + + var @lock = _distributedLockProvider.CreateLock($"UserAccount"); + + using (await @lock.AcquireAsync()) + { + await Task.Delay(3); + IntValue--; + Console.WriteLine(IntValue); + } + + return ResponseOutput.Ok(IntValue); + } + + [AllowAnonymous] public async Task GetMemoryStoreData() { From dfef88d663ab3d6dae1d4820cd54a2a9e07a4e5c Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 11 Oct 2023 17:44:13 +0800 Subject: [PATCH 04/34] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E9=94=81=20?= =?UTF-8?q?=20sqlserver=20=E6=B5=8B=E8=AF=95=2004=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Application/TestService.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/IRaCIS.Core.Application/TestService.cs b/IRaCIS.Core.Application/TestService.cs index e2705a9b9..5e0bf334f 100644 --- a/IRaCIS.Core.Application/TestService.cs +++ b/IRaCIS.Core.Application/TestService.cs @@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Caching.Distributed; +using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using MiniExcelLibs; using System.Linq.Expressions; @@ -37,7 +38,9 @@ namespace IRaCIS.Application.Services private readonly IDistributedLockProvider _distributedLockProvider; - public TestService(IRepository dicRepository, IRepository trialRepository/*, IDistributedCache cache*/ + private readonly ILogger _logger; + + public TestService(IRepository dicRepository, IRepository trialRepository,ILogger logger , IOptionsMonitor systemEmailConfig, IOptionsMonitor basicConfig, IRepository visitTaskRepository, IDistributedLockProvider distributedLockProvider) { @@ -50,6 +53,8 @@ namespace IRaCIS.Application.Services _trialRepository = trialRepository; _distributedLockProvider= distributedLockProvider; + + _logger= logger; //_cache = cache; } @@ -59,13 +64,16 @@ namespace IRaCIS.Application.Services public async Task TestDistributedLock( ) { Console.WriteLine($"鎴戣繘鏉ヤ簡褰撳墠鍊兼槸锛" + IntValue); + _logger.LogWarning($"鎴戣繘鏉ヤ簡褰撳墠鍊兼槸锛" + IntValue); var @lock = _distributedLockProvider.CreateLock($"UserAccount"); using (await @lock.AcquireAsync()) { - await Task.Delay(3); + await Task.Delay(4); IntValue--; + + _logger.LogWarning( IntValue.ToString()); Console.WriteLine(IntValue); } From 14908c4eeda913f018e9c3b62dadc6f5427e4e1e Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 12 Oct 2023 09:34:09 +0800 Subject: [PATCH 05/34] =?UTF-8?q?=E5=88=86=E5=B8=83=E5=BC=8F=E9=94=81=20?= =?UTF-8?q?=20sqlserver=2005=20=E9=A1=B9=E7=9B=AE=E8=BF=81=E7=A7=BB?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IRaCIS.Core.Application.csproj | 1 - .../Service/Common/MailService.cs | 2 - .../ImageAndDoc/DicomArchiveService.cs | 25 ++- .../Service/ImageAndDoc/StudyService.cs | 34 +-- .../Service/Institution/SiteService.cs | 16 +- .../Service/Management/UserService.cs | 44 ++-- .../Service/QC/NoneDicomStudyService.cs | 12 +- .../Service/QC/QCOperationService.cs | 13 +- .../SiteSurvey/TrialSiteSurveyService.cs | 14 +- .../TrialSiteUser/TrialExternalUserService.cs | 196 +++++++++--------- 10 files changed, 191 insertions(+), 166 deletions(-) diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj index 15f4a5eb9..179a30f94 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj @@ -100,7 +100,6 @@ true - diff --git a/IRaCIS.Core.Application/Service/Common/MailService.cs b/IRaCIS.Core.Application/Service/Common/MailService.cs index 2a4e0bb2d..d821708b6 100644 --- a/IRaCIS.Core.Application/Service/Common/MailService.cs +++ b/IRaCIS.Core.Application/Service/Common/MailService.cs @@ -6,7 +6,6 @@ using Microsoft.AspNetCore.Hosting; using IRaCIS.Core.Application.Auth; using AutoMapper; using IRaCIS.Application.Contracts; -using Nito.AsyncEx; using Microsoft.Extensions.Options; namespace IRaCIS.Application.Services @@ -55,7 +54,6 @@ namespace IRaCIS.Application.Services - private readonly AsyncLock _mutex = new AsyncLock(); private readonly SystemEmailSendConfig _systemEmailConfig; diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/DicomArchiveService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/DicomArchiveService.cs index f797c8ca4..9b990c306 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/DicomArchiveService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/DicomArchiveService.cs @@ -8,10 +8,11 @@ using IRaCIS.Core.Application.Contracts; using IRaCIS.Core.Application.Helper; using Microsoft.AspNetCore.Hosting; using IRaCIS.Core.Infrastructure; +using Medallion.Threading; namespace IRaCIS.Core.Application.Services { - public class DicomArchiveService :BaseService, IDicomArchiveService + public class DicomArchiveService : BaseService, IDicomArchiveService { private readonly IRepository _studyRepository; private readonly IRepository _seriesRepository; @@ -21,7 +22,7 @@ namespace IRaCIS.Core.Application.Services private readonly IWebHostEnvironment _hostEnvironment; - private static object lockCodeGenerate = new object(); + private readonly IDistributedLockProvider _distributedLockProvider; private List _instanceIdList = new List(); @@ -31,8 +32,9 @@ namespace IRaCIS.Core.Application.Services IRepository instanceRepository, IWebHostEnvironment hostEnvironment, IRepository dictionaryRepository, - IEasyCachingProvider provider) + IEasyCachingProvider provider, IDistributedLockProvider distributedLockProvider) { + _distributedLockProvider = distributedLockProvider; _hostEnvironment = hostEnvironment; _studyRepository = studyRepository; @@ -50,7 +52,7 @@ namespace IRaCIS.Core.Application.Services return success; } - + public async Task<(Guid StudyId, string StudyCode)> ArchiveDicomStreamAsync(Stream dicomStream, @@ -129,7 +131,7 @@ namespace IRaCIS.Core.Application.Services DicomStudy dicomStudy = CreateDicomStudy(dataset, addtionalInfo, out bool isStudyNeedAdd); DicomSeries dicomSeries = CreateDicomSeries(dataset, dicomStudy, out bool isSeriesNeedAdd); - DicomInstance dicomInstance = CreateDicomInstance(dataset, dicomStudy, dicomSeries,out bool isInstanceNeedAdd); + DicomInstance dicomInstance = CreateDicomInstance(dataset, dicomStudy, dicomSeries, out bool isInstanceNeedAdd); dicomSeries.DicomStudy = dicomStudy; @@ -183,7 +185,7 @@ namespace IRaCIS.Core.Application.Services //姝e父淇濆瓨 涓嶅仛澶勭悊 await dicomFile.SaveAsync(physicalPath); } - else + else { //RLELossless 淇濆瓨 await dicomFile.Clone(DicomTransferSyntax.RLELossless).SaveAsync(physicalPath); //RLELossless @@ -235,7 +237,7 @@ namespace IRaCIS.Core.Application.Services { modalityForEdit = "PET"; } - if(modality== "PT銆丆T") + if (modality == "PT銆丆T") { modalityForEdit = "PET-CT"; } @@ -282,9 +284,10 @@ namespace IRaCIS.Core.Application.Services dicomStudy.PatientBirthDate = $"{dicomStudy.PatientBirthDate[0]}{dicomStudy.PatientBirthDate[1]}{dicomStudy.PatientBirthDate[2]}{dicomStudy.PatientBirthDate[3]}-{dicomStudy.PatientBirthDate[4]}{dicomStudy.PatientBirthDate[5]}-{dicomStudy.PatientBirthDate[6]}{dicomStudy.PatientBirthDate[7]}"; } - lock (lockCodeGenerate) - { + var @lock = _distributedLockProvider.CreateLock($"StudyCode"); + using (@lock.Acquire()) + { //鏌ヨ鏁版嵁搴撹幏鍙栨渶澶х殑Code 娌℃湁璁板綍鍒欎负0 var dbStudyCodeIntMax = _studyRepository.Where(s => s.TrialId == addtionalInfo.TrialId).Select(t => t.Code).DefaultIfEmpty().Max(); @@ -298,9 +301,9 @@ namespace IRaCIS.Core.Application.Services dicomStudy.StudyCode = AppSettings.GetCodeStr(currentNextCodeInt, nameof(DicomStudy)); _provider.Set($"{addtionalInfo.TrialId}_{StaticData.CacheKey.StudyMaxCode}", dicomStudy.Code, TimeSpan.FromMinutes(30)); - } + #region Setting Code old //var studyCode = _studyRepository.Where(s => s.TrialId == addtionalInfo.TrialId).Select(t => t.StudyCode).OrderByDescending(c => c).FirstOrDefault(); @@ -468,7 +471,7 @@ namespace IRaCIS.Core.Application.Services _instanceIdList.Add(instanceId); } - + return dicomInstance; } diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs index 173c643f1..adb1f224a 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs @@ -14,16 +14,13 @@ using IRaCIS.Core.Application.MediatR.Handlers; using Microsoft.AspNetCore.Http; using Newtonsoft.Json; using System.Threading; -using Nito.AsyncEx; +using Medallion.Threading; namespace IRaCIS.Core.Application.Service.ImageAndDoc { [ApiExplorerSettings(GroupName = "Image")] public class StudyService : BaseService, IStudyService { - private static object lockObj = new object(); - private static readonly AsyncLock _mutex = new AsyncLock(); - private static readonly AsyncLock _mutex2 = new AsyncLock(); private readonly IEasyCachingProvider _provider; @@ -35,12 +32,12 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc private readonly IRepository _dictionaryRepository; private readonly IRepository _studyMonitorRepository; - + private readonly IDistributedLockProvider _distributedLockProvider; public StudyService(IEasyCachingProvider provider , IRepository subjectVisitRepository, IRepository dicomInstanceRepository, - IRepository dicomSeriesRepository, IRepository dicomstudyRepository, IRepository dictionaryRepository, IRepository studyMonitorRepository) + IRepository dicomSeriesRepository, IRepository dicomstudyRepository, IRepository dictionaryRepository, IRepository studyMonitorRepository, IDistributedLockProvider distributedLockProvider) { _provider = provider; _subjectVisitRepository = subjectVisitRepository; @@ -49,6 +46,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc _dicomstudyRepository = dicomstudyRepository; _dictionaryRepository = dictionaryRepository; _studyMonitorRepository = studyMonitorRepository; + _distributedLockProvider = distributedLockProvider; } @@ -160,7 +158,9 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc { var study = _mapper.Map(incommand.Study); - using (await _mutex.LockAsync()) + var @lock = _distributedLockProvider.CreateLock($"StudyCode"); + + using (await @lock.AcquireAsync()) { //鏌ヨ鏁版嵁搴撹幏鍙栨渶澶х殑Code 娌℃湁璁板綍鍒欎负0 var dbStudyCodeIntMax = _dicomstudyRepository.Where(s => s.TrialId == trialId).Select(t => t.Code).DefaultIfEmpty().Max(); @@ -306,11 +306,11 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc } - using (await _mutex2.LockAsync()) + var @lock2 = _distributedLockProvider.CreateLock($"StudyCommit"); + + using (await @lock2.AcquireAsync()) { await _dicomInstanceRepository.SaveChangesAsync(); - - } } catch (Exception ex) @@ -765,7 +765,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc if (_provider.Exists($"StudyUid_{trialId}_{studyInstanceUid}")) { - + result.AllowUpload = false; result.AllowReUpload = false; @@ -826,22 +826,22 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc } result.StudyInstanceUid = studyInstanceUid; + var @lock = _distributedLockProvider.CreateLock($"StudyUpload"); - if (result.AllowReUpload || result.AllowUpload) + using (@lock.Acquire()) { - lock (lockObj) + if (result.AllowReUpload || result.AllowUpload) { _provider.Set($"StudyUid_{trialId}_{studyInstanceUid}", _userInfo.Id, TimeSpan.FromSeconds(30)); } - } - else - { - lock (lockObj) + else { _provider.Remove($"StudyUid_{trialId}_{studyInstanceUid}"); } } + + return result; } diff --git a/IRaCIS.Core.Application/Service/Institution/SiteService.cs b/IRaCIS.Core.Application/Service/Institution/SiteService.cs index 137d4ffd0..b65b2379f 100644 --- a/IRaCIS.Core.Application/Service/Institution/SiteService.cs +++ b/IRaCIS.Core.Application/Service/Institution/SiteService.cs @@ -3,7 +3,7 @@ using IRaCIS.Application.Contracts; using IRaCIS.Core.Infra.EFCore; using Microsoft.AspNetCore.Mvc; using IRaCIS.Core.Domain.Share; -using Nito.AsyncEx; +using Medallion.Threading; namespace IRaCIS.Application.Services { @@ -12,13 +12,13 @@ namespace IRaCIS.Application.Services { private readonly IRepository _siteRepository; private readonly IRepository _trialSiteUserRepository; + private readonly IDistributedLockProvider _distributedLockProvider; - private readonly AsyncLock _mutex = new AsyncLock(); - - public SiteService(IRepository siteRepository, IRepository trialSiteUserRepository) + public SiteService(IRepository siteRepository, IRepository trialSiteUserRepository, IDistributedLockProvider distributedLockProvider) { _siteRepository = siteRepository; - this._trialSiteUserRepository = trialSiteUserRepository; + _trialSiteUserRepository = trialSiteUserRepository; + _distributedLockProvider = distributedLockProvider; } /// 鍒嗛〉鑾峰彇鐮旂┒涓績鍒楄〃 @@ -27,7 +27,7 @@ namespace IRaCIS.Application.Services { var siteQueryable = _siteRepository - .WhereIf(!string.IsNullOrWhiteSpace(searchModel.SiteName), t => t.SiteName.Contains(searchModel.SiteName)||t.SiteNameCN.Contains(searchModel.SiteName)) + .WhereIf(!string.IsNullOrWhiteSpace(searchModel.SiteName), t => t.SiteName.Contains(searchModel.SiteName) || t.SiteNameCN.Contains(searchModel.SiteName)) .WhereIf(!string.IsNullOrWhiteSpace(searchModel.AliasName), t => t.AliasName.Contains(searchModel.AliasName)) .WhereIf(!string.IsNullOrWhiteSpace(searchModel.City), t => t.City.Contains(searchModel.City)) .WhereIf(!string.IsNullOrWhiteSpace(searchModel.Country), t => t.Country.Contains(searchModel.Country)) @@ -58,7 +58,9 @@ namespace IRaCIS.Application.Services VerifyMsg = _localizer["Site_DupName"] }; - using (await _mutex.LockAsync()) + var @lock = _distributedLockProvider.CreateLock($"SiteAdd"); + + using (await @lock.AcquireAsync()) { if (siteCommand.Id == null) { diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index 32df5fa15..b36859015 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -12,6 +12,7 @@ using IRaCIS.Core.Infra.Common.Cache; using Microsoft.Identity.Client; using static IRaCIS.Core.Domain.Share.StaticData; using IRaCIS.Core.Application.ViewModel; +using Medallion.Threading; namespace IRaCIS.Application.Services { @@ -24,7 +25,7 @@ namespace IRaCIS.Application.Services private readonly IRepository _userTrialRepository; private readonly IRepository _userLogRepository; - + private readonly IDistributedLockProvider _distributedLockProvider; private readonly IMemoryCache _cache; private readonly IOptionsMonitor _verifyConfig; @@ -38,7 +39,8 @@ namespace IRaCIS.Application.Services IRepository userTrialRepository, IOptionsMonitor verifyConfig, IRepository userLogRepository - ) +, + IDistributedLockProvider distributedLockProvider) { _userLogRepository = userLogRepository; @@ -47,9 +49,10 @@ namespace IRaCIS.Application.Services _userRepository = userRepository; _mailVerificationService = mailVerificationService; _verificationCodeRepository = verificationCodeRepository; - + _userTrialRepository = userTrialRepository; _userLogRepository = userLogRepository; + _distributedLockProvider = distributedLockProvider; } @@ -502,29 +505,32 @@ namespace IRaCIS.Application.Services var saveItem = _mapper.Map(userAddModel); - saveItem.Code = await _userRepository.Select(t => t.Code).DefaultIfEmpty().MaxAsync() + 1; + var @lock = _distributedLockProvider.CreateLock($"UserAccount"); - saveItem.UserCode = AppSettings.GetCodeStr(saveItem.Code, nameof(User)); - - if (saveItem.IsZhiZhun) + using (await @lock.AcquireAsync()) { - saveItem.OrganizationName = AppSettings.DefaultInternalOrganizationName; + saveItem.Code = await _userRepository.Select(t => t.Code).DefaultIfEmpty().MaxAsync() + 1; + + saveItem.UserCode = AppSettings.GetCodeStr(saveItem.Code, nameof(User)); + + if (saveItem.IsZhiZhun) + { + saveItem.OrganizationName = AppSettings.DefaultInternalOrganizationName; + } + + + saveItem.Password = MD5Helper.Md5("123456"); + + await _userRepository.AddAsync(saveItem); + + var success = await _userRepository.SaveChangesAsync(); } - - saveItem.Password = MD5Helper.Md5("123456"); - - await _userRepository.AddAsync(saveItem); - - var success = await _userRepository.SaveChangesAsync(); - - + await _mailVerificationService.AddUserSendEmailAsync(saveItem.Id, userAddModel.BaseUrl, userAddModel.RouteUrl); - - - return ResponseOutput.Result(success, new UserAddedReturnDTO { Id = saveItem.Id, UserCode = saveItem.UserCode }); + return ResponseOutput.Ok( new UserAddedReturnDTO { Id = saveItem.Id, UserCode = saveItem.UserCode }); } diff --git a/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs b/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs index fa912838f..e6a40c3bf 100644 --- a/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs +++ b/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs @@ -5,10 +5,10 @@ //-------------------------------------------------------------------- using Microsoft.AspNetCore.Mvc; using IRaCIS.Core.Application.Filter; -using Nito.AsyncEx; using System.ComponentModel.DataAnnotations; using IRaCIS.Core.Application.Service; using IRaCIS.Core.Domain.Share; +using Medallion.Threading; namespace IRaCIS.Core.Application.Contracts { @@ -20,19 +20,19 @@ namespace IRaCIS.Core.Application.Contracts { private readonly IRepository _noneDicomStudyRepository; private readonly IRepository _noneDicomStudyFileRepository; - private readonly AsyncLock _mutex = new AsyncLock(); + private readonly IDistributedLockProvider _distributedLockProvider; private readonly QCCommon _qCCommon; public NoneDicomStudyService(IRepository noneDicomStudyRepository, QCCommon qCCommon, - IRepository noneDicomStudyFileRepository) + IRepository noneDicomStudyFileRepository, IDistributedLockProvider distributedLockProvider) { _qCCommon = qCCommon; _noneDicomStudyRepository = noneDicomStudyRepository; _noneDicomStudyFileRepository = noneDicomStudyFileRepository; - + _distributedLockProvider = distributedLockProvider; } @@ -62,7 +62,9 @@ namespace IRaCIS.Core.Application.Contracts } NoneDicomStudy? optEntity = null; - using (await _mutex.LockAsync()) + var @lock = _distributedLockProvider.CreateLock($"NoneDicomCode"); + + using (await @lock.AcquireAsync()) { if (addOrEditNoneDicomStudy.Id == Guid.Empty || addOrEditNoneDicomStudy.Id == null) { diff --git a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs index 0e905e2f8..5f8e7e621 100644 --- a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs +++ b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs @@ -10,13 +10,13 @@ using WinSCP; using Newtonsoft.Json; using IRaCIS.Core.Infrastructure; using IRaCIS.Core.Application.Service.Inspection.DTO; -using Nito.AsyncEx; using System.ComponentModel.DataAnnotations; using IRaCIS.Core.Application.Auth; using IRaCIS.Core.Application.Helper; using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Domain.Models; using IRaCIS.Core.Application.Service; +using Medallion.Threading; namespace IRaCIS.Core.Application.Image.QA { @@ -35,8 +35,7 @@ namespace IRaCIS.Core.Application.Image.QA private readonly IRepository _trialRepository; private readonly IRepository _visitTaskRepository; private readonly IVisitTaskHelpeService _IVisitTaskHelpeService; - - private readonly AsyncLock _mutex = new AsyncLock(); + private readonly IDistributedLockProvider _distributedLockProvider; public QCOperationService(IRepository subjectVisitRepository, IRepository qcChallengeRepository, @@ -48,7 +47,8 @@ namespace IRaCIS.Core.Application.Image.QA IRepository readingClinicalDataRepository, IRepository qCChallengeDialogrepository, IRepository checkChallengeDialogrepository, - IVisitTaskHelpeService visitTaskHelpeService + IVisitTaskHelpeService visitTaskHelpeService, + IDistributedLockProvider distributedLockProvider ) { _subjectVisitRepository = subjectVisitRepository; @@ -62,6 +62,7 @@ namespace IRaCIS.Core.Application.Image.QA _trialRepository = trialRepository; this._visitTaskRepository = visitTaskRepository; _IVisitTaskHelpeService = visitTaskHelpeService; + _distributedLockProvider = distributedLockProvider; } #region QC璐ㄧ枒 浠ュ強鍥炲 鍏抽棴 @@ -108,9 +109,9 @@ namespace IRaCIS.Core.Application.Image.QA var trialConfig = (await _trialRepository.Where(t => t.Id == trialId).Select(t => new { TrialId = t.Id, t.QCProcessEnum, t.IsImageConsistencyVerification }).FirstOrDefaultAsync()).IfNullThrowException(); + var @lock = _distributedLockProvider.CreateLock($"QCChallengeCode"); - - using (await _mutex.LockAsync()) + using (await @lock.AcquireAsync()) { //鑾峰彇缂栧彿 var code = _qcChallengeRepository.Where(t => t.TrialId == trialId).Select(t => t.Code).DefaultIfEmpty().Max(); diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs index 0984a186b..523db6363 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs @@ -21,6 +21,7 @@ using DocumentFormat.OpenXml.Spreadsheet; using IRaCIS.Core.Domain.Models; using IRaCIS.Core.Application.ViewModel; using Dicom; +using Medallion.Threading; namespace IRaCIS.Core.Application.Contracts { @@ -36,13 +37,14 @@ namespace IRaCIS.Core.Application.Contracts private readonly IRepository _trialSiteRepository; private readonly IRepository _trialUserRepository; private readonly IRepository _trialSiteUserRepository; + private readonly IDistributedLockProvider _distributedLockProvider; private readonly ITokenService _tokenService; private readonly IMailVerificationService _mailVerificationService; public TrialSiteSurveyService(IRepository trialSiteSurveyRepository, IRepository trialUserRepository, IRepository trialSiteUserSurveyRepository, IRepository userRepository, IRepository trialSiteRepository, ITokenService tokenService, - IMailVerificationService mailVerificationService, IRepository trialSiteUserRepository) + IMailVerificationService mailVerificationService, IRepository trialSiteUserRepository, IDistributedLockProvider distributedLockProvider) { _trialSiteSurveyRepository = trialSiteSurveyRepository; _trialSiteUserSurveyRepository = trialSiteUserSurveyRepository; @@ -52,9 +54,9 @@ namespace IRaCIS.Core.Application.Contracts _tokenService = tokenService; _mailVerificationService = mailVerificationService; _trialSiteUserRepository = trialSiteUserRepository; + _distributedLockProvider = distributedLockProvider; } - private object lockObj { get; set; } = new object(); /// /// 鍙戦侀獙璇佺爜 @@ -792,7 +794,9 @@ namespace IRaCIS.Core.Application.Contracts if (sysUserInfo == null) { - lock (lockObj) + var @lock = _distributedLockProvider.CreateLock($"UserCode"); + + using (await @lock.AcquireAsync()) { var saveItem = _mapper.Map(item); @@ -972,7 +976,9 @@ namespace IRaCIS.Core.Application.Contracts if (sysUserInfo == null) { - lock (lockObj) + var @lock = _distributedLockProvider.CreateLock($"UserCode"); + + using (await @lock.AcquireAsync()) { var saveItem = _mapper.Map(item); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs index 6bf00a16e..96704f954 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs @@ -16,6 +16,7 @@ using Panda.DynamicWebApi.Attributes; using IRaCIS.Core.Application.Auth; using IRaCIS.Application.Services; using IRaCIS.Core.Application.Filter; +using Medallion.Threading; namespace IRaCIS.Core.Application.Service { @@ -31,10 +32,11 @@ namespace IRaCIS.Core.Application.Service private readonly IRepository _trialSiteSurveyUserRepository; private readonly IRepository _trialSiteUserRepository; private readonly IMailVerificationService _mailVerificationService; + private readonly IDistributedLockProvider _distributedLockProvider; public TrialExternalUserService(IRepository trialExternalUseRepository, IRepository userRepository, IRepository trialUserRepository, IRepository trialSiteSurveyUserRepository, IRepository trialSiteUserRepository, - IMailVerificationService mailVerificationService) + IMailVerificationService mailVerificationService, IDistributedLockProvider distributedLockProvider) { _trialExternalUseRepository = trialExternalUseRepository; _userRepository = userRepository; @@ -43,6 +45,7 @@ namespace IRaCIS.Core.Application.Service _trialSiteUserRepository = trialSiteUserRepository; _mailVerificationService = mailVerificationService; + _distributedLockProvider = distributedLockProvider; } @@ -75,121 +78,125 @@ namespace IRaCIS.Core.Application.Service if (addOrEditTrialExternalUser.Id == null) { - var existSysUser = await _userRepository.FirstOrDefaultAsync(t => t.EMail == addOrEditTrialExternalUser.Email && t.UserTypeId == addOrEditTrialExternalUser.UserTypeId); + var @lock = _distributedLockProvider.CreateLock($"UserCode"); - if (existSysUser != null) + using (await @lock.AcquireAsync()) { - if (existSysUser.LastName != addOrEditTrialExternalUser.LastName || existSysUser.FirstName != addOrEditTrialExternalUser.FirstName) + var existSysUser = await _userRepository.FirstOrDefaultAsync(t => t.EMail == addOrEditTrialExternalUser.Email && t.UserTypeId == addOrEditTrialExternalUser.UserTypeId); + + if (existSysUser != null) { - //$"璇ョ敤鎴峰湪绯荤粺涓殑鐢ㄦ埛鍚嶄负锛歿existSysUser.LastName + " / " + existSysUser.FirstName} 鐢佃瘽锛歿existSysUser.Phone}锛屼笌濉啓淇℃伅瀛樺湪涓嶄竴鑷撮」, 璇峰皢鐣岄潰淇℃伅淇敼涓轰笌绯荤粺涓鑷达紝鍐嶈繘琛屼繚瀛", - return ResponseOutput.NotOk(_localizer["TrialExternalUser_Inconsistency", existSysUser.LastName + " / " + existSysUser.FirstName, existSysUser.Phone], new { existSysUser.LastName, existSysUser.FirstName, existSysUser.Phone, existSysUser.IsZhiZhun, existSysUser.IsTestUser }, ApiResponseCodeEnum.NeedTips); + if (existSysUser.LastName != addOrEditTrialExternalUser.LastName || existSysUser.FirstName != addOrEditTrialExternalUser.FirstName) + { + //$"璇ョ敤鎴峰湪绯荤粺涓殑鐢ㄦ埛鍚嶄负锛歿existSysUser.LastName + " / " + existSysUser.FirstName} 鐢佃瘽锛歿existSysUser.Phone}锛屼笌濉啓淇℃伅瀛樺湪涓嶄竴鑷撮」, 璇峰皢鐣岄潰淇℃伅淇敼涓轰笌绯荤粺涓鑷达紝鍐嶈繘琛屼繚瀛", + return ResponseOutput.NotOk(_localizer["TrialExternalUser_Inconsistency", existSysUser.LastName + " / " + existSysUser.FirstName, existSysUser.Phone], new { existSysUser.LastName, existSysUser.FirstName, existSysUser.Phone, existSysUser.IsZhiZhun, existSysUser.IsTestUser }, ApiResponseCodeEnum.NeedTips); + } + } - } + //澶勭悊 鐢熸垚璐︽埛 - //澶勭悊 鐢熸垚璐︽埛 - - if (await _trialExternalUseRepository.AnyAsync(t => - t.Email == addOrEditTrialExternalUser.Email && - t.UserTypeId == addOrEditTrialExternalUser.UserTypeId && t.TrialId == addOrEditTrialExternalUser.TrialId)) - { - //---绯荤粺宸茬粡瀛樺湪涓庡垪琛ㄤ腑濉啓鐨勯偖绠卞拰鐢ㄦ埛绫诲瀷鐩稿悓鐨勮处鎴凤紝璇风‘璁ゃ - return ResponseOutput.NotOk(_localizer["TrialExternalUser_EmailTypeDuplicate"]); - } + if (await _trialExternalUseRepository.AnyAsync(t => + t.Email == addOrEditTrialExternalUser.Email && + t.UserTypeId == addOrEditTrialExternalUser.UserTypeId && t.TrialId == addOrEditTrialExternalUser.TrialId)) + { + //---绯荤粺宸茬粡瀛樺湪涓庡垪琛ㄤ腑濉啓鐨勯偖绠卞拰鐢ㄦ埛绫诲瀷鐩稿悓鐨勮处鎴凤紝璇风‘璁ゃ + return ResponseOutput.NotOk(_localizer["TrialExternalUser_EmailTypeDuplicate"]); + } - var addEntity = _mapper.Map(addOrEditTrialExternalUser); + var addEntity = _mapper.Map(addOrEditTrialExternalUser); - await _trialExternalUseRepository.AddAsync(addEntity); + await _trialExternalUseRepository.AddAsync(addEntity); - var existUser = await _userRepository.FirstOrDefaultAsync(t => t.EMail == addOrEditTrialExternalUser.Email && t.UserTypeId == addOrEditTrialExternalUser.UserTypeId); - var trialType = await _repository.Where(t => t.Id == addOrEditTrialExternalUser.TrialId).Select(t => t.TrialType).FirstOrDefaultAsync(); + var existUser = await _userRepository.FirstOrDefaultAsync(t => t.EMail == addOrEditTrialExternalUser.Email && t.UserTypeId == addOrEditTrialExternalUser.UserTypeId); + var trialType = await _repository.Where(t => t.Id == addOrEditTrialExternalUser.TrialId).Select(t => t.TrialType).FirstOrDefaultAsync(); - if (existUser != null) - { - addEntity.IsSystemUser = true; - addEntity.SystemUserId = existUser.Id; + if (existUser != null) + { + addEntity.IsSystemUser = true; + addEntity.SystemUserId = existUser.Id; - } - else - { + } + else + { - //鐢熸垚璐︽埛 骞舵彃鍏 + //鐢熸垚璐︽埛 骞舵彃鍏 - var generateUser = _mapper.Map(addOrEditTrialExternalUser); + var generateUser = _mapper.Map(addOrEditTrialExternalUser); + + if (trialType == TrialType.NoneOfficial) + { + generateUser.IsTestUser = true; + } + + // 澶栭儴浜哄憳鐢熸垚璐﹀彿 閮芥槸澶栭儴鐨 + generateUser.IsZhiZhun = false; + + generateUser.Code = _userRepository.Select(t => t.Code).DefaultIfEmpty().Max() + 1; + + + generateUser.UserCode = AppSettings.GetCodeStr(generateUser.Code, nameof(User)); + + generateUser.UserName = generateUser.UserCode; + + generateUser.UserTypeEnum = _repository.Where(t => t.Id == generateUser.UserTypeId).Select(t => t.UserTypeEnum).First(); + + generateUser.Password = MD5Helper.Md5("123456"); + + generateUser.Status = UserStateEnum.Disable; + + var newAddUser = await _repository.AddAsync(generateUser); + + + addEntity.IsSystemUser = false; + addEntity.SystemUserId = newAddUser.Id; + + + existUser = newAddUser; + + } + + #region 楠岃瘉鐢ㄦ埛 鑳藉惁鍔犲叆 + + if (trialType == TrialType.OfficialTrial || trialType == TrialType.Training) + { + + if (existUser.IsTestUser) + { + //---姝e紡绫诲瀷 銆佸煿璁被鍨嬬殑椤圭洰 涓嶅厑璁稿姞鍏ユ祴璇曠敤鎴 + throw new BusinessValidationFailedException(_localizer["TrialExternalUser_TestUserNotAllowed"]); + + } + } if (trialType == TrialType.NoneOfficial) { - generateUser.IsTestUser = true; + + if (existUser.IsTestUser == false) + { + //---娴嬭瘯椤圭洰 涓嶅厑璁稿姞鍏ユ寮忕敤鎴 + throw new BusinessValidationFailedException(_localizer["TrialExternalUser_FormalUserNotAllowed"]); + } } - // 澶栭儴浜哄憳鐢熸垚璐﹀彿 閮芥槸澶栭儴鐨 - generateUser.IsZhiZhun = false; - - generateUser.Code = _userRepository.Select(t => t.Code).DefaultIfEmpty().Max() + 1; + #endregion - generateUser.UserCode = AppSettings.GetCodeStr(generateUser.Code, nameof(User)); - - generateUser.UserName = generateUser.UserCode; - - generateUser.UserTypeEnum = _repository.Where(t => t.Id == generateUser.UserTypeId).Select(t => t.UserTypeEnum).First(); - - generateUser.Password = MD5Helper.Md5("123456"); - - generateUser.Status = UserStateEnum.Disable; - - var newAddUser = await _repository.AddAsync(generateUser); + await _trialExternalUseRepository.SaveChangesAsync(); - addEntity.IsSystemUser = false; - addEntity.SystemUserId = newAddUser.Id; - - - existUser = newAddUser; - - } - - #region 楠岃瘉鐢ㄦ埛 鑳藉惁鍔犲叆 - - if (trialType == TrialType.OfficialTrial || trialType == TrialType.Training) - { - - if (existUser.IsTestUser) + //娣诲姞鐨勬椂鍊欏氨鍙戦偖浠 鐜板湪鐪佺暐 + if (addOrEditTrialExternalUser.IsSendEmail) { - //---姝e紡绫诲瀷 銆佸煿璁被鍨嬬殑椤圭洰 涓嶅厑璁稿姞鍏ユ祴璇曠敤鎴 - throw new BusinessValidationFailedException(_localizer["TrialExternalUser_TestUserNotAllowed"]); - - } - } - - if (trialType == TrialType.NoneOfficial) - { - - if (existUser.IsTestUser == false ) - { - //---娴嬭瘯椤圭洰 涓嶅厑璁稿姞鍏ユ寮忕敤鎴 - throw new BusinessValidationFailedException(_localizer["TrialExternalUser_FormalUserNotAllowed"]); - } - } - - #endregion - - - await _trialExternalUseRepository.SaveChangesAsync(); - - - //娣诲姞鐨勬椂鍊欏氨鍙戦偖浠 鐜板湪鐪佺暐 - if (addOrEditTrialExternalUser.IsSendEmail) - { - await SendExternalUserJoinEmail(new TrialExternalUserSendEmail() - { - BaseUrl = addOrEditTrialExternalUser.BaseUrl, - RouteUrl = addOrEditTrialExternalUser.RouteUrl, - TrialId = addOrEditTrialExternalUser.TrialId, - SendUsers = new List() + await SendExternalUserJoinEmail(new TrialExternalUserSendEmail() + { + BaseUrl = addOrEditTrialExternalUser.BaseUrl, + RouteUrl = addOrEditTrialExternalUser.RouteUrl, + TrialId = addOrEditTrialExternalUser.TrialId, + SendUsers = new List() { new UserEmail() { @@ -199,12 +206,13 @@ namespace IRaCIS.Core.Application.Service SystemUserId=addEntity.SystemUserId } } - }); + }); + } + + + return ResponseOutput.Ok(addEntity.Id.ToString()); } - - return ResponseOutput.Ok(addEntity.Id.ToString()); - } else { From a27dcd6399483d8300e01e1cd21b9fda32324057 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 12 Oct 2023 13:26:06 +0800 Subject: [PATCH 06/34] =?UTF-8?q?=E5=8D=87=E7=BA=A7efcore=20=20=E6=B8=85?= =?UTF-8?q?=E7=90=86=E4=B9=8B=E5=89=8D=E7=9A=84=E5=86=99=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Serilog/SerilogSetup.cs | 2 +- .../Swagger/JsonPatchDocumentFilter.cs | 55 ------ .../Swagger/SwaggerSetup.cs | 1 - .../Service/Common/DictionaryService.cs | 2 +- .../Service/Common/_MapConfig.cs | 2 +- .../Service/Document/SystemDocumentService.cs | 2 +- .../Service/Document/TrialDocumentService.cs | 10 +- .../Service/Document/_MapConfig.cs | 3 +- .../Service/TrialSiteUser/TrialService.cs | 4 +- .../Service/TrialSiteUser/_MapConfig.cs | 7 +- IRaCIS.Core.Domain/Common/Dictionary.cs | 3 - .../Context/IRaCISDBContext.cs | 17 +- .../Extention/RequestExtension.cs | 158 ------------------ IRaCIS.Core.Infrastructure/Helper/IPHelper.cs | 43 ----- .../IRaCIS.Core.Infrastructure.csproj | 12 +- 15 files changed, 32 insertions(+), 289 deletions(-) delete mode 100644 IRaCIS.Core.API/_ServiceExtensions/Swagger/JsonPatchDocumentFilter.cs delete mode 100644 IRaCIS.Core.Infrastructure/Extention/RequestExtension.cs delete mode 100644 IRaCIS.Core.Infrastructure/Helper/IPHelper.cs diff --git a/IRaCIS.Core.API/_ServiceExtensions/Serilog/SerilogSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/Serilog/SerilogSetup.cs index f0740dbbf..a27de1505 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/Serilog/SerilogSetup.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/Serilog/SerilogSetup.cs @@ -21,7 +21,7 @@ namespace IRaCIS.Core.API .MinimumLevel.Override("Hangfire", LogEventLevel.Warning) .MinimumLevel.Override("System.Net.Http.HttpClient.HttpReports", LogEventLevel.Warning) .Enrich.WithClientIp() - .Enrich.WithClientAgent() + .Enrich.FromLogContext() //鎺у埗鍙 鏂逛究璋冭瘯 闂 鎴戜滑鏄剧ず璁板綍鏃ュ織 鏃 鑾峰彇涓婁笅鏂囩殑ip 鍜岀敤鎴峰悕 鐢ㄦ埛绫诲瀷 diff --git a/IRaCIS.Core.API/_ServiceExtensions/Swagger/JsonPatchDocumentFilter.cs b/IRaCIS.Core.API/_ServiceExtensions/Swagger/JsonPatchDocumentFilter.cs deleted file mode 100644 index 9f3562072..000000000 --- a/IRaCIS.Core.API/_ServiceExtensions/Swagger/JsonPatchDocumentFilter.cs +++ /dev/null @@ -1,55 +0,0 @@ -锘縰sing Microsoft.OpenApi.Models; -using Swashbuckle.AspNetCore.SwaggerGen; -using System.Collections.Generic; -using System.Linq; - -namespace IRaCIS.Core.API -{ - public class JsonPatchDocumentFilter : IDocumentFilter - { - public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context) - { - var schemas = swaggerDoc.Components.Schemas.ToList(); - foreach (var item in schemas) - { - if (item.Key.StartsWith("Operation") || item.Key.StartsWith("JsonPatchDocument")) - swaggerDoc.Components.Schemas.Remove(item.Key); - } - - swaggerDoc.Components.Schemas.Add("Operation", new OpenApiSchema - { - Type = "object", - Properties = new Dictionary - { - { "op", new OpenApiSchema { Type = "string" } }, - {"value", new OpenApiSchema{ Type = "object", Nullable = true } }, - { "path", new OpenApiSchema { Type = "string" } } - } - }); - - swaggerDoc.Components.Schemas.Add("JsonPatchDocument", new OpenApiSchema - { - Type = "array", - Items = new OpenApiSchema - { - Reference = new OpenApiReference { Type = ReferenceType.Schema, Id = "Operation" } - }, - Description = "Array of operations to perform" - }); - - foreach (var path in swaggerDoc.Paths.SelectMany(p => p.Value.Operations) - .Where(p => p.Key == Microsoft.OpenApi.Models.OperationType.Patch)) - { - foreach (var item in path.Value.RequestBody.Content.Where(c => c.Key != "application/json-patch+json")) - path.Value.RequestBody.Content.Remove(item.Key); - - var response = path.Value.RequestBody.Content.SingleOrDefault(c => c.Key == "application/json-patch+json"); - - response.Value.Schema = new OpenApiSchema - { - Reference = new OpenApiReference { Type = ReferenceType.Schema, Id = "JsonPatchDocument" } - }; - } - } - } -} diff --git a/IRaCIS.Core.API/_ServiceExtensions/Swagger/SwaggerSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/Swagger/SwaggerSetup.cs index 4a16162e7..35978b51e 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/Swagger/SwaggerSetup.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/Swagger/SwaggerSetup.cs @@ -63,7 +63,6 @@ namespace IRaCIS.Core.API // 鍦╤eader涓坊鍔爐oken锛屼紶閫掑埌鍚庡彴 options.OperationFilter(); - options.DocumentFilter(); // 娣诲姞鐧诲綍鎸夐挳 options.AddSecurityDefinition("bearerAuth", new OpenApiSecurityScheme() diff --git a/IRaCIS.Core.Application/Service/Common/DictionaryService.cs b/IRaCIS.Core.Application/Service/Common/DictionaryService.cs index 9d5aa7e7f..82a48b05a 100644 --- a/IRaCIS.Core.Application/Service/Common/DictionaryService.cs +++ b/IRaCIS.Core.Application/Service/Common/DictionaryService.cs @@ -249,7 +249,7 @@ namespace IRaCIS.Application.Services public async Task>> GetBasicDataSelect(string[] searchArray) { - var searchList = await _dicRepository.Where(t => searchArray.Contains(t.Parent.Code) && t.ParentId != null && t.IsEnable).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + var searchList = await _dicRepository.Where(t => searchArray.Contains(t.Parent.Code) && t.ParentId != null && t.IsEnable).ProjectTo(_mapper.ConfigurationProvider,new { isEn_Us = _userInfo.IsEn_Us}).ToListAsync(); return searchList.GroupBy(t => t.ParentCode).ToDictionary(g => g.Key, g => g.OrderBy(t => t.ShowOrder).ToList()); diff --git a/IRaCIS.Core.Application/Service/Common/_MapConfig.cs b/IRaCIS.Core.Application/Service/Common/_MapConfig.cs index 9c2c3c95c..f157924cb 100644 --- a/IRaCIS.Core.Application/Service/Common/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Common/_MapConfig.cs @@ -58,7 +58,7 @@ namespace IRaCIS.Core.Application.Service CreateMap() .ForMember(o => o.ParentChildCodeEnum, t => t.MapFrom(u => u.Parent.ChildCodeEnum)) - .ForMember(o => o.Value, t => t.MapFrom(u => u.MappedValue)) + .ForMember(o => o.Value, t => t.MapFrom(u => isEn_Us? u.Value : u.ValueCN )) .ForMember(o => o.ParentCode, t => t.MapFrom(u => u.Parent.Code)); CreateMap() diff --git a/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs b/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs index 4d3003ad9..21480bae3 100644 --- a/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs +++ b/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs @@ -170,7 +170,7 @@ namespace IRaCIS.Core.Application.Services SignViewMinimumMinutes = sysDoc.SignViewMinimumMinutes, Name = sysDoc.Name, Path = sysDoc.Path, - FileType = sysDoc.FileType.MappedValue, + FileType = _userInfo.IsEn_Us? sysDoc.FileType.Value: sysDoc.FileType.ValueCN, UpdateTime = sysDoc.UpdateTime, FullFilePath = sysDoc.Path , diff --git a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs index 620998555..5ba66e44d 100644 --- a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs +++ b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs @@ -57,7 +57,7 @@ namespace IRaCIS.Core.Application.Services var trialDocumentQueryable = _trialDocumentRepository.AsQueryable(true).Where(t => t.TrialId == queryTrialDocument.TrialId) .WhereIf(!string.IsNullOrEmpty(queryTrialDocument.Name), t => t.Name.Contains(queryTrialDocument.Name)) .WhereIf(queryTrialDocument.FileTypeId != null, t => t.FileTypeId == queryTrialDocument.FileTypeId) - .ProjectTo(_mapper.ConfigurationProvider, new { token = _userInfo.UserToken }); + .ProjectTo(_mapper.ConfigurationProvider, new { token = _userInfo.UserToken, isEn_Us=_userInfo.IsEn_Us }); return await trialDocumentQueryable.ToPagedListAsync(queryTrialDocument.PageIndex, queryTrialDocument.PageSize, queryTrialDocument.SortField, queryTrialDocument.Asc); } @@ -157,7 +157,7 @@ namespace IRaCIS.Core.Application.Services Name = needConfirmedUserType.SystemDocument.Name, Path = needConfirmedUserType.SystemDocument.Path, FileTypeId = needConfirmedUserType.SystemDocument.FileTypeId, - FileType = needConfirmedUserType.SystemDocument.FileType.MappedValue, + FileType = _userInfo.IsEn_Us? needConfirmedUserType.SystemDocument.FileType.Value: needConfirmedUserType.SystemDocument.FileType.ValueCN, UpdateTime = needConfirmedUserType.SystemDocument.UpdateTime, FullFilePath = needConfirmedUserType.SystemDocument.Path , @@ -189,7 +189,7 @@ namespace IRaCIS.Core.Application.Services Name = trialDoc.Name, Path = trialDoc.Path, FileTypeId = trialDoc.FileTypeId, - FileType = trialDoc.FileType.MappedValue, + FileType = _userInfo.IsEn_Us ? trialDoc.FileType.Value: trialDoc.FileType.ValueCN, UpdateTime = trialDoc.UpdateTime, SignViewMinimumMinutes = trialDoc.SignViewMinimumMinutes, @@ -311,7 +311,7 @@ namespace IRaCIS.Core.Application.Services Name = trialDocumentNeedConfirmedUserType.TrialDocument.Name, Path = trialDocumentNeedConfirmedUserType.TrialDocument.Path, FileTypeId = trialDocumentNeedConfirmedUserType.TrialDocument.FileTypeId, - FileType = trialDocumentNeedConfirmedUserType.TrialDocument.FileType.MappedValue, + FileType = _userInfo.IsEn_Us ? trialDocumentNeedConfirmedUserType.TrialDocument.FileType.Value : trialDocumentNeedConfirmedUserType.TrialDocument.FileType.ValueCN, UpdateTime = trialDocumentNeedConfirmedUserType.TrialDocument.UpdateTime, @@ -345,7 +345,7 @@ namespace IRaCIS.Core.Application.Services SignViewMinimumMinutes = needConfirmEdUserType.SystemDocument.SignViewMinimumMinutes, Name = needConfirmEdUserType.SystemDocument.Name, Path = needConfirmEdUserType.SystemDocument.Path, - FileType = needConfirmEdUserType.SystemDocument.FileType.MappedValue, + FileType = _userInfo.IsEn_Us ? needConfirmEdUserType.SystemDocument.FileType.Value : needConfirmEdUserType.SystemDocument.FileType.ValueCN, FileTypeId = needConfirmEdUserType.SystemDocument.FileTypeId, UpdateTime = needConfirmEdUserType.SystemDocument.UpdateTime, diff --git a/IRaCIS.Core.Application/Service/Document/_MapConfig.cs b/IRaCIS.Core.Application/Service/Document/_MapConfig.cs index 3f0c411bd..225e4284b 100644 --- a/IRaCIS.Core.Application/Service/Document/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Document/_MapConfig.cs @@ -14,12 +14,13 @@ namespace IRaCIS.Core.Application.Service var userId = Guid.Empty; var token = string.Empty; + var isEn_Us = false; CreateMap() .ForMember(d => d.FileType, u => u.MapFrom(s => s.FileType.Value)) .ForMember(d => d.FullFilePath, u => u.MapFrom(s => s.Path)); CreateMap() - .ForMember(d => d.FileType, u => u.MapFrom(s => s.FileType.MappedValue)) + .ForMember(d => d.FileType, u => u.MapFrom(s => isEn_Us ? s.FileType.Value : s.FileType.ValueCN )) .ForMember(d => d.IsSomeUserSigned, u => u.MapFrom(s => s.TrialDocConfirmedUserList.Any(t=>t.ConfirmTime!=null))) .ForMember(d => d.FullFilePath, u => u.MapFrom(s => s.Path )); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs index 27338466c..b9ee2f43b 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs @@ -92,7 +92,7 @@ namespace IRaCIS.Application.Services .WhereIf(multiCriteriaSelectCount > 0, t => t.TrialDicList.Count(t => t.KeyName == StaticData.Criterion) == multiCriteriaSelectCount) .WhereIf(multiReviewTypeSelectCount > 0, t => t.TrialDicList.Count(t => t.KeyName == StaticData.ReviewType) == multiReviewTypeSelectCount) .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin, t => t.TrialUserList.Any(t => t.UserId == _userInfo.Id && t.IsDeleted == false) && t.IsDeleted == false) - .ProjectTo(_mapper.ConfigurationProvider, new { userTypeEnumInt = _userInfo.UserTypeEnumInt, userId = _userInfo.Id }); + .ProjectTo(_mapper.ConfigurationProvider, new { userTypeEnumInt = _userInfo.UserTypeEnumInt, userId = _userInfo.Id , isEn_Us= _userInfo.IsEn_Us }); return await query.ToPagedListAsync(searchParam.PageIndex, searchParam.PageSize, string.IsNullOrWhiteSpace(searchParam.SortField) ? "CreateTime" : searchParam.SortField, searchParam.Asc); @@ -118,7 +118,7 @@ namespace IRaCIS.Application.Services [HttpGet("{projectId:guid}")] public async Task GetTrialInfoAndLockState(Guid projectId) { - return (await _trialRepository.Where(o => o.Id == projectId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); + return (await _trialRepository.Where(o => o.Id == projectId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider, new {isEn_Us = _userInfo.IsEn_Us }).FirstOrDefaultAsync()).IfNullThrowException(); } diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig.cs index ed95fb96a..7d61be101 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig.cs @@ -65,16 +65,17 @@ namespace IRaCIS.Core.Application.Service var userId = Guid.Empty; var userTypeEnumInt = 0; + var isEn_Us = false; CreateMap() .ForMember(x=>x.CriterionList,y=>y.MapFrom(z=>z.ReadingQuestionCriterionTrialList.Where(n=>n.IsConfirm).Select(m=>m.CriterionName))) .ForMember(d => d.DictionaryList, u => u.MapFrom(s => s.TrialDicList.Select(t => t.Dictionary).OrderBy(t => t.ShowOrder))) //.ForMember(d => d.Code, u => u.MapFrom(s => s.TrialCode)) .ForMember(d => d.Sponsor, u => u.MapFrom(s => s.Sponsor.SponsorName)) - .ForMember(d => d.Phase, u => u.MapFrom(s => s.Phase.MappedValue)) + .ForMember(d => d.Phase, u => u.MapFrom(s => isEn_Us? s.Phase.Value: s.Phase.ValueCN)) //.ForMember(d => d.DeclarationType, u => u.MapFrom(s => s.DeclarationType.MappedValue)) - .ForMember(d => d.IndicationType, u => u.MapFrom(s => s.IndicationType.MappedValue)) + .ForMember(d => d.IndicationType, u => u.MapFrom(s => isEn_Us ? s.IndicationType.Value:s.IndicationType.ValueCN)) .ForMember(d => d.CRO, u => u.MapFrom(s => s.CRO.CROName)) - .ForMember(d => d.ReviewMode, u => u.MapFrom(s => s.ReviewMode.MappedValue)) + .ForMember(d => d.ReviewMode, u => u.MapFrom(s => isEn_Us ? s.ReviewMode.Value:s.ReviewMode.ValueCN)) //.ForMember(d => d.ReviewType, u => u.MapFrom(s => s.ReviewType.Value)) //.ForMember(d => d.SiteCount, u => u.MapFrom(s => userTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator ? s.TrialSiteUserList.Count(k => k.UserId == userId) : s.TrialSiteList.Count())) diff --git a/IRaCIS.Core.Domain/Common/Dictionary.cs b/IRaCIS.Core.Domain/Common/Dictionary.cs index 2117bd7cc..34e5327b7 100644 --- a/IRaCIS.Core.Domain/Common/Dictionary.cs +++ b/IRaCIS.Core.Domain/Common/Dictionary.cs @@ -56,9 +56,6 @@ namespace IRaCIS.Core.Domain.Models public List ChildList { get; set; } = new List(); - [NotMapped] - public string MappedValue { get; set; } - [Projectable] public string TranslateValue( string value, string valueCN,bool isCN) => isCN?valueCN:value; diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs index 849440fd9..d50f72cc5 100644 --- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs +++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs @@ -122,14 +122,15 @@ namespace IRaCIS.Core.Infra.EFCore modelBuilder.Entity().HasMany(t => t.ChildList).WithOne(t => t.Parent); - if (_userInfo.IsEn_Us) - { - modelBuilder.Entity().Property(t => t.MappedValue).HasColumnName(nameof(Domain.Models.Dictionary.Value)); - } - else - { - modelBuilder.Entity().Property(t => t.MappedValue).HasColumnName(nameof(Domain.Models.Dictionary.ValueCN)); - } + modelBuilder.Entity().HasMany(t => t.EarlierSubjectUserList).WithOne(t => t.OrignalSubjectUser); + //if (_userInfo.IsEn_Us) + //{ + // modelBuilder.Entity().Property(t => t.MappedValue).HasColumnName(nameof(Domain.Models.Dictionary.Value)); + //} + //else + //{ + // modelBuilder.Entity().Property(t => t.MappedValue).HasColumnName(nameof(Domain.Models.Dictionary.ValueCN)); + //} //閬嶅巻瀹炰綋妯″瀷鎵嬪姩閰嶇疆 diff --git a/IRaCIS.Core.Infrastructure/Extention/RequestExtension.cs b/IRaCIS.Core.Infrastructure/Extention/RequestExtension.cs deleted file mode 100644 index 1aecdeb67..000000000 --- a/IRaCIS.Core.Infrastructure/Extention/RequestExtension.cs +++ /dev/null @@ -1,158 +0,0 @@ -锘縰sing Microsoft.AspNetCore.Http; -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; - -namespace IRaCIS.Core.Infrastructure.Extention -{ - public static class HttpContextExtension - { - - public static T GetService(this HttpContext context) where T : class - { - return context.RequestServices.GetService(typeof(T)) as T; - } - - - public static string GetUserIp(this HttpContext context) - { - string realIP = null; - string forwarded = null; - string remoteIpAddress = context.Connection.RemoteIpAddress.ToString(); - if (context.Request.Headers.ContainsKey("X-Real-IP")) - { - realIP = context.Request.Headers["X-Real-IP"].ToString(); - if (realIP != remoteIpAddress) - { - remoteIpAddress = realIP; - } - } - if (context.Request.Headers.ContainsKey("X-Forwarded-For")) - { - forwarded = context.Request.Headers["X-Forwarded-For"].ToString(); - if (forwarded != remoteIpAddress) - { - remoteIpAddress = forwarded; - } - } - return remoteIpAddress; - } - - - - /// - /// 鑾峰彇Request鍊 - /// - /// - /// - /// - public static string Request(this HttpContext context, string parameter) - { - try - { - if (context == null) - return null; - if (context.Request.Method == "POST") - return context.Request.Form[parameter].ToString(); - else - return context.Request.Query[parameter].ToString(); - } - catch (System.Exception ex) - { - Console.Write(ex.Message + ex.InnerException); - return context.RequestString(parameter); - } - } - - public static T Request(this HttpContext context, string parameter) where T : class - { - return context.RequestString(parameter)?.DeserializeObject(); - } - public static string RequestString(this HttpContext context, string parameter) - { - string requestParam = context.GetRequestParameters(); - if (string.IsNullOrEmpty(requestParam)) return null; - Dictionary keyValues = requestParam.DeserializeObject>(); - if (keyValues == null || keyValues.Count == 0) return null; - if (keyValues.TryGetValue(parameter, out object value)) - { - if (value == null) return null; - if (value.GetType() == typeof(string)) - { - return value?.ToString(); - } - return value.Serialize(); - } - return null; - } - /// - /// 鏄惁涓篴jax璇锋眰 - /// - /// - /// - public static bool IsAjaxRequest(this HttpContext context) - { - return context.Request("X-Requested-With") == "XMLHttpRequest" - || (context.Request.Headers != null - && context.Request.Headers["X-Requested-With"] == "XMLHttpRequest"); - } - - public static UserAgent GetAgentType(this HttpContext context) - { - string agent = context.Request.Headers["User-Agent"].ToString().ToLower(); - - if (agent.Contains("ios") || agent.Contains("ipod") || agent.Contains("ipad")) - { - return UserAgent.IOS; - } - if (agent.Contains("windows")) - { - return UserAgent.Windows; - } - return UserAgent.Android; - - } - - /// - /// 鑾峰彇璇锋眰鐨勫弬鏁 - /// net core 2.0宸插鍔犲洖璇绘柟娉 context.Request.EnableRewind(); - /// - /// - /// - /// - - public static string GetRequestParameters(this HttpContext context) - { - if (context.Request.Body == null || !context.Request.Body.CanRead || !context.Request.Body.CanSeek) - return null; - if (context.Request.Body.Length == 0) - return null; - if (context.Request.Body.Position > 0) - context.Request.Body.Position = 0; - - string prarameters = null; - var bodyStream = context.Request.Body; - - using (var buffer = new MemoryStream()) - { - bodyStream.CopyToAsync(buffer); - buffer.Position = 0L; - bodyStream.Position = 0L; - using (var reader = new StreamReader(buffer, Encoding.UTF8)) - { - buffer.Seek(0, SeekOrigin.Begin); - prarameters = reader.ReadToEnd(); - } - } - return prarameters; - } - } - public enum UserAgent - { - IOS = 0, - Android = 1, - Windows = 2, - Linux - } -} diff --git a/IRaCIS.Core.Infrastructure/Helper/IPHelper.cs b/IRaCIS.Core.Infrastructure/Helper/IPHelper.cs deleted file mode 100644 index c8827eab0..000000000 --- a/IRaCIS.Core.Infrastructure/Helper/IPHelper.cs +++ /dev/null @@ -1,43 +0,0 @@ -锘縰sing System.Linq; -using System.Text.RegularExpressions; -using Microsoft.AspNetCore.Http; - -namespace IRaCIS.Core.Infrastructure -{ - public class IPHelper - { - /// - /// 鏄惁涓篿p - /// - /// - /// - public static bool IsIP(string ip) - { - return Regex.IsMatch(ip, @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$"); - } - - public static string GetIP(HttpRequest request) - { - if (request == null) - { - return ""; - } - - string ip = request.Headers["X-Real-IP"].FirstOrDefault(); - if (string.IsNullOrEmpty(ip)) - { - ip = request.Headers["X-Forwarded-For"].FirstOrDefault(); - } - if (string.IsNullOrEmpty(ip)) - { - ip = request.HttpContext?.Connection?.RemoteIpAddress?.ToString(); - } - if (string.IsNullOrEmpty(ip) || !IsIP(ip)) - { - ip = "127.0.0.1"; - } - - return ip; - } - } -} \ No newline at end of file diff --git a/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj b/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj index 7d0a4080a..9976f5251 100644 --- a/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj +++ b/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj @@ -9,12 +9,12 @@ - - - - - - + + + + + + From a53626b66cb9f57fd05410b74976197731c9f81e Mon Sep 17 00:00:00 2001 From: he <10978375@qq.com> Date: Thu, 12 Oct 2023 13:49:13 +0800 Subject: [PATCH 07/34] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReadingImageTask/ReadingImageTaskService.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs index 1059da1e1..f332883f7 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs @@ -15,6 +15,7 @@ using Newtonsoft.Json.Linq; using Microsoft.Extensions.Caching.Memory; using IRaCIS.Core.Application.Filter; using DocumentFormat.OpenXml.Drawing; +using EasyCaching.Core; using Quartz; using IRaCIS.Application.Services.BackGroundJob; @@ -47,6 +48,7 @@ namespace IRaCIS.Application.Services private readonly IRepository _organInfoRepository; private readonly IRepository _trialDocumentRepository; private readonly IRepository _userRepository; + private readonly IEasyCachingProvider _provider; private readonly IRepository _readingCustomTagRepository; private readonly IRepository _readingCriterionDictionaryRepository; private readonly IRepository _readingTrialCriterionDictionaryRepository; @@ -87,6 +89,7 @@ namespace IRaCIS.Application.Services IRepository organInfoRepository, IRepository trialDocumentRepository, IRepository userRepository, + IEasyCachingProvider provider, IRepository readingCustomTagRepository, IMemoryCache cache, IRepository readingCriterionDictionaryRepository, @@ -127,6 +130,7 @@ namespace IRaCIS.Application.Services this._organInfoRepository = organInfoRepository; this._trialDocumentRepository = trialDocumentRepository; this._userRepository = userRepository; + this._provider = provider; this._readingCustomTagRepository = readingCustomTagRepository; this._readingCriterionDictionaryRepository = readingCriterionDictionaryRepository; this._tumorAssessmentRepository = tumorAssessmentRepository; @@ -2470,10 +2474,13 @@ namespace IRaCIS.Application.Services public async Task VerifyReadingRestTime() { var cacheKey = _userInfo.Id.ToString(); - var value = _cache.Get(cacheKey); + + + var value = _provider.Get(cacheKey).Value; if (value == null) { - _cache.Set(cacheKey, DateTime.Now.ToString(), TimeSpan.FromHours(5)); + _provider.Set(cacheKey, DateTime.Now.ToString(), TimeSpan.FromHours(5)); + // _cache.Set(cacheKey, DateTime.Now.ToString(), TimeSpan.FromHours(5)); } else @@ -2488,7 +2495,8 @@ namespace IRaCIS.Application.Services else if (timespanMin > 140) { cacheDate = cacheDate.AddMinutes((Math.Floor((double)(timespanMin / 140))) * 140); - _cache.Set(cacheKey, cacheDate.ToString(), TimeSpan.FromHours(5)); + _provider.Set(cacheKey, cacheDate.ToString(), TimeSpan.FromHours(5)); + // _cache.Set(cacheKey, cacheDate.ToString(), TimeSpan.FromHours(5)); } #endregion From 33b9113993fb760b6f193eab6483c372454a19bf Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 12 Oct 2023 14:03:30 +0800 Subject: [PATCH 08/34] =?UTF-8?q?nuget=20=E5=8C=85=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=EF=BC=8C=E6=B8=85=E7=90=86=E6=B2=A1=E7=94=A8=E7=9A=84=E5=8C=85?= =?UTF-8?q?=EF=BC=8C=E9=A2=84=E5=A4=87net8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/IRaCIS.Core.API.csproj | 25 +++++---- IRaCIS.Core.API/Startup.cs | 2 +- .../Swagger/SwaggerSetup.cs | 1 - .../IRaCIS.Core.Application.csproj | 49 ++++++++---------- .../IRaCIS.Core.Application.xml | 5 -- .../ImageAndDoc/DicomArchiveService.cs | 5 +- .../Interface/JsonPatchUserRequestExample.cs | 51 ------------------- .../SiteSurvey/TrialSiteSurveyService.cs | 1 - .../Service/TrialSiteUser/_MapConfig.cs | 1 - .../Allocation/TaskMedicalReview.cs | 10 ++-- IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj | 8 +-- .../ReadingMedicalReviewDialog.cs | 8 +-- .../Context/IRaCISDBContext.cs | 2 +- .../EntityConfigration/StudyConfigration.cs | 3 +- .../IRaCIS.Core.Infra.EFCore.csproj | 13 +++-- IRaCIS.Core.Test/IRaCIS.Core.Test.csproj | 8 +-- 16 files changed, 63 insertions(+), 129 deletions(-) delete mode 100644 IRaCIS.Core.Application/Service/SiteSurvey/Interface/JsonPatchUserRequestExample.cs diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.csproj b/IRaCIS.Core.API/IRaCIS.Core.API.csproj index a823da33e..70da0d235 100644 --- a/IRaCIS.Core.API/IRaCIS.Core.API.csproj +++ b/IRaCIS.Core.API/IRaCIS.Core.API.csproj @@ -66,28 +66,27 @@ - - + + - - - - + + + + - - - - - - + + + + + - + diff --git a/IRaCIS.Core.API/Startup.cs b/IRaCIS.Core.API/Startup.cs index b095f6b07..f19961aed 100644 --- a/IRaCIS.Core.API/Startup.cs +++ b/IRaCIS.Core.API/Startup.cs @@ -112,7 +112,7 @@ namespace IRaCIS.Core.API //JWT Token 验证 services.AddJWTAuthSetup(_configuration); // MediatR 进程内消息 事件解耦 从程序集中 注册命令和handler对应关系 - services.AddMediatR(typeof(ConsistencyVerificationHandler).Assembly); + services.AddMediatR(cfg => cfg.RegisterServicesFromAssemblyContaining()); // EasyCaching 缓存 services.AddEasyCachingSetup(); diff --git a/IRaCIS.Core.API/_ServiceExtensions/Swagger/SwaggerSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/Swagger/SwaggerSetup.cs index 35978b51e..a5c53cd7f 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/Swagger/SwaggerSetup.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/Swagger/SwaggerSetup.cs @@ -18,7 +18,6 @@ namespace IRaCIS.Core.API { public static void AddSwaggerSetup(this IServiceCollection services) { - services.AddSwaggerExamplesFromAssemblyOf(); services.AddSwaggerGen(options => { diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj index bf608d946..929eca75b 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj @@ -65,45 +65,40 @@ - + - + - - true - - - - + + + + + - - + + true - + true - - - - - - true - - - - + + + + + + true - - - - - - + + + + + + diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 81d47f5b6..0e30712ac 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -9509,11 +9509,6 @@ TrialSiteUserSurveyAddOrEdit 鍒楄〃鏌ヨ鍙傛暟妯″瀷 - - - 瀹炴祴 鏍囨敞鍦ㄦ湇鍔℃柟娉曚笂 娌$敤 - - TrialSiteEquipmentSurveyService diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/DicomArchiveService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/DicomArchiveService.cs index f797c8ca4..5b1115177 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/DicomArchiveService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/DicomArchiveService.cs @@ -1,5 +1,4 @@ -锘縰sing Dicom; -using Dicom.Imaging.Codec; +锘 using EasyCaching.Core; using IRaCIS.Core.Application.Contracts.Dicom; using IRaCIS.Core.Domain.Share; @@ -8,6 +7,8 @@ using IRaCIS.Core.Application.Contracts; using IRaCIS.Core.Application.Helper; using Microsoft.AspNetCore.Hosting; using IRaCIS.Core.Infrastructure; +using FellowOakDicom; +using FellowOakDicom.Imaging.Codec; namespace IRaCIS.Core.Application.Services { diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/Interface/JsonPatchUserRequestExample.cs b/IRaCIS.Core.Application/Service/SiteSurvey/Interface/JsonPatchUserRequestExample.cs deleted file mode 100644 index 0fa6ff834..000000000 --- a/IRaCIS.Core.Application/Service/SiteSurvey/Interface/JsonPatchUserRequestExample.cs +++ /dev/null @@ -1,51 +0,0 @@ -锘縰sing Microsoft.AspNetCore.JsonPatch.Operations; -using Swashbuckle.AspNetCore.Filters; - -namespace IRaCIS.Core.Application.Contracts -{ - /// - /// 瀹炴祴 鏍囨敞鍦ㄦ湇鍔℃柟娉曚笂 娌$敤 - /// - public class JsonPatchUserRequestExample : IExamplesProvider - { - public Operation[] GetExamples() - { - return new[] - { - new Operation - { - op = "replace", - path = "/name", - value = "Gordon" - }, - new Operation - { - op = "replace", - path = "/surname", - value = "Freeman" - } - }; - } - - object IExamplesProvider.GetExamples() - { - return new[] - { - new Operation - { - op = "replace", - path = "/name", - value = "Gordon" - }, - new Operation - { - op = "replace", - path = "/surname", - value = "Freeman" - } - }; - } - } - - -} diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs index 0984a186b..29bcead40 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs @@ -20,7 +20,6 @@ using Microsoft.VisualBasic; using DocumentFormat.OpenXml.Spreadsheet; using IRaCIS.Core.Domain.Models; using IRaCIS.Core.Application.ViewModel; -using Dicom; namespace IRaCIS.Core.Application.Contracts { diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig.cs index 7d61be101..c8fde011f 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/_MapConfig.cs @@ -107,7 +107,6 @@ namespace IRaCIS.Core.Application.Service .ForMember(d => d.TrialId, u => u.MapFrom(s => trialId)) .ForMember(d => d.IsSelect, u => u.MapFrom(t => t.UserTrials.Any(t => t.TrialId == trialId))); - var isEn_Us = false; CreateMap() .ForMember(d => d.HospitalName, u => u.MapFrom(s => s.Hospital.HospitalName)); diff --git a/IRaCIS.Core.Domain/Allocation/TaskMedicalReview.cs b/IRaCIS.Core.Domain/Allocation/TaskMedicalReview.cs index 7c77ea807..901e4c984 100644 --- a/IRaCIS.Core.Domain/Allocation/TaskMedicalReview.cs +++ b/IRaCIS.Core.Domain/Allocation/TaskMedicalReview.cs @@ -178,7 +178,7 @@ namespace IRaCIS.Core.Domain.Models /// 鏂囦欢 /// [NotMapped] - public List FileList + public List FileList { get { @@ -186,13 +186,13 @@ namespace IRaCIS.Core.Domain.Models try { - var result= JsonConvert.DeserializeObject>(this.ImagePath); - return result==null?new List() : result; + var result= JsonConvert.DeserializeObject>(this.ImagePath); + return result==null?new List() : result; } catch (Exception) { - return new List(); + return new List(); } } @@ -210,7 +210,7 @@ namespace IRaCIS.Core.Domain.Models #region 鏂囦欢瀵硅薄 - public class ImageInfo + public class OSSImageInfo { public string FileName { get; set; } diff --git a/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj b/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj index 1397d105f..41daad173 100644 --- a/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj +++ b/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj @@ -9,10 +9,10 @@ - - - - + + + + diff --git a/IRaCIS.Core.Domain/Reading/MedicalAudit/ReadingMedicalReviewDialog.cs b/IRaCIS.Core.Domain/Reading/MedicalAudit/ReadingMedicalReviewDialog.cs index c3f46259f..e00db79c7 100644 --- a/IRaCIS.Core.Domain/Reading/MedicalAudit/ReadingMedicalReviewDialog.cs +++ b/IRaCIS.Core.Domain/Reading/MedicalAudit/ReadingMedicalReviewDialog.cs @@ -113,7 +113,7 @@ namespace IRaCIS.Core.Domain.Models /// 鏂囦欢 /// [NotMapped] - public List FileList + public List FileList { get { @@ -121,13 +121,13 @@ namespace IRaCIS.Core.Domain.Models try { - var result = JsonConvert.DeserializeObject>(this.ImagePath); - return result == null ? new List() : result; + var result = JsonConvert.DeserializeObject>(this.ImagePath); + return result == null ? new List() : result; } catch (Exception) { - return new List(); + return new List(); } } diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs index d50f72cc5..f272fcf77 100644 --- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs +++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs @@ -122,7 +122,7 @@ namespace IRaCIS.Core.Infra.EFCore modelBuilder.Entity().HasMany(t => t.ChildList).WithOne(t => t.Parent); - modelBuilder.Entity().HasMany(t => t.EarlierSubjectUserList).WithOne(t => t.OrignalSubjectUser); + //if (_userInfo.IsEn_Us) //{ // modelBuilder.Entity().Property(t => t.MappedValue).HasColumnName(nameof(Domain.Models.Dictionary.Value)); diff --git a/IRaCIS.Core.Infra.EFCore/EntityConfigration/StudyConfigration.cs b/IRaCIS.Core.Infra.EFCore/EntityConfigration/StudyConfigration.cs index 7caa43966..de9adcb08 100644 --- a/IRaCIS.Core.Infra.EFCore/EntityConfigration/StudyConfigration.cs +++ b/IRaCIS.Core.Infra.EFCore/EntityConfigration/StudyConfigration.cs @@ -36,8 +36,7 @@ namespace IRaCIS.Core.Infra.EFCore.EntityConfigration public void Configure(EntityTypeBuilder builder) { - builder.Property(e => e.MappedValue).Metadata.SetBeforeSaveBehavior(PropertySaveBehavior.Ignore); - builder.Property(e => e.MappedValue).Metadata.SetAfterSaveBehavior(PropertySaveBehavior.Ignore); + } } diff --git a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj index 4baefc5d5..30c574f0d 100644 --- a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj +++ b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj @@ -17,15 +17,14 @@ - - - + + - - - - + + + + diff --git a/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj b/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj index 16b11378d..899f95036 100644 --- a/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj +++ b/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj @@ -13,10 +13,10 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive From f1b3ec7d7c7300fdcc40db905000640909eff76e Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 12 Oct 2023 14:20:03 +0800 Subject: [PATCH 09/34] =?UTF-8?q?=E6=9B=B4=E6=96=B0nuget?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IRaCIS.Core.Application.csproj | 16 ++++++++-------- .../Reading/Dto/ReadingMedicalReviewDto.cs | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj index 076870710..9773ae528 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj @@ -69,13 +69,13 @@ - + - + @@ -97,12 +97,12 @@ true - - - - - - + + + + + + diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingMedicalReviewDto.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingMedicalReviewDto.cs index f9f6b0f38..9a730f4b6 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingMedicalReviewDto.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingMedicalReviewDto.cs @@ -266,7 +266,7 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto public string ImagePath { get; set; } = string.Empty; - public List FileList { get; set; } = new List(); + public List FileList { get; set; } = new List(); } @@ -314,7 +314,7 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto - public List FileList { get; set; } = new List(); + public List FileList { get; set; } = new List(); @@ -455,7 +455,7 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto public Guid TaskMedicalReviewId { get; set; } - public List FileList { get; set; } = new List(); + public List FileList { get; set; } = new List(); /// @@ -502,7 +502,7 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto public string Questioning { get; set; } = string.Empty; - public List FileList { get; set; } = new List(); + public List FileList { get; set; } = new List(); /// /// 瀹℃牳寤鸿 From edefc8f3e7d4a044346f9eb37f81e1d5cf754294 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 12 Oct 2023 15:16:52 +0800 Subject: [PATCH 10/34] =?UTF-8?q?=E4=BF=AE=E6=94=B9nuget?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/IRaCIS.Core.API.csproj | 3 --- 1 file changed, 3 deletions(-) diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.csproj b/IRaCIS.Core.API/IRaCIS.Core.API.csproj index 988372377..9293b7ab7 100644 --- a/IRaCIS.Core.API/IRaCIS.Core.API.csproj +++ b/IRaCIS.Core.API/IRaCIS.Core.API.csproj @@ -69,13 +69,10 @@ - - - From 270de8665811598a3651d6c9ad6ac03fd8123d7a Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 12 Oct 2023 17:28:34 +0800 Subject: [PATCH 11/34] =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Infra.EFCore/Repository/IRaCISContextExtension.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IRaCIS.Core.Infra.EFCore/Repository/IRaCISContextExtension.cs b/IRaCIS.Core.Infra.EFCore/Repository/IRaCISContextExtension.cs index 5428578f6..547a5119b 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/IRaCISContextExtension.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/IRaCISContextExtension.cs @@ -157,7 +157,7 @@ namespace IRaCIS.Core.Infra.EFCore { if (deleteFilter == null) throw new ArgumentNullException(nameof(deleteFilter)); - return await _dbContext.Set().IgnoreQueryFilters().Where(deleteFilter).BatchDeleteAsync() > 0; + return await _dbContext.Set().IgnoreQueryFilters().Where(deleteFilter).ExecuteDeleteAsync() > 0; } From 79d150829a3bcd221c41d822d92284da71e4d4c9 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Fri, 13 Oct 2023 11:18:26 +0800 Subject: [PATCH 12/34] =?UTF-8?q?EntityFrameworkCore.Projectables=20=20?= =?UTF-8?q?=E5=8C=85=E9=97=AE=E9=A2=98=20=E5=AF=BC=E8=87=B4=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=87=BA=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs | 2 +- IRaCIS.Core.Application/TestService.cs | 3 +++ IRaCIS.Core.Domain/Allocation/VisitTask.cs | 3 +-- IRaCIS.Core.Domain/Common/Dictionary.cs | 4 ---- IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj | 7 ------- IRaCIS.Core.Domain/Management/User.cs | 4 ++-- .../IRaCIS.Core.Infrastructure.csproj | 6 +++++- 7 files changed, 12 insertions(+), 17 deletions(-) diff --git a/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs index 6c679d676..7330c7493 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs @@ -27,7 +27,7 @@ namespace IRaCIS.Core.API options.AddInterceptors(new QueryWithNoLockDbCommandInterceptor()); - options.UseProjectables(); + //options.UseProjectables(); //options.AddInterceptors(new AuditingInterceptor(configuration.GetSection("ConnectionStrings:RemoteNew").Value)); diff --git a/IRaCIS.Core.Application/TestService.cs b/IRaCIS.Core.Application/TestService.cs index 5e0bf334f..6de525061 100644 --- a/IRaCIS.Core.Application/TestService.cs +++ b/IRaCIS.Core.Application/TestService.cs @@ -63,6 +63,9 @@ namespace IRaCIS.Application.Services [AllowAnonymous] public async Task TestDistributedLock( ) { + + _repository.Where().Select(t => t.FullName).FirstOrDefault(); + Console.WriteLine($"鎴戣繘鏉ヤ簡褰撳墠鍊兼槸锛" + IntValue); _logger.LogWarning($"鎴戣繘鏉ヤ簡褰撳墠鍊兼槸锛" + IntValue); diff --git a/IRaCIS.Core.Domain/Allocation/VisitTask.cs b/IRaCIS.Core.Domain/Allocation/VisitTask.cs index 263ac8f46..4fa044f69 100644 --- a/IRaCIS.Core.Domain/Allocation/VisitTask.cs +++ b/IRaCIS.Core.Domain/Allocation/VisitTask.cs @@ -9,7 +9,6 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Collections.Generic; using System.Linq; -using EntityFrameworkCore.Projectables; namespace IRaCIS.Core.Domain.Models { @@ -324,7 +323,7 @@ namespace IRaCIS.Core.Domain.Models public Guid? BeforeConvertedTaskId { get; set; } - [Projectable] + [NotMapped] [JsonIgnore] public bool IsConvertedTask => BeforeConvertedTaskId != null || IsHistoryConvertedTask || Subject.SubjectVisitTaskList.Where(t => t.TrialReadingCriterionId == TrialReadingCriterionId && t.DoctorUserId == DoctorUserId && t.BeforeConvertedTaskId != null diff --git a/IRaCIS.Core.Domain/Common/Dictionary.cs b/IRaCIS.Core.Domain/Common/Dictionary.cs index 34e5327b7..c0b4d6b07 100644 --- a/IRaCIS.Core.Domain/Common/Dictionary.cs +++ b/IRaCIS.Core.Domain/Common/Dictionary.cs @@ -1,4 +1,3 @@ -using EntityFrameworkCore.Projectables; using IRaCIS.Core.Domain.Share; using System; using System.Collections.Generic; @@ -57,9 +56,6 @@ namespace IRaCIS.Core.Domain.Models - [Projectable] - public string TranslateValue( string value, string valueCN,bool isCN) => isCN?valueCN:value; - } } diff --git a/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj b/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj index 41daad173..9213bafcd 100644 --- a/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj +++ b/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj @@ -8,13 +8,6 @@ ..\bin - - - - - - - diff --git a/IRaCIS.Core.Domain/Management/User.cs b/IRaCIS.Core.Domain/Management/User.cs index 07a572a50..3c50f6ee7 100644 --- a/IRaCIS.Core.Domain/Management/User.cs +++ b/IRaCIS.Core.Domain/Management/User.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using EntityFrameworkCore.Projectables; using IRaCIS.Core.Domain.Share; namespace IRaCIS.Core.Domain.Models @@ -87,7 +86,8 @@ namespace IRaCIS.Core.Domain.Models /// public bool AutoCutNextTask { get; set; } = false; - [Projectable] public string FullName => LastName + " / " + FirstName; + [NotMapped] + public string FullName => LastName + " / " + FirstName; //[Projectable] public string FullName => $"{LastName} / {FirstName}"; } diff --git a/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj b/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj index 9976f5251..66854efcc 100644 --- a/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj +++ b/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj @@ -11,7 +11,11 @@ - + + + + + From 290578d8243a3d13e32f3d9c17debf9bbbab5275 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Fri, 13 Oct 2023 11:34:55 +0800 Subject: [PATCH 13/34] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=B2=A1=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Management/UserService.cs | 1 - .../IRaCIS.Core.Domain.Share.csproj | 4 + IRaCIS.Core.Infrastructure/Cache/CacheType.cs | 18 --- IRaCIS.Core.Infrastructure/Cache/ICache.cs | 107 --------------- .../Cache/MemoryCache.cs | 127 ------------------ .../Cache/RedisCache.cs | 88 ------------ .../IRaCIS.Core.Infrastructure.csproj | 2 +- 7 files changed, 5 insertions(+), 342 deletions(-) delete mode 100644 IRaCIS.Core.Infrastructure/Cache/CacheType.cs delete mode 100644 IRaCIS.Core.Infrastructure/Cache/ICache.cs delete mode 100644 IRaCIS.Core.Infrastructure/Cache/MemoryCache.cs delete mode 100644 IRaCIS.Core.Infrastructure/Cache/RedisCache.cs diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index b36859015..3a6af0f62 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -8,7 +8,6 @@ using Panda.DynamicWebApi.Attributes; using Microsoft.AspNetCore.Authorization; using Microsoft.Extensions.Options; using Microsoft.Extensions.Caching.Memory; -using IRaCIS.Core.Infra.Common.Cache; using Microsoft.Identity.Client; using static IRaCIS.Core.Domain.Share.StaticData; using IRaCIS.Core.Application.ViewModel; diff --git a/IRaCIS.Core.Domain.Share/IRaCIS.Core.Domain.Share.csproj b/IRaCIS.Core.Domain.Share/IRaCIS.Core.Domain.Share.csproj index 85a1db3cc..bbcde76bb 100644 --- a/IRaCIS.Core.Domain.Share/IRaCIS.Core.Domain.Share.csproj +++ b/IRaCIS.Core.Domain.Share/IRaCIS.Core.Domain.Share.csproj @@ -10,6 +10,10 @@ + + + + diff --git a/IRaCIS.Core.Infrastructure/Cache/CacheType.cs b/IRaCIS.Core.Infrastructure/Cache/CacheType.cs deleted file mode 100644 index 5f64f0cc8..000000000 --- a/IRaCIS.Core.Infrastructure/Cache/CacheType.cs +++ /dev/null @@ -1,18 +0,0 @@ -锘 -namespace IRaCIS.Core.Infra.Common.Cache -{ - /// - /// 缂撳瓨绫诲瀷 - /// - public enum CacheType - { - /// - /// 鍐呭瓨缂撳瓨 - /// - Memory, - /// - /// Redis缂撳瓨 - /// - Redis - } -} diff --git a/IRaCIS.Core.Infrastructure/Cache/ICache.cs b/IRaCIS.Core.Infrastructure/Cache/ICache.cs deleted file mode 100644 index defd2dd98..000000000 --- a/IRaCIS.Core.Infrastructure/Cache/ICache.cs +++ /dev/null @@ -1,107 +0,0 @@ -锘縰sing System; -using System.Threading.Tasks; - -namespace IRaCIS.Core.Infra.Common.Cache -{ - /// - /// 缂撳瓨鎺ュ彛 - /// - public interface ICache - { - /// - /// 鐢ㄤ簬鍦 key 瀛樺湪鏃跺垹闄 key - /// - /// 閿 - long Del(params string[] key); - - /// - /// 鐢ㄤ簬鍦 key 瀛樺湪鏃跺垹闄 key - /// - /// 閿 - /// - Task DelAsync(params string[] key); - - /// - /// 鐢ㄤ簬鍦 key 妯℃澘瀛樺湪鏃跺垹闄 - /// - /// key妯℃澘 - /// - Task DelByPatternAsync(string pattern); - - /// - /// 妫鏌ョ粰瀹 key 鏄惁瀛樺湪 - /// - /// 閿 - /// - bool Exists(string key); - - /// - /// 妫鏌ョ粰瀹 key 鏄惁瀛樺湪 - /// - /// 閿 - /// - Task ExistsAsync(string key); - - /// - /// 鑾峰彇鎸囧畾 key 鐨勫 - /// - /// 閿 - /// - string Get(string key); - - /// - /// 鑾峰彇鎸囧畾 key 鐨勫 - /// - /// byte[] 鎴栧叾浠栫被鍨 - /// 閿 - /// - T Get(string key); - - /// - /// 鑾峰彇鎸囧畾 key 鐨勫 - /// - /// 閿 - /// - Task GetAsync(string key); - - /// - /// 鑾峰彇鎸囧畾 key 鐨勫 - /// - /// byte[] 鎴栧叾浠栫被鍨 - /// 閿 - /// - Task GetAsync(string key); - - /// - /// 璁剧疆鎸囧畾 key 鐨勫硷紝鎵鏈夊啓鍏ュ弬鏁皁bject閮芥敮鎸乻tring | byte[] | 鏁板 | 瀵硅薄 - /// - /// 閿 - /// 鍊 - bool Set(string key, object value); - - /// - /// 璁剧疆鎸囧畾 key 鐨勫硷紝鎵鏈夊啓鍏ュ弬鏁皁bject閮芥敮鎸乻tring | byte[] | 鏁板 | 瀵硅薄 - /// - /// 閿 - /// 鍊 - /// 鏈夋晥鏈 - bool Set(string key, object value, TimeSpan expire); - - /// - /// 璁剧疆鎸囧畾 key 鐨勫硷紝鎵鏈夊啓鍏ュ弬鏁皁bject閮芥敮鎸乻tring | byte[] | 鏁板 | 瀵硅薄 - /// - /// 閿 - /// 鍊 - /// - Task SetAsync(string key, object value); - - /// - /// 璁剧疆鎸囧畾 key 鐨勫硷紝鎵鏈夊啓鍏ュ弬鏁皁bject閮芥敮鎸乻tring | byte[] | 鏁板 | 瀵硅薄 - /// - /// 閿 - /// 鍊 - /// 鏈夋晥鏈 - /// - Task SetAsync(string key, object value, TimeSpan expire); - } -} diff --git a/IRaCIS.Core.Infrastructure/Cache/MemoryCache.cs b/IRaCIS.Core.Infrastructure/Cache/MemoryCache.cs deleted file mode 100644 index 16ffd5760..000000000 --- a/IRaCIS.Core.Infrastructure/Cache/MemoryCache.cs +++ /dev/null @@ -1,127 +0,0 @@ -锘縰sing System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using Microsoft.Extensions.Caching.Memory; - -namespace IRaCIS.Core.Infra.Common.Cache -{ - /// - /// 鍐呭瓨缂撳瓨 - /// - public class MemoryCache : ICache - { - private readonly IMemoryCache _memoryCache; - public MemoryCache(IMemoryCache memoryCache) - { - _memoryCache = memoryCache; - } - - public long Del(params string[] key) - { - foreach(var k in key) - { - _memoryCache.Remove(k); - } - return key.Length; - } - - public Task DelAsync(params string[] key) - { - foreach (var k in key) - { - _memoryCache.Remove(k); - } - - return Task.FromResult((long)key.Length); - } - - public async Task DelByPatternAsync(string pattern) - { - if (string.IsNullOrEmpty(pattern)) - return default; - - pattern = Regex.Replace(pattern, @"\{.*\}", "(.*)"); - - var keys = GetAllKeys().Where(k => Regex.IsMatch(k, pattern)); - - if(keys != null && keys.Count() > 0) - { - return await DelAsync(keys.ToArray()); - } - - return default; - } - - public bool Exists(string key) - { - return _memoryCache.TryGetValue(key, out _); - } - - public Task ExistsAsync(string key) - { - return Task.FromResult(_memoryCache.TryGetValue(key, out _)); - } - - public string Get(string key) - { - return _memoryCache.Get(key)?.ToString(); - } - - public T Get(string key) - { - return _memoryCache.Get(key); - } - - public Task GetAsync(string key) - { - return Task.FromResult(Get(key)); - } - - public Task GetAsync(string key) - { - return Task.FromResult(Get(key)); - } - - public bool Set(string key, object value) - { - _memoryCache.Set(key, value); - return true; - } - - public bool Set(string key, object value, TimeSpan expire) - { - _memoryCache.Set(key, value, expire); - return true; - } - - public Task SetAsync(string key, object value) - { - Set(key, value); - return Task.FromResult(true); - } - - public Task SetAsync(string key, object value, TimeSpan expire) - { - Set(key, value, expire); - return Task.FromResult(true); - } - - private List GetAllKeys() - { - const BindingFlags flags = BindingFlags.Instance | BindingFlags.NonPublic; - var entries = _memoryCache.GetType().GetField("_entries", flags).GetValue(_memoryCache); - var cacheItems = entries as IDictionary; - var keys = new List(); - if (cacheItems == null) return keys; - foreach (DictionaryEntry cacheItem in cacheItems) - { - keys.Add(cacheItem.Key.ToString()); - } - return keys; - } - } -} diff --git a/IRaCIS.Core.Infrastructure/Cache/RedisCache.cs b/IRaCIS.Core.Infrastructure/Cache/RedisCache.cs deleted file mode 100644 index 1c540178f..000000000 --- a/IRaCIS.Core.Infrastructure/Cache/RedisCache.cs +++ /dev/null @@ -1,88 +0,0 @@ -锘縰sing System; -using System.Text.RegularExpressions; -using System.Threading.Tasks; - -namespace IRaCIS.Core.Infra.Common.Cache -{ - /// - /// Redis缂撳瓨 - /// - public class RedisCache : ICache - { - public long Del(params string[] key) - { - return RedisHelper.Del(key); - } - - public Task DelAsync(params string[] key) - { - return RedisHelper.DelAsync(key); - } - - public async Task DelByPatternAsync(string pattern) - { - if (string.IsNullOrEmpty(pattern)) - return default; - - pattern = Regex.Replace(pattern, @"\{.*\}", "*"); - - var keys = (await RedisHelper.KeysAsync(pattern)); - if(keys != null && keys.Length > 0) - { - return await RedisHelper.DelAsync(keys); - } - - return default; - } - - public bool Exists(string key) - { - return RedisHelper.Exists(key); - } - - public Task ExistsAsync(string key) - { - return RedisHelper.ExistsAsync(key); - } - - public string Get(string key) - { - return RedisHelper.Get(key); - } - - public T Get(string key) - { - return RedisHelper.Get(key); - } - - public Task GetAsync(string key) - { - return RedisHelper.GetAsync(key); - } - - public Task GetAsync(string key) - { - return RedisHelper.GetAsync(key); - } - - public bool Set(string key, object value) - { - return RedisHelper.Set(key, value); - } - - public bool Set(string key, object value, TimeSpan expire) - { - return RedisHelper.Set(key, value, expire); - } - - public Task SetAsync(string key, object value) - { - return RedisHelper.SetAsync(key, value); - } - - public Task SetAsync(string key, object value, TimeSpan expire) - { - return RedisHelper.SetAsync(key, value, expire); - } - } -} diff --git a/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj b/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj index 66854efcc..714d8b400 100644 --- a/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj +++ b/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj @@ -10,12 +10,12 @@ - + From 75ed6375c259da677e8f9d386714ac94ab0cda2c Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Fri, 13 Oct 2023 11:53:52 +0800 Subject: [PATCH 14/34] =?UTF-8?q?=E4=BF=AE=E6=94=B9nuget=E5=8C=85=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IRaCIS.Core.Domain.Share.csproj | 11 ++++------- IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj | 6 +++++- .../IRaCIS.Core.Infra.EFCore.csproj | 5 +++-- .../IRaCIS.Core.Infrastructure.csproj | 7 ++----- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/IRaCIS.Core.Domain.Share/IRaCIS.Core.Domain.Share.csproj b/IRaCIS.Core.Domain.Share/IRaCIS.Core.Domain.Share.csproj index bbcde76bb..2bcd3bb69 100644 --- a/IRaCIS.Core.Domain.Share/IRaCIS.Core.Domain.Share.csproj +++ b/IRaCIS.Core.Domain.Share/IRaCIS.Core.Domain.Share.csproj @@ -8,12 +8,9 @@ ..\bin - - - - - - - + + + + diff --git a/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj b/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj index 9213bafcd..3bf41a0f1 100644 --- a/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj +++ b/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj @@ -12,7 +12,11 @@ - + + + + + diff --git a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj index 30c574f0d..5cad3e7b0 100644 --- a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj +++ b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj @@ -17,13 +17,14 @@ - + + + - diff --git a/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj b/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj index 714d8b400..8007ae0ee 100644 --- a/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj +++ b/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj @@ -10,15 +10,12 @@ - - - - - + + From 7c6dcbbe38b960cfe84a714174c6ae55b90b1fb8 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Fri, 13 Oct 2023 18:02:33 +0800 Subject: [PATCH 15/34] =?UTF-8?q?=E5=9B=9E=E9=80=80=E5=8C=85=EF=BC=8C?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E4=B8=B4=E6=97=B6=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IRaCIS.Core.Application.csproj | 34 +++++++-------- .../Service/Document/TrialDocumentService.cs | 34 ++++++++++++--- .../IRaCIS.Core.Infra.EFCore.csproj | 18 ++++---- .../Repository/IRaCISContextExtension.cs | 2 +- .../IRaCIS.Core.Infrastructure.csproj | 2 +- .../_IRaCIS/IQueryablePageListExtensions.cs | 39 +++++++++++++++++ IRaCIS.Core.Test/IRaCIS.Core.Test.csproj | 1 - IRaCIS.Core.Test/Test/Audit/AuditContext.cs | 43 ------------------- 8 files changed, 94 insertions(+), 79 deletions(-) delete mode 100644 IRaCIS.Core.Test/Test/Audit/AuditContext.cs diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj index 9773ae528..b9927d32f 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj @@ -15,14 +15,14 @@ - 1701;1702;1591;1587 + 1701;1702;1591;1587 - + @@ -50,16 +50,16 @@ - - PreserveNewest - true - PreserveNewest - - - Always - true - PreserveNewest - + + PreserveNewest + true + PreserveNewest + + + Always + true + PreserveNewest + @@ -76,16 +76,14 @@ - - - + - true + true - true + true @@ -94,7 +92,7 @@ - true + true diff --git a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs index 5ba66e44d..e1d7999e2 100644 --- a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs +++ b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs @@ -203,13 +203,35 @@ namespace IRaCIS.Core.Application.Services }; - var unionQuery = systemDocumentQueryable.Union(trialDocQueryable) - .WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name)) - .WhereIf(querySystemDocument.FileTypeId != null, t => t.FileTypeId == querySystemDocument.FileTypeId) - .WhereIf(querySystemDocument.IsSign == true, t => t.ConfirmTime != null) - .WhereIf(querySystemDocument.IsSign == false, t => t.ConfirmTime == null); + #region 鎶ラ敊 濂囨殑bug + //var unionQuery = systemDocumentQueryable.Union(trialDocQueryable) + // .WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name)) + // .WhereIf(querySystemDocument.FileTypeId != null, t => t.FileTypeId == querySystemDocument.FileTypeId) + // .WhereIf(querySystemDocument.IsSign == true, t => t.ConfirmTime != null) + // .WhereIf(querySystemDocument.IsSign == false, t => t.ConfirmTime == null); - var result = await unionQuery.ToPagedListAsync(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc); + //var result = await unionQuery.ToPagedListAsync(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc); + #endregion + + #region 涓存椂鏂规 + + var list1 = systemDocumentQueryable + .WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name)) + .WhereIf(querySystemDocument.FileTypeId != null, t => t.FileTypeId == querySystemDocument.FileTypeId) + .WhereIf(querySystemDocument.IsSign == true, t => t.ConfirmTime != null) + .WhereIf(querySystemDocument.IsSign == false, t => t.ConfirmTime == null).ToList(); + + var list2 = trialDocQueryable + .WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name)) + .WhereIf(querySystemDocument.FileTypeId != null, t => t.FileTypeId == querySystemDocument.FileTypeId) + .WhereIf(querySystemDocument.IsSign == true, t => t.ConfirmTime != null) + .WhereIf(querySystemDocument.IsSign == false, t => t.ConfirmTime == null).ToList(); + + var list3 = list1.Union(list2).ToList(); + + var result = list3.ToPagedList(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc); + + #endregion var needSignTrialDocCount = await _trialDocumentRepository.AsQueryable(true).Where(t => t.TrialId== querySystemDocument.TrialId && t.Trial.TrialStatusStr != StaticData.TrialState.TrialStopped) .Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.Id)) diff --git a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj index 5cad3e7b0..d848f33c0 100644 --- a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj +++ b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj @@ -17,15 +17,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/IRaCIS.Core.Infra.EFCore/Repository/IRaCISContextExtension.cs b/IRaCIS.Core.Infra.EFCore/Repository/IRaCISContextExtension.cs index 547a5119b..5428578f6 100644 --- a/IRaCIS.Core.Infra.EFCore/Repository/IRaCISContextExtension.cs +++ b/IRaCIS.Core.Infra.EFCore/Repository/IRaCISContextExtension.cs @@ -157,7 +157,7 @@ namespace IRaCIS.Core.Infra.EFCore { if (deleteFilter == null) throw new ArgumentNullException(nameof(deleteFilter)); - return await _dbContext.Set().IgnoreQueryFilters().Where(deleteFilter).ExecuteDeleteAsync() > 0; + return await _dbContext.Set().IgnoreQueryFilters().Where(deleteFilter).BatchDeleteAsync() > 0; } diff --git a/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj b/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj index 8007ae0ee..533a51994 100644 --- a/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj +++ b/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj @@ -11,7 +11,7 @@ - + diff --git a/IRaCIS.Core.Infrastructure/_IRaCIS/IQueryablePageListExtensions.cs b/IRaCIS.Core.Infrastructure/_IRaCIS/IQueryablePageListExtensions.cs index bb102cd7d..2fa3db58a 100644 --- a/IRaCIS.Core.Infrastructure/_IRaCIS/IQueryablePageListExtensions.cs +++ b/IRaCIS.Core.Infrastructure/_IRaCIS/IQueryablePageListExtensions.cs @@ -3,11 +3,50 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; using System.Linq.Dynamic.Core; +using System.Collections.Generic; namespace IRaCIS.Core.Infrastructure.Extention { public static class QueryablePageListExtensions { + //鍐呭瓨鎺掑簭 鍚庢湡鍒犻櫎 + public static PageOutput ToPagedList(this IList source, int pageIndex, int pageSize, string defaultSortFiled = "Id", bool isAsc = true) + { + if (pageIndex <= 0) + { + pageIndex = 1; + } + if (pageSize <= 0) + { + pageSize = 10; + } + var count = source.Count(); + + if (count == 0) + { + return new PageOutput() { CurrentPageData = new List() }; + } + + var propName = string.IsNullOrWhiteSpace(defaultSortFiled) ? "Id" : defaultSortFiled; + + IQueryable sourceQuery = isAsc ? source.AsQueryable().OrderBy(propName) : source.AsQueryable().OrderBy(propName + " desc"); + + sourceQuery = sourceQuery.Skip((pageIndex - 1) * pageSize); + + var items = sourceQuery + .Take(pageSize) + .ToArray(); + + var pagedList = new PageOutput() + { + PageIndex = pageIndex, + PageSize = pageSize, + TotalCount = count, + CurrentPageData = items + }; + + return pagedList; + } //鍗曞瓧娈垫帓搴 public static PageOutput ToPagedList(this IQueryable source, int pageIndex, int pageSize, string defaultSortFiled = "Id", bool isAsc = true) { diff --git a/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj b/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj index 899f95036..ef69f8834 100644 --- a/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj +++ b/IRaCIS.Core.Test/IRaCIS.Core.Test.csproj @@ -13,7 +13,6 @@ - diff --git a/IRaCIS.Core.Test/Test/Audit/AuditContext.cs b/IRaCIS.Core.Test/Test/Audit/AuditContext.cs deleted file mode 100644 index 2fc55e0ea..000000000 --- a/IRaCIS.Core.Test/Test/Audit/AuditContext.cs +++ /dev/null @@ -1,43 +0,0 @@ -锘縰sing System; -using System.Collections.Generic; -using Microsoft.EntityFrameworkCore; - -#region AuditContext -public class AuditContext : DbContext -{ - private readonly string _connectionString; - - public AuditContext(string connectionString) - { - _connectionString = connectionString; - } - - //protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - // => optionsBuilder.Usesq(_connectionString); - - public DbSet SaveChangesAudits { get; set; } -} - - -public class SaveChangesAudit -{ - public int Id { get; set; } - public Guid AuditId { get; set; } - public DateTime StartTime { get; set; } - public DateTime EndTime { get; set; } - public bool Succeeded { get; set; } - public string ErrorMessage { get; set; } - - public ICollection Entities { get; } = new List(); -} - -public class EntityAudit -{ - public int Id { get; set; } - public EntityState State { get; set; } - public string AuditMessage { get; set; } - - public SaveChangesAudit SaveChangesAudit { get; set; } -} - -#endregion \ No newline at end of file From 3962178c683075cd5e3e5af36c27faca12a9740a Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Fri, 13 Oct 2023 21:28:10 +0800 Subject: [PATCH 16/34] =?UTF-8?q?efcore=206=20=20=E5=8D=87=E7=BA=A7?= =?UTF-8?q?=E5=88=B06=E7=89=88=E6=9C=AC=E6=9C=80=E6=96=B0=EF=BC=8C?= =?UTF-8?q?=E5=90=8C=E6=97=B6EFCore.BulkExtensions=20=E4=B9=9F=E6=98=AF6?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E6=9C=80=E6=96=B0=EF=BC=8C=E4=BD=86=E6=98=AF?= =?UTF-8?q?projectable=20=E4=B8=8D=E8=83=BD=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/IRaCIS.Core.API.csproj | 2 +- IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs | 14 ++++---- .../IRaCIS.Core.Application.csproj | 2 +- .../Service/Document/TrialDocumentService.cs | 36 +++++++++---------- IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj | 2 ++ IRaCIS.Core.Domain/Management/User.cs | 3 +- .../IRaCIS.Core.Infra.EFCore.csproj | 4 +-- .../IRaCIS.Core.Infrastructure.csproj | 2 +- 8 files changed, 34 insertions(+), 31 deletions(-) diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.csproj b/IRaCIS.Core.API/IRaCIS.Core.API.csproj index 9293b7ab7..5d91f6a36 100644 --- a/IRaCIS.Core.API/IRaCIS.Core.API.csproj +++ b/IRaCIS.Core.API/IRaCIS.Core.API.csproj @@ -73,7 +73,7 @@ - + diff --git a/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs index 7330c7493..c11f34521 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs @@ -2,7 +2,7 @@ using IRaCIS.Core.Application.Triggers; using IRaCIS.Core.Infra.EFCore; using Medallion.Threading; -using Medallion.Threading.SqlServer; +//using Medallion.Threading.SqlServer; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -27,7 +27,7 @@ namespace IRaCIS.Core.API options.AddInterceptors(new QueryWithNoLockDbCommandInterceptor()); - //options.UseProjectables(); + options.UseProjectables(); //options.AddInterceptors(new AuditingInterceptor(configuration.GetSection("ConnectionStrings:RemoteNew").Value)); @@ -57,12 +57,12 @@ namespace IRaCIS.Core.API }); //娉ㄦ剰鍖哄垎 easy caching 涔熸湁 IDistributedLockProvider - services.AddSingleton(sp => - { - //var connection = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); + //services.AddSingleton(sp => + //{ + // //var connection = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); - return new SqlDistributedSynchronizationProvider(configuration.GetSection("ConnectionStrings:RemoteNew").Value); - }); + // return new SqlDistributedSynchronizationProvider(configuration.GetSection("ConnectionStrings:RemoteNew").Value); + //}); //services.AddAssemblyTriggers(typeof(SubjectVisitImageDateTrigger).Assembly); } diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj index b9927d32f..c2efc37bc 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj @@ -69,7 +69,7 @@ - + diff --git a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs index e1d7999e2..c4629983e 100644 --- a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs +++ b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs @@ -204,32 +204,32 @@ namespace IRaCIS.Core.Application.Services #region 鎶ラ敊 濂囨殑bug - //var unionQuery = systemDocumentQueryable.Union(trialDocQueryable) - // .WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name)) - // .WhereIf(querySystemDocument.FileTypeId != null, t => t.FileTypeId == querySystemDocument.FileTypeId) - // .WhereIf(querySystemDocument.IsSign == true, t => t.ConfirmTime != null) - // .WhereIf(querySystemDocument.IsSign == false, t => t.ConfirmTime == null); + var unionQuery = systemDocumentQueryable.Union(trialDocQueryable) + .WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name)) + .WhereIf(querySystemDocument.FileTypeId != null, t => t.FileTypeId == querySystemDocument.FileTypeId) + .WhereIf(querySystemDocument.IsSign == true, t => t.ConfirmTime != null) + .WhereIf(querySystemDocument.IsSign == false, t => t.ConfirmTime == null); - //var result = await unionQuery.ToPagedListAsync(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc); + var result = await unionQuery.ToPagedListAsync(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc); #endregion #region 涓存椂鏂规 - var list1 = systemDocumentQueryable - .WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name)) - .WhereIf(querySystemDocument.FileTypeId != null, t => t.FileTypeId == querySystemDocument.FileTypeId) - .WhereIf(querySystemDocument.IsSign == true, t => t.ConfirmTime != null) - .WhereIf(querySystemDocument.IsSign == false, t => t.ConfirmTime == null).ToList(); + //var list1 = systemDocumentQueryable + // .WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name)) + // .WhereIf(querySystemDocument.FileTypeId != null, t => t.FileTypeId == querySystemDocument.FileTypeId) + // .WhereIf(querySystemDocument.IsSign == true, t => t.ConfirmTime != null) + // .WhereIf(querySystemDocument.IsSign == false, t => t.ConfirmTime == null).ToList(); - var list2 = trialDocQueryable - .WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name)) - .WhereIf(querySystemDocument.FileTypeId != null, t => t.FileTypeId == querySystemDocument.FileTypeId) - .WhereIf(querySystemDocument.IsSign == true, t => t.ConfirmTime != null) - .WhereIf(querySystemDocument.IsSign == false, t => t.ConfirmTime == null).ToList(); + //var list2 = trialDocQueryable + // .WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name)) + //.WhereIf(querySystemDocument.FileTypeId != null, t => t.FileTypeId == querySystemDocument.FileTypeId) + //.WhereIf(querySystemDocument.IsSign == true, t => t.ConfirmTime != null) + //.WhereIf(querySystemDocument.IsSign == false, t => t.ConfirmTime == null).ToList(); - var list3 = list1.Union(list2).ToList(); + //var list3 = list1.Union(list2).ToList(); - var result = list3.ToPagedList(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc); + //var result = list3.ToPagedList(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc); #endregion diff --git a/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj b/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj index 3bf41a0f1..a37091132 100644 --- a/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj +++ b/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj @@ -13,6 +13,8 @@ + + diff --git a/IRaCIS.Core.Domain/Management/User.cs b/IRaCIS.Core.Domain/Management/User.cs index 3c50f6ee7..42bf5689b 100644 --- a/IRaCIS.Core.Domain/Management/User.cs +++ b/IRaCIS.Core.Domain/Management/User.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; +using EntityFrameworkCore.Projectables; using IRaCIS.Core.Domain.Share; namespace IRaCIS.Core.Domain.Models @@ -86,7 +87,7 @@ namespace IRaCIS.Core.Domain.Models /// public bool AutoCutNextTask { get; set; } = false; - [NotMapped] + [Projectable] public string FullName => LastName + " / " + FirstName; //[Projectable] public string FullName => $"{LastName} / {FirstName}"; diff --git a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj index d848f33c0..6ef22758e 100644 --- a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj +++ b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj @@ -17,10 +17,10 @@ - + - + diff --git a/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj b/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj index 533a51994..6c59e571c 100644 --- a/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj +++ b/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj @@ -11,7 +11,7 @@ - + From 17ebdce96ed7b46b8210c04068496a7831c3ea77 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Fri, 13 Oct 2023 22:17:11 +0800 Subject: [PATCH 17/34] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=BA=9F=E5=BC=83?= =?UTF-8?q?=E7=9A=84=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Application/IRaCIS.Core.Application.csproj | 1 - .../AuthUser/IUserInfo.cs | 0 .../AuthUser/UserInfo.cs | 0 .../IRaCIS.Core.Infra.EFCore.csproj | 10 +++++----- 4 files changed, 5 insertions(+), 6 deletions(-) rename {IRaCIS.Core.Domain.Share => IRaCIS.Core.Infra.EFCore}/AuthUser/IUserInfo.cs (100%) rename {IRaCIS.Core.Domain.Share => IRaCIS.Core.Infra.EFCore}/AuthUser/UserInfo.cs (100%) diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj index c2efc37bc..e7f2fad49 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj @@ -69,7 +69,6 @@ - diff --git a/IRaCIS.Core.Domain.Share/AuthUser/IUserInfo.cs b/IRaCIS.Core.Infra.EFCore/AuthUser/IUserInfo.cs similarity index 100% rename from IRaCIS.Core.Domain.Share/AuthUser/IUserInfo.cs rename to IRaCIS.Core.Infra.EFCore/AuthUser/IUserInfo.cs diff --git a/IRaCIS.Core.Domain.Share/AuthUser/UserInfo.cs b/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs similarity index 100% rename from IRaCIS.Core.Domain.Share/AuthUser/UserInfo.cs rename to IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs diff --git a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj index 6ef22758e..22ae45235 100644 --- a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj +++ b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj @@ -8,7 +8,9 @@ ..\bin - + + + @@ -18,11 +20,9 @@ - + - - - + From 77352245fce637968c0a8edefbbaa41973aadeb7 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Fri, 13 Oct 2023 22:38:28 +0800 Subject: [PATCH 18/34] =?UTF-8?q?=E6=B5=8B=E8=AF=95=20=E5=8D=87=E7=BA=A7nu?= =?UTF-8?q?get=E5=8C=85ok?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/IRaCIS.Core.API.csproj | 3 +-- IRaCIS.Core.Application/IRaCIS.Core.Application.csproj | 3 ++- IRaCIS.Core.Domain.Share/IRaCIS.Core.Domain.Share.csproj | 5 ----- IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj | 4 ++-- IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj | 2 +- 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.csproj b/IRaCIS.Core.API/IRaCIS.Core.API.csproj index 5d91f6a36..8419b93f5 100644 --- a/IRaCIS.Core.API/IRaCIS.Core.API.csproj +++ b/IRaCIS.Core.API/IRaCIS.Core.API.csproj @@ -73,13 +73,12 @@ - - + diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj index e7f2fad49..8d0730455 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj @@ -73,8 +73,9 @@ + - + diff --git a/IRaCIS.Core.Domain.Share/IRaCIS.Core.Domain.Share.csproj b/IRaCIS.Core.Domain.Share/IRaCIS.Core.Domain.Share.csproj index 2bcd3bb69..1c168175c 100644 --- a/IRaCIS.Core.Domain.Share/IRaCIS.Core.Domain.Share.csproj +++ b/IRaCIS.Core.Domain.Share/IRaCIS.Core.Domain.Share.csproj @@ -8,9 +8,4 @@ ..\bin - - - - - diff --git a/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj b/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj index a37091132..f8ab4c72b 100644 --- a/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj +++ b/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj @@ -16,8 +16,8 @@ - - + + diff --git a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj index 22ae45235..b58b2ac05 100644 --- a/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj +++ b/IRaCIS.Core.Infra.EFCore/IRaCIS.Core.Infra.EFCore.csproj @@ -19,7 +19,7 @@ - + From d66209452cd90d226f4405ed65df12e8aff0d297 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Fri, 13 Oct 2023 22:48:00 +0800 Subject: [PATCH 19/34] =?UTF-8?q?=E5=8D=87=E7=BA=A7EF=20core=207?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj b/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj index 6c59e571c..8007ae0ee 100644 --- a/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj +++ b/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj @@ -11,7 +11,7 @@ - + From 4c7ce217da4ab95af4bf799cc86220091b933bfc Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Fri, 13 Oct 2023 23:38:04 +0800 Subject: [PATCH 20/34] =?UTF-8?q?nuget=20=E5=8C=85=E7=A1=AE=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IRaCIS.Core.Application.csproj | 1 - IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj | 27 +++++++------- .../IRaCIS.Core.Infrastructure.csproj | 37 ++++++++++--------- 3 files changed, 32 insertions(+), 33 deletions(-) diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj index 8d0730455..7c5eedd25 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.csproj @@ -64,7 +64,6 @@ - diff --git a/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj b/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj index f8ab4c72b..1648985a9 100644 --- a/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj +++ b/IRaCIS.Core.Domain/IRaCIS.Core.Domain.csproj @@ -1,28 +1,27 @@ 锘 - - net6.0 - + + net6.0 + - - ..\bin - + + ..\bin + - - - + + + - - - - + + + - + diff --git a/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj b/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj index 8007ae0ee..db54dbbe4 100644 --- a/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj +++ b/IRaCIS.Core.Infrastructure/IRaCIS.Core.Infrastructure.csproj @@ -1,28 +1,29 @@ 锘 - - net6.0 - + + net6.0 + - - ..\bin - + + ..\bin + - - - - - - - - - + + + + + + + + + + - - - + + + From 69c2cd339c9cf1cfd875eb96f5ccc890a8c3ba81 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Mon, 16 Oct 2023 09:20:44 +0800 Subject: [PATCH 21/34] =?UTF-8?q?=E6=89=93=E5=BC=80=E5=88=86=E5=B8=83?= =?UTF-8?q?=E5=BC=8F=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs index c11f34521..705df609c 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs @@ -57,12 +57,12 @@ namespace IRaCIS.Core.API }); //娉ㄦ剰鍖哄垎 easy caching 涔熸湁 IDistributedLockProvider - //services.AddSingleton(sp => - //{ - // //var connection = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); + services.AddSingleton(sp => + { + //var connection = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); - // return new SqlDistributedSynchronizationProvider(configuration.GetSection("ConnectionStrings:RemoteNew").Value); - //}); + return new SqlDistributedSynchronizationProvider(configuration.GetSection("ConnectionStrings:RemoteNew").Value); + }); //services.AddAssemblyTriggers(typeof(SubjectVisitImageDateTrigger).Assembly); } From 8afcbf3d5e60f7039969444cd5a9db8520141a68 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Mon, 16 Oct 2023 09:20:44 +0800 Subject: [PATCH 22/34] =?UTF-8?q?=E6=89=93=E5=BC=80=E5=88=86=E5=B8=83?= =?UTF-8?q?=E5=BC=8F=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs index c11f34521..6c679d676 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/EFSetup.cs @@ -2,7 +2,7 @@ using IRaCIS.Core.Application.Triggers; using IRaCIS.Core.Infra.EFCore; using Medallion.Threading; -//using Medallion.Threading.SqlServer; +using Medallion.Threading.SqlServer; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -57,12 +57,12 @@ namespace IRaCIS.Core.API }); //娉ㄦ剰鍖哄垎 easy caching 涔熸湁 IDistributedLockProvider - //services.AddSingleton(sp => - //{ - // //var connection = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); + services.AddSingleton(sp => + { + //var connection = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!); - // return new SqlDistributedSynchronizationProvider(configuration.GetSection("ConnectionStrings:RemoteNew").Value); - //}); + return new SqlDistributedSynchronizationProvider(configuration.GetSection("ConnectionStrings:RemoteNew").Value); + }); //services.AddAssemblyTriggers(typeof(SubjectVisitImageDateTrigger).Assembly); } From bca8f2ddb915be38e6cf2cbc6e0e8fb159169219 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 18 Oct 2023 10:41:20 +0800 Subject: [PATCH 23/34] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E5=BC=82=E5=B8=B8=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs index f272fcf77..bf54cfa5a 100644 --- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs +++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs @@ -558,6 +558,12 @@ namespace IRaCIS.Core.Infra.EFCore throw new DBSaveFailedException("SQL 浜嬪姟澶辫触,璇锋鏌ョ幆澧冦"); } + catch (Exception ex) + { + _logger.LogError(ex.InnerException is null ? ex.Message : ex.InnerException?.Message); + + throw new DBSaveFailedException("鏁版嵁淇濆瓨寮傚父銆"); + } } From 34b12b89e4e5659920ee7035a22317e1d81f69f3 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Mon, 30 Oct 2023 14:43:36 +0800 Subject: [PATCH 24/34] =?UTF-8?q?=E8=AE=BF=E8=A7=86=E6=8B=B7=E8=B4=9D?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Allocation/VisitTaskService.cs | 108 ++++++++++++------ 1 file changed, 71 insertions(+), 37 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index 7eb28540c..84500ecfa 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -25,6 +25,7 @@ using Quartz; using IRaCIS.Application.Services.BackGroundJob; using Magicodes.ExporterAndImporter.Core.Extension; using Hangfire; +using MassTransit; namespace IRaCIS.Core.Application.Service.Allocation { @@ -1229,18 +1230,9 @@ namespace IRaCIS.Core.Application.Service.Allocation { if (origenalTask.ReadingCategory == ReadingCategory.Visit) { - var list = _readingTaskQuestionAnswerRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList(); - - foreach (var item in list) - { - item.Id = Guid.Empty; - item.VisitTaskId = newTask.Id; - } - - _ = _readingTaskQuestionAnswerRepository.AddRangeAsync(list).Result; + CopyForms(newTask, origenalTask); } - } //鎷疯礉鍚庣画琛ㄥ崟 @@ -1248,15 +1240,7 @@ namespace IRaCIS.Core.Application.Service.Allocation { if (origenalTask.ReadingCategory == ReadingCategory.Visit) { - var list = _readingTaskQuestionAnswerRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList(); - - foreach (var item in list) - { - item.Id = Guid.Empty; - item.VisitTaskId = newTask.Id; - } - - _ = _readingTaskQuestionAnswerRepository.AddRangeAsync(list).Result; + CopyForms(newTask, origenalTask); } } @@ -1352,15 +1336,7 @@ namespace IRaCIS.Core.Application.Service.Allocation { if (origenalTask.ReadingCategory == ReadingCategory.Visit) { - var list = _readingTaskQuestionAnswerRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList(); - - foreach (var item in list) - { - item.Id = Guid.Empty; - item.VisitTaskId = newTask.Id; - } - - _ = _readingTaskQuestionAnswerRepository.AddRangeAsync(list).Result; + CopyForms(newTask, origenalTask); } } @@ -1370,15 +1346,7 @@ namespace IRaCIS.Core.Application.Service.Allocation { if (origenalTask.ReadingCategory == ReadingCategory.Visit) { - var list = _readingTaskQuestionAnswerRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList(); - - foreach (var item in list) - { - item.Id = Guid.Empty; - item.VisitTaskId = newTask.Id; - } - - _ = _readingTaskQuestionAnswerRepository.AddRangeAsync(list).Result; + CopyForms(newTask, origenalTask); } } @@ -1437,7 +1405,73 @@ namespace IRaCIS.Core.Application.Service.Allocation return ResponseOutput.Ok(); } + private void CopyForms(VisitTask newTask, VisitTask origenalTask) + { + //鑷畾涔 + var readingCustomTagList = _repository.Where(t => t.VisitTaskId == origenalTask.Id).ToList(); + + foreach (var item in readingCustomTagList) + { + item.Id = Guid.Empty; + item.VisitTaskId = newTask.Id; + } + + _ = _repository.AddRangeAsync(readingCustomTagList).Result; + + + var readingTaskQuestionMarkList = _repository.Where(t => t.VisitTaskId == origenalTask.Id).ToList(); + + foreach (var item in readingTaskQuestionMarkList) + { + item.Id = Guid.Empty; + item.VisitTaskId = newTask.Id; + } + + _ = _repository.AddRangeAsync(readingTaskQuestionMarkList).Result; + + var readingTaskQuestionAnswerList = _repository.Where(t => t.VisitTaskId == origenalTask.Id).ToList(); + + foreach (var item in readingTaskQuestionAnswerList) + { + item.Id = Guid.Empty; + item.VisitTaskId = newTask.Id; + } + _ = _repository.AddRangeAsync(readingTaskQuestionAnswerList).Result; + + + + //ReadingTableAnswerRowInfo ReadingTableQuestionAnswer 涓璧峰姞 + var readingTableAnswerRowInfoList = _repository.Where(t => t.VisitTaskId == origenalTask.Id).Include(t => t.LesionAnswerList).ToList(); + + foreach (var item in readingTableAnswerRowInfoList) + { + item.Id = NewId.NextSequentialGuid(); + item.VisitTaskId = newTask.Id; + + foreach (var item2 in item.LesionAnswerList) + { + item2.Id = Guid.Empty; + item2.RowId = item.Id; + item2.VisitTaskId = newTask.Id; + } + } + + _ = _repository.AddRangeAsync(readingTableAnswerRowInfoList).Result; + + + //var readingTableQuestionAnswerList = _repository.Where(t => t.VisitTaskId == origenalTask.Id).ToList(); + + //foreach (var item in readingTableQuestionAnswerList) + //{ + // item.Id = Guid.Empty; + // item.VisitTaskId = newTask.Id; + //} + + //_ = _repository.AddRangeAsync(readingTableQuestionAnswerList).Result; + + + } /// /// PM 璁剧疆浠诲姟 閫鍥 /// From 56f261b8ced6e87e494c8604b1f98fb99f16ed89 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Mon, 30 Oct 2023 15:26:59 +0800 Subject: [PATCH 25/34] =?UTF-8?q?=E6=8B=B7=E8=B4=9D=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E5=B1=8F=E8=94=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Allocation/VisitTaskService.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index 84500ecfa..058570807 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -1420,15 +1420,15 @@ namespace IRaCIS.Core.Application.Service.Allocation _ = _repository.AddRangeAsync(readingCustomTagList).Result; - var readingTaskQuestionMarkList = _repository.Where(t => t.VisitTaskId == origenalTask.Id).ToList(); + //var readingTaskQuestionMarkList = _repository.Where(t => t.VisitTaskId == origenalTask.Id).ToList(); - foreach (var item in readingTaskQuestionMarkList) - { - item.Id = Guid.Empty; - item.VisitTaskId = newTask.Id; - } + //foreach (var item in readingTaskQuestionMarkList) + //{ + // item.Id = Guid.Empty; + // item.VisitTaskId = newTask.Id; + //} - _ = _repository.AddRangeAsync(readingTaskQuestionMarkList).Result; + //_ = _repository.AddRangeAsync(readingTaskQuestionMarkList).Result; var readingTaskQuestionAnswerList = _repository.Where(t => t.VisitTaskId == origenalTask.Id).ToList(); From 1094f318f9f438c85527d07352145f9e3b8088b5 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Mon, 30 Oct 2023 16:13:26 +0800 Subject: [PATCH 26/34] =?UTF-8?q?=E9=A2=84=E7=95=99=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=B3=BB=E7=BB=9F=E9=82=AE=E4=BB=B6=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/TrialSiteUser/TrialService.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs index b9ee2f43b..e6a45c6ea 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs @@ -25,13 +25,17 @@ namespace IRaCIS.Application.Services private readonly IRepository _trialUserRepository; private readonly IOptionsMonitor _verifyConfig; + //private readonly IOptionsMonitor _systemEmailSendConfig; + public bool TrialExpeditedChange { get; set; } = false; public TrialService(IEasyCachingProvider provider, IRepository trialRepository, IRepository trialUserRepository, IOptionsMonitor verifyConfig + //, IOptionsMonitor systemEmailSendConfig ) { + //_systemEmailSendConfig = systemEmailSendConfig; _verifyConfig = verifyConfig; _provider = provider; _trialRepository = trialRepository; @@ -213,6 +217,15 @@ namespace IRaCIS.Application.Services await _repository.AddAsync(new VisitStage { TrialId = trial.Id, VisitNum = 0, BlindName = "B" + 0.ToString("D3"), VisitDay = 0, VisitName = "Baseline", IsBaseLine = true }); await _repository.AddAsync(new VisitStage { TrialId = trial.Id, VisitNum = 1, BlindName = "B" + 10.ToString("D3"), VisitDay = 30, VisitName = "Visit 1" }); + //榛樿閲囩敤绯荤粺閭欢 + + //trial.EmailAuthorizationCode = _systemEmailSendConfig.CurrentValue.AuthorizationCode; + //trial.EmailFromEmail = _systemEmailSendConfig.CurrentValue.FromEmail; + //trial.EmailFromName = _systemEmailSendConfig.CurrentValue.FromName; + //trial.EmailSMTPServerAddress = _systemEmailSendConfig.CurrentValue.Host; + //trial.EmailSMTPServerPort = _systemEmailSendConfig.CurrentValue.Port; + //trial.IsConfigureEmail = true; + var success = await _repository.SaveChangesAsync(); From 3c532389d9a4ae2727e4291a09269300840f0ffc Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Mon, 30 Oct 2023 16:20:33 +0800 Subject: [PATCH 27/34] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/TrialSiteUser/TrialService.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs index e6a45c6ea..b92b011ad 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs @@ -25,17 +25,17 @@ namespace IRaCIS.Application.Services private readonly IRepository _trialUserRepository; private readonly IOptionsMonitor _verifyConfig; - //private readonly IOptionsMonitor _systemEmailSendConfig; + private readonly IOptionsMonitor _systemEmailSendConfig; public bool TrialExpeditedChange { get; set; } = false; public TrialService(IEasyCachingProvider provider, IRepository trialRepository, IRepository trialUserRepository, IOptionsMonitor verifyConfig - //, IOptionsMonitor systemEmailSendConfig + , IOptionsMonitor systemEmailSendConfig ) { - //_systemEmailSendConfig = systemEmailSendConfig; + _systemEmailSendConfig = systemEmailSendConfig; _verifyConfig = verifyConfig; _provider = provider; _trialRepository = trialRepository; @@ -219,12 +219,12 @@ namespace IRaCIS.Application.Services //榛樿閲囩敤绯荤粺閭欢 - //trial.EmailAuthorizationCode = _systemEmailSendConfig.CurrentValue.AuthorizationCode; - //trial.EmailFromEmail = _systemEmailSendConfig.CurrentValue.FromEmail; - //trial.EmailFromName = _systemEmailSendConfig.CurrentValue.FromName; - //trial.EmailSMTPServerAddress = _systemEmailSendConfig.CurrentValue.Host; - //trial.EmailSMTPServerPort = _systemEmailSendConfig.CurrentValue.Port; - //trial.IsConfigureEmail = true; + trial.EmailAuthorizationCode = _systemEmailSendConfig.CurrentValue.AuthorizationCode; + trial.EmailFromEmail = _systemEmailSendConfig.CurrentValue.FromEmail; + trial.EmailFromName = _systemEmailSendConfig.CurrentValue.FromName; + trial.EmailSMTPServerAddress = _systemEmailSendConfig.CurrentValue.Host; + trial.EmailSMTPServerPort = _systemEmailSendConfig.CurrentValue.Port; + trial.IsConfigureEmail = true; var success = await _repository.SaveChangesAsync(); From 9ec97f7d37b0f965f89c84dff4da0f781416c3a4 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 31 Oct 2023 15:21:35 +0800 Subject: [PATCH 28/34] =?UTF-8?q?=E6=8B=B7=E8=B4=9D=E7=97=85=E7=81=B6?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/appsettings.Prod_Study.json | 2 +- .../Service/Allocation/VisitTaskService.cs | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/IRaCIS.Core.API/appsettings.Prod_Study.json b/IRaCIS.Core.API/appsettings.Prod_Study.json index b04f38c44..72cf72b24 100644 --- a/IRaCIS.Core.API/appsettings.Prod_Study.json +++ b/IRaCIS.Core.API/appsettings.Prod_Study.json @@ -40,7 +40,7 @@ "Port": 465, "Host": "smtp.qiye.aliyun.com", "FromEmail": "study@extimaging.com", - "FromName": "study.extimaging", + "FromName": "鐮旂┒鍗曚綅闃呯墖绯荤粺", "AuthorizationCode": "zhanying123", "SiteUrl": "https://study.extimaging.com/login" } diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index 058570807..55c545aee 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -1446,8 +1446,12 @@ namespace IRaCIS.Core.Application.Service.Allocation foreach (var item in readingTableAnswerRowInfoList) { + var originalVisitTaskId = item.VisitTaskId; + var originalFristAddTaskId = item.FristAddTaskId; + item.Id = NewId.NextSequentialGuid(); item.VisitTaskId = newTask.Id; + item.FristAddTaskId = originalVisitTaskId == originalFristAddTaskId ? newTask.Id : item.FristAddTaskId; foreach (var item2 in item.LesionAnswerList) { @@ -1460,15 +1464,7 @@ namespace IRaCIS.Core.Application.Service.Allocation _ = _repository.AddRangeAsync(readingTableAnswerRowInfoList).Result; - //var readingTableQuestionAnswerList = _repository.Where(t => t.VisitTaskId == origenalTask.Id).ToList(); - //foreach (var item in readingTableQuestionAnswerList) - //{ - // item.Id = Guid.Empty; - // item.VisitTaskId = newTask.Id; - //} - - //_ = _repository.AddRangeAsync(readingTableQuestionAnswerList).Result; } From e925d5bdb273d6a4f1732e37c17f14a86fe1a944 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 1 Nov 2023 11:18:53 +0800 Subject: [PATCH 29/34] x --- IRaCIS.Core.Domain/Allocation/VisitTask.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/IRaCIS.Core.Domain/Allocation/VisitTask.cs b/IRaCIS.Core.Domain/Allocation/VisitTask.cs index 4fa044f69..263ac8f46 100644 --- a/IRaCIS.Core.Domain/Allocation/VisitTask.cs +++ b/IRaCIS.Core.Domain/Allocation/VisitTask.cs @@ -9,6 +9,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Collections.Generic; using System.Linq; +using EntityFrameworkCore.Projectables; namespace IRaCIS.Core.Domain.Models { @@ -323,7 +324,7 @@ namespace IRaCIS.Core.Domain.Models public Guid? BeforeConvertedTaskId { get; set; } - [NotMapped] + [Projectable] [JsonIgnore] public bool IsConvertedTask => BeforeConvertedTaskId != null || IsHistoryConvertedTask || Subject.SubjectVisitTaskList.Where(t => t.TrialReadingCriterionId == TrialReadingCriterionId && t.DoctorUserId == DoctorUserId && t.BeforeConvertedTaskId != null From a56ffaee58ce9a9b418582b613b979e14adecf82 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 1 Nov 2023 13:21:17 +0800 Subject: [PATCH 30/34] =?UTF-8?q?admin=20=E5=8F=AF=E4=BB=A5=E7=9C=8B?= =?UTF-8?q?=E5=88=B0=E9=A1=B9=E7=9B=AE=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/TrialSiteUser/PersonalWorkstation.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs index 71cd81d3c..a3a7a328a 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs @@ -1031,7 +1031,7 @@ namespace IRaCIS.Core.Application .WhereIf(!string.IsNullOrEmpty(inQuery.Code), o => o.TrialCode.Contains(inQuery.Code)) .WhereIf(!string.IsNullOrEmpty(inQuery.ResearchProgramNo), o => o.ResearchProgramNo.Contains(inQuery.ResearchProgramNo)) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.ExperimentName), o => o.ExperimentName.Contains(inQuery.ExperimentName)) - .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin, t => t.TrialUserList.Any(t => t.UserId == _userInfo.Id && t.IsDeleted == false) && t.IsDeleted == false) + .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin || _userInfo.UserTypeEnumInt != (int)UserTypeEnum.Admin, t => t.TrialUserList.Any(t => t.UserId == _userInfo.Id && t.IsDeleted == false) && t.IsDeleted == false) .Select(t => new TrialToBeDoneDto() { TrialId = t.Id, From 419d5de7f10a14d164014208fb700698c29c5d2e Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 2 Nov 2023 10:06:53 +0800 Subject: [PATCH 31/34] =?UTF-8?q?admin=20=E9=A1=B9=E7=9B=AE=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=9F=A5=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/TrialSiteUser/PersonalWorkstation.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs index a3a7a328a..f9caadb9e 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs @@ -1031,7 +1031,7 @@ namespace IRaCIS.Core.Application .WhereIf(!string.IsNullOrEmpty(inQuery.Code), o => o.TrialCode.Contains(inQuery.Code)) .WhereIf(!string.IsNullOrEmpty(inQuery.ResearchProgramNo), o => o.ResearchProgramNo.Contains(inQuery.ResearchProgramNo)) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.ExperimentName), o => o.ExperimentName.Contains(inQuery.ExperimentName)) - .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin || _userInfo.UserTypeEnumInt != (int)UserTypeEnum.Admin, t => t.TrialUserList.Any(t => t.UserId == _userInfo.Id && t.IsDeleted == false) && t.IsDeleted == false) + .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.Admin, t => t.TrialUserList.Any(t => t.UserId == _userInfo.Id && t.IsDeleted == false) && t.IsDeleted == false) .Select(t => new TrialToBeDoneDto() { TrialId = t.Id, From 99439a4809092a012c948a472e807d6e511b3e9f Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 2 Nov 2023 15:53:09 +0800 Subject: [PATCH 32/34] =?UTF-8?q?=E5=AE=B9=E5=99=A8=E7=9C=9F=E5=AE=9Eip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs b/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs index 890033cda..eddead0fd 100644 --- a/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs +++ b/IRaCIS.Core.Infra.EFCore/AuthUser/UserInfo.cs @@ -212,7 +212,7 @@ namespace IRaCIS.Core.Domain.Share get { - return _accessor?.HttpContext?.Connection.RemoteIpAddress.ToString(); + return _accessor?.HttpContext.GetClientIP(); } } @@ -341,4 +341,33 @@ namespace IRaCIS.Core.Domain.Share } + + public static class HttpContextExtension + { + public static string GetClientIP(this HttpContext context) + { + var ip = context.Request.Headers["Cdn-Src-Ip"].FirstOrDefault(); + if (!string.IsNullOrEmpty(ip)) + return IpReplace(ip); + + ip = context.Request.Headers["X-Forwarded-For"].FirstOrDefault(); + if (!string.IsNullOrEmpty(ip)) + return IpReplace(ip); + + ip = context.Connection.RemoteIpAddress.ToString(); + + return IpReplace(ip); + } + + static string IpReplace(string inip) + { + //::ffff: + //::ffff:192.168.2.131 杩欑IP澶勭悊 + if (inip.Contains("::ffff:")) + { + inip = inip.Replace("::ffff:", ""); + } + return inip; + } + } } From dc6ae3913057728af02bc7da1a1c7b3bcf480c84 Mon Sep 17 00:00:00 2001 From: he <10978375@qq.com> Date: Fri, 3 Nov 2023 09:55:05 +0800 Subject: [PATCH 33/34] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/IRaCIS.Core.API.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/IRaCIS.Core.API/IRaCIS.Core.API.csproj b/IRaCIS.Core.API/IRaCIS.Core.API.csproj index 8419b93f5..d00bf4bd9 100644 --- a/IRaCIS.Core.API/IRaCIS.Core.API.csproj +++ b/IRaCIS.Core.API/IRaCIS.Core.API.csproj @@ -80,6 +80,7 @@ + From b461216d877d02e04104eea256e695379a3b382c Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Fri, 3 Nov 2023 12:15:13 +0800 Subject: [PATCH 34/34] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/appsettings.Prod_Study.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/IRaCIS.Core.API/appsettings.Prod_Study.json b/IRaCIS.Core.API/appsettings.Prod_Study.json index 72cf72b24..accbb9c34 100644 --- a/IRaCIS.Core.API/appsettings.Prod_Study.json +++ b/IRaCIS.Core.API/appsettings.Prod_Study.json @@ -23,13 +23,13 @@ "BasicSystemConfig": { - "OpenUserComplexPassword": false, + "OpenUserComplexPassword": true, - "OpenSignDocumentBeforeWork": false, + "OpenSignDocumentBeforeWork": true, "OpenTrialRelationDelete": true, - "OpenLoginLimit": false, + "OpenLoginLimit": true, "LoginMaxFailCount": 5, "LoginFailLockMinutes": 30