动态切换存储中间件修改结束

Uat_Study
hang 2023-05-17 11:48:27 +08:00
parent 8cffbd9901
commit e000b7ea6d
1 changed files with 32 additions and 26 deletions

View File

@ -49,7 +49,13 @@ namespace IRaCIS.Core.API
var isDicomFile = path.Contains($"{StaticData.Folder.DicomFolder}"); var isDicomFile = path.Contains($"{StaticData.Folder.DicomFolder}");
//先从默认里面去找
if (isIRacisFile)
{
var defaultFileProvider = new PhysicalFileProvider(FileStoreHelper.GetIRaCISRootPath(_hostingEnv)); var defaultFileProvider = new PhysicalFileProvider(FileStoreHelper.GetIRaCISRootPath(_hostingEnv));
var staticFileOptions = new StaticFileOptions var staticFileOptions = new StaticFileOptions
{ {
FileProvider = defaultFileProvider, FileProvider = defaultFileProvider,
@ -58,11 +64,6 @@ namespace IRaCIS.Core.API
DefaultContentType = "application/octet-stream" DefaultContentType = "application/octet-stream"
}; };
var defaultRoot = Path.GetPathRoot(iRaCISDefaultDataFolder);
//先从默认里面去找
if (isIRacisFile)
{
if (defaultFileProvider.GetFileInfo(context.Request.Path).Exists) if (defaultFileProvider.GetFileInfo(context.Request.Path).Exists)
{ {
@ -78,7 +79,14 @@ namespace IRaCIS.Core.API
//dicom影像从多个文件夹尝试因为会存在切换磁盘 //dicom影像从多个文件夹尝试因为会存在切换磁盘
if (isDicomFile) if (isDicomFile)
{ {
var disks = GetDisks().Where(t=>!t.Contains(defaultRoot)); var defaultRoot = Path.GetPathRoot(iRaCISDefaultDataFolder);
//除默认部署路径的其他路径
var disks = DriveInfo.GetDrives()
.Where(d => d.IsReady && d.DriveType == DriveType.Fixed)/*.Where(t => !t.Name.Contains("C") && !t.Name.Contains("c"))*/
.OrderBy(d => d.AvailableFreeSpace)
.Select(d => d.RootDirectory.FullName)
.ToArray().Where(t=>!t.Contains(defaultRoot));
foreach (var item in disks) foreach (var item in disks)
@ -92,13 +100,7 @@ namespace IRaCIS.Core.API
var otherFileProvider= new PhysicalFileProvider(otherFileStoreFolder); var otherFileProvider= new PhysicalFileProvider(otherFileStoreFolder);
var otherStaticFileOptions = new StaticFileOptions
{
FileProvider = otherFileProvider,
RequestPath = $"/{StaticData.Folder.IRaCISDataFolder}",
ServeUnknownFileTypes = true,
DefaultContentType = "application/octet-stream"
};
if (otherFileProvider.GetFileInfo(context.Request.Path).Exists) if (otherFileProvider.GetFileInfo(context.Request.Path).Exists)
{ {
@ -108,9 +110,20 @@ namespace IRaCIS.Core.API
//方式一 //方式一
await context.Response.SendFileAsync( new PhysicalFileInfo(new FileInfo(actrualPath))); await context.Response.SendFileAsync( new PhysicalFileInfo(new FileInfo(actrualPath)));
//方式二 #region 方式二 报错 otherFileProvider 应该还包含/{StaticData.Folder.IRaCISDataFolder} 这一层级
//var otherStaticFileOptions = new StaticFileOptions
//{
// FileProvider = otherFileProvider,
// RequestPath = $"/{StaticData.Folder.IRaCISDataFolder}",
// ServeUnknownFileTypes = true,
// DefaultContentType = "application/octet-stream"
//};
//var staticFileMiddleware = new StaticFileMiddleware(_next, _hostingEnv, Options.Create(otherStaticFileOptions), _loggerFactory); //var staticFileMiddleware = new StaticFileMiddleware(_next, _hostingEnv, Options.Create(otherStaticFileOptions), _loggerFactory);
//await staticFileMiddleware.Invoke(context); //await staticFileMiddleware.Invoke(context);
#endregion
return; return;
} }
} }
@ -123,14 +136,7 @@ namespace IRaCIS.Core.API
private string[] GetDisks()
{
// 获取系统中所有可用的磁盘
return DriveInfo.GetDrives()
.Where(d => d.IsReady && d.DriveType == DriveType.Fixed).Where(t => !t.Name.Contains("C") && !t.Name.Contains("c"))
.Select(d => d.RootDirectory.FullName)
.ToArray();
}
//private static string GetContentType(string path) //private static string GetContentType(string path)