From e736fe65577a422772fc89b981f1a3a8885415ea Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 16 May 2023 16:55:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BC=A9=E7=95=A5=E5=9B=BE?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/ImageAndDoc/SeriesService.cs | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/SeriesService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/SeriesService.cs index 7467fea44..4fe42154f 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/SeriesService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/SeriesService.cs @@ -140,13 +140,40 @@ namespace IRaCIS.Core.Application.Services path = (await _instanceRepository.Where(s => s.SeriesId == seriesId).Select(t => t.Path).FirstOrDefaultAsync()).IfNullThrowException(); - var physicalPath = FileStoreHelper.GetPhysicalFilePath(_hostEnvironment, path); + #region 切换磁盘存储之前 + //var physicalPath = FileStoreHelper.GetPhysicalFilePath(_hostEnvironment, path); - //DicomInstance dicomInstance = await _instanceRepository.FirstOrDefaultAsync(s => s.SeriesId == seriesId).IfNullThrowException(); + #endregion + + #region 切换磁盘存储后 + + var physicalPath = string.Empty; + + //找到所有磁盘 + var drives = DriveInfo.GetDrives() + .Where(d => d.DriveType == DriveType.Fixed && d.IsReady) + //剩余空间最多的 + .OrderByDescending(d => d.AvailableFreeSpace) + + //存储空间相同,则按照按照总空间从大到小排序 + .ThenByDescending(d => d.TotalSize - d.TotalFreeSpace) + .Select(d => d.RootDirectory.FullName) + .ToList(); + + + foreach (var drive in drives) + { + physicalPath = Path.Combine(drive, _hostEnvironment.EnvironmentName, path.Trim('/')); + + if(File.Exists(physicalPath)) + { + break; + } + } + + #endregion - //DicomStudy dicomStudy = await _studyRepository.FirstOrDefaultAsync(s => s.Id == dicomInstance.StudyId).IfNullThrowException(); - //var (physicalPath, relativePath) = FileStoreHelper.GetDicomInstanceFilePath(_hostEnvironment, dicomStudy.TrialId, dicomStudy.SiteId, dicomStudy.SubjectId, dicomStudy.SubjectVisitId, dicomStudy.Id, dicomInstance.Id); using (var sw = ImageHelper.RenderPreviewJpeg(physicalPath)) {