コード例 #1
0
        /// <summary> Forwards the given message to any Applications that have been registered to
        /// accept messages of that type and trigger event.
        /// </summary>
        /// <throws>  ApplicationException if no such Applications are registered, or if </throws>
        /// <summary>      the underlying Application throws this exception during processing.
        /// </summary>
        public virtual Message processMessage(Message in_Renamed)
        {
            Message out_Renamed;

            try
            {
                NuGenApplication matchingApp = this.getMatchingApplication(in_Renamed);
                out_Renamed = matchingApp.processMessage(in_Renamed);
            }
            catch (NuGenHL7Exception e)
            {
                throw new NuGenApplicationException("Error internally routing message: " + e.ToString(), e);
            }
            return(out_Renamed);
        }
コード例 #2
0
ファイル: NuGenResponder.cs プロジェクト: carlhuth/GenXSource
        /// <summary> Processes an incoming message string and returns the response message string.
        /// Message processing consists of parsing the message, finding an appropriate
        /// Application and processing the message with it, and encoding the response.
        /// Applications are chosen from among those registered using
        /// <code>registerApplication</code>.  The Parser is obtained from the Connection
        /// associated with this Responder.
        /// </summary>
        protected internal virtual System.String processMessage(System.String incomingMessageString)
        {
            Message incomingMessageObject = null;

            System.String outgoingMessageString = null;
            try
            {
                incomingMessageObject = parser.parse(incomingMessageString);
            }
            catch (NuGenHL7Exception e)
            {
                outgoingMessageString = logAndMakeErrorMessage(e, parser.getCriticalResponseData(incomingMessageString), parser, parser.getEncoding(incomingMessageString));
            }

            if (outgoingMessageString == null)
            {
                try
                {
                    //optionally check integrity of parse
                    try
                    {
                        if (checkWriter != null)
                        {
                            checkParse(incomingMessageString, incomingMessageObject, parser);
                        }
                    }
                    catch (System.IO.IOException)
                    {
                    }

                    //message validation (in terms of optionality, cardinality) would go here ***

                    NuGenApplication app      = findApplication(incomingMessageObject);
                    Message          response = app.processMessage(incomingMessageObject);

                    //Here we explicitly use the same encoding as that of the inbound message - this is important with GenericParser, which might use a different encoding by default
                    outgoingMessageString = parser.encode(response, parser.getEncoding(incomingMessageString));
                }
                catch (System.Exception e)
                {
                    outgoingMessageString = logAndMakeErrorMessage(e, (Segment)incomingMessageObject.get_Renamed("MSH"), parser, parser.getEncoding(incomingMessageString));
                }
            }

            return(outgoingMessageString);
        }