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)) {