From a5b4ab65318565fb69b01be2d798e68fe2b6aada Mon Sep 17 00:00:00 2001 From: he <109787524@qq.com> Date: Thu, 3 Apr 2025 09:20:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../General/GeneralCalculateService.cs | 64 ++++++++++--------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/General/GeneralCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/General/GeneralCalculateService.cs index 6fbbe51bb..8ee63d348 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/General/GeneralCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/General/GeneralCalculateService.cs @@ -31,7 +31,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate IRepository _tumorAssessmentRepository, IRepository _readingTaskQuestionAnswerRepository, IRepository _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 { - 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 }); } catch (Exception) @@ -763,37 +763,43 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate /// A public async Task 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(); - responseStream.Close(); + await _oSSService.DownLoadFromOSSAsync(url, savePath); - return savePath; - } - catch (Exception) - { + return savePath; - 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"]); + //} }