From b5f09e97747598e88d1b62e4936eb890c1f052db Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Fri, 27 May 2022 16:30:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AD=98=E5=82=A8=E8=B7=AF?= =?UTF-8?q?=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/Controllers/UploadController.cs | 10 +++++----- .../Helper/FileStoreHelper.cs | 16 ++++++++++++++++ .../ImageAndDoc/Helper/DicomFileStoreHelper.cs | 5 +++-- .../Service/QC/ClinicalDataService.cs | 2 +- .../Service/QC/NoneDicomStudyService.cs | 2 +- 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/IRaCIS.Core.API/Controllers/UploadController.cs b/IRaCIS.Core.API/Controllers/UploadController.cs index 4d143e12b..95397fab5 100644 --- a/IRaCIS.Core.API/Controllers/UploadController.cs +++ b/IRaCIS.Core.API/Controllers/UploadController.cs @@ -197,7 +197,7 @@ namespace IRaCIS.Core.API.Controllers private void DealCommonStorePath(/*string fileType, string moduleType,*/ string fileRealName, out string serverFilePath, out string relativePath) { - var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).FullName; + var rootPath = FileStoreHelper.GetIRaCISRootDataFolder(_hostEnvironment) ; //上传根路径 var _fileStorePath = Path.Combine(rootPath, StaticData.SystemDataFolder); @@ -218,7 +218,7 @@ namespace IRaCIS.Core.API.Controllers private void DealSystemNoticePath(string fileRealName, out string serverFilePath, out string relativePath) { - var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).FullName; + var rootPath = FileStoreHelper.GetIRaCISRootDataFolder(_hostEnvironment); //上传根路径 var _fileStorePath = Path.Combine(rootPath, StaticData.SystemDataFolder); @@ -239,7 +239,7 @@ namespace IRaCIS.Core.API.Controllers private void DealSysTemStorePath( string fileRealName, out string serverFilePath, out string relativePath) { - var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).FullName; + var rootPath = FileStoreHelper.GetIRaCISRootDataFolder(_hostEnvironment); //上传根路径 var _fileStorePath = Path.Combine(rootPath, StaticData.SystemDataFolder); @@ -261,7 +261,7 @@ namespace IRaCIS.Core.API.Controllers private void DealTrialStorePath(Guid trialId,string fileRealName, out string serverFilePath, out string relativePath) { - var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).FullName; + var rootPath = FileStoreHelper.GetIRaCISRootDataFolder(_hostEnvironment); //上传根路径 var _fileStorePath = Path.Combine(rootPath, StaticData.TrialDataFolder); @@ -334,7 +334,7 @@ namespace IRaCIS.Core.API.Controllers private void DealStorePath(Guid subjectVisitId, string realName, UploadFileTypeEnum typeEnum, out string serverFilePath, out string relativePath, IRepository _subjectVisitRepository) { - var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).FullName; + var rootPath = FileStoreHelper.GetIRaCISRootDataFolder(_hostEnvironment); //上传根路径 var _fileStorePath = Path.Combine(rootPath, StaticData.TrialDataFolder); diff --git a/IRaCIS.Core.Application/Helper/FileStoreHelper.cs b/IRaCIS.Core.Application/Helper/FileStoreHelper.cs index 76f3899ee..50bb7d075 100644 --- a/IRaCIS.Core.Application/Helper/FileStoreHelper.cs +++ b/IRaCIS.Core.Application/Helper/FileStoreHelper.cs @@ -1,5 +1,8 @@  +using IRaCIS.Core.Domain.Share; +using Microsoft.AspNetCore.Hosting; + namespace IRaCIS.Core.Application.Helper; public static class FileStoreHelper @@ -25,5 +28,18 @@ public static class FileStoreHelper return (trustedFileNameForFileStorage, fileName); } + + + public static string GetIRaCISRootDataFolder(IWebHostEnvironment _hostEnvironment) + { + var root = (Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\'))).IfNullThrowException().FullName; + + + var rootFolder =Path.Combine(root, StaticData.IRaCISDataFolder) ; + + + return rootFolder; + } + } diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/Helper/DicomFileStoreHelper.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/Helper/DicomFileStoreHelper.cs index 6e47afc79..70e8f2c63 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/Helper/DicomFileStoreHelper.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/Helper/DicomFileStoreHelper.cs @@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Logging; using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Infrastructure.Extention; +using IRaCIS.Core.Application.Helper; namespace IRaCIS.Core.Application { @@ -20,10 +21,10 @@ namespace IRaCIS.Core.Application { _logger = logger; _hostEnvironment = hostEnvironment; - var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).IfNullThrowException().FullName; + var rootPath = FileStoreHelper.GetIRaCISRootDataFolder(_hostEnvironment); //上传根路径 - _fileStorePath = Path.Combine(rootPath, StaticData.TrialDataFolder); + _fileStorePath = Path.Combine(rootPath, StaticData.TrialDataFolder); } diff --git a/IRaCIS.Core.Application/Service/QC/ClinicalDataService.cs b/IRaCIS.Core.Application/Service/QC/ClinicalDataService.cs index c0302062d..1981d4015 100644 --- a/IRaCIS.Core.Application/Service/QC/ClinicalDataService.cs +++ b/IRaCIS.Core.Application/Service/QC/ClinicalDataService.cs @@ -58,7 +58,7 @@ namespace IRaCIS.Core.Application.Contracts { await QCCommonVerify.VerifyIsCRCSubmmitAsync(_repository, _userInfo, subjectVisitId); - var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).IfNullThrowException().FullName; + var rootPath = FileStoreHelper.GetIRaCISRootDataFolder(_hostEnvironment); //上传根路径 var _fileStorePath = Path.Combine(rootPath, StaticData.TrialDataFolder); diff --git a/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs b/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs index 69f749d43..57e5bf202 100644 --- a/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs +++ b/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs @@ -187,7 +187,7 @@ namespace IRaCIS.Core.Application.Contracts { await QCCommonVerify.VerifyIsCRCSubmmitAsync(_repository, _userInfo, subjectVisitId); - var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).IfNullThrowException().FullName; + var rootPath = FileStoreHelper.GetIRaCISRootDataFolder(_hostEnvironment); //上传根路径 var _fileStorePath = Path.Combine(rootPath, StaticData.TrialDataFolder);