增加c-store-scp
parent
fdba16de86
commit
8cce399430
|
@ -25,8 +25,9 @@ using Microsoft.AspNetCore.HttpOverrides;
|
||||||
using IRaCIS.Application.Services.BackGroundJob;
|
using IRaCIS.Application.Services.BackGroundJob;
|
||||||
using LogDashboard;
|
using LogDashboard;
|
||||||
using OfficeOpenXml.Utils;
|
using OfficeOpenXml.Utils;
|
||||||
|
using FellowOakDicom.Network;
|
||||||
|
using IRaCIS.Core.Application.Service.ImageAndDoc;
|
||||||
|
|
||||||
Console.WriteLine("这是一个示例文本,示例文本中会出现示例多次。".Replace("示例", "替换"));
|
|
||||||
|
|
||||||
#region 获取环境变量
|
#region 获取环境变量
|
||||||
//以配置文件为准,否则 从url中取环境值(服务以命令行传递参数启动,配置文件配置了就不需要传递环境参数)
|
//以配置文件为准,否则 从url中取环境值(服务以命令行传递参数启动,配置文件配置了就不需要传递环境参数)
|
||||||
|
@ -291,6 +292,8 @@ try
|
||||||
//Log.Logger.Warning($"ContentRootPath——GetParent:{Directory.GetParent(env.ContentRootPath).Parent.FullName}");
|
//Log.Logger.Warning($"ContentRootPath——GetParent:{Directory.GetParent(env.ContentRootPath).Parent.FullName}");
|
||||||
//Log.Logger.Warning($"ContentRootPath——xx:{Path.GetDirectoryName(Path.GetDirectoryName(env.ContentRootPath))}");
|
//Log.Logger.Warning($"ContentRootPath——xx:{Path.GetDirectoryName(Path.GetDirectoryName(env.ContentRootPath))}");
|
||||||
|
|
||||||
|
//DicomServerFactory.Create<CStoreSCPService>(11112);
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,132 @@
|
||||||
|
using FellowOakDicom.Network;
|
||||||
|
using FellowOakDicom;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using IRaCIS.Core.Application.Contracts.Dicom;
|
||||||
|
|
||||||
|
namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||||
|
{
|
||||||
|
|
||||||
|
public class CStoreSCPService : DicomService, IDicomServiceProvider, IDicomCStoreProvider, IDicomCEchoProvider
|
||||||
|
{
|
||||||
|
public readonly IDicomArchiveService _dicomArchiveService;
|
||||||
|
|
||||||
|
|
||||||
|
private static readonly DicomTransferSyntax[] _acceptedTransferSyntaxes = new DicomTransferSyntax[]
|
||||||
|
{
|
||||||
|
DicomTransferSyntax.ExplicitVRLittleEndian,
|
||||||
|
DicomTransferSyntax.ExplicitVRBigEndian,
|
||||||
|
DicomTransferSyntax.ImplicitVRLittleEndian
|
||||||
|
};
|
||||||
|
|
||||||
|
private static readonly DicomTransferSyntax[] _acceptedImageTransferSyntaxes = new DicomTransferSyntax[]
|
||||||
|
{
|
||||||
|
// Lossless
|
||||||
|
DicomTransferSyntax.JPEGLSLossless,
|
||||||
|
DicomTransferSyntax.JPEG2000Lossless,
|
||||||
|
DicomTransferSyntax.JPEGProcess14SV1,
|
||||||
|
DicomTransferSyntax.JPEGProcess14,
|
||||||
|
DicomTransferSyntax.RLELossless,
|
||||||
|
// Lossy
|
||||||
|
DicomTransferSyntax.JPEGLSNearLossless,
|
||||||
|
DicomTransferSyntax.JPEG2000Lossy,
|
||||||
|
DicomTransferSyntax.JPEGProcess1,
|
||||||
|
DicomTransferSyntax.JPEGProcess2_4,
|
||||||
|
// Uncompressed
|
||||||
|
DicomTransferSyntax.ExplicitVRLittleEndian,
|
||||||
|
DicomTransferSyntax.ExplicitVRBigEndian,
|
||||||
|
DicomTransferSyntax.ImplicitVRLittleEndian
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
public CStoreSCPService(INetworkStream stream, Encoding fallbackEncoding, ILogger log, DicomServiceDependencies dependencies/*, IDicomArchiveService dicomArchiveService*/)
|
||||||
|
: base(stream, fallbackEncoding, log, dependencies)
|
||||||
|
{
|
||||||
|
//_dicomArchiveService = dicomArchiveService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Task OnReceiveAssociationRequestAsync(DicomAssociation association)
|
||||||
|
{
|
||||||
|
if (association.CalledAE != "STORESCP")
|
||||||
|
{
|
||||||
|
return SendAssociationRejectAsync(
|
||||||
|
DicomRejectResult.Permanent,
|
||||||
|
DicomRejectSource.ServiceUser,
|
||||||
|
DicomRejectReason.CalledAENotRecognized);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var pc in association.PresentationContexts)
|
||||||
|
{
|
||||||
|
if (pc.AbstractSyntax == DicomUID.Verification)
|
||||||
|
{
|
||||||
|
pc.AcceptTransferSyntaxes(_acceptedTransferSyntaxes);
|
||||||
|
}
|
||||||
|
else if (pc.AbstractSyntax.StorageCategory != DicomStorageCategory.None)
|
||||||
|
{
|
||||||
|
pc.AcceptTransferSyntaxes(_acceptedImageTransferSyntaxes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return SendAssociationAcceptAsync(association);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Task OnReceiveAssociationReleaseRequestAsync()
|
||||||
|
{
|
||||||
|
return SendAssociationReleaseResponseAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void OnReceiveAbort(DicomAbortSource source, DicomAbortReason reason)
|
||||||
|
{
|
||||||
|
/* nothing to do here */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void OnConnectionClosed(Exception exception)
|
||||||
|
{
|
||||||
|
/* nothing to do here */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<DicomCStoreResponse> OnCStoreRequestAsync(DicomCStoreRequest request)
|
||||||
|
{
|
||||||
|
var studyUid = request.Dataset.GetSingleValue<string>(DicomTag.StudyInstanceUID).Trim();
|
||||||
|
var instUid = request.SOPInstanceUID.UID;
|
||||||
|
|
||||||
|
var path = Path.GetFullPath(@".\DICOM-Store");
|
||||||
|
|
||||||
|
path = Path.Combine(path, studyUid);
|
||||||
|
|
||||||
|
if (!Directory.Exists(path))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
path = Path.Combine(path, instUid) + ".dcm";
|
||||||
|
|
||||||
|
await request.File.SaveAsync(path);
|
||||||
|
|
||||||
|
return new DicomCStoreResponse(request, DicomStatus.Success);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Task OnCStoreRequestExceptionAsync(string tempFileName, Exception e)
|
||||||
|
{
|
||||||
|
// let library handle logging and error response
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Task<DicomCEchoResponse> OnCEchoRequestAsync(DicomCEchoRequest request)
|
||||||
|
{
|
||||||
|
return Task.FromResult(new DicomCEchoResponse(request, DicomStatus.Success));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -144,7 +144,6 @@ namespace IRaCIS.Core.Application.Contracts
|
||||||
{
|
{
|
||||||
userTypeEnums = new List<UserTypeEnum>() { UserTypeEnum.CRA, UserTypeEnum.ClinicalResearchCoordinator };
|
userTypeEnums = new List<UserTypeEnum>() { UserTypeEnum.CRA, UserTypeEnum.ClinicalResearchCoordinator };
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue