【原创】用反射实现HL7消息的接受的实现

 

         /// <summary>
        /// 将受到的消息进行处理
        /// 作者QQ:147777583
        /// </summary>
        public static string ManageReceiveMsg(string msg)
        {
            try
            {
                //string returnStr = null;
                Type a = typeof(Hl7ResoluMsg);
                AtlastigerHl7api.Base.Parser.PipeParser Parser = new AtlastigerHl7api.Base.Parser.PipeParser();
                AtlastigerHl7api.Base.Model.IMessage m = Parser.Parse(msg);
                string typeStr=m.Message.ToString ();
                string Str=null ;
                String returnStr = null;

                if(typeStr.IndexOf("ORM")>0 )
                {
                    Str = "ResoluORM" + m.Version.Replace('.', '_').ToString() + "Str";
                }
                else if (typeStr.IndexOf("ADT") > 0)
                {
                    Str = "ResoluADTA08" + m.Version.Replace('.', '_').ToString() + "Str";
                }
                else
                {
                    returnStr = MyFuction.responsionErrorHl7(msg);
                    return returnStr;

                }
                   
                Type t = Type.GetType("Atlastiger.CommonTools.Hl7ResoluMsg");

                try
                {

                    returnStr=(String)t.InvokeMember(Str, BindingFlags.Default | BindingFlags.InvokeMethod, null, null, new object[] {Parser, m, msg });
                }
                catch
                {
                    returnStr = MyFuction.responsionErrorHl7(msg);
                }
 
                return returnStr;

            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
 

 

展开阅读全文

没有更多推荐了,返回首页