From a19ba3c21542793df68b66e7dcb70b967d0274a8 Mon Sep 17 00:00:00 2001
From: hang <872297557@qq.com>
Date: Fri, 29 Aug 2025 11:36:27 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86scp=E6=9C=8D=E5=8A=A1=20?=
=?UTF-8?q?=E6=8B=86=E5=88=86=E5=BD=B1=E5=83=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
IRC.Core.SCP/Service/CStoreSCPService.cs | 59 ++++++++++++++++++-
.../IRaCIS.Core.Application.xml | 2 +-
2 files changed, 59 insertions(+), 2 deletions(-)
diff --git a/IRC.Core.SCP/Service/CStoreSCPService.cs b/IRC.Core.SCP/Service/CStoreSCPService.cs
index aea8f9e32..19a47ac0a 100644
--- a/IRC.Core.SCP/Service/CStoreSCPService.cs
+++ b/IRC.Core.SCP/Service/CStoreSCPService.cs
@@ -24,6 +24,8 @@ using IRaCIS.Core.Infrastructure;
using IRaCIS.Core.Infrastructure.Extention;
using Newtonsoft.Json;
using FellowOakDicom.Imaging.Codec;
+using FellowOakDicom.IO.Buffer;
+using System.Diagnostics.CodeAnalysis;
namespace IRaCIS.Core.SCP.Service
{
@@ -237,7 +239,7 @@ namespace IRaCIS.Core.SCP.Service
}
else
{
- Log.Logger.Error($"未找到{g.Key.StudyInstanceUid}的Cmove记录");
+ Log.Logger.Warning($"未找到{g.Key.StudyInstanceUid}的Cmove记录");
}
}
@@ -319,6 +321,7 @@ namespace IRaCIS.Core.SCP.Service
long fileSize = 0;
+
try
{
@@ -326,7 +329,61 @@ namespace IRaCIS.Core.SCP.Service
{
await request.File.SaveAsync(ms);
+ #region 1帧拆成多个固定大小的,方便移动端浏览
+ // 回到开头,读取 dicom
+ ms.Position = 0;
+ var dicomFile = DicomFile.Open(ms);
+
+ var pixelData = DicomPixelData.Create(dicomFile.Dataset);
+ var syntax = pixelData.Syntax;
+
+ // 每个 fragment 固定大小 (64KB 示例,可以自己调整)
+ int fragmentSize = 20 * 1024;
+
+ if (syntax.IsEncapsulated)
+ {
+ var newFragments = new DicomOtherByteFragment(DicomTag.PixelData);
+
+ for (int n = 0; n < pixelData.NumberOfFrames; n++)
+ {
+ var frameData = pixelData.GetFrame(n); // 获取完整一帧
+ var data = frameData.Data;
+ int offset = 0;
+
+ while (offset < data.Length)
+ {
+ int size = Math.Min(fragmentSize, data.Length - offset);
+ var buffer = new byte[size];
+ Buffer.BlockCopy(data, offset, buffer, 0, size);
+
+ newFragments.Fragments.Add(new MemoryByteBuffer(buffer));
+ offset += size;
+ }
+ }
+
+ // 替换原 PixelData
+ dicomFile.Dataset.AddOrUpdate(newFragments);
+ }
+
+ // 重新保存 dicom 到流
+ ms.SetLength(0);
+ dicomFile.Save(ms);
+ ms.Position = 0;
+
+ #endregion
+
+
+ #region 本地测试
+ //// --- 保存到本地文件测试 ---
+ //var localPath = @"D:\TestDicom.dcm";
+ //using (var fs = new FileStream(localPath, FileMode.Create, FileAccess.Write))
+ //{
+ // ms.CopyTo(fs);
+ //}
+ //return new DicomCStoreResponse(request, DicomStatus.Success);
+
+ #endregion
//irc 从路径最后一截取Guid
diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
index 94b5168e3..a6f8a7ba2 100644
--- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
+++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
@@ -13604,7 +13604,7 @@
-
+
GA用户列表