修改
continuous-integration/drone/push Build is passing Details

Test_HIR_Net8
he 2025-04-03 09:55:04 +08:00
parent d5609560e2
commit 5874223866
1 changed files with 51 additions and 29 deletions

View File

@ -23,6 +23,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
IRepository<VisitTask> _visitTaskRepository,
IRepository<ReadingQuestionCriterionTrial> _readingQuestionCriterionTrialRepository,
ILogger<GeneralCalculateService> _logger,
IRepository<ReadingTableQuestionTrial> _readingTableQuestionTrialRepository,
IRepository<ReadingTableAnswerRowInfo> _readingTableAnswerRowInfoRepository,
IRepository<ReadingQuestionTrial> _readingQuestionTrialRepository,
@ -764,42 +765,63 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
public async Task<string> 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"]);
//}
}