修改接收服务多帧判断
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
78597d6866
commit
8ad11f018b
|
|
@ -1,34 +1,35 @@
|
||||||
using FellowOakDicom.Network;
|
using FellowOakDicom;
|
||||||
using FellowOakDicom;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Hosting;
|
|
||||||
using IRaCIS.Core.SCP.Service;
|
|
||||||
using IRaCIS.Core.Domain.Models;
|
|
||||||
using IRaCIS.Core.Infra.EFCore;
|
|
||||||
using Medallion.Threading;
|
|
||||||
using IRaCIS.Core.Domain.Share;
|
|
||||||
using Serilog;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using System.Data;
|
|
||||||
using FellowOakDicom.Imaging;
|
using FellowOakDicom.Imaging;
|
||||||
using SharpCompress.Common;
|
|
||||||
using SixLabors.ImageSharp.Formats.Jpeg;
|
|
||||||
using IRaCIS.Core.Infrastructure;
|
|
||||||
using IRaCIS.Core.Infrastructure.Extention;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using FellowOakDicom.Imaging.Codec;
|
using FellowOakDicom.Imaging.Codec;
|
||||||
using FellowOakDicom.IO.Buffer;
|
using FellowOakDicom.IO.Buffer;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using FellowOakDicom.Network;
|
||||||
using FellowOakDicom.Network.Client;
|
using FellowOakDicom.Network.Client;
|
||||||
|
using IRaCIS.Core.Domain.Models;
|
||||||
|
using IRaCIS.Core.Domain.Share;
|
||||||
|
using IRaCIS.Core.Infra.EFCore;
|
||||||
|
using IRaCIS.Core.Infrastructure;
|
||||||
|
using IRaCIS.Core.Infrastructure.Extention;
|
||||||
|
using IRaCIS.Core.SCP.Service;
|
||||||
using MassTransit.Futures.Contracts;
|
using MassTransit.Futures.Contracts;
|
||||||
|
using Medallion.Threading;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
using Microsoft.Identity.Client;
|
using Microsoft.Identity.Client;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Serilog;
|
||||||
|
using SharpCompress.Common;
|
||||||
|
using SixLabors.ImageSharp.Formats.Jpeg;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace IRaCIS.Core.SCP.Service
|
namespace IRaCIS.Core.SCP.Service
|
||||||
{
|
{
|
||||||
|
|
@ -472,6 +473,12 @@ namespace IRaCIS.Core.SCP.Service
|
||||||
ms.Position = 0;
|
ms.Position = 0;
|
||||||
var dicomFile = DicomFile.Open(ms);
|
var dicomFile = DicomFile.Open(ms);
|
||||||
|
|
||||||
|
var numberOfFrames = dicomFile.Dataset.GetSingleValueOrDefault(DicomTag.NumberOfFrames, 1);
|
||||||
|
|
||||||
|
//多帧处理逻辑
|
||||||
|
if(numberOfFrames > 1)
|
||||||
|
{
|
||||||
|
//一定要有像素数据才处理
|
||||||
var pixelData = DicomPixelData.Create(dicomFile.Dataset);
|
var pixelData = DicomPixelData.Create(dicomFile.Dataset);
|
||||||
|
|
||||||
if (pixelData != null)
|
if (pixelData != null)
|
||||||
|
|
@ -479,14 +486,14 @@ namespace IRaCIS.Core.SCP.Service
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Log.Logger.Warning($"CallingAE:{Association.CallingAE} CalledAE:{Association.CalledAE} 开始处理多帧instanceId:{instanceId}");
|
||||||
|
|
||||||
var syntax = pixelData.Syntax;
|
var syntax = pixelData.Syntax;
|
||||||
|
|
||||||
// 每个 fragment 固定大小 (64KB 示例,可以自己调整)
|
// 每个 fragment 固定大小 (64KB 示例,可以自己调整)
|
||||||
int fragmentSize = 20 * 1024;
|
int fragmentSize = 20 * 1024;
|
||||||
|
|
||||||
var numberOfFrames = dicomFile.Dataset.GetSingleValueOrDefault(DicomTag.NumberOfFrames, 1);
|
|
||||||
|
|
||||||
var frag = dicomFile.Dataset.GetDicomItem<DicomOtherByteFragment>(DicomTag.PixelData);
|
var frag = dicomFile.Dataset.GetDicomItem<DicomOtherByteFragment>(DicomTag.PixelData);
|
||||||
|
|
||||||
|
|
@ -559,7 +566,7 @@ namespace IRaCIS.Core.SCP.Service
|
||||||
//Console.WriteLine(newOffsetTable.ToJsonStr());
|
//Console.WriteLine(newOffsetTable.ToJsonStr());
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 暂时废弃
|
#region 最终使用
|
||||||
|
|
||||||
for (int n = 0; n < pixelData.NumberOfFrames; n++)
|
for (int n = 0; n < pixelData.NumberOfFrames; n++)
|
||||||
{
|
{
|
||||||
|
|
@ -667,6 +674,7 @@ namespace IRaCIS.Core.SCP.Service
|
||||||
|
|
||||||
// 重新保存 DICOM 到流
|
// 重新保存 DICOM 到流
|
||||||
ms.SetLength(0);
|
ms.SetLength(0);
|
||||||
|
|
||||||
dicomFile.Save(ms);
|
dicomFile.Save(ms);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -677,6 +685,10 @@ namespace IRaCIS.Core.SCP.Service
|
||||||
Log.Logger.Warning($"CallingAE:{Association.CallingAE} CalledAE:{Association.CalledAE} 处理多帧失败,上传原始文件:{mutiEx.ToString()}");
|
Log.Logger.Warning($"CallingAE:{Association.CallingAE} CalledAE:{Association.CalledAE} 处理多帧失败,上传原始文件:{mutiEx.ToString()}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue