public void Level_GetterOnRequestCreatedFromCommand_Throws() { var request = new DicomCMoveRequest(new DicomDataset()); var exception = Record.Exception(() => request.Level); Assert.NotNull(exception); }
public void AddSeveralUIDsToQuery() { var e = Record.Exception(() => { var request = new DicomCMoveRequest("DestinationAE", "1.2.3.456"); request.Dataset.Add(DicomTag.SeriesInstanceUID, "1.2.3\\3.4.5"); Assert.Equal(2, request.Dataset.GetValueCount(DicomTag.SeriesInstanceUID)); }); Assert.Null(e); e = Record.Exception(() => { var request = new DicomCMoveRequest("DestinationAE", "1.2.3.456"); request.Dataset.Add(DicomTag.SeriesInstanceUID, "1.2.3", "2.3.4"); Assert.Equal(2, request.Dataset.GetValueCount(DicomTag.SeriesInstanceUID)); }); Assert.Null(e); e = Record.Exception(() => { var request = new DicomCMoveRequest("DestinationAE", "1.2.3.456"); request.Dataset.Add(new DicomUniqueIdentifier(DicomTag.SeriesInstanceUID, "1.2.3", "3.4.5")); Assert.Equal(2, request.Dataset.GetValueCount(DicomTag.SeriesInstanceUID)); }); Assert.Null(e); }
public void CreateQueryWithInvalidUID() { var invalidStudyUID = "1.2.0004"; var e = Record.Exception(() => { var request = new DicomCMoveRequest("DestinationAE", invalidStudyUID); Assert.Equal(invalidStudyUID, request.Dataset.GetSingleValue <string>(DicomTag.StudyInstanceUID)); }); Assert.Null(e); }
public void AddInvalidUIDToQuery() { var invalidStudyUID = "1.2.0004"; var e = Record.Exception(() => { var request = new DicomCMoveRequest("DestinationAE", invalidStudyUID); request.Dataset.AddOrUpdate(DicomTag.SeriesInstanceUID, invalidStudyUID); Assert.Equal(invalidStudyUID, request.Dataset.GetSingleValue <string>(DicomTag.SeriesInstanceUID)); }); Assert.Null(e); }
/// <summary> /// Constructor. Creates Dicom C-MOVE request for given <paramref name="destinationAE"/> and <paramref name="identifier"/>. /// </summary> /// <param name="destinationAE">Application entity of the destination server</param> /// <param name="identifier">Identifier of the object to be moved</param> /// <exception cref="ArgumentNullException"><paramref name="destinationAE"/> is <see langword="null"/> -or- <paramref name="identifier"/> is <see langword="null"/></exception> public FellowOakDicomMoveRequest([NotNull] string destinationAE, [NotNull] InfoIdentifier identifier) { if (destinationAE == null) { throw new ArgumentNullException(nameof(destinationAE)); } if (identifier == null) { throw new ArgumentNullException(nameof(identifier)); } mInnerRequest = new DicomCMoveRequest(destinationAE, identifier.StringRepresentation); }
public DicomCMoveResponse(DicomCMoveRequest request, DicomStatus status) : base(request, status) { }
public void Level_Getter_ReturnsCorrectQueryRetrieveLevel(DicomCMoveRequest request, DicomQueryRetrieveLevel expected) { var actual = request.Level; Assert.Equal(expected, actual); }
public DicomCMoveResponse(DicomCMoveRequest request, DicomStatus status) : base(request, status) { }
static void Main(string[] args) { //开启C-STORE SCP服务,用于接收C-MOVE SCP返回的图像 CStoreSCP.OnCStoreRequestCallBack = (request) => { var studyUid = request.Dataset.Get<string>(DicomTag.StudyInstanceUID); var instUid = request.SOPInstanceUID.UID; var path = Path.GetFullPath(@"c:\cmove-scu"); path = Path.Combine(path, studyUid); if (!Directory.Exists(path)) Directory.CreateDirectory(path); path = Path.Combine(path, instUid) + ".dcm"; request.File.Save(path); return new DicomCStoreResponse(request, DicomStatus.Success); }; var cstoreServer = new DicomServer<CStoreSCP>(22345); //发起C-MOVE-RQ操作,发送请求的StudyID是12 DicomCMoveRequest req=new DicomCMoveRequest("DEST-AE","12"); var client=new DicomClient(); client.NegotiateAsyncOps(); client.AddRequest(req); //这里的IP地址是C-MOVE SCP的地址,12345端口号是C-MOVE SCP提供C-MOVE服务的端口 //在C-MOVE SCP端发出的C-STORE-RQ子操作请求的是C-MOVE SCU端我们实现的C-STORE SCP,C-STORE SCP绑定的端口是22345 client.Send("127.0.0.1", 12345,false, "DEST-AE", "SCP-AE"); Console.ReadLine(); }
public virtual IEnumerable<DicomCMoveResponse> OnCMoveRequest(DicomCMoveRequest request) { DicomStatus status = DicomStatus.Success; IList<DicomCMoveResponse> rsp = new List<DicomCMoveResponse>(); /*----to do------*/ //添加查询数据库的代码,即根据request的条件提取指定的图像 //然后将图像信息添加到rsp响应中 //创建C-STORE-SCU,发起C-STORE-RQ IList<DicomDataset> queries; DicomClient clt = new DicomClient(); if (OnZSCMoveRequest != null) { queries = OnZSCMoveRequest(request); if (queries != null) { Logger.Info("需要发送{0}个数据", queries.Count); int len = queries.Count; int cnt = 0; foreach (var item in queries) { //zssure: //取巧的方法直接利用request来构造response中相同的部分 //这部分与mDCM方式很不同 var studyUid = item.Get<string>(DicomTag.StudyInstanceUID); var instUid = item.Get<string>(DicomTag.SOPInstanceUID); //需要在c:\cmovetest目录下手动添加C-MOVE SCU请求的图像 //本地构造的目录结构为, // c:\cmovetest\12\0.dcm // c:\cmovetest\12\1.dcm // c:\cmovetest\12\2.dcm var path = Path.GetFullPath(@"c:\cmovetest"); try { path = Path.Combine(path, studyUid); if (!Directory.Exists(path)) Directory.CreateDirectory(path); path = Path.Combine(path, instUid) + ".dcm"; DicomCStoreRequest cstorerq = new DicomCStoreRequest(path); cstorerq.OnResponseReceived = (rq, rs) => { if (rs.Status != DicomStatus.Pending) { } if (rs.Status == DicomStatus.Success) { DicomCMoveResponse rsponse = new DicomCMoveResponse(request, DicomStatus.Pending); rsponse.Remaining = --len; rsponse.Completed = ++cnt; rsponse.Warnings = 0; rsponse.Failures = 0; //zssure:2014-12-24 //修复发送C-MOVE-RSP的逻辑错误 SendResponse(rsponse); //rsp.Add(rsponse); //zssure:end } }; clt.AddRequest(cstorerq); //注意:这里给出的IP地址与C-MOVE请求的IP地址相同,意思就是说C-MOVE SCP需要向C-MOVE SCU发送C-STORE-RQ请求 //将查询到的图像返回给C-MOVE SCU //所以四尺C-STORE-RQ中的IP地址与C-MOVE SCU相同,但是端口不同,因为同一个端口不能被绑定多次。 clt.Send("127.0.0.1", 22345, false, this.Association.CalledAE, request.DestinationAE); } catch (System.Exception ex) { DicomCMoveResponse rs = new DicomCMoveResponse(request, DicomStatus.StorageStorageOutOfResources); rsp.Add(rs); return rsp; } } //zssure: //发送完成后统一返回C-MOVE RESPONSE //貌似响应流程有问题,有待进一步核实 //注意,如果最后为发送DicomStatus.Success消息,TCP连接不会释放,浪费资源 rsp.Add(new DicomCMoveResponse(request, DicomStatus.Success)); return rsp; } else { rsp.Add(new DicomCMoveResponse(request, DicomStatus.NoSuchObjectInstance)); return rsp; } } rsp.Add(new DicomCMoveResponse(request, DicomStatus.NoSuchObjectInstance)); return rsp; }