示例#1
0
        // This method is used to send a message to the server
        public bool Send(string cmdstring)
        {
            hl7 hl7 = new hl7();

            cmdstring = hl7.CreateMLLPMessage(cmdstring);


            exceptionthrown = false;

            //var parameters = os_util.ParseParams(cmdstring);
            if (cmdstring.Length > 0)
            {
                try
                {
                    // We need a connection to the server to send a message
                    if (connectionsocket.Connected)
                    {
                        byte[] byData = System.Text.Encoding.ASCII.GetBytes(cmdstring);
                        connectionsocket.Send(byData);
                        // connectionsocket.Receive()
                        return true;
                    }
                    else
                    {
                        try
                        {
                            
                            this.Connect(intSet.RemoteIPAddress, Convert.ToInt32(intSet.RemotePort));
                        
                            if (connectionsocket.Connected)
                            {
                                byte[] byData = System.Text.Encoding.ASCII.GetBytes(cmdstring);
                                connectionsocket.Send(byData);
                                return true;
                            }
                            return false;
                        }
                        catch (Exception ex)
                        {
                            lasterror = ex.ToString();
                            return false;
                        }

                    }
                }
                catch (Exception ex)
                {
                    lasterror = ex.ToString();
                    return false;
                }
            }
            else
            {
                lasterror = "No message provided for Send.";
                return false;
            }
        }
示例#2
0
        public String makeAck(String message)
        {
            String        tempString    = message.Substring(1, message.IndexOf((char)13));
            String        firstPartAck  = @"MSH|^~\&|MagView||||20140510233808||ACK|";
            String        secondPartAck = "|T|2.x||||||||";
            String        thirdPartAck  = "MSA|AA||||||";
            StringBuilder t             = new StringBuilder(firstPartAck);
            String        messageId     = this.getMessageId(message, 9);
            String        tempString2   = "";

            t.Append(messageId);
            t.Append(secondPartAck);
            t.Append((char)13);
            t.Append(thirdPartAck);
            hl7 hl7 = new hl7();

            tempString2 = hl7.CreateMLLPMessage(t.ToString());

            this.ack = tempString2;

            return(tempString2);
        }