背景:
之前博文对比过多次C-MOVE与C-GET服务的区别,两者最大的区别在于C-GET是基于单个TCP连接的点对点的两方服务,而C-MOVE是基于两个TCP连接的三方服务(详情参见:《DICOM:C-GET与C-MOVE对比剖析》,以及DICOM:C-GET与C-MOVE对比剖析(续))。加之前一篇专栏博文DICOM:DICOM3.0网络通信协议之“开源库实现剖析”也已详细对比了dcm4che和fo-dicom开源库的底层实现,因此本篇博文直接给出基于fo-dicom开源库的C-GET服务实现的主要代码,着重介绍C-GET服务端与C-MOVE服务端发起C-STORE 子操作的区别。
C-GET-SCU:
在fo-dicom开源库中DICOM的各种Client端已经抽象出了DicomClientBase类,针对各种DIMSE-C服务(诸如C-STORE、C-GET、C-MOVE、C-ECHO、C-FIND)唯一不同的就是绑定各自对应的委托即可。C-GET-SCU客户端的核心代码如下:
#region Protected Overrides
protected override void OnConnected()
{
DcmAssociate associate = new DcmAssociate();
byte pcid = associate.AddPresentationContext(_getSopClass);
associate.AddTransferSyntax(pcid, DicomTransferSyntax.ExplicitVRLittleEndian);
associate.AddTransferSyntax(pcid, DicomTransferSyntax.ImplicitVRLittleEndian);
byte pcid2 = associate.AddPresentationContext(DicomUID.CTImageStorage);
associate.AddTransferSyntax(pcid2, DicomTransferSyntax.ExplicitVRLittleEndian);
associate.AddTransferSyntax(pcid2, DicomTransferSyntax.ImplicitVRLittleEndian);
associate.CalledAE = CalledAE;
associate.CallingAE = CallingAE;
associate.MaximumPduLength = MaxPduSize;
//zssure:2015/07/06
//Add UserIdentity Information
//http://medical.nema.org/medical/dicom/current/output/html/part07.html#sect_D.3.3.7
if (userIdentity == null)
SendAssociateRequest(associate);
else
SendAssociateRequest(associate, userIdentity);
//zssure:end,2015/07/06
}
private void PerformQueryOrRelease()
{
if (_getQueries.Count > 0)