Beispiel #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);
            }
        }
Beispiel #2
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);
        }