当前位置: 首页>>代码示例>>C#>>正文


C# IMessage.GetStructureName方法代码示例

本文整理汇总了C#中IMessage.GetStructureName方法的典型用法代码示例。如果您正苦于以下问题:C# IMessage.GetStructureName方法的具体用法?C# IMessage.GetStructureName怎么用?C# IMessage.GetStructureName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMessage的用法示例。


在下文中一共展示了IMessage.GetStructureName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: test

        /// <summary>
        /// Test
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public override ValidationException[] test(IMessage msg)
        {
            ValidationException[] result = new ValidationException[0];

            foreach (SegmentMandatoryRule rule in segmentRules)
            {
                bool flag1 = (rule.Version == "*") || (msg.Version == rule.Version);
                
                string structureName = msg.GetStructureName();
                string[] sNames = structureName.Split('_');
                bool flag2 = (rule.MessageType == "*") || (sNames[0] == rule.MessageType);
                bool flag3 = (rule.TriggerEvent == "*") || (sNames[1] == rule.TriggerEvent);

                if (flag1 && flag2 && flag3)
                {
                    PipeParser parser = new PipeParser();
                    if (!parser.SegmentExists(msg, rule.MadatorySegment))
                    {
                        result = new ValidationException[1] { new ValidationException(string.Format("Segment {0} not available in message", rule.MadatorySegment)) };
                    }
                }

                if (result.Count() > 0)
                    break;
            }

            return result;
        }
开发者ID:mrgoodman2014,项目名称:NHapiTools,代码行数:33,代码来源:MessageSegmentMandatoryRule.cs

示例2: Send

        public override bool Send(IMessage msg)
        {
            bool result = true; 
            EditMessageHeader(msg);

            try
            {
                PipeParser parser = new PipeParser();
                string res = SendRequest(parser.Encode(msg));
                IMessage response = parser.Parse(res);

                Terser terser = new Terser(response);
                string ackCode = terser.Get("/MSA-1");
                result = (ackCode == "AA");
            }
            catch (Exception ex)
            {
                Logger.ErrorFormat("Error in delivering message '{0}' to Http endpoint with uri '{1}'. Error: {2}", msg.GetStructureName(), serverUri, ex.Message);
                result = false;
            }

            return result;
        }
开发者ID:mrgoodman2014,项目名称:HL7Fuse,代码行数:23,代码来源:HttpEndPoint.cs

示例3: DoEncode

		/// <summary> Formats a Message object into an HL7 message string using this parser's
		/// default encoding ("VB").
		/// </summary>
		/// <throws>  HL7Exception if the data fields in the message do not permit encoding </throws>
		/// <summary>      (e.g. required fields are null)
		/// </summary>
		protected internal override String DoEncode(IMessage source)
		{
			//get encoding characters ...
			ISegment msh = (ISegment) source.GetStructure("MSH");
			String fieldSepString = Terser.Get(msh, 1, 0, 1, 1);
			if (fieldSepString == null)
			{
				//cdc: This was breaking when trying to construct a blank message, and there is no way to set the fieldSeperator, so fill in a default
				//throw new HL7Exception("Can't encode message: MSH-1 (field separator) is missing");
				fieldSepString = "|";
				Terser.Set(msh, 1, 0, 1, 1, fieldSepString);
			}

			char fieldSep = '|';
			if (fieldSepString != null && fieldSepString.Length > 0)
				fieldSep = fieldSepString[0];

			String encCharString = Terser.Get(msh, 2, 0, 1, 1);

			if (encCharString == null)
			{
				//cdc: This was breaking when trying to construct a blank message, and there is no way to set the EncChars, so fill in a default
				//throw new HL7Exception("Can't encode message: MSH-2 (encoding characters) is missing");
				encCharString = @"^~\&";
				Terser.Set(msh, 2, 0, 1, 1, encCharString);
			}

			string version = Terser.Get(msh, 12, 0, 1, 1);
			if (version == null)
			{
				//Put in the message version
				Terser.Set(msh, 12, 0, 1, 1, source.Version);
			}

			string msgStructure = Terser.Get(msh, 9, 0, 1, 1);
			if (msgStructure == null)
			{
				//Create the MsgType and Trigger Event if not there
				string messageTypeFullname = source.GetStructureName();
				int i = messageTypeFullname.IndexOf("_");
				if (i > 0)
				{
					string type = messageTypeFullname.Substring(0, i);
					string triggerEvent = messageTypeFullname.Substring(i + 1);
					Terser.Set(msh, 9, 0, 1, 1, type);
					Terser.Set(msh, 9, 0, 2, 1, triggerEvent);
				}
				else
				{
					Terser.Set(msh, 9, 0, 1, 1, messageTypeFullname);
				}
			}

			if (encCharString.Length != 4)
				throw new HL7Exception("Encoding characters '" + encCharString + "' invalid -- must be 4 characters",
					HL7Exception.DATA_TYPE_ERROR);
			EncodingCharacters en = new EncodingCharacters(fieldSep, encCharString);

			//pass down to group encoding method which will operate recursively on children ...
			return Encode((IGroup) source, en);
		}
开发者ID:RickIsWright,项目名称:nHapi,代码行数:67,代码来源:PipeParser.cs

示例4: GetFileName

 private string GetFileName(IMessage msg)
 {
     // Format filename as yyyyMMDD_HHmmSS_EVENTNAME.HL7
     return string.Format("{0}_{1}_{2}.HL7", DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmssfff"), msg.GetStructureName());
 }
开发者ID:mrgoodman2014,项目名称:HL7Fuse,代码行数:5,代码来源:FileEndPoint.cs

示例5: GetRelevantEndPoints

        private Dictionary<string, IEndPoint> GetRelevantEndPoints(IMessage message)
        {
            // Filter the messages to get the relevant endpoints
            Dictionary<string, IEndPoint> endpoints = new Dictionary<string, IEndPoint>();
            foreach (RoutingRuleSet rule in routingRules)
            {
                if (rule.IncludeEndpoint(message))
                {
                    KeyValuePair<string, IEndPoint> endp = clients.FirstOrDefault(ep => ep.Key == rule.EndPoint);
                    if (endp.Key != null)
                    {
                        Logger.DebugFormat("Endpoint '{0}' is relevant for '{1}'.", endp.Key, message.GetStructureName());
                        if (!endpoints.ContainsKey(endp.Key))
                            endpoints.Add(endp.Key, endp.Value);
                    }
                }
                else
                    Logger.DebugFormat("Endpoint '{0}' is not relevant for '{1}'.", rule.EndPoint, message.GetStructureName());
            }

            return endpoints;
        }
开发者ID:mrgoodman2014,项目名称:HL7Fuse,代码行数:22,代码来源:ConnectionManager.cs


注:本文中的IMessage.GetStructureName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。