Test_HIR_Net8
he 2025-04-03 09:20:22 +08:00
parent 20718bca5d
commit a5b4ab6531
1 changed files with 35 additions and 29 deletions

View File

@ -31,7 +31,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
IRepository<TumorAssessment_RECIST1Point1> _tumorAssessmentRepository, IRepository<TumorAssessment_RECIST1Point1> _tumorAssessmentRepository,
IRepository<ReadingTaskQuestionAnswer> _readingTaskQuestionAnswerRepository, IRepository<ReadingTaskQuestionAnswer> _readingTaskQuestionAnswerRepository,
IRepository<InspectionFile> _inspectionFileRepository, IRepository<InspectionFile> _inspectionFileRepository,
IOSSService oSSService, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, IGeneralCalculateService IOSSService _oSSService, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, IGeneralCalculateService
{ {
@ -78,7 +78,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
try try
{ {
var ossRelativePath = await oSSService.UploadToOSSAsync(fileStream, "InspectionUpload/"+ pathCode, file.FileName); var ossRelativePath = await _oSSService.UploadToOSSAsync(fileStream, "InspectionUpload/"+ pathCode, file.FileName);
await _inspectionFileRepository.AddAsync(new InspectionFile() { FileName = file.FileName, RelativePath = ossRelativePath, TrialId = trialId }); await _inspectionFileRepository.AddAsync(new InspectionFile() { FileName = file.FileName, RelativePath = ossRelativePath, TrialId = trialId });
} }
catch (Exception) catch (Exception)
@ -763,37 +763,43 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
/// <returns><placeholder>A <see cref="Task"/> /// <returns><placeholder>A <see cref="Task"/>
public async Task<string> FileDownSave(string url, string savePath) public async Task<string> FileDownSave(string url, string savePath)
{ {
try
{
HttpClient httpClient = new HttpClient();
if (!string.IsNullOrWhiteSpace(url))
{
string[] strArry = url.Split('/');
savePath = savePath + "/" + strArry[strArry.Length - 1];
}
var t = httpClient.GetByteArrayAsync(url);
t.Wait();
Stream responseStream = new MemoryStream(t.Result);
Stream stream = new FileStream(savePath, FileMode.Create);
byte[] bArr = new byte[1024];
int size = responseStream.Read(bArr, 0, bArr.Length);
while (size > 0)
{
stream.Write(bArr, 0, size);
size = responseStream.Read(bArr, 0, bArr.Length);
}
stream.Close(); await _oSSService.DownLoadFromOSSAsync(url, savePath);
responseStream.Close();
return savePath; return savePath;
}
catch (Exception)
{
throw new BusinessValidationFailedException(_localizer["ReadingCalculate_ImageNotExist"]); //try
} //{
// HttpClient httpClient = new HttpClient();
// if (!string.IsNullOrWhiteSpace(url))
// {
// string[] strArry = url.Split('/');
// savePath = savePath + "/" + strArry[strArry.Length - 1];
// }
// var t = httpClient.GetByteArrayAsync(url);
// t.Wait();
// Stream responseStream = new MemoryStream(t.Result);
// Stream stream = new FileStream(savePath, FileMode.Create);
// byte[] bArr = new byte[1024];
// int size = responseStream.Read(bArr, 0, bArr.Length);
// while (size > 0)
// {
// stream.Write(bArr, 0, size);
// size = responseStream.Read(bArr, 0, bArr.Length);
// }
// stream.Close();
// responseStream.Close();
// return savePath;
//}
//catch (Exception)
//{
// throw new BusinessValidationFailedException(_localizer["ReadingCalculate_ImageNotExist"]);
//}
} }