修改一版

Test.EIImageViewer
he 2023-03-09 15:21:12 +08:00
parent 80370e000a
commit cbae1e8d5e
2 changed files with 58 additions and 0 deletions

View File

@ -542,6 +542,34 @@ namespace IRaCIS.Core.API.Controllers
}
/// <summary>
/// 上传截图
/// </summary>
/// <param name="subjectId"></param>
/// <returns></returns>
[HttpPost("Printscreen/UploadPrintscreen/{subjectId:guid}")]
[TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })]
public async Task<IResponseOutput<FileDto>> UploadPrintscreen(Guid subjectId)
{
var subjectInfo = await this._repository.Where<Subject>(x => x.Id == subjectId).FirstNotNullAsync();
FileDto fileDto = new FileDto();
await FileUploadAsync(async (fileName) =>
{
var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetUploadPrintscreenFilePath(_hostEnvironment, fileName, subjectInfo.TrialId, subjectInfo.SiteId, subjectInfo.Id);
fileDto.Path = relativePath;
fileDto.FileName = fileName;
await Task.CompletedTask;
return serverFilePath;
});
return ResponseOutput.Ok(fileDto);
}
/// <summary>
/// 上传Reading问题的图像
/// </summary>

View File

@ -365,6 +365,36 @@ public static class FileStoreHelper
}
/// <summary>
/// 上传截图
/// </summary>
/// <param name="_hostEnvironment"></param>
/// <param name="fileName"></param>
/// <param name="trialId"></param>
/// <param name="siteid"></param>
/// <param name="subjectId"></param>
/// <param name="type"></param>
/// <returns></returns>
public static (string PhysicalPath, string RelativePath, string FileRealName) GetUploadPrintscreenFilePath(IWebHostEnvironment _hostEnvironment, string fileName, Guid trialId, Guid siteid, Guid subjectId)
{
var rootPath = FileStoreHelper.GetIRaCISRootDataFolder(_hostEnvironment);
string uploadFolderPath = Path.Combine(rootPath, StaticData.Folder.TrialDataFolder, trialId.ToString(), siteid.ToString(), subjectId.ToString());
if (!Directory.Exists(uploadFolderPath)) Directory.CreateDirectory(uploadFolderPath);
var (trustedFileNameForFileStorage, fileRealName) = FileStoreHelper.GetStoreFileName(fileName);
var relativePath = $"/{StaticData.Folder.IRaCISDataFolder}/{StaticData.Folder.TrialDataFolder}/{trialId}/{siteid}/{subjectId}/{trustedFileNameForFileStorage}";
var serverFilePath = Path.Combine(uploadFolderPath, trustedFileNameForFileStorage);
return (serverFilePath, relativePath, fileRealName);
}
/// <summary>
/// 通用获取文件路径
/// </summary>