Exemple #1
0
        internal bool Send(string message, DicomObject fragment)
        {
            //Logging.Log("Association.Send");

            try
            {
                if (fragment.Size > this.packetSize)
                {
                    Logging.Log(LogLevel.Error, "fragment exceeds packet size.");
                    return(false);
                }

                MemoryStream memory = new MemoryStream();
                fragment.Write(memory);

                NetworkStream output = new NetworkStream(socket, FileAccess.Write, false);

                byte[] bytes = memory.ToArray();
                Dump(">> " + message, bytes);

                output.Write(bytes, 0, (int)memory.Length);

                State = (State != State.Closing) ? State.Waiting : State;
            }
            catch (Exception ex)
            {
                Logging.Log(LogLevel.Error, ex.Message);
                return(false);
            }
            return(true);
        }
Exemple #2
0
        internal bool SendPdu(ServiceClass service, string message, DicomObject pdu)
        {
            //Logging.Log("Association.SendPdu");

            try
            {
                if (State == State.Aborted)
                {
                    throw AbortException;
                }

                MemoryStream memory = new MemoryStream();
                pdu.Write(memory);

                NetworkStream output = new NetworkStream(socket, FileAccess.Write, false);

                byte[] bytes = memory.ToArray();
                Dump(">> " + message, bytes);

                if (service != null)
                {
                    service.LastMessage = null;
                }
                output.Write(bytes, 0, (int)memory.Length);

                State = (State != State.Closing) ? State.Waiting : State;
            }
            catch (Exception ex)
            {
                Logging.Log(LogLevel.Error, ex.Message);
                throw;
            }
            return(true);
        }