diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs index 5bf595a63..e3bac406e 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs @@ -145,6 +145,22 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] public async Task AddOrUpdateArchiveStudy(NewArchiveStudyCommand incommand) { + + var @uploadLock = _distributedLockProvider.CreateLock($"UploadDicom"); + + using (await @uploadLock.AcquireAsync()) + { + if (_provider.Exists($"StudyUid_{incommand.TrialId}_{incommand.Study.StudyInstanceUid}")) + { + //---当前已有人正在上传和归档该检查! + return ResponseOutput.NotOk(StaticData.International("UploadDownLoad_ArchiveInProgress")); + } + else + { + _provider.Set($"StudyUid_{incommand.TrialId}_{incommand.Study.StudyInstanceUid}", _userInfo.Id, TimeSpan.FromSeconds(30)); + } + } + var modalitys = string.Empty; try @@ -191,7 +207,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc study.SubjectVisitId = incommand.SubjectVisitId; //如果因为意外情况,连续点击两次,导致第一次插入了,第二次进来也会插入,在此判断一下 - var findStudy = await _dicomstudyRepository.FirstOrDefaultAsync(t => t.Id == study.Id); + var findStudy = await _dicomstudyRepository.FirstOrDefaultAsync(t => t.Id == study.Id); if (findStudy != null) { @@ -372,7 +388,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc VisitNum = t.SubjectVisit.VisitNum, IsDicom = true, - IsFromPACS=t.IsFromPACS, + IsFromPACS = t.IsFromPACS, SubjectCode = t.Subject.Code, @@ -422,7 +438,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc VisitNum = t.SubjectVisit.VisitNum, IsDicom = false, - IsFromPACS=false, + IsFromPACS = false, SubjectCode = t.Subject.Code, @@ -543,7 +559,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc path = (await _dicomInstanceRepository.Where(s => s.StudyId == studyId).Select(t => t.Path).FirstOrDefaultAsync()).IfNullThrowException(); - + using (var sw = ImageHelper.RenderPreviewJpeg(path)) {