From 58742238662a9352c312f773772793c6097e4de7 Mon Sep 17 00:00:00 2001 From: he <109787524@qq.com> Date: Thu, 3 Apr 2025 09:55:04 +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 | 80 ++++++++++++------- 1 file changed, 51 insertions(+), 29 deletions(-) diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/General/GeneralCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/General/GeneralCalculateService.cs index 8ee63d348..e51495f89 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/General/GeneralCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/General/GeneralCalculateService.cs @@ -23,6 +23,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate IRepository _visitTaskRepository, IRepository _readingQuestionCriterionTrialRepository, ILogger _logger, + IRepository _readingTableQuestionTrialRepository, IRepository _readingTableAnswerRowInfoRepository, IRepository _readingQuestionTrialRepository, @@ -764,42 +765,63 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate public async Task FileDownSave(string url, string savePath) { + #region 新 + try + { + url= url.Replace(_options.CurrentValue.MinIO.ViewEndpoint, ""); + if (!string.IsNullOrWhiteSpace(url)) + { + string[] strArry = url.Split('/'); + savePath = savePath + "/" + strArry[strArry.Length - 1]; + } + await _oSSService.DownLoadFromOSSAsync(url, savePath); - 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]; - // } + #endregion - // 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) - //{ + #region 之前 + 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"]); + } + #endregion - // throw new BusinessValidationFailedException(_localizer["ReadingCalculate_ImageNotExist"]); - //} }