예제 #1
0
        /// <summary>
        /// Allows the on change.
        /// </summary>
        /// <param name="cNode">The c node.</param>
        /// <returns></returns>
        protected bool AllowOnChange(IConfigNode cNode)
        {
            var rValue = true;

            foreach (var cAttr in _allowOnChangeAttribute)
            {
                if (cNode.GetAttribute(cAttr.XPath, cAttr.AttrName, cAttr.Value) != cAttr.Value)
                {
                    rValue = false;
                    break;
                }
            }

            return(rValue);
        }
예제 #2
0
        /// <summary>
        /// The get message direction.
        /// </summary>
        /// <param name="evt">
        /// The event id.
        /// </param>
        /// <param name="messageSource">
        /// The message source.
        /// </param>
        /// <param name="messageDestination">
        /// The message destination.
        /// </param>
        public void GetMessageDirection(IEvent evt, out string messageSource, out string messageDestination, out string msgname)
        {
            lock (this)
            {
                messageSource      = string.Empty;
                messageDestination = string.Empty;
                msgname            = string.Empty;
                IConfigNode eventConfigBodyNode =
                    ConfigurationManager.Singleton.GetEventConfiguration(evt.Version).GetEventBodyNodeById(
                        evt.EventIdentifier);
                if (eventConfigBodyNode == null)
                {
                    return;
                }

                string messageDirectionAttribute = eventConfigBodyNode.GetAttribute("MsgDirection");
                string messageDirection          = messageDirectionAttribute;
                msgname = eventConfigBodyNode.GetAttribute("Describe");
                if (messageDirectionAttribute.IndexOf("{", StringComparison.Ordinal) >= 0)
                {
                    var   bindingRegex = new Regex(@"{Binding (\w+)\s*}", RegexOptions.IgnoreCase);
                    Match m            = bindingRegex.Match(messageDirectionAttribute);
                    IConfigNodeWrapper rootEventTreeNode = SecondaryParser.Singleton.Parse(evt);
                    if (rootEventTreeNode == null)
                    {
                        Log.Error("GetMessageDirection,rootEventTreeNode is null.");
                        return;
                    }
                    if (m.Groups.Count < 1)
                    {
                        Log.Error("No match!!!!!");
                        return;
                    }
                    messageDirection = rootEventTreeNode.GetChildNodeById(m.Groups[1].Value).ValueDescription;
                    string[] directionInfos = messageDirection.Split('{', '}');
                    if (directionInfos.Length > 1)
                    {
                        messageDirection = directionInfos[1].Trim('{', '}');
                    }

                    rootEventTreeNode.Dispose();
                }

                if (messageDirection.Contains("->"))
                {
                    /*类似"EPC->eNB"的处理*/
                    var stringSeparators = new[] { "->" };
                    var splitResult      = messageDirection.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries);
                    /*EPC->eNB拆分后为两个字串*/
                    if (splitResult.Length >= 2)
                    {
                        messageSource      = splitResult[0].Trim();
                        messageDestination = splitResult[1].Trim();
                    }
                    else
                    {
                        Log.Error(string.Format(@"Event消息方向填写错误,{0}", messageDirectionAttribute));
                    }
                }
            }
        }