예제 #1
0
        /// <summary>
        /// Loads any values that were pulled for the given line into the property object
        /// </summary>
        private static void LoadFileValues(FileData file, LogPropertyBaseModel p)
        {
            if (file == null)
            {
                return;
            }

            foreach (var item in file.FileValues.Where(item => item.iLine == p.iLine))
            {
                p.AddProperty(Keywords.FILE_VALUES, "", item.Name, item.Value);
            }
        }
예제 #2
0
        /// <summary>
        /// Returns the first Name that is not blank
        /// Skips any EventPattern that have "IgnoreName"
        /// </summary>
        public static string GetFirstName(LogPropertyBaseModel property)
        {
            string distinctName = null;

            // Use the first EventPattern that has a Document Map Name
            foreach (var eventId in property.EventIds)
            {
                var e = XmlDal.DataModel.GetEvent(eventId);

                if (e.IgnoreName)
                {
                    continue;
                }

                if (string.IsNullOrEmpty(e.Name))
                {
                    continue;
                }

                distinctName = e.Name;
            }
            return(distinctName);
        }
예제 #3
0
        /// <summary>
        /// Returns a property model for the existing line
        /// Loads the first EventPattern that matches into the property object
        /// Loads any values found for the given line into the property object
        /// </summary>
        /// <returns></returns>
        private static LogPropertyBaseModel LookupEvent(string path, LogPropertyBaseModel property)
        {
            var file = XmlDal.CacheModel.GetFile(path);

            PropertyLookup item         = null;
            var            eventMatches = 0;
            var            eventIds     = new List <int>();
            var            values       = new List <EventValue>();
            var            storedEvents = new List <EventLR>();

            string highlightColor = null;

            foreach (var e in EventService.GetModel().Events.Where(n => n.ContainsSourceType(file.SourceType)))
            {
                if (!RegularExpression.HasMatch(property.Line, e.RegularExpression))
                {
                    continue;
                }

                storedEvents.Add(e);

                if (e.HighlightColor != null && e.HighlightColor != "Transparent")
                {
                    highlightColor = e.HighlightColor;
                }

                foreach (var value in e.EventValues)
                {
                    values.Add(new EventValue
                    {
                        PropertyCategory    = value.PropertyCategory,
                        PropertyDescription = value.PropertyDescription,
                        PropertyName        = value.PropertyName,
                        Value = RegularExpression.GetFirstValue(property.Line, value.RegularExpression)
                    });
                }

                // If the last EventPattern found has IgnoredDocumentation, then display the next EventPattern in the Property Window
                if (item == null || item.Event.IgnoreDocumentation)
                {
                    var oldItem = item;

                    item = new PropertyLookup(property)
                    {
                        Documentation = e.Documentation,
                        SourceType    = e.SourceType,
                        iLine         = property.iLine,
                        Properties    = oldItem != null ? oldItem.Properties : new List <DynamicProperty>(),
                        Direction     = oldItem != null ? oldItem.Direction : NetworkDirection.Na
                    };

                    eventMatches++;
                    eventIds.Add(e.EventId);
                    LoadEvent(item, e);
                    LoadFileValues(file, item);
                    item.IsDocumentated = !item.Event.IgnoreDocumentation;
                    item.HighlightColor = e.HighlightColor;
                }
                else
                {
                    eventMatches++;
                    eventIds.Add(e.EventId);
                }

                if (e.Network == NetworkDirection.Na)
                {
                    continue;
                }

                item.Direction = e.Network;
                item.AddProperty(Keywords.NETWORK, "Direction of the Network Message", Keywords.NETWORK_DIRECTION, NetworkHelper.NetworkDirectionToString(e.Network));
            }



            if (item != null)
            {
                property = item;
            }

            property.EventMatches   = eventMatches;
            property.EventIds       = eventIds;
            property.HighlightColor = highlightColor;

            foreach (var value in values)
            {
                property.AddProperty(value.PropertyCategory, value.PropertyDescription, value.PropertyName, value.Value);
            }

            LoadLookupValues(new LookupArgs
            {
                FilePath       = path,
                SourceProperty = property,
            }, storedEvents);
            LoadFileValues(file, property);
            return(property);
        }
        public static CriteriaMatchModel GetCriteriaMatches(int networkMapId, LineArgs source, LineArgs target, bool noNetworkMessages)
        {
            var matches = new List <CriteriaMatch>();

            var map = XmlDal.DataModel.GetNetworkMap(networkMapId);

            var sourceMessage = XmlDal.CacheModel.GetFile(source.Path).GetNetworkMessage(source.iLine);

            if (sourceMessage == null)
            {
                Log.WriteError("sourceMessage should never be null!!!!", typeof(NetworkMapService).FullName, MethodBase.GetCurrentMethod().Name);
                return(new CriteriaMatchModel());
            }
            var targetMessage = XmlDal.CacheModel.GetFile(target.Path).GetNetworkMessage(target.iLine);

            foreach (var criteria in map.Criteria)
            {
                var match = IsMatch(criteria, sourceMessage, targetMessage, target.Path);

                if (criteria.UseSourceValue)
                {
                    match.SourceValue = $"=={match.CriteriaSourceValue} [{match.SourceValue}]";
                }
                if (criteria.UseTargetValue)
                {
                    match.TargetValue = $"=={match.CriteriaTargetValue} [{match.TargetValue}]";
                }
                if (criteria.TimeConditionMs != null)
                {
                    match.TargetValue = $"{match.TargetValue} tc:{criteria.TimeConditionMs}";
                }

                matches.Add(new CriteriaMatch
                {
                    Enabled     = criteria.Enabled,
                    IsMatch     = match.IsMatch,
                    Operator    = criteria.Operator,
                    SourceName  = criteria.SourceName,
                    SourceType  = criteria.SourceType.ToString(),
                    SourceValue = match.SourceValue,
                    TargetName  = criteria.TargetName,
                    TargetType  = criteria.TargetType.ToString(),
                    TargetValue = match.TargetValue
                });
            }

            LogPropertyBaseModel targetProperty = null;

            if (!noNetworkMessages)
            {
                targetProperty = PropertyService.GetProperty(target);
            }
            var sourceProperty     = PropertyService.GetProperty(source);
            var dateTimeDifference = CalculateDateTimeDifference(targetProperty, sourceProperty);

            return(new CriteriaMatchModel
            {
                DateTimeDifference = dateTimeDifference,
                Matches = matches
            });
        }