コード例 #1
0
        public void ReceiveMessage(IPushRoute route, Message message)
        {
            if (message != null &&
                message.Header != null) // &&
            //MessageRegistry.RHISPIX_NotificationMessageType.EqualsTo(message.Header.Type))    // do not need validation so strict
            {
                string id = message.Header.ID.ToString();
                _context.Log.Write(string.Format("Begin processing subscribed message. Message ID: {0}", id));

                SOAPClientControlerProcessStatus s = _controler.ProcessSubscribedMessage(message);

                _context.Log.Write(string.Format("End processing subscribed message. Message ID: {0}. Result: {1}", id, s));
                _context.Log.Write("");

                //SendLogMessage(string.Format("Receive SOAP response {0}",s),message.Body.ToString(),"null");
                if (s == SOAPClientControlerProcessStatus.SendingSOAPMessageError)
                {
                    LPCException.RaiseLPCException(route, "Sending SOAP message error, maybe retry is needed.");
                }

                if (s == SOAPClientControlerProcessStatus.RecevingFailureSOAPResponse)
                {
                    LPCException.RaiseLPCException(route, "Sending SOAP message success, and recieve a failure response.");
                }
            }
            else
            {
                _context.Log.Write(LogType.Error, "Received publishing message failed or receive a unwanted publishing message.");
            }
        }
コード例 #2
0
        public bool ProcessSubscribedMessage(IPushRoute route, MSG.Message msg)
        {
            if (msg == null || msg.Header == null)
            {
                return(false);
            }
            string msgId = msg.Header.ID.ToString();

            bool res = false;

            _entity.Context.Log.Write(string.Format("Begin processing message. ID: {0}", msgId));

            MSG.Message csbMsg = TransformToCSBDataSetSchemedXDSGWMessage(msg, msgId);
            if (csbMsg != null)
            {
                DataSet ds = GenerateCSBrokerDataSet(csbMsg.Body);
                if (ds != null)
                {
                    res = InsertIntoCSBrokerDatabase(route, ds);
                }
            }

            if (!res)
            {
                DumpErrorMessage(msg, msgId);
            }
            _entity.Context.Log.Write(string.Format("Finish processing message. ID: {0}, Result: {1}.\r\n", msgId, res));
            return(res);
        }
コード例 #3
0
        public void ReceiveMessage(IPushRoute route, Message message)
        {
            bool sndResult = false;

            try
            {
                if (message != null &&
                    message.Header != null)
                {
                    string desc = string.Format("processing message type: {0} id: {1} in thread id: {2}",
                                                message.Header.Type, message.Header.ID.ToString(), System.Threading.Thread.CurrentThread.ManagedThreadId);

                    Program.Log.Write(string.Format("Subscriber begin {0}", desc));
                    sndResult = _controler.DispatchSubscriberMessage(message);
                    Program.Log.Write(string.Format("Subscriber finish {0}. Result: {1}", desc, sndResult));
                    Program.Log.Write("");
                }
                else
                {
                    Program.Log.Write(LogType.Error, "Received publishing message failed or receive a unwanted publishing message.");
                }
            }
            catch (Exception err)
            {
                Program.Log.Write(err);
            }

            if (!sndResult)
            {
                LPCException.RaiseLPCException(route, "Dispatching and processing message success but sending message failed, maybe retry is needed.");
            }
        }
コード例 #4
0
        public void ReceiveMessage(IPushRoute route, Message message)
        {
            bool sndResult = false;

            try
            {
                if (message != null &&
                    message.Header != null)
                {
                    switch (_context.ConfigMgr.Config.MessageProcessingType)
                    {
                    case MessageProcessType.HL7v2Text:
                        string payload = HL7MessageHelper.GetHL7V2PayLoad(message);
                        sndResult = _controler.SendMLLPNotification(payload);
                        break;

                    case MessageProcessType.HL7v2XML:
                        string hl7xml = message.Body;
                        sndResult = _controler.SendHL7v2XMLNotification(hl7xml);
                        break;

                    default:
                    case MessageProcessType.OtherXML:
                        sndResult = _controler.SendOtherXMLNotification(message);
                        break;
                    }

                    ////if (MessageRegistry.HL7V2_NotificationMessageType.EqualsTo(message.Header.Type))
                    //if (!_context.Context.ConfigMgr.Config.EnableHL7XMLTransform)
                    //{
                    //    string payload = HL7MessageHelper.GetHL7V2PayLoad(message);
                    //    sndResult = _controler.SendNotification(payload);
                    //}
                    ////else if (MessageRegistry.HL7V2XML_NotificationMessageType.EqualsTo(message.Header.Type))
                    //else
                    //{
                    //    string hl7xml = message.Body;
                    //    sndResult = _controler.SendXMLNotification(hl7xml);
                    //}
                    ////else
                    ////{
                    ////    _context.Log.Write(LogType.Error, "Received a unwanted publishing message.");
                    ////}
                }
                else
                {
                    _context.Log.Write(LogType.Error, "Received publishing message failed.");
                }
            }
            catch (Exception e)
            {
                _context.Log.Write(e);
            }

            if (!sndResult)
            {
                LPCException.RaiseLPCException(route, "Send HL7 message failed, maybe retry is needed.");
            }
        }
コード例 #5
0
        public static void RaiseMSMQException(IPushRoute route, string message)
        {
            PushChannelConfig cfg = route as PushChannelConfig;

            if (cfg != null && cfg.ProtocolType == ProtocolType.MSMQ)
            {
                throw new MSMQReceiveCancelException(message);
            }
        }
コード例 #6
0
        public static void RaiseLPCException(IPushRoute route, string message)
        {
            PushChannelConfig cfg = route as PushChannelConfig;

            if (cfg != null && cfg.ProtocolType == ProtocolType.LPC)
            {
                throw new LPCException(message);
            }
        }
コード例 #7
0
 public PushChannelConfig FindChannel(IPushRoute route)
 {
     if (route == null)
     {
         return(null);
     }
     foreach (PushChannelConfig chn in _channels)
     {
         if (chn.ID == route.ID)
         {
             return(chn);
         }
     }
     return(null);
 }
コード例 #8
0
        public void ReceiveMessage(IPushRoute route, Message message)
        {
            if (message != null && message.Header != null)
            {
                string id = message.Header.ID.ToString();
                _context.Log.Write(string.Format("Begin processing subscribed message. Message ID: {0}", id));

                bool res = _controler.ProcessSubscribedMessage(message);
                _context.Log.Write(string.Format("End processing subscribed message. Message ID: {0}. Result: {1}", id, res));
                _context.Log.Write("");

                if (!res)
                {
                    LPCException.RaiseLPCException(route, "File Writer process error.maybe need republish it.");
                }
            }
            else
            {
                _context.Log.Write(LogType.Error, "Received publishing message failed or receive a unwanted publishing message.");
            }
        }
コード例 #9
0
        private bool InsertIntoCSBrokerDatabase(IPushRoute route, DataSet csbDataSet)
        {
            bool res = false;

            try
            {
                if (csbDataSet == null || csbDataSet.Tables.Count < 1)
                {
                    return(false);
                }
                _entity.Context.Log.Write("Begin calling CS Broker storage procedure.");

                if (_entity.Context.ConfigMgr.Config.EnaleKanJiReplacement)
                {
                    KanJiReplacement(csbDataSet);
                }



                string dbcnn  = _entity.Context.ConfigMgr.Config.CSBrokerOLEDBConnectionString;
                string spName = string.Format("sp_{0}_{1}", // e.g. "sp_SQLIN_Order",
                                              _entity.Context.ConfigMgr.Config.CSBrokerPassiveSQLInboundInterfaceName,
                                              csbDataSet.DataSetName);

                DataTable tb = csbDataSet.Tables[0];
                CSBrokerOutboundHelper.ReplaceValueInCSBrokerDataSet(tb, _entity.Context);



                int i = 1;
                int c = tb.Rows.Count;
                foreach (DataRow dr in tb.Rows)
                {
                    _entity.Context.Log.Write(string.Format("Inserting record {0}/{1}", i++, c));

                    OleDbCommand cmd = new OleDbCommand(spName);
                    cmd.CommandType = CommandType.StoredProcedure;

                    foreach (DataColumn dc in tb.Columns)
                    {
                        string pvalue = dr[dc] as string;
                        string pname  = string.Format("@{0}_{1}",
                                                      _entity.Context.ConfigMgr.Config.CSBrokerPassiveSQLInboundInterfaceName,
                                                      dc.ColumnName);

                        _entity.Context.Log.Write(string.Format("{0}:{1}", pname, pvalue));

                        OleDbParameter p = new OleDbParameter(pname, OleDbType.VarWChar);
                        p.Direction = ParameterDirection.Input;
                        p.Value     = (pvalue != null) ? pvalue : "";
                        cmd.Parameters.Add(p);
                    }

                    using (OleDbConnection conn = new OleDbConnection(dbcnn))
                    {
                        conn.Open();
                        cmd.Connection = conn;
                        cmd.ExecuteNonQuery();
                        conn.Close();
                    }
                }

                res = true;
            }
            catch (OleDbException dberr)
            {
                _entity.Context.Log.Write(dberr);
                MSMQReceiveCancelException.RaiseMSMQException(route, dberr.Message);
            }
            catch (Exception err)
            {
                _entity.Context.Log.Write(err);
            }

            _entity.Context.Log.Write(string.Format("Finish calling CS Broker storage procedure. Result: " + res));
            return(res);
        }