コード例 #1
0
        public void Level_GetterOnRequestCreatedFromCommand_Throws()
        {
            var request   = new DicomCGetRequest(new DicomDataset());
            var exception = Record.Exception(() => request.Level);

            Assert.NotNull(exception);
        }
コード例 #2
0
        public void AddSeveralUIDsToQuery()
        {
            var e = Record.Exception(() =>
            {
                var request = new DicomCGetRequest("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 DicomCGetRequest("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 DicomCGetRequest("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);
        }
コード例 #3
0
        public void DicomCGetRequest_OneImageInSeries_Received()
        {
            var client = new DicomClient();
            client.Options = new DicomServiceOptions { IgnoreAsyncOps = true };

            var pcs = DicomPresentationContext.GetScpRolePresentationContextsFromStorageUids(
                DicomStorageCategory.Image,
                DicomTransferSyntax.ExplicitVRLittleEndian,
                DicomTransferSyntax.ImplicitVRLittleEndian,
                DicomTransferSyntax.ImplicitVRBigEndian);
            client.AdditionalPresentationContexts.AddRange(pcs);

            DicomDataset dataset = null;
            client.OnCStoreRequest = request =>
                {
                    dataset = request.Dataset;
                    return new DicomCStoreResponse(request, DicomStatus.Success);
                };

            var get = new DicomCGetRequest(
                "1.2.840.113619.2.1.1.322987881.621.736170080.681",
                "1.2.840.113619.2.1.2411.1031152382.365.736169244");

            var handle = new ManualResetEventSlim();
            get.OnResponseReceived = (request, response) =>
            {
                handle.Set();
            };
            client.AddRequest(get);
            client.Send("localhost", 11112, false, "SCU", "COMMON");
            handle.Wait();

            Assert.Equal("RT ANKLE", dataset.Get<string>(DicomTag.StudyDescription));
        }
コード例 #4
0
        public async Task OnCGetRequestAsync_Pending_ShouldRespond()
        {
            var port = Ports.GetNext();

            using (DicomServer.Create <PendingAsyncDicomCGetProvider>(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)
                };

                var responses = new ConcurrentQueue <DicomCGetResponse>();
                DicomRequest.OnTimeoutEventArgs timeout = null;
                var studyInstanceUID = DicomUIDGenerator.GenerateDerivedFromUUID().ToString();
                var request          = new DicomCGetRequest(studyInstanceUID)
                {
                    OnResponseReceived = (req, res) => responses.Enqueue(res),
                    OnTimeout          = (sender, args) => timeout = args
                };

                await client.AddRequestAsync(request).ConfigureAwait(false);

                await client.SendAsync().ConfigureAwait(false);

                Assert.Collection(
                    responses,
                    response1 => Assert.Equal(DicomStatus.Pending, response1.Status),
                    response2 => Assert.Equal(DicomStatus.Pending, response2.Status),
                    response3 => Assert.Equal(DicomStatus.Success, response3.Status)
                    );
                Assert.Null(timeout);
            }
        }
コード例 #5
0
        public void CreateQueryWithInvalidUID()
        {
            var invalidStudyUID = "1.2.0004";
            var e = Record.Exception(() =>
            {
                var request = new DicomCGetRequest(invalidStudyUID, DicomPriority.Medium);
                Assert.Equal(invalidStudyUID, request.Dataset.GetSingleValue <string>(DicomTag.StudyInstanceUID));
            });

            Assert.Null(e);
        }
コード例 #6
0
        public void AddInvalidUIDToQuery()
        {
            var invalidStudyUID = "1.2.0004";
            var e = Record.Exception(() =>
            {
                var request = new DicomCGetRequest(invalidStudyUID, DicomPriority.Medium);
                request.Dataset.AddOrUpdate(DicomTag.SeriesInstanceUID, invalidStudyUID);
                Assert.Equal(invalidStudyUID, request.Dataset.GetSingleValue <string>(DicomTag.SeriesInstanceUID));
            });

            Assert.Null(e);
        }
コード例 #7
0
        public void DicomCGetRequest_PickCTImagesInStudy_OnlyCTImagesRetrieved()
        {
            var client = new DicomClient();

            var pc = DicomPresentationContext.GetScpRolePresentationContext(DicomUID.CTImageStorage);

            client.AdditionalPresentationContexts.Add(pc);

            var counter = 0;
            var locker  = new object();

            client.OnCStoreRequest = request =>
            {
                lock (locker)
                {
                    ++counter;
                }

                return(new DicomCStoreResponse(request, DicomStatus.Success));
            };

            var get = new DicomCGetRequest("1.2.840.113619.2.55.3.2609388324.145.1222836278.84");

            var handle = new ManualResetEventSlim();

            get.OnResponseReceived = (request, response) =>
            {
                if (response.Remaining == 0)
                {
                    handle.Set();
                }
            };
            client.AddRequest(get);
            client.Send("localhost", 11112, false, "SCU", "COMMON");
            handle.Wait();

            Assert.Equal(140, counter);
        }
コード例 #8
0
        public void DicomCGetRequest_OneImageInSeries_Received()
        {
            var client = new DicomClient();

            var pcs = DicomPresentationContext.GetScpRolePresentationContextsFromStorageUids(
                DicomStorageCategory.Image,
                DicomTransferSyntax.ExplicitVRLittleEndian,
                DicomTransferSyntax.ImplicitVRLittleEndian,
                DicomTransferSyntax.ImplicitVRBigEndian);

            client.AdditionalPresentationContexts.AddRange(pcs);

            DicomDataset dataset = null;

            client.OnCStoreRequest = request =>
            {
                dataset = request.Dataset;
                return(new DicomCStoreResponse(request, DicomStatus.Success));
            };

            var get = new DicomCGetRequest(
                "1.2.840.113619.2.1.1.322987881.621.736170080.681",
                "1.2.840.113619.2.1.2411.1031152382.365.736169244");

            var handle = new ManualResetEventSlim();

            get.OnResponseReceived = (request, response) =>
            {
                handle.Set();
            };
            client.AddRequest(get);
            client.Send("localhost", 11112, false, "SCU", "COMMON");
            handle.Wait();

            Assert.Equal("RT ANKLE", dataset.Get <string>(DicomTag.StudyDescription));
        }
コード例 #9
0
        public void DicomCGetRequest_PickCTImagesInStudy_OnlyCTImagesRetrieved()
        {
            var client = new DicomClient();
            client.Options = new DicomServiceOptions { IgnoreAsyncOps = true };

            var pc = DicomPresentationContext.GetScpRolePresentationContext(DicomUID.CTImageStorage);
            client.AdditionalPresentationContexts.Add(pc);

            var counter = 0;
            var locker = new object();
            client.OnCStoreRequest = request =>
            {
                lock (locker)
                {
                    ++counter;
                }

                return new DicomCStoreResponse(request, DicomStatus.Success);
            };

            var get = new DicomCGetRequest("1.2.840.113619.2.55.3.2609388324.145.1222836278.84");

            var handle = new ManualResetEventSlim();
            get.OnResponseReceived = (request, response) =>
            {
                if (response.Remaining == 0)
                {
                    handle.Set();
                }
            };
            client.AddRequest(get);
            client.Send("localhost", 11112, false, "SCU", "COMMON");
            handle.Wait();

            Assert.Equal(140, counter);
        }
コード例 #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DicomCGetResponse"/> class.
 /// </summary>
 /// <param name="request">
 /// The C-GET request associated with the response.
 /// </param>
 /// <param name="status">
 /// The status of the response.
 /// </param>
 public DicomCGetResponse(DicomCGetRequest request, DicomStatus status)
     : base(request, status)
 {
 }
コード例 #11
0
        public void Level_Getter_ReturnsCorrectQueryRetrieveLevel(DicomCGetRequest request, DicomQueryRetrieveLevel expected)
        {
            var actual = request.Level;

            Assert.Equal(expected, actual);
        }
コード例 #12
0
ファイル: DicomCGetResponse.cs プロジェクト: aerik/fo-dicom
 /// <summary>
 /// Initializes a new instance of the <see cref="DicomCGetResponse"/> class.
 /// </summary>
 /// <param name="request">
 /// The C-GET request associated with the response.
 /// </param>
 /// <param name="status">
 /// The status of the response.
 /// </param>
 public DicomCGetResponse(DicomCGetRequest request, DicomStatus status)
     : base(request, status)
 {
 }
コード例 #13
0
        public async Task <IEnumerable <Task <DicomCGetResponse> > > OnCGetRequestAsync(DicomCGetRequest request)
        {
            return(InnerOnCGetRequestAsync());

            IEnumerable <Task <DicomCGetResponse> > InnerOnCGetRequestAsync()
            {
                yield return(Task.FromResult(new DicomCGetResponse(request, DicomStatus.Pending)));

                yield return(Task.FromResult(new DicomCGetResponse(request, DicomStatus.Pending)));

                yield return(Task.FromResult(new DicomCGetResponse(request, DicomStatus.Success)));
            }
        }