修改存储路径

Uat_Study
hang 2022-05-27 16:30:20 +08:00
parent 72d84b18d4
commit b5f09e9774
5 changed files with 26 additions and 9 deletions

View File

@ -197,7 +197,7 @@ namespace IRaCIS.Core.API.Controllers
private void DealCommonStorePath(/*string fileType, string moduleType,*/ string fileRealName, out string serverFilePath, out string relativePath) 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); 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) 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); 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) 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); 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) 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); 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<SubjectVisit> _subjectVisitRepository) private void DealStorePath(Guid subjectVisitId, string realName, UploadFileTypeEnum typeEnum, out string serverFilePath, out string relativePath, IRepository<SubjectVisit> _subjectVisitRepository)
{ {
var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).FullName; var rootPath = FileStoreHelper.GetIRaCISRootDataFolder(_hostEnvironment);
//上传根路径 //上传根路径
var _fileStorePath = Path.Combine(rootPath, StaticData.TrialDataFolder); var _fileStorePath = Path.Combine(rootPath, StaticData.TrialDataFolder);

View File

@ -1,5 +1,8 @@
 
using IRaCIS.Core.Domain.Share;
using Microsoft.AspNetCore.Hosting;
namespace IRaCIS.Core.Application.Helper; namespace IRaCIS.Core.Application.Helper;
public static class FileStoreHelper public static class FileStoreHelper
@ -25,5 +28,18 @@ public static class FileStoreHelper
return (trustedFileNameForFileStorage, fileName); 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;
}
} }

View File

@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Infrastructure.Extention; using IRaCIS.Core.Infrastructure.Extention;
using IRaCIS.Core.Application.Helper;
namespace IRaCIS.Core.Application namespace IRaCIS.Core.Application
{ {
@ -20,7 +21,7 @@ namespace IRaCIS.Core.Application
{ {
_logger = logger; _logger = logger;
_hostEnvironment = hostEnvironment; _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);

View File

@ -58,7 +58,7 @@ namespace IRaCIS.Core.Application.Contracts
{ {
await QCCommonVerify.VerifyIsCRCSubmmitAsync(_repository, _userInfo, subjectVisitId); 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); var _fileStorePath = Path.Combine(rootPath, StaticData.TrialDataFolder);

View File

@ -187,7 +187,7 @@ namespace IRaCIS.Core.Application.Contracts
{ {
await QCCommonVerify.VerifyIsCRCSubmmitAsync(_repository, _userInfo, subjectVisitId); 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); var _fileStorePath = Path.Combine(rootPath, StaticData.TrialDataFolder);