コード例 #1
0
        public async Task AcceptStoreContexts()
        {
            int port = Ports.GetNext();

            using (DicomServer.Create <AcceptOnlyEchoStoreProvider>(port))
            {
                var         echoReq    = new DicomCEchoRequest();
                DicomStatus echoStatus = DicomStatus.Pending;
                echoReq.OnResponseReceived += (req, resp) => echoStatus = resp.Status;

                var         storeReq    = new DicomCStoreRequest(@".\Test Data\CT1_J2KI");
                DicomStatus storeStatus = DicomStatus.Pending;
                storeReq.OnResponseReceived += (req, resp) => storeStatus = resp.Status;

                var         filmSession = new FilmSession(DicomUID.BasicFilmSession, DicomUID.Generate());
                var         printReq    = new DicomNCreateRequest(filmSession.SOPClassUID, filmSession.SOPInstanceUID);
                DicomStatus printStatus = DicomStatus.Pending;
                printReq.OnResponseReceived += (req, resp) => printStatus = resp.Status;

                var client = new Client.DicomClient("127.0.0.1", port, false, "SCU", "ANY-SCP");
                await client.AddRequestsAsync(echoReq, storeReq, printReq);

                await client.SendAsync();

                Assert.Equal(DicomStatus.Success, echoStatus);
                Assert.Equal(DicomStatus.Success, storeStatus);
                Assert.Equal(DicomStatus.SOPClassNotSupported, printStatus);
            }
        }
コード例 #2
0
 public DicomResponse(DicomMessage request, DicomStatus status) : base()
 {
     Type             = (DicomCommandField)(0x8000 | (int)request.Type);
     SOPClassUID      = request.SOPClassUID;
     RequestMessageID = request.MessageID;
     Status           = status;
 }
コード例 #3
0
        public void Lookup_MaskedEntryExists_LooksUpCorrectValue()
        {
            var testStatus = DicomStatus.PrintManagementFilmBoxEmptyPage;
            var status     = DicomStatus.Lookup(testStatus.Code);

            Assert.True(status.Code == testStatus.Code);
        }
コード例 #4
0
		public DicomResponse(DicomMessage request, DicomStatus status) : base() {
			Type = (DicomCommandField)(0x8000 | (int)request.Type);
			SOPClassUID = request.SOPClassUID;
			RequestMessageID = request.MessageID;
			Status = status;
			abstractSyntaxUID = request.abstractSyntaxUID;
		}
コード例 #5
0
ファイル: DicomServerTest.cs プロジェクト: fo-dicom/fo-dicom
        public void Send_PrivateRegisteredSOPClass_SendSucceeds()
        {
            var uid = new DicomUID("1.1.1.1", "Private Fo-Dicom Storage", DicomUidType.SOPClass);

            DicomUID.Register(uid);
            var ds = new DicomDataset(
                new DicomUniqueIdentifier(DicomTag.SOPClassUID, uid),
                new DicomUniqueIdentifier(DicomTag.SOPInstanceUID, "1.2.3.4.5"));

            var port = Ports.GetNext();

            using (DicomServer.Create <SimpleCStoreProvider>(port))
            {
                DicomStatus status  = null;
                var         request = new DicomCStoreRequest(new DicomFile(ds))
                {
                    OnResponseReceived = (req, res) => status = res.Status
                };

                var client = new DicomClient();
                client.AddRequest(request);

                client.Send("127.0.0.1", port, false, "SCU", "ANY-SCP");

                Assert.Equal(DicomStatus.Success, status);
            }
        }
コード例 #6
0
ファイル: DicomResponse.cs プロジェクト: vdrm/fo-dicom
 public DicomResponse(DicomMessage request, DicomStatus status)
     : base()
 {
     Type = (DicomCommandField)(0x8000 | (int)request.Type);
     AffectedSOPClassUID = request.AffectedSOPClassUID;
     RequestMessageID = request.MessageID;
     Status = status;
 }
コード例 #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DicomResponse"/> class.
        /// </summary>
        /// <param name="request">
        /// The request initiating the response.
        /// </param>
        /// <param name="status">
        /// Response status.
        /// </param>
        protected DicomResponse(DicomRequest request, DicomStatus status)
        {
            PresentationContext = request.PresentationContext;

            Type             = (DicomCommandField)(0x8000 | (int)request.Type);
            SOPClassUID      = request.SOPClassUID;
            RequestMessageID = request.MessageID;
            Status           = status;
        }
コード例 #8
0
ファイル: DicomResponse.cs プロジェクト: dremerdt/fo-dicom
		public DicomResponse(DicomMessage request, DicomStatus status) : base() {

            PresentationContext = request.PresentationContext;

			Type = (DicomCommandField)(0x8000 | (int)request.Type);
			SOPClassUID = request.SOPClassUID;
			RequestMessageID = request.MessageID;
			Status = status;
		}
コード例 #9
0
        public void ErrorCommentIsThereForFailure()
        {
            var rsp = new DicomResponse(new DicomDataset());

            var failure = new DicomStatus("FF01", DicomState.Failure, "Failed", "Comment on the failure mode");

            rsp.Status = failure;

            Assert.True(rsp.Command.Contains(DicomTag.ErrorComment));
        }
コード例 #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DicomNEventReportResponse"/> class.
        /// </summary>
        /// <param name="request">
        /// The request associated with the N-EVENTREPORT response.
        /// </param>
        /// <param name="status">
        /// The response status.
        /// </param>
        public DicomNEventReportResponse(DicomNEventReportRequest request, DicomStatus status)
            : base(request, status)
        {
            if (request.HasSOPInstanceUID)
            {
                this.SOPInstanceUID = request.SOPInstanceUID;
            }

            this.EventTypeID = request.EventTypeID;
        }
コード例 #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DicomNActionResponse"/> class.
        /// </summary>
        /// <param name="request">
        /// The associated N-ACTION request.
        /// </param>
        /// <param name="status">
        /// The response status.
        /// </param>
        public DicomNActionResponse(DicomNActionRequest request, DicomStatus status)
            : base(request, status)
        {
            if (request.HasSOPInstanceUID)
            {
                this.SOPInstanceUID = request.SOPInstanceUID;
            }

            this.ActionTypeID = request.ActionTypeID;
        }
コード例 #12
0
ファイル: DicomStatus.cs プロジェクト: yuya-goojooob/fo-dicom
 /// <summary>
 /// Initializes a new instance of the <see cref="DicomStatus"/> class.
 /// </summary>
 internal DicomStatus(ushort code, DicomStatus baseStatus)
 {
     // set the code given by param code...
     Code = code;
     // ... and copy all other values from baseStatus
     Description  = baseStatus.Description;
     ErrorComment = baseStatus.ErrorComment;
     Mask         = baseStatus.Mask;
     State        = baseStatus.State;
 }
コード例 #13
0
        public void Lookup_WithWarning_ReturnsCorrectStatusClass()
        {
            var statusTest = DicomStatus.Lookup(UPSIsAlreadyCompleted.Code);

            // Code B306 is not in the known list. So the DicomStatus.Lookup shall return
            // the original code, but a status and Description that matches best one of
            // the known states.
            Assert.Equal(UPSIsAlreadyCompleted.State, statusTest.State);
            Assert.Equal(UPSIsAlreadyCompleted.Code, statusTest.Code);
            Assert.NotEqual(UPSIsAlreadyCompleted.Description, statusTest.Description);
        }
コード例 #14
0
        public void StatusSetter_ChangesFromStatusWithCommentToWithout_UpdatesErrorComment()
        {
            var           comment = "This is a comment";
            DicomResponse x       = new DicomNActionResponse(new DicomDataset());
            var           status  = new DicomStatus(
                "C303",
                DicomState.Failure,
                "Refused: The UPS may only become SCHEDULED via N-CREATE, not N-SET or N-ACTION",
                comment);

            x.Status = status;
            Assert.Equal(x.Command.Get <string>(DicomTag.ErrorComment), comment);

            x.Status = DicomStatus.Success;
            Assert.False(x.Command.Contains(DicomTag.ErrorComment));
        }
コード例 #15
0
 public void AddKnownDicomStatuses_WithFailure_IsLookedupCorrectly()
 {
     try
     {
         DicomStatus.AddKnownDicomStatuses(new[] { UPSIsAlreadyCompleted, SOPInstanceDoesNotExist });
         var upsCompleteTest = DicomStatus.Lookup(UPSIsAlreadyCompleted.Code);
         Assert.Equal(UPSIsAlreadyCompleted, upsCompleteTest);
         Assert.Equal(UPSIsAlreadyCompleted.Code, upsCompleteTest.Code);
         Assert.Equal(UPSIsAlreadyCompleted.Description, upsCompleteTest.Description);
         var sopDoesNotExistTest = DicomStatus.Lookup(UPSIsAlreadyCompleted.Code);
         Assert.Equal(UPSIsAlreadyCompleted, sopDoesNotExistTest);
         Assert.Equal(UPSIsAlreadyCompleted.Code, sopDoesNotExistTest.Code);
         Assert.Equal(UPSIsAlreadyCompleted.Description, sopDoesNotExistTest.Description);
     }
     finally
     {
         DicomStatus.ResetEntries();
     }
 }
コード例 #16
0
        public void Send_Ipv6AnyListenerKnownSOPClass_SendSucceeds()
        {
            var port = Ports.GetNext();

            using (DicomServer.Create <SimpleCStoreProvider>(NetworkManager.IPv6Any, port))
            {
                DicomStatus status  = null;
                var         request = new DicomCStoreRequest(@".\Test Data\CT-MONO2-16-ankle");
                request.OnResponseReceived = (req, res) =>
                { status = res.Status; };

                var client = new DicomClient();
                client.AddRequest(request);

                client.Send(NetworkManager.IPv6Loopback, port, false, "SCU", "ANY-SCP");

                Assert.Equal(DicomStatus.Success, status);
            }
        }
コード例 #17
0
ファイル: DicomServerTest.cs プロジェクト: zinan/fo-dicom
        public void Send_PrivateNotRegisteredSOPClass_SendFails()
        {
            var port = Ports.GetNext();

            using (DicomServer.Create <SimpleCStoreProvider>(port))
            {
                DicomStatus status  = null;
                var         request = new DicomCStoreRequest(@".\Test Data\GH355.dcm");
                request.OnResponseReceived = (req, res) =>
                { status = res.Status; };

                var client = new DicomClient();
                client.AddRequest(request);

                client.Send("127.0.0.1", port, false, "SCU", "ANY-SCP");

                Assert.Equal(DicomStatus.SOPClassNotSupported, status);
            }
        }
コード例 #18
0
ファイル: DicomServerTest.cs プロジェクト: fo-dicom/fo-dicom
        public void Send_KnownSOPClass_SendSucceeds()
        {
            var port = Ports.GetNext();

            using (DicomServer.Create <SimpleCStoreProvider>(port))
            {
                DicomStatus status  = null;
                var         request = new DicomCStoreRequest(@".\Test Data\CT-MONO2-16-ankle")
                {
                    OnResponseReceived = (req, res) => status = res.Status
                };

                var client = new DicomClient();
                client.AddRequest(request);

                client.Send("127.0.0.1", port, false, "SCU", "ANY-SCP");

                Assert.Equal(DicomStatus.Success, status);
            }
        }
コード例 #19
0
        public void Send_ToDicomServer_ReturnsSuccess()
        {
            Task.Run(() => new DicomServer <DicomCEchoProvider>(104)).Wait(100);

            var client = new DicomClient();

            client.NegotiateAsyncOps();

            DicomStatus status  = null;
            var         request = new DicomCEchoRequest {
                OnResponseReceived = (echoRequest, response) => status = response.Status
            };

            client.AddRequest(request);
            client.Send("localhost", 104, false, "ECHOSCU", "ECHOSCP");

            while (status == null)
            {
                Thread.Sleep(10);
            }
            Assert.AreEqual(DicomStatus.Success, status);
        }
コード例 #20
0
ファイル: DicomServerTest.cs プロジェクト: zinan/fo-dicom
        public void Send_PrivateRegisteredSOPClass_SendSucceeds()
        {
            var uid = new DicomUID("1.3.46.670589.11.0.0.12.1", "Private MR Spectrum Storage", DicomUidType.SOPClass);

            DicomUID.Register(uid);

            var port = Ports.GetNext();

            using (DicomServer.Create <SimpleCStoreProvider>(port))
            {
                DicomStatus status  = null;
                var         request = new DicomCStoreRequest(@".\Test Data\GH355.dcm");
                request.OnResponseReceived = (req, res) =>
                { status = res.Status; };

                var client = new DicomClient();
                client.AddRequest(request);

                client.Send("127.0.0.1", port, false, "SCU", "ANY-SCP");

                Assert.Equal(DicomStatus.Success, status);
            }
        }
コード例 #21
0
		public DicomNSetResponse(DicomNSetRequest request, DicomStatus status) : base(request, status) {
			SOPInstanceUID = request.SOPInstanceUID;
		}
コード例 #22
0
ファイル: DicomStatus.cs プロジェクト: ZeryZhang/fo-dicom
		/// <summary>
		/// Initializes a new instance of the <see cref="DicomStatus"/> class.
		/// </summary>
		/// <param name="status">The status.</param>
		/// <param name="comment">The comment.</param>
		public DicomStatus(DicomStatus status, string comment)
			: this(String.Format("{0:x4}", status.Code), status.State, status.Description, comment) {
		}
コード例 #23
0
 public DicomNActionResponse(DicomNActionRequest request, DicomStatus status)
     : base(request, status)
 {
 }
コード例 #24
0
ファイル: DicomCFindResponse.cs プロジェクト: GMZ/fo-dicom
 public DicomCFindResponse(DicomCFindRequest request, DicomStatus status)
     : base(request, status)
 {
 }
コード例 #25
0
ファイル: DicomCStoreResponse.cs プロジェクト: jwake/fo-dicom
 public DicomCStoreResponse(DicomCStoreRequest request, DicomStatus status)
     : base(request, status)
 {
 }
コード例 #26
0
 /// <summary>
 /// Initializes an instance of the <see cref="DicomCFindResponse"/> class.
 /// </summary>
 /// <param name="request">C-FIND request for which the response should be made.</param>
 /// <param name="status">Response status.</param>
 public DicomCFindResponse(DicomCFindRequest request, DicomStatus status)
     : base(request, status)
 {
 }
コード例 #27
0
        public async Task ClientHandleNEventReport_SynchronousEvent()
        {
            var port = Ports.GetNext();

            using (DicomServer.Create <SimpleStorageComitmentProvider>(port))
            {
                DicomStatus status                   = null;
                int         verifiedInstances        = 0;
                DateTime    stampNActionResponse     = DateTime.MinValue;
                DateTime    stampNEventReportRequest = DateTime.MinValue;

                var dicomClient = new Client.DicomClient("127.0.0.1", port, false, "SCU", "ANY-SCP");

                var nActionDicomDataSet = new DicomDataset
                {
                    { DicomTag.TransactionUID, DicomUIDGenerator.GenerateDerivedFromUUID().UID },
                    {
                        DicomTag.ReferencedSOPSequence,
                        new DicomDataset()
                        {
                            { DicomTag.ReferencedSOPClassUID, "1.2.840.10008.5.1.4.1.1.1" },
                            { DicomTag.ReferencedSOPInstanceUID, "1.3.46.670589.30.2273540226.4.54" }
                        },
                        new DicomDataset()
                        {
                            { DicomTag.ReferencedSOPClassUID, "1.2.840.10008.5.1.4.1.1.1" },
                            { DicomTag.ReferencedSOPInstanceUID, "1.3.46.670589.30.2273540226.4.59" }
                        }
                    }
                };

                var nActionRequest = new DicomNActionRequest(DicomUID.StorageCommitmentPushModel,
                                                             DicomUID.StorageCommitmentPushModel, 1)
                {
                    Dataset            = nActionDicomDataSet,
                    OnResponseReceived = (DicomNActionRequest request, DicomNActionResponse response) =>
                    {
                        status = response.Status;
                        stampNActionResponse = DateTime.Now;
                    },
                };

                await dicomClient.AddRequestAsync(nActionRequest);

                dicomClient.OnNEventReportRequest = (eventReq) =>
                {
                    var refSopSequence = eventReq.Dataset.GetSequence(DicomTag.ReferencedSOPSequence);
                    foreach (var item in refSopSequence.Items)
                    {
                        verifiedInstances += 1;
                    }
                    stampNEventReportRequest = DateTime.Now;
                    return(Task.FromResult(new DicomNEventReportResponse(eventReq, DicomStatus.Success)));
                };

                dicomClient.AssociationLingerTimeoutInMs = (int)TimeSpan.FromSeconds(5).TotalMilliseconds;
                await dicomClient.SendAsync().ConfigureAwait(false);

                Assert.Equal(DicomStatus.Success, status);
                Assert.Equal(2, verifiedInstances);
                Assert.True(stampNActionResponse < stampNEventReportRequest);
            }
        }
コード例 #28
0
 public DicomNEventReportResponse(DicomNEventReportRequest request, DicomStatus status)
     : base(request, status)
 {
 }
コード例 #29
0
		public DicomNEventReportResponse(DicomNEventReportRequest request, DicomStatus status) : base(request, status) {
		}
コード例 #30
0
		public DicomNCreateResponse(DicomNCreateRequest request, DicomStatus status) : base(request, status) {
		}
コード例 #31
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DicomNActionResponse"/> class.
 /// </summary>
 /// <param name="request">
 /// The associated N-ACTION request.
 /// </param>
 /// <param name="status">
 /// The response status.
 /// </param>
 public DicomNActionResponse(DicomNActionRequest request, DicomStatus status)
     : base(request, status)
 {
     SOPInstanceUID = request.SOPInstanceUID;
     ActionTypeID   = request.ActionTypeID;
 }
コード例 #32
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DicomNEventReportResponse"/> class.
 /// </summary>
 /// <param name="request">
 /// The request associated with the N-EVENTREPORT response.
 /// </param>
 /// <param name="status">
 /// The response status.
 /// </param>
 public DicomNEventReportResponse(DicomNEventReportRequest request, DicomStatus status)
     : base(request, status)
 {
     SOPInstanceUID = request.SOPInstanceUID;
     EventTypeID    = request.EventTypeID;
 }
コード例 #33
0
 /// <summary>
 /// Initializes DICOM C-Store response to be returned to SCU.
 /// </summary>
 /// <param name="request">DICOM C-Store request being responded to</param>
 /// <param name="status">Status result of the C-Store operation</param>
 public DicomCStoreResponse(DicomCStoreRequest request, DicomStatus status) : base(request, status)
 {
 }
コード例 #34
0
ファイル: DicomStatus.cs プロジェクト: yuya-goojooob/fo-dicom
 /// <summary>
 /// Initializes a new instance of the <see cref="DicomStatus"/> class.
 /// </summary>
 /// <param name="status">The status.</param>
 /// <param name="comment">The comment.</param>
 public DicomStatus(DicomStatus status, string comment)
     : this(String.Format("{0:x4}", status.Code), status.State, status.Description, comment)
 {
 }
コード例 #35
0
		public DicomNActionResponse(DicomNActionRequest request, DicomStatus status) : base(request, status) {
		}
コード例 #36
0
 public DicomNGetResponse(DicomNGetRequest request, DicomStatus status) : base(request, status)
 {
     SOPInstanceUID = request.SOPInstanceUID;
 }
コード例 #37
0
 public DicomNDeleteResponse(DicomNDeleteRequest request, DicomStatus status) : base(request, status)
 {
 }