minio 底层下载流 增加日志提示
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
4c11dd203c
commit
b3976783df
|
|
@ -5,6 +5,7 @@ using ExcelDataReader;
|
|||
using FellowOakDicom;
|
||||
using FellowOakDicom.Imaging;
|
||||
using FellowOakDicom.IO.Buffer;
|
||||
using FellowOakDicom.Media;
|
||||
using Hangfire.Storage;
|
||||
using IRaCIS.Application.Contracts;
|
||||
using IRaCIS.Application.Interfaces;
|
||||
|
|
@ -1050,25 +1051,27 @@ namespace IRaCIS.Core.API.Controllers
|
|||
|
||||
// ---------- DICOMDIR ----------
|
||||
var dicomDirPath = $"{patient.PatientIdStr}/{studyTime}_{modalitysStr}/DICOMDIR";
|
||||
var dicomDirEntry = zip.CreateEntry(dicomDirPath, CompressionLevel.Fastest);
|
||||
|
||||
Log.Logger.Warning($"DIRPath: {study.StudyDIRPath}");
|
||||
|
||||
if (study.StudyDIRPath.IsNotNullOrEmpty())
|
||||
{
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
await using (var entryStream = dicomDirEntry.Open())
|
||||
|
||||
await using (var dirStream = await _oSSService.GetStreamFromOSSAsync(study.StudyDIRPath))
|
||||
{
|
||||
var dicomDirEntry = zip.CreateEntry(dicomDirPath, CompressionLevel.Fastest);
|
||||
|
||||
await using var entryStream = dicomDirEntry.Open();
|
||||
|
||||
await dirStream.CopyToAsync(entryStream, 32 * 1024, abortToken);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Logger.Warning($"处理文件DIR{study.StudyDIRPath}失败: {ex.Message}");
|
||||
Log.Logger.Warning($"处理文件{study.StudyCode}DIR失败: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1083,7 +1086,7 @@ namespace IRaCIS.Core.API.Controllers
|
|||
try
|
||||
{
|
||||
//当前完成大小
|
||||
receivedSize = receivedSize + instance.FileSize ?? 0;
|
||||
receivedSize += instance.FileSize ?? 0;
|
||||
receivedCount++;
|
||||
|
||||
|
||||
|
|
@ -1091,9 +1094,7 @@ namespace IRaCIS.Core.API.Controllers
|
|||
$"{patient.PatientIdStr}/{studyTime}_{modalitysStr}/IMAGE/{instance.FileName}";
|
||||
|
||||
var entry = zip.CreateEntry(entryPath, CompressionLevel.Fastest);
|
||||
|
||||
await using var entryStream = entry.Open();
|
||||
await using var source = await _oSSService.GetStreamFromOSSAsync(instance.Path);
|
||||
|
||||
if (instance.IsEncapsulated && instance.NumberOfFrames > 1)
|
||||
{
|
||||
|
|
@ -1165,20 +1166,17 @@ namespace IRaCIS.Core.API.Controllers
|
|||
|
||||
if (!ok)
|
||||
{
|
||||
await using var source2 = await _oSSService.GetStreamFromOSSAsync(instance.Path);
|
||||
await source2.CopyToAsync(entryStream, 32 * 1024, abortToken);
|
||||
await using var source = await _oSSService.GetStreamFromOSSAsync(instance.Path);
|
||||
await source.CopyToAsync(entryStream, 32 * 1024, abortToken);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
await using var source = await _oSSService.GetStreamFromOSSAsync(instance.Path);
|
||||
await source.CopyToAsync(entryStream, 32 * 1024, abortToken);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -1403,7 +1401,7 @@ namespace IRaCIS.Core.API.Controllers
|
|||
try
|
||||
{
|
||||
//当前完成大小
|
||||
receivedSize = receivedSize + instance.FileSize ?? 0;
|
||||
receivedSize += instance.FileSize ?? 0;
|
||||
receivedCount++;
|
||||
|
||||
|
||||
|
|
@ -1625,7 +1623,7 @@ namespace IRaCIS.Core.API.Controllers
|
|||
try
|
||||
{
|
||||
//当前完成大小
|
||||
receivedSize = receivedSize + instance.FileSize ?? 0;
|
||||
receivedSize += instance.FileSize ?? 0;
|
||||
receivedCount++;
|
||||
|
||||
|
||||
|
|
@ -1847,7 +1845,7 @@ namespace IRaCIS.Core.API.Controllers
|
|||
try
|
||||
{
|
||||
//当前完成大小
|
||||
receivedSize = receivedSize + instance.FileSize ?? 0;
|
||||
receivedSize += instance.FileSize ?? 0;
|
||||
receivedCount++;
|
||||
|
||||
|
||||
|
|
@ -2078,19 +2076,21 @@ namespace IRaCIS.Core.API.Controllers
|
|||
|
||||
// ---------- DICOMDIR ----------
|
||||
var dicomDirPath = $"{visit.SubjectCode}_{visit.VisitName}/{studyTime}_{modalitysStr}/DICOMDIR";
|
||||
var dicomDirEntry = zip.CreateEntry(dicomDirPath, CompressionLevel.Fastest);
|
||||
|
||||
Log.Logger.Warning($"DIRPath: {study.StudyDIRPath}");
|
||||
|
||||
if (study.StudyDIRPath.IsNotNullOrEmpty())
|
||||
{
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
await using (var entryStream = dicomDirEntry.Open())
|
||||
|
||||
await using (var dirStream = await _oSSService.GetStreamFromOSSAsync(study.StudyDIRPath))
|
||||
{
|
||||
var dicomDirEntry = zip.CreateEntry(dicomDirPath, CompressionLevel.Fastest);
|
||||
|
||||
await using var entryStream = dicomDirEntry.Open();
|
||||
|
||||
await dirStream.CopyToAsync(entryStream, 32 * 1024, abortToken);
|
||||
}
|
||||
}
|
||||
|
|
@ -2111,17 +2111,17 @@ namespace IRaCIS.Core.API.Controllers
|
|||
try
|
||||
{
|
||||
//当前完成大小
|
||||
receivedSize = receivedSize + instance.FileSize ?? 0;
|
||||
receivedSize += instance.FileSize ?? 0;
|
||||
receivedCount++;
|
||||
|
||||
|
||||
var entryPath =
|
||||
$"{visit.SubjectCode}_{visit.VisitName}/{studyTime}_{modalitysStr}/IMAGE/{instance.FileName}";
|
||||
|
||||
var entry = zip.CreateEntry(entryPath, CompressionLevel.Fastest);
|
||||
|
||||
|
||||
var entry = zip.CreateEntry(entryPath, CompressionLevel.Fastest);
|
||||
await using var entryStream = entry.Open();
|
||||
await using var source = await _oSSService.GetStreamFromOSSAsync(instance.Path);
|
||||
|
||||
|
||||
if (instance.IsEncapsulated && instance.NumberOfFrames > 1)
|
||||
|
|
@ -2194,17 +2194,20 @@ namespace IRaCIS.Core.API.Controllers
|
|||
|
||||
if (!ok)
|
||||
{
|
||||
await using var source = await _oSSService.GetStreamFromOSSAsync(instance.Path);
|
||||
await source.CopyToAsync(entryStream, 32 * 1024, abortToken);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
await using var source = await _oSSService.GetStreamFromOSSAsync(instance.Path);
|
||||
await source.CopyToAsync(entryStream, 32 * 1024, abortToken);
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
failedCount++;
|
||||
|
||||
Log.Logger.Warning($"处理文件{instance.Path}失败: {ex.Message}");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -551,9 +551,9 @@ public class OSSService : IOSSService
|
|||
var args = new GetObjectArgs()
|
||||
.WithBucket(minIOConfig.BucketName)
|
||||
.WithObject(ossRelativePath)
|
||||
.WithCallbackStream( stream =>
|
||||
.WithCallbackStream(async stream =>
|
||||
{
|
||||
stream.CopyTo(pipe.Writer.AsStream());
|
||||
await stream.CopyToAsync(pipe.Writer.AsStream());
|
||||
});
|
||||
|
||||
await minioClient.GetObjectAsync(args);
|
||||
|
|
@ -561,10 +561,12 @@ public class OSSService : IOSSService
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"minio 获取流错误:{ex.Message}");
|
||||
await pipe.Writer.CompleteAsync(ex);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return pipe.Reader.AsStream();
|
||||
|
||||
#region 废弃
|
||||
|
|
|
|||
Loading…
Reference in New Issue