nuget 包升级,清理没用的包,预备net8
commit
5171af975d
|
@ -69,6 +69,10 @@
|
|||
<PackageReference Include="aliyun-net-sdk-sts" Version="3.1.2" />
|
||||
<PackageReference Include="AspNetCoreRateLimit" Version="5.0.0" />
|
||||
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.0" />
|
||||
<PackageReference Include="EasyCaching.Interceptor.Castle" Version="1.9.1" />
|
||||
<PackageReference Include="EasyCaching.Serialization.MessagePack" Version="1.9.1" />
|
||||
<PackageReference Include="EntityFrameworkCore.Triggered.Extensions" Version="3.2.1" />
|
||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
||||
<PackageReference Include="EasyCaching.InMemory" Version="1.9.1" />
|
||||
<PackageReference Include="EasyCaching.Interceptor.Castle" Version="1.9.1" />
|
||||
|
|
|
@ -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(cfg => cfg.RegisterServicesFromAssemblyContaining<ConsistencyVerificationHandler>());
|
||||
// EasyCaching 缓存
|
||||
services.AddEasyCachingSetup();
|
||||
services.AddEasyCachingSetup(_configuration);
|
||||
|
||||
//services.AddDistributedMemoryCache();
|
||||
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
using IRaCIS.Core.Application.Triggers;
|
||||
using 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<IDistributedLockProvider>(sp =>
|
||||
{
|
||||
//var connection = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]!);
|
||||
|
||||
return new SqlDistributedSynchronizationProvider(configuration.GetSection("ConnectionStrings:RemoteNew").Value);
|
||||
});
|
||||
|
||||
//services.AddAssemblyTriggers(typeof(SubjectVisitImageDateTrigger).Assembly);
|
||||
}
|
||||
|
|
|
@ -1,17 +1,26 @@
|
|||
using 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -65,7 +65,11 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.13.0" />
|
||||
<PackageReference Include="AutoMapper.Collection.EntityFrameworkCore" Version="9.0.0" />
|
||||
<PackageReference Include="EntityFrameworkCore.Triggered" Version="3.2.2" />
|
||||
<PackageReference Include="DistributedLock.Redis" Version="1.0.2" />
|
||||
<PackageReference Include="DistributedLock.SqlServer" Version="1.0.3" />
|
||||
<PackageReference Include="EasyCaching.InMemory" Version="1.9.1" />
|
||||
<PackageReference Include="EasyCaching.Redis" Version="1.9.1" />
|
||||
<PackageReference Include="EntityFrameworkCore.Triggered" Version="3.2.1" />
|
||||
<PackageReference Include="Castle.Core.AsyncInterceptor" Version="2.1.0" />
|
||||
<PackageReference Include="EasyCaching.Interceptor.AspectCore" Version="1.9.1" />
|
||||
<PackageReference Include="ExcelDataReader" Version="3.6.0" />
|
||||
|
@ -93,12 +97,12 @@
|
|||
<TreatAsUsed>true</TreatAsUsed>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Nito.AsyncEx" Version="5.1.2" />
|
||||
<PackageReference Include="NPOI" Version="2.6.2" />
|
||||
<PackageReference Include="Panda.DynamicWebApi" Version="1.2.1" />
|
||||
<PackageReference Include="Quartz" Version="3.7.0" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.2" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="7.0.11" />
|
||||
<PackageReference Include="WinSCP" Version="6.1.2" />
|
||||
<PackageReference Include="NPOI" Version="2.6.0" />
|
||||
<PackageReference Include="Panda.DynamicWebApi" Version="1.2.0" />
|
||||
<PackageReference Include="Quartz" Version="3.5.0" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.3" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Filters" Version="7.0.5" />
|
||||
<PackageReference Include="WinSCP" Version="5.21.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Hosting;
|
|||
using IRaCIS.Core.Infrastructure;
|
||||
using FellowOakDicom;
|
||||
using FellowOakDicom.Imaging.Codec;
|
||||
using Medallion.Threading;
|
||||
|
||||
namespace IRaCIS.Core.Application.Services
|
||||
{
|
||||
|
@ -22,7 +23,7 @@ namespace IRaCIS.Core.Application.Services
|
|||
|
||||
private readonly IWebHostEnvironment _hostEnvironment;
|
||||
|
||||
private static object lockCodeGenerate = new object();
|
||||
private readonly IDistributedLockProvider _distributedLockProvider;
|
||||
|
||||
|
||||
private List<Guid> _instanceIdList = new List<Guid>();
|
||||
|
@ -32,8 +33,9 @@ namespace IRaCIS.Core.Application.Services
|
|||
IRepository<DicomInstance> instanceRepository,
|
||||
IWebHostEnvironment hostEnvironment,
|
||||
IRepository<Dictionary> dictionaryRepository,
|
||||
IEasyCachingProvider provider)
|
||||
IEasyCachingProvider provider, IDistributedLockProvider distributedLockProvider)
|
||||
{
|
||||
_distributedLockProvider = distributedLockProvider;
|
||||
_hostEnvironment = hostEnvironment;
|
||||
_studyRepository = studyRepository;
|
||||
|
||||
|
@ -283,9 +285,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();
|
||||
|
||||
|
@ -299,9 +302,9 @@ namespace IRaCIS.Core.Application.Services
|
|||
dicomStudy.StudyCode = AppSettings.GetCodeStr(currentNextCodeInt, nameof(DicomStudy));
|
||||
|
||||
_provider.Set<int>($"{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();
|
||||
|
|
|
@ -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<Dictionary> _dictionaryRepository;
|
||||
|
||||
private readonly IRepository<StudyMonitor> _studyMonitorRepository;
|
||||
|
||||
private readonly IDistributedLockProvider _distributedLockProvider;
|
||||
|
||||
public StudyService(IEasyCachingProvider provider
|
||||
, IRepository<SubjectVisit> subjectVisitRepository,
|
||||
IRepository<DicomInstance> dicomInstanceRepository,
|
||||
IRepository<DicomSeries> dicomSeriesRepository, IRepository<DicomStudy> dicomstudyRepository, IRepository<Dictionary> dictionaryRepository, IRepository<StudyMonitor> studyMonitorRepository)
|
||||
IRepository<DicomSeries> dicomSeriesRepository, IRepository<DicomStudy> dicomstudyRepository, IRepository<Dictionary> dictionaryRepository, IRepository<StudyMonitor> 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<DicomStudy>(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)
|
||||
|
@ -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)
|
||||
{
|
||||
_provider.Remove($"StudyUid_{trialId}_{studyInstanceUid}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Site> _siteRepository;
|
||||
private readonly IRepository<TrialSiteUser> _trialSiteUserRepository;
|
||||
private readonly IDistributedLockProvider _distributedLockProvider;
|
||||
|
||||
private readonly AsyncLock _mutex = new AsyncLock();
|
||||
|
||||
public SiteService(IRepository<Site> siteRepository, IRepository<TrialSiteUser> trialSiteUserRepository)
|
||||
public SiteService(IRepository<Site> siteRepository, IRepository<TrialSiteUser> trialSiteUserRepository, IDistributedLockProvider distributedLockProvider)
|
||||
{
|
||||
_siteRepository = siteRepository;
|
||||
this._trialSiteUserRepository = trialSiteUserRepository;
|
||||
_trialSiteUserRepository = trialSiteUserRepository;
|
||||
_distributedLockProvider = distributedLockProvider;
|
||||
}
|
||||
|
||||
/// <summary> 分页获取研究中心列表 </summary>
|
||||
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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<TrialUser> _userTrialRepository;
|
||||
private readonly IRepository<UserLog> _userLogRepository;
|
||||
|
||||
|
||||
private readonly IDistributedLockProvider _distributedLockProvider;
|
||||
private readonly IMemoryCache _cache;
|
||||
|
||||
private readonly IOptionsMonitor<ServiceVerifyConfigOption> _verifyConfig;
|
||||
|
@ -38,7 +39,8 @@ namespace IRaCIS.Application.Services
|
|||
IRepository<TrialUser> userTrialRepository,
|
||||
IOptionsMonitor<ServiceVerifyConfigOption> verifyConfig,
|
||||
IRepository<UserLog> userLogRepository
|
||||
)
|
||||
,
|
||||
IDistributedLockProvider distributedLockProvider)
|
||||
{
|
||||
_userLogRepository = userLogRepository;
|
||||
|
||||
|
@ -50,6 +52,7 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
_userTrialRepository = userTrialRepository;
|
||||
_userLogRepository = userLogRepository;
|
||||
_distributedLockProvider = distributedLockProvider;
|
||||
}
|
||||
|
||||
|
||||
|
@ -502,6 +505,10 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
var saveItem = _mapper.Map<User>(userAddModel);
|
||||
|
||||
var @lock = _distributedLockProvider.CreateLock($"UserAccount");
|
||||
|
||||
using (await @lock.AcquireAsync())
|
||||
{
|
||||
saveItem.Code = await _userRepository.Select(t => t.Code).DefaultIfEmpty().MaxAsync() + 1;
|
||||
|
||||
saveItem.UserCode = AppSettings.GetCodeStr(saveItem.Code, nameof(User));
|
||||
|
@ -517,14 +524,13 @@ namespace IRaCIS.Application.Services
|
|||
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 });
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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<NoneDicomStudy> _noneDicomStudyRepository;
|
||||
private readonly IRepository<NoneDicomStudyFile> _noneDicomStudyFileRepository;
|
||||
private readonly AsyncLock _mutex = new AsyncLock();
|
||||
private readonly IDistributedLockProvider _distributedLockProvider;
|
||||
private readonly QCCommon _qCCommon;
|
||||
|
||||
|
||||
public NoneDicomStudyService(IRepository<NoneDicomStudy> noneDicomStudyRepository,
|
||||
QCCommon qCCommon,
|
||||
IRepository<NoneDicomStudyFile> noneDicomStudyFileRepository)
|
||||
IRepository<NoneDicomStudyFile> 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)
|
||||
{
|
||||
|
|
|
@ -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<Trial> _trialRepository;
|
||||
private readonly IRepository<VisitTask> _visitTaskRepository;
|
||||
private readonly IVisitTaskHelpeService _IVisitTaskHelpeService;
|
||||
|
||||
private readonly AsyncLock _mutex = new AsyncLock();
|
||||
private readonly IDistributedLockProvider _distributedLockProvider;
|
||||
|
||||
public QCOperationService(IRepository<SubjectVisit> subjectVisitRepository,
|
||||
IRepository<QCChallenge> qcChallengeRepository,
|
||||
|
@ -48,7 +47,8 @@ namespace IRaCIS.Core.Application.Image.QA
|
|||
IRepository<ReadingClinicalData> readingClinicalDataRepository,
|
||||
IRepository<QCChallengeDialog> qCChallengeDialogrepository,
|
||||
IRepository<CheckChallengeDialog> 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();
|
||||
|
|
|
@ -20,6 +20,7 @@ using Microsoft.VisualBasic;
|
|||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using IRaCIS.Core.Domain.Models;
|
||||
using IRaCIS.Core.Application.ViewModel;
|
||||
using Medallion.Threading;
|
||||
|
||||
namespace IRaCIS.Core.Application.Contracts
|
||||
{
|
||||
|
@ -35,13 +36,14 @@ namespace IRaCIS.Core.Application.Contracts
|
|||
private readonly IRepository<TrialSite> _trialSiteRepository;
|
||||
private readonly IRepository<TrialUser> _trialUserRepository;
|
||||
private readonly IRepository<TrialSiteUser> _trialSiteUserRepository;
|
||||
private readonly IDistributedLockProvider _distributedLockProvider;
|
||||
private readonly ITokenService _tokenService;
|
||||
private readonly IMailVerificationService _mailVerificationService;
|
||||
|
||||
public TrialSiteSurveyService(IRepository<TrialSiteSurvey> trialSiteSurveyRepository, IRepository<TrialUser> trialUserRepository, IRepository<TrialSiteUserSurvey> trialSiteUserSurveyRepository,
|
||||
IRepository<User> userRepository, IRepository<TrialSite> trialSiteRepository,
|
||||
ITokenService tokenService,
|
||||
IMailVerificationService mailVerificationService, IRepository<TrialSiteUser> trialSiteUserRepository)
|
||||
IMailVerificationService mailVerificationService, IRepository<TrialSiteUser> trialSiteUserRepository, IDistributedLockProvider distributedLockProvider)
|
||||
{
|
||||
_trialSiteSurveyRepository = trialSiteSurveyRepository;
|
||||
_trialSiteUserSurveyRepository = trialSiteUserSurveyRepository;
|
||||
|
@ -51,9 +53,9 @@ namespace IRaCIS.Core.Application.Contracts
|
|||
_tokenService = tokenService;
|
||||
_mailVerificationService = mailVerificationService;
|
||||
_trialSiteUserRepository = trialSiteUserRepository;
|
||||
_distributedLockProvider = distributedLockProvider;
|
||||
}
|
||||
|
||||
private object lockObj { get; set; } = new object();
|
||||
|
||||
/// <summary>
|
||||
/// 发送验证码
|
||||
|
@ -791,7 +793,9 @@ namespace IRaCIS.Core.Application.Contracts
|
|||
if (sysUserInfo == null)
|
||||
{
|
||||
|
||||
lock (lockObj)
|
||||
var @lock = _distributedLockProvider.CreateLock($"UserCode");
|
||||
|
||||
using (await @lock.AcquireAsync())
|
||||
{
|
||||
var saveItem = _mapper.Map<User>(item);
|
||||
|
||||
|
@ -971,7 +975,9 @@ namespace IRaCIS.Core.Application.Contracts
|
|||
if (sysUserInfo == null)
|
||||
{
|
||||
|
||||
lock (lockObj)
|
||||
var @lock = _distributedLockProvider.CreateLock($"UserCode");
|
||||
|
||||
using (await @lock.AcquireAsync())
|
||||
{
|
||||
var saveItem = _mapper.Map<User>(item);
|
||||
|
||||
|
|
|
@ -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<TrialSiteUserSurvey> _trialSiteSurveyUserRepository;
|
||||
private readonly IRepository<TrialSiteUser> _trialSiteUserRepository;
|
||||
private readonly IMailVerificationService _mailVerificationService;
|
||||
private readonly IDistributedLockProvider _distributedLockProvider;
|
||||
|
||||
public TrialExternalUserService(IRepository<TrialExternalUser> trialExternalUseRepository, IRepository<User> userRepository, IRepository<TrialUser> trialUserRepository,
|
||||
IRepository<TrialSiteUserSurvey> trialSiteSurveyUserRepository, IRepository<TrialSiteUser> 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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -74,6 +77,10 @@ namespace IRaCIS.Core.Application.Service
|
|||
{
|
||||
|
||||
if (addOrEditTrialExternalUser.Id == null)
|
||||
{
|
||||
var @lock = _distributedLockProvider.CreateLock($"UserCode");
|
||||
|
||||
using (await @lock.AcquireAsync())
|
||||
{
|
||||
var existSysUser = await _userRepository.FirstOrDefaultAsync(t => t.EMail == addOrEditTrialExternalUser.Email && t.UserTypeId == addOrEditTrialExternalUser.UserTypeId);
|
||||
|
||||
|
@ -204,6 +211,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
|
||||
return ResponseOutput.Ok(addEntity.Id.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,15 +1,19 @@
|
|||
using IRaCIS.Core.Application.Service;
|
||||
using 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;
|
||||
using Microsoft.Extensions.Caching.Distributed;
|
||||
using Microsoft.Extensions.Logging;
|
||||
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 +24,8 @@ namespace IRaCIS.Application.Services
|
|||
[ApiExplorerSettings(GroupName = "Institution")]
|
||||
public class TestService : BaseService
|
||||
{
|
||||
|
||||
public static int IntValue = 100;
|
||||
private readonly IRepository<Dictionary> _dicRepository;
|
||||
private readonly IRepository<Trial> _trialRepository;
|
||||
|
||||
|
@ -30,10 +36,13 @@ namespace IRaCIS.Application.Services
|
|||
private readonly IOptionsMonitor<ServiceVerifyConfigOption> _basicConfig;
|
||||
private readonly IRepository<VisitTask> _visitTaskRepositoryy;
|
||||
|
||||
private readonly IDistributedLockProvider _distributedLockProvider;
|
||||
|
||||
public TestService(IRepository<Dictionary> dicRepository, IRepository<Trial> trialRepository/*, IDistributedCache cache*/
|
||||
private readonly ILogger<TestService> _logger;
|
||||
|
||||
, IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig, IOptionsMonitor<ServiceVerifyConfigOption> basicConfig, IRepository<VisitTask> visitTaskRepository)
|
||||
public TestService(IRepository<Dictionary> dicRepository, IRepository<Trial> trialRepository,ILogger<TestService> logger
|
||||
|
||||
, IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig, IOptionsMonitor<ServiceVerifyConfigOption> basicConfig, IRepository<VisitTask> visitTaskRepository, IDistributedLockProvider distributedLockProvider)
|
||||
{
|
||||
_visitTaskRepositoryy = visitTaskRepository;
|
||||
|
||||
|
@ -42,10 +51,36 @@ namespace IRaCIS.Application.Services
|
|||
|
||||
_dicRepository = dicRepository;
|
||||
_trialRepository = trialRepository;
|
||||
|
||||
_distributedLockProvider= distributedLockProvider;
|
||||
|
||||
_logger= logger;
|
||||
//_cache = cache;
|
||||
}
|
||||
|
||||
|
||||
|
||||
[AllowAnonymous]
|
||||
public async Task<IResponseOutput> TestDistributedLock( )
|
||||
{
|
||||
Console.WriteLine($"我进来了当前值是:" + IntValue);
|
||||
_logger.LogWarning($"我进来了当前值是:" + IntValue);
|
||||
|
||||
var @lock = _distributedLockProvider.CreateLock($"UserAccount");
|
||||
|
||||
using (await @lock.AcquireAsync())
|
||||
{
|
||||
await Task.Delay(4);
|
||||
IntValue--;
|
||||
|
||||
_logger.LogWarning( IntValue.ToString());
|
||||
Console.WriteLine(IntValue);
|
||||
}
|
||||
|
||||
return ResponseOutput.Ok(IntValue);
|
||||
}
|
||||
|
||||
|
||||
[AllowAnonymous]
|
||||
public async Task<IResponseOutput> GetMemoryStoreData()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue