예제 #1
0
파일: DcmItem.cs 프로젝트: gogorrr/mdcm
 public DcmItem(DicomTag tag, DicomVR vr, long pos, Endian endian)
 {
     _tag = tag;
     _vr = vr;
     _streamPosition = pos;
     _endian = endian;
 }
예제 #2
0
 public void ConstructorPrivateCreator()
 {
     var t = new DicomTag(0x2000, 0x2001, "TEST CREATOR");
     Assert.AreEqual(0x2000, t.Group);
     Assert.AreEqual(0x2001, t.Element);
     Assert.AreEqual("TEST CREATOR", t.PrivateCreator);
 }
예제 #3
0
파일: DcmItem.cs 프로젝트: gogorrr/mdcm
 public DcmItem(DicomTag tag, DicomVR vr)
 {
     _tag = tag;
     _vr = vr;
     _streamPosition = 0;
     _endian = Endian.LocalMachine;
 }
예제 #4
0
 public void ConstructorSimple()
 {
     var t = new DicomTag(0x0028, 0x1203);
     Assert.AreEqual(t.Group, 0x0028);
     Assert.AreEqual(t.Element, 0x1203);
     Assert.IsEmpty(t.PrivateCreator);
 }
예제 #5
0
 public void Equals()
 {
     var a = new DicomTag(0x0028, 0x9145);
     var b = new DicomTag(0x0028, 0x9146);
     var c = new DicomTag(0x0028, 0x9146);
     var z = default(DicomTag);
     Assert.IsFalse(a.Equals(b));
     Assert.IsFalse(b.Equals(a));
     Assert.IsTrue(b.Equals(c));
     Assert.IsTrue(c.Equals(b));
     Assert.IsFalse(a.Equals(z));
     Assert.IsFalse(b.Equals(z));
 }
예제 #6
0
 public void EqualsObject()
 {
     var a = new DicomTag(0x0028, 0x9145);
     var b = new DicomTag(0x0028, 0x9146);
     var c = new DicomTag(0x0028, 0x9146);
     var z = default(DicomTag);
     Assert.IsFalse(a.Equals((object)b));
     Assert.IsFalse(b.Equals((object)a));
     Assert.IsTrue(b.Equals((object)c));
     Assert.IsTrue(c.Equals((object)b));
     Assert.IsFalse(a.Equals((object)z));
     Assert.IsFalse(b.Equals((object)z));
 }
예제 #7
0
 public void OpNEq()
 {
     var a = new DicomTag(0x0028, 0x9145);
     var b = new DicomTag(0x0028, 0x9146);
     var c = new DicomTag(0x0028, 0x9146);
     var z = default(DicomTag);
     Assert.IsTrue(a != b);
     Assert.IsTrue(b != a);
     Assert.IsFalse(b != c);
     Assert.IsFalse(c != b);
     Assert.IsTrue(z != a);
     Assert.IsTrue(a != z);
     Assert.IsTrue(z != b);
     Assert.IsTrue(b != z);
 }
예제 #8
0
 public void OpEq()
 {
     var a = new DicomTag(0x0028, 0x9145);
     var b = new DicomTag(0x0028, 0x9146);
     var c = new DicomTag(0x0028, 0x9146);
     var z = default(DicomTag);
     Assert.IsFalse(a == b);
     Assert.IsFalse(b == a);
     Assert.IsTrue(b == c);
     Assert.IsTrue(c == b);
     Assert.IsFalse(z == a);
     Assert.IsFalse(a == z);
     Assert.IsFalse(z == b);
     Assert.IsFalse(b == z);
 }
예제 #9
0
 public DcmUnsignedLong GetUL(DicomTag tag)
 {
     DcmElement elem = GetElement(tag);
     if (elem is DcmUnsignedLong)
         return elem as DcmUnsignedLong;
     if (elem != null)
         throw new DicomDataException("Tried to access element with incorrect VR");
     return null;
 }
예제 #10
0
 public ushort GetUInt16(DicomTag tag, ushort deflt)
 {
     DcmUnsignedShort us = GetUS(tag);
     if (us != null && us.Length > 0)
         return us.GetValue();
     return deflt;
 }
예제 #11
0
 public DicomUID GetUID(DicomTag tag)
 {
     DcmUniqueIdentifier ui = GetUI(tag);
     if (ui != null && ui.Length > 0)
         return ui.GetUID();
     return null;
 }
예제 #12
0
 public DcmUniqueIdentifier GetUI(DicomTag tag)
 {
     DcmElement elem = GetElement(tag);
     if (elem is DcmUniqueIdentifier)
         return elem as DcmUniqueIdentifier;
     if (elem != null)
         throw new DicomDataException("Tried to access element with incorrect VR");
     return null;
 }
예제 #13
0
 public short GetInt16(DicomTag tag, short deflt)
 {
     DcmSignedShort ss = GetSS(tag);
     if (ss != null && ss.Length > 0)
         return ss.GetValue();
     return deflt;
 }
예제 #14
0
 protected virtual void OnReceiveNGetRequest(byte presentationID, ushort messageID, DicomUID requestedClass, DicomUID requestedInstance, DicomTag[] attributes)
 {
     SendAbort(DcmAbortSource.ServiceProvider, DcmAbortReason.NotSpecified);
 }
예제 #15
0
 public DicomVR GetVR(DicomTag tag)
 {
     DcmElement elem = GetElement(tag);
     if (elem == null)
         return null;
     return elem.VR;
 }
예제 #16
0
 public string GetString(DicomTag tag, string deflt)
 {
     return GetString(tag, 0, deflt);
 }
예제 #17
0
 public DcmSignedShort GetSS(DicomTag tag)
 {
     DcmElement elem = GetElement(tag);
     if (elem is DcmSignedShort)
         return elem as DcmSignedShort;
     if (elem != null)
         throw new DicomDataException("Tried to access element with incorrect VR");
     return null;
 }
예제 #18
0
 public DcmItemSequence GetSQ(DicomTag tag)
 {
     DcmItem item = GetItem(tag);
     if (item is DcmItemSequence)
         return item as DcmItemSequence;
     if (item != null)
         throw new DicomDataException("Tried to access element with incorrect VR");
     return null;
 }
예제 #19
0
 public DcmOtherWord GetOW(DicomTag tag)
 {
     DcmElement elem = GetElement(tag);
     if (elem is DcmOtherWord)
         return elem as DcmOtherWord;
     if (elem != null)
         throw new DicomDataException("Tried to access element with incorrect VR");
     return null;
 }
예제 #20
0
 public DcmItem GetItem(DicomTag tag)
 {
     DcmItem item = null;
     if (!_items.TryGetValue(tag, out item))
         return null;
     return item;
 }
예제 #21
0
 public int GetInt32(DicomTag tag, int deflt)
 {
     DcmElement elem = GetElement(tag);
     if (elem != null && elem.Length > 0) {
         if (elem.VR == DicomVR.IS)
             return (elem as DcmIntegerString).GetInt32();
         else if (elem.VR == DicomVR.SL)
             return (elem as DcmSignedLong).GetValue();
         else
             throw new DicomDataException("Tried to access element " + tag.ToString() + " with incorrect VR");
     }
     return deflt;
 }
예제 #22
0
 public DcmUnlimitedText GetUT(DicomTag tag)
 {
     DcmElement elem = GetElement(tag);
     if (elem is DcmUnlimitedText)
         return elem as DcmUnlimitedText;
     if (elem != null)
         throw new DicomDataException("Tried to access element with incorrect VR");
     return null;
 }
예제 #23
0
 public string GetValueString(DicomTag tag)
 {
     DcmElement elem = GetElement(tag);
     if (elem == null)
         return null;
     return elem.GetValueString();
 }
예제 #24
0
 public DcmFloatingPointSingle GetFL(DicomTag tag)
 {
     DcmElement elem = GetElement(tag);
     if (elem is DcmFloatingPointSingle)
         return elem as DcmFloatingPointSingle;
     if (elem != null)
         throw new DicomDataException("Tried to access element with incorrect VR");
     return null;
 }
예제 #25
0
        private bool ProcessDimse(byte presentationID)
        {
            if (!Associate.HasPresentationContextID(presentationID) ||
                Associate.GetPresentationContextResult(presentationID) != DcmPresContextResult.Accept) {
                Log.Error("{0} -> Received DIMSE for unaccepted Presentation Context ID [pcid: {1}]", LogID, presentationID);
                SendAbort(DcmAbortSource.ServiceUser, DcmAbortReason.NotSpecified);
                return true;
            }

            if (_dimse.Command == null) {
                Log.Error("{0} -> Unable to process DIMSE; Command DataSet not received.", LogID);
                SendAbort(DcmAbortSource.ServiceUser, DcmAbortReason.NotSpecified);
                return true;
            }

            DcmCommandField commandField = _dimse.Command.CommandField;

            if (commandField == DcmCommandField.CStoreRequest) {
                ushort messageID = _dimse.Command.MessageID;
                DcmPriority priority = _dimse.Command.Priority;
                DicomUID affectedInstance = _dimse.Command.AffectedSOPInstanceUID;
                string moveAE = _dimse.Command.MoveOriginatorAE;
                ushort moveMessageID = _dimse.Command.MoveOriginatorMessageID;
                Log.Info("{0} <- C-Store request [pc: {1}; id: {2}]{3}",
                    LogID, presentationID, messageID, (_dimse.DatasetFile != null ? " (stream)" : ""));
                try {
                    OnReceiveCStoreRequest(presentationID, messageID, affectedInstance, priority, moveAE, moveMessageID, _dimse.Dataset, _dimse.DatasetFile);
                } finally {
                    OnPostReceiveCStoreRequest(presentationID, messageID, affectedInstance, _dimse.Dataset, _dimse.DatasetFile);
                }
                return true;
            }

            if (commandField == DcmCommandField.CStoreResponse) {
                ushort messageIdRespondedTo = _dimse.Command.MessageIDBeingRespondedTo;
                DicomUID affectedInstance = _dimse.Command.AffectedSOPInstanceUID;
                DcmStatus status = _dimse.Command.Status;
                if (status.State == DcmState.Success) {
                    Log.Info("{0} <- C-Store response [id: {1}]: {2}",
                        LogID, messageIdRespondedTo, status);
                }
                else {
                    Log.Info("{0} <- C-Store response [id: {1}]: {2}\n\t=> {3}",
                        LogID, messageIdRespondedTo, status, _dimse.Command.GetErrorString());
                }
                OnReceiveCStoreResponse(presentationID, messageIdRespondedTo, affectedInstance, status);
                return true;
            }

            if (commandField == DcmCommandField.CEchoRequest) {
                ushort messageID = _dimse.Command.MessageID;
                DcmPriority priority = _dimse.Command.Priority;
                Log.Info("{0} <- C-Echo request [pc: {1}; id: {2}]",
                    LogID, presentationID, messageID);
                OnReceiveCEchoRequest(presentationID, messageID, priority);
                return true;
            }

            if (commandField == DcmCommandField.CEchoResponse) {
                ushort messageIdRespondedTo = _dimse.Command.MessageIDBeingRespondedTo;
                DcmStatus status = _dimse.Command.Status;
                if (status.State == DcmState.Success) {
                    Log.Info("{0} <- C-Echo response [{1}]: {2}",
                        LogID, messageIdRespondedTo, status);
                }
                else {
                    Log.Info("{0} <- C-Echo response [{1}]: {2}\n\t=> {3}",
                        LogID, messageIdRespondedTo, status, _dimse.Command.GetErrorString());
                }
                OnReceiveCEchoResponse(presentationID, messageIdRespondedTo, status);
                return true;
            }

            if (commandField == DcmCommandField.CFindRequest) {
                ushort messageID = _dimse.Command.MessageID;
                DcmPriority priority = _dimse.Command.Priority;
                String level = _dimse.Dataset.GetString(DicomTags.QueryRetrieveLevel, "UNKNOWN");
                Log.Info("{0} <- C-Find request [pc: {1}; id: {2}; lvl: {3}]",
                    LogID, presentationID, messageID, level);
                OnReceiveCFindRequest(presentationID, messageID, priority, _dimse.Dataset);
                return true;
            }

            if (commandField == DcmCommandField.CFindResponse) {
                ushort messageIdRespondedTo = _dimse.Command.MessageIDBeingRespondedTo;
                DcmStatus status = _dimse.Command.Status;
                if (status.State == DcmState.Success || status.State == DcmState.Pending) {
                    Log.Info("{0} <- C-Find response [id: {1}]: {2}",
                        LogID, messageIdRespondedTo, status);
                }
                else {
                    Log.Info("{0} <- C-Find response [id: {1}]: {2}=>\n\t {3}",
                        LogID, messageIdRespondedTo, status, _dimse.Command.GetErrorString());
                }
                OnReceiveCFindResponse(presentationID, messageIdRespondedTo, _dimse.Dataset, status);
                return true;
            }

            if (commandField == DcmCommandField.CGetRequest) {
                ushort messageID = _dimse.Command.MessageID;
                DcmPriority priority = _dimse.Command.Priority;
                String level = _dimse.Dataset.GetString(DicomTags.QueryRetrieveLevel, "UNKNOWN");
                Log.Info("{0} <- C-Get request [pc: {1}; id: {2}; lvl: {3}]",
                    LogID, presentationID, messageID, level);
                OnReceiveCGetRequest(presentationID, messageID, priority, _dimse.Dataset);
                return true;
            }

            if (commandField == DcmCommandField.CGetResponse) {
                ushort messageIdRespondedTo = _dimse.Command.MessageIDBeingRespondedTo;
                DcmStatus status = _dimse.Command.Status;
                ushort remain = _dimse.Command.NumberOfRemainingSuboperations;
                ushort complete = _dimse.Command.NumberOfCompletedSuboperations;
                ushort warning = _dimse.Command.NumberOfWarningSuboperations;
                ushort failure = _dimse.Command.NumberOfFailedSuboperations;
                if (status.State == DcmState.Success || status.State == DcmState.Pending) {
                    Log.Info("{0} <- C-Get response [id: {1}; remain: {2}; complete: {3}; warning: {4}; failure: {5}]: {6}",
                        LogID, messageIdRespondedTo, remain, complete, warning, failure, status);
                }
                else {
                    Log.Info("{0} <- C-Get response [id: {1}; remain: {2}; complete: {3}; warning: {4}; failure: {5}]: {6}\n\t=> {7}",
                        LogID, messageIdRespondedTo, remain, complete, warning, failure, status, _dimse.Command.GetErrorString());
                }
                OnReceiveCGetResponse(presentationID, messageIdRespondedTo, _dimse.Dataset, status, remain, complete, warning, failure);
                return true;
            }

            if (commandField == DcmCommandField.CMoveRequest) {
                ushort messageID = _dimse.Command.MessageID;
                DcmPriority priority = _dimse.Command.Priority;
                string destAE = _dimse.Command.MoveDestinationAE;
                String level = _dimse.Dataset.GetString(DicomTags.QueryRetrieveLevel, "UNKNOWN");
                Log.Info("{0} <- C-Move request [pc: {1}; id: {2}; lvl: {3}; dest: {4}]",
                    LogID, presentationID, messageID, level, destAE);
                OnReceiveCMoveRequest(presentationID, messageID, destAE, priority, _dimse.Dataset);
                return true;
            }

            if (commandField == DcmCommandField.CMoveResponse) {
                ushort messageIdRespondedTo = _dimse.Command.MessageIDBeingRespondedTo;
                DcmStatus status = _dimse.Command.Status;
                ushort remain = _dimse.Command.NumberOfRemainingSuboperations;
                ushort complete = _dimse.Command.NumberOfCompletedSuboperations;
                ushort warning = _dimse.Command.NumberOfWarningSuboperations;
                ushort failure = _dimse.Command.NumberOfFailedSuboperations;
                if (status.State == DcmState.Success || status.State == DcmState.Pending) {
                    Log.Info("{0} <- C-Move response [id: {1}; remain: {2}; complete: {3}; warning: {4}; failure: {5}]: {6}",
                        LogID, messageIdRespondedTo, remain, complete, warning, failure, status);
                }
                else {
                    Log.Info("{0} <- C-Move response [id: {1}; remain: {2}; complete: {3}; warning: {4}; failure: {5}]: {6}\n\t=> {7}",
                        LogID, messageIdRespondedTo, remain, complete, warning, failure, status, _dimse.Command.GetErrorString());
                }
                OnReceiveCMoveResponse(presentationID, messageIdRespondedTo, _dimse.Dataset, status, remain, complete, warning, failure);
                return true;
            }

            if (commandField == DcmCommandField.CCancelRequest) {
                ushort messageIdRespondedTo = _dimse.Command.MessageIDBeingRespondedTo;
                Log.Info("{0} <- C-Cancel request [pc: {1}; id: {2}]", LogID, presentationID, messageIdRespondedTo);
                OnReceiveCCancelRequest(presentationID, messageIdRespondedTo);
                return true;
            }

            if (commandField == DcmCommandField.NEventReportRequest) {
                ushort messageID = _dimse.Command.MessageID;
                DicomUID affectedClass = _dimse.Command.AffectedSOPClassUID;
                DicomUID affectedInstance = _dimse.Command.AffectedSOPInstanceUID;
                ushort eventTypeID = _dimse.Command.EventTypeID;
                Log.Info("{0} <- N-EventReport request [pc: {1}; id: {2}; class: {3}; event: {4:x4}]",
                    LogID, presentationID, messageID, affectedClass.Description, eventTypeID);
                OnReceiveNEventReportRequest(presentationID, messageID, affectedClass, affectedInstance, eventTypeID, _dimse.Dataset);
                return true;
            }

            if (commandField == DcmCommandField.NEventReportResponse) {
                ushort messageIdRespondedTo = _dimse.Command.MessageIDBeingRespondedTo;
                DicomUID affectedClass = _dimse.Command.AffectedSOPClassUID;
                DicomUID affectedInstance = _dimse.Command.AffectedSOPInstanceUID;
                ushort eventTypeID = _dimse.Command.EventTypeID;
                DcmStatus status = _dimse.Command.Status;
                if (status.State == DcmState.Success) {
                    Log.Info("{0} <- N-EventReport response [id: {1}; class: {2}; event: {3:x4}]: {4}",
                        LogID, messageIdRespondedTo, affectedClass.Description, eventTypeID, status);
                }
                else {
                    Log.Info("{0} <- N-EventReport response [id: {1}; class: {2}; event: {3:x4}]: {4}\n\t=> {5}",
                        LogID, messageIdRespondedTo, affectedClass.Description, eventTypeID, status, _dimse.Command.GetErrorString());
                }
                OnReceiveNEventReportResponse(presentationID, messageIdRespondedTo, affectedClass, affectedInstance, eventTypeID, _dimse.Dataset, status);
                return true;
            }

            if (commandField == DcmCommandField.NGetRequest) {
                ushort messageID = _dimse.Command.MessageID;
                DicomUID requestedClass = _dimse.Command.RequestedSOPClassUID;
                DicomUID requestedInstance = _dimse.Command.RequestedSOPInstanceUID;
                DicomTag[] attributes = new DicomTag[0];
                if (_dimse.Command.AttributeIdentifierList != null)
                    attributes = _dimse.Command.AttributeIdentifierList.GetValues();
                Log.Info("{0} <- N-Get request [pc: {1}; id: {2}; class: {3}]",
                    LogID, presentationID, messageID, requestedClass.Description);
                OnReceiveNGetRequest(presentationID, messageID, requestedClass, requestedInstance, attributes);
                return true;
            }

            if (commandField == DcmCommandField.NGetResponse) {
                ushort messageIdRespondedTo = _dimse.Command.MessageIDBeingRespondedTo;
                DicomUID affectedClass = _dimse.Command.AffectedSOPClassUID;
                DicomUID affectedInstance = _dimse.Command.AffectedSOPInstanceUID;
                DcmStatus status = _dimse.Command.Status;
                if (status.State == DcmState.Success) {
                    Log.Info("{0} <- N-Get response [id: {1}; class: {2}]: {3}",
                        LogID, messageIdRespondedTo, affectedClass.Description, status);
                }
                else {
                    Log.Info("{0} <- N-Get response [id: {1}; class: {2}]: {3}\n\t=> {4}",
                        LogID, messageIdRespondedTo, affectedClass.Description, status, _dimse.Command.GetErrorString());
                }
                OnReceiveNGetResponse(presentationID, messageIdRespondedTo, affectedClass, affectedInstance, _dimse.Dataset, status);
                return true;
            }

            if (commandField == DcmCommandField.NSetRequest) {
                ushort messageID = _dimse.Command.MessageID;
                DicomUID requestedClass = _dimse.Command.RequestedSOPClassUID;
                DicomUID requestedInstance = _dimse.Command.RequestedSOPInstanceUID;
                Log.Info("{0} <- N-Set request [pc: {1}; id: {2}; class: {3}]",
                    LogID, presentationID, messageID, requestedClass.Description);
                OnReceiveNSetRequest(presentationID, messageID, requestedClass, requestedInstance, _dimse.Dataset);
                return true;
            }

            if (commandField == DcmCommandField.NSetResponse) {
                ushort messageIdRespondedTo = _dimse.Command.MessageIDBeingRespondedTo;
                DicomUID affectedClass = _dimse.Command.AffectedSOPClassUID;
                DicomUID affectedInstance = _dimse.Command.AffectedSOPInstanceUID;
                DcmStatus status = _dimse.Command.Status;
                if (status.State == DcmState.Success) {
                    Log.Info("{0} <- N-Set response [id: {1}; class: {2}]: {3}",
                        LogID, messageIdRespondedTo, affectedClass.Description, status);
                }
                else {
                    Log.Info("{0} <- N-Set response [id: {1}; class: {2}]: {3}\n\t=> {4}",
                        LogID, messageIdRespondedTo, affectedClass.Description, status, _dimse.Command.GetErrorString());
                }
                OnReceiveNSetResponse(presentationID, messageIdRespondedTo, affectedClass, affectedInstance, _dimse.Dataset, status);
                return true;
            }

            if (commandField == DcmCommandField.NActionRequest) {
                ushort messageID = _dimse.Command.MessageID;
                DicomUID requestedClass = _dimse.Command.RequestedSOPClassUID;
                DicomUID requestedInstance = _dimse.Command.RequestedSOPInstanceUID;
                ushort actionTypeID = _dimse.Command.ActionTypeID;
                Log.Info("{0} <- N-Action request [pc: {1}; id: {2}; class: {3}; action: {4:x4}]",
                    LogID, presentationID, messageID, requestedClass.Description, actionTypeID);
                OnReceiveNActionRequest(presentationID, messageID, requestedClass, requestedInstance, actionTypeID, _dimse.Dataset);
                return true;
            }

            if (commandField == DcmCommandField.NActionResponse) {
                ushort messageIdRespondedTo = _dimse.Command.MessageIDBeingRespondedTo;
                DicomUID affectedClass = _dimse.Command.AffectedSOPClassUID;
                DicomUID affectedInstance = _dimse.Command.AffectedSOPInstanceUID;
                ushort actionTypeID = _dimse.Command.ActionTypeID;
                DcmStatus status = _dimse.Command.Status;
                if (status.State == DcmState.Success) {
                    Log.Info("{0} <- N-Action response [id: {1}; class: {2}; action: {3:x4}]: {4}",
                        LogID, messageIdRespondedTo, affectedClass.Description, actionTypeID, status);
                }
                else {
                    Log.Info("{0} <- N-Action response [id: {1}; class: {2}; action: {3:x4}]: {4}\n\t=> {5}",
                        LogID, messageIdRespondedTo, affectedClass.Description, actionTypeID, status, _dimse.Command.GetErrorString());
                }
                OnReceiveNActionResponse(presentationID, messageIdRespondedTo, affectedClass, affectedInstance, actionTypeID, _dimse.Dataset, status);
                return true;
            }

            if (commandField == DcmCommandField.NCreateRequest) {
                ushort messageID = _dimse.Command.MessageID;
                DicomUID affectedClass = _dimse.Command.AffectedSOPClassUID;
                DicomUID affectedInstance = _dimse.Command.AffectedSOPInstanceUID;
                Log.Info("{0} <- N-Create request [pc: {1}; id: {2}; class: {3}]",
                    LogID, presentationID, messageID, affectedClass.Description);
                OnReceiveNCreateRequest(presentationID, messageID, affectedClass, affectedInstance, _dimse.Dataset);
                return true;
            }

            if (commandField == DcmCommandField.NCreateResponse) {
                ushort messageIdRespondedTo = _dimse.Command.MessageIDBeingRespondedTo;
                DicomUID affectedClass = _dimse.Command.AffectedSOPClassUID;
                DicomUID affectedInstance = _dimse.Command.AffectedSOPInstanceUID;
                DcmStatus status = _dimse.Command.Status;
                if (status.State == DcmState.Success) {
                    Log.Info("{0} <- N-Create response [id: {1}; class: {2}]: {3}",
                        LogID, messageIdRespondedTo, affectedClass.Description, status);
                }
                else {
                    Log.Info("{0} <- N-Create response [id: {1}; class: {2}]: {3}\n\t=> {4}",
                        LogID, messageIdRespondedTo, affectedClass.Description, status, _dimse.Command.GetErrorString());
                }
                OnReceiveNCreateResponse(presentationID, messageIdRespondedTo, affectedClass, affectedInstance, _dimse.Dataset, status);
                return true;
            }

            if (commandField == DcmCommandField.NDeleteRequest) {
                ushort messageID = _dimse.Command.MessageID;
                DicomUID requestedClass = _dimse.Command.RequestedSOPClassUID;
                DicomUID requestedInstance = _dimse.Command.RequestedSOPInstanceUID;
                Log.Info("{0} <- N-Delete request [pc: {1}; id: {2}; class: {3}]",
                    LogID, presentationID, messageID, requestedClass.Description);
                OnReceiveNDeleteRequest(presentationID, messageID, requestedClass, requestedInstance);
                return true;
            }

            if (commandField == DcmCommandField.NDeleteResponse) {
                ushort messageIdRespondedTo = _dimse.Command.MessageIDBeingRespondedTo;
                DicomUID affectedClass = _dimse.Command.AffectedSOPClassUID;
                DicomUID affectedInstance = _dimse.Command.AffectedSOPInstanceUID;
                DcmStatus status = _dimse.Command.Status;
                if (status.State == DcmState.Success) {
                    Log.Info("{0} <- N-Delete response [id: {1}; class: {2}]: {3}",
                        LogID, messageIdRespondedTo, affectedClass.Description, status);
                }
                else {
                    Log.Info("{0} <- N-Delete response [id: {1}; class: {2}]: {3}\n\t=> {4}",
                        LogID, messageIdRespondedTo, affectedClass.Description, status, _dimse.Command.GetErrorString());
                }
                OnReceiveNDeleteResponse(presentationID, messageIdRespondedTo, affectedClass, affectedInstance, status);
                return true;
            }

            return false;
        }
예제 #26
0
 public DcmTime GetTM(DicomTag tag)
 {
     DcmElement elem = GetElement(tag);
     if (elem is DcmTime)
         return elem as DcmTime;
     if (elem != null)
         throw new DicomDataException("Tried to access element with incorrect VR");
     return null;
 }
예제 #27
0
 protected void SendNGetRequest(byte presentationID, ushort messageID, DicomUID requestedClass, DicomUID requestedInstance, DicomTag[] attributes)
 {
     DcmCommand command = new DcmCommand();
     command.RequestedSOPClassUID = requestedClass;
     command.CommandField = DcmCommandField.NGetRequest;
     command.MessageID = messageID;
     command.HasDataset = false;
     command.RequestedSOPInstanceUID = requestedInstance;
     command.AttributeIdentifierList = new DcmAttributeTag(DicomTags.AttributeIdentifierList);
     command.AttributeIdentifierList.SetValues(attributes);
     Log.Info("{0} -> N-Get request [pc: {1}; id: {2}; class: {3}]", LogID, presentationID, messageID, requestedClass.Description);
     SendDimse(presentationID, command, null);
 }
예제 #28
0
 public float GetFloat(DicomTag tag, float deflt)
 {
     DcmElement elem = GetElement(tag);
     if (elem != null && elem.Length > 0) {
         if (elem.VR == DicomVR.FL)
             return (elem as DcmFloatingPointSingle).GetValue();
         else if (elem.VR == DicomVR.DS)
             return (elem as DcmDecimalString).GetFloat();
         else
             throw new DicomDataException("Tried to access element " + tag.ToString() + " with incorrect VR");
     }
     return deflt;
 }
예제 #29
0
 public string GetString(DicomTag tag, int index, string deflt)
 {
     DcmElement elem = GetElement(tag);
     if (elem is DcmStringElement)
         return (elem as DcmStringElement).GetValue(index);
     if (elem is DcmMultiStringElement)
         return (elem as DcmMultiStringElement).GetValue(index);
     if (elem != null)
         throw new DicomDataException("Tried to access element " + tag.ToString() + " with incorrect VR");
     return deflt;
 }
예제 #30
0
 public string[] GetStringArray(DicomTag tag, string[] deflt)
 {
     DcmElement elem = GetElement(tag);
     if (elem is DcmMultiStringElement)
         return (elem as DcmMultiStringElement).GetValues();
     if (elem is DcmStringElement)
         return new string[] { (elem as DcmStringElement).GetValue() };
     if (elem != null)
         throw new DicomDataException("Tried to access element " + tag.ToString() + " with incorrect VR");
     return deflt;
 }