public virtual IEnumerable<DicomCFindResponse> OnCFindRequest(DicomCFindRequest request) { DicomStatus status = DicomStatus.Success; IList<DicomDataset> queries; List<DicomCFindResponse> responses = new List<DicomCFindResponse>(); if (OnZSCFindRequest != null) { //此处通过代理来返回在服务端本机进行的操作结果,也就是DICOM协议中说的匹配查询结果 queries = OnZSCFindRequest(request); if (queries != null) { Logger.Info("查询到{0}个数据", queries.Count); foreach (var item in queries) { //对于每一个查询匹配的结果,都需要有一个单独的C-FIND-RSP消息来返回到请求端 //【注】:每次发送的状态都必须是Pending,表明后续还会继续发送查询结果 DicomCFindResponse rsp = new DicomCFindResponse(request, DicomStatus.Pending); rsp.Dataset = item; responses.Add(rsp); } } else { status = DicomStatus.QueryRetrieveOutOfResources; } } //随后需要发送查询结束的状态,即Success到C-FIND SCU端 responses.Add(new DicomCFindResponse(request, DicomStatus.Success)); //这里貌似是一起将多个response发送出去的?需要后续在研究一下DicomService中的实现代码 //搞清楚具体的发送机制 return responses; }
public async Task OnCFindRequestAsync_ImmediateSuccess_ShouldRespond() { var port = Ports.GetNext(); using (DicomServer.Create <ImmediateSuccessAsyncDicomCFindProvider>(port, logger: _logger.IncludePrefix("DicomServer"))) { var client = new Client.DicomClient("127.0.0.1", port, false, "SCU", "ANY-SCP") { Logger = _logger.IncludePrefix(typeof(DicomClient).Name) }; DicomCFindResponse response = null; DicomRequest.OnTimeoutEventArgs timeout = null; var request = new DicomCFindRequest(DicomQueryRetrieveLevel.Study) { OnResponseReceived = (req, res) => response = res, OnTimeout = (sender, args) => timeout = args }; await client.AddRequestAsync(request).ConfigureAwait(false); await client.SendAsync().ConfigureAwait(false); Assert.NotNull(response); Assert.Equal(DicomStatus.Success, response.Status); Assert.Null(timeout); } }
public void Constructor_ResponseCallbackIsCalled() { // Arrange var mockProvider = new MockProvider(); var fellowOakMockProvider = new FellowOakMockProvider(); var whereCollection = mockProvider.GetWhereCollection(); var infoBuilder = mockProvider.GetDicomInfoBuilderFake(); infoBuilder.BuildInfo<TestInfo>(Arg.Any<object>()).Returns(new TestInfo { PatientID = 666, PatientName = "patientName" }); var response = new DicomCFindResponse(new DicomDataset()) { Dataset = new DicomDataset() }; TestInfo responseItem = null; var responseAction = new Action<TestInfo>(item => { responseItem = item; }); // Act var dicomFindRequest = new FellowOakDicomFindRequest<TestInfo>(mockProvider.GetDicomMappingFake(), fellowOakMockProvider.GetDicomTagAdapterFake(), infoBuilder, mockProvider.GetGeneralizedInfoProviderFake(), fellowOakMockProvider.GetDicomSopClassUidProviderFake(), responseAction, whereCollection.GetDicomWhereCollections().First()); var innerRequest = (DicomCFindRequest)dicomFindRequest.InnerRequest; innerRequest.OnResponseReceived(null, response); // Assert Assert.That(responseItem.PatientID, Is.EqualTo(666)); Assert.That(responseItem.PatientName, Is.EqualTo("patientName")); }
public IEnumerable<DicomCFindResponse> OnCFindRequest(DicomCFindRequest request) { IList<DicomCFindResponse> responses=new List<DicomCFindResponse>(); //固定返回C-FIND-RSP给客户端 for (int i = 0; i < 2; ++i) { DicomCFindResponse response = new DicomCFindResponse(request, DicomStatus.Pending) { Dataset = request.Dataset }; response.Completed = i+100; responses.Add(response); } DicomCFindResponse rsp = new DicomCFindResponse(request, DicomStatus.Success) { Dataset = request.Dataset }; rsp.Completed = 2234; responses.Add(rsp); return responses; }