Example #1
0
 //
 // - Methods -
 //
 /// <summary>
 /// Override this method to handle an A-ABORT.
 /// </summary>
 /// <param name="abort">The received A-ABORT.</param>
 /// <returns>Return true when this methods has handled the received A-ABORT, otherwise false.</returns>
 public virtual bool HandleAbort(Abort abort)
 {
     return false;
 }
Example #2
0
 /// <summary>
 /// This method is called after an A-ABORT has been received but before it
 /// (possibly) will be handled by the (zero or more) MessageHandler objects that
 /// are attached to this object.
 /// 
 /// Default, nothing is done in this method. Override if needed.
 /// </summary>
 /// <param name="abort">The received A-ABORT.</param>
 public virtual void BeforeHandlingAbort(Abort abort)
 {
     // Do nothing.
 }
Example #3
0
        /// <summary>
        /// Receive a message (can be a Dicom or Dul message).
        /// 
        /// An exception is thrown when receiving of a message fails.
        /// </summary>
        /// <returns>The received message.</returns>
        public Message ReceiveMessage()
        {
            // Start Interface logging.
            // InterfaceLogging.Start(this);

            DicomProtocolMessage receivedMessage = null;

            DvtkData.Message dvtkDataMessage = null;

            WriteInformation("Receive message...");

            Dvtk.Sessions.ReceiveReturnCode receiveReturnCode = DvtkScriptSession.Receive(out dvtkDataMessage);

            if (receiveReturnCode != Dvtk.Sessions.ReceiveReturnCode.Success)
            {
                DvtkHighLevelInterfaceException.Throw("Error while trying to receive a Message. Error code " + receiveReturnCode.ToString() + ".");
            }
            else
            {
                if (dvtkDataMessage is DvtkData.Dimse.DicomMessage)
                {
                    receivedMessage = new DicomMessage(dvtkDataMessage as DvtkData.Dimse.DicomMessage);
                }
                else if (dvtkDataMessage is DvtkData.Dul.A_ASSOCIATE_RQ)
                {
                    lastAssociateRq = new AssociateRq(dvtkDataMessage as DvtkData.Dul.A_ASSOCIATE_RQ);
                    receivedMessage = lastAssociateRq;
                }
                else if (dvtkDataMessage is DvtkData.Dul.A_ASSOCIATE_AC)
                {
                    receivedMessage = new AssociateAc(dvtkDataMessage as DvtkData.Dul.A_ASSOCIATE_AC);
                }
                else if (dvtkDataMessage is DvtkData.Dul.A_ASSOCIATE_RJ)
                {
                    receivedMessage = new AssociateRj(dvtkDataMessage as DvtkData.Dul.A_ASSOCIATE_RJ);
                }
                else if (dvtkDataMessage is DvtkData.Dul.A_RELEASE_RQ)
                {
                    receivedMessage = new ReleaseRq(dvtkDataMessage as DvtkData.Dul.A_RELEASE_RQ);
                }
                else if (dvtkDataMessage is DvtkData.Dul.A_RELEASE_RP)
                {
                    receivedMessage = new ReleaseRp(dvtkDataMessage as DvtkData.Dul.A_RELEASE_RP);
                }
                else if (dvtkDataMessage is DvtkData.Dul.A_ABORT)
                {
                    receivedMessage = new Abort(dvtkDataMessage as DvtkData.Dul.A_ABORT);
                }
                else
                {
                    Debug.Assert(true, "Unexpected DvtkData Message descendant type.");
                }

                // If the options AutoValidate is true, try to validate as much
                // as possible for the received message.
                if (Options.AutoValidate)
                {
                    Validate(receivedMessage);
                }

                receivedMessage.IsReceived = true;
                ThreadManager.DataWarehouse.AddMessage(this, receivedMessage);

                if (receivedMessage is ReleaseRq)
                {
                    if (AssociationReleasedEvent != null)
                    {
                        AssociationReleasedEvent(this);
                    }
                }
            }

            // End Interface logging.
            // InterfaceLogging.End(receivedMessage);

            return(receivedMessage);
        }
Example #4
0
 /// <summary>
 /// This method is called after an A-ABORT has been received and has 
 /// (possibly) been handled by the (zero or more) MessageHandler objects that
 /// are attached to this object.
 /// 
 /// Default, nothing is done in this method. Override if needed.
 /// </summary>
 /// <param name="abort">The received A-ABORT.</param>
 public virtual void AfterHandlingAbort(Abort abort)
 {
     // Do nothing.
 }