Esempio n. 1
0
        public Priority GetPriority(string fileName, IEnumerable <ILogLine> samples)
        {
            Priority result = Priority.NotSupport;

            int timeStampCount = 0;

            foreach (var line in samples)
            {
                if (line == null || string.IsNullOrEmpty(line.FullLine))
                {
                    continue;
                }
                var timeDeterminer = new TimeFormatDeterminer();
                if (null != timeDeterminer.DetermineDateTimeFormatInfo(line.FullLine))
                {
                    timeStampCount++;
                }
                else
                {
                    timeStampCount--;
                }
            }

            if (timeStampCount > 0)
            {
                result = Priority.WellSupport;
            }

            return(result);
        }
        public Priority GetPriority(string fileName, IEnumerable <ILogLine> samples)
        {
            Priority             result         = Priority.NotSupport;
            TimeFormatDeterminer timeDeterminer = new TimeFormatDeterminer();
            int timeStampExistsCount            = 0;
            int bracketsExistsCount             = 0;
            int maxBracketNumbers = 1;

            foreach (var logline in samples)
            {
                string line = logline?.FullLine;
                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }

                int bracketNumbers = 1;
                if (null != timeDeterminer.DetermineDateTimeFormatInfo(line))
                {
                    timeStampExistsCount++;
                }
                else
                {
                    timeStampExistsCount--;
                }

                string noSpaceLine = line.Replace(" ", string.Empty);
                if (noSpaceLine.IndexOf('[') >= 0 && noSpaceLine.IndexOf(']') >= 0 &&
                    noSpaceLine.IndexOf('[') < noSpaceLine.IndexOf(']'))
                {
                    bracketNumbers += Regex.Matches(noSpaceLine, @"\]\[").Count;
                    bracketsExistsCount++;
                }
                else
                {
                    bracketsExistsCount--;
                }

                maxBracketNumbers = Math.Max(bracketNumbers, maxBracketNumbers);
            }

            // Add message
            _columnCount  = maxBracketNumbers + 1;
            _isTimeExists = timeStampExistsCount > 0;
            if (_isTimeExists)
            {
                _columnCount += 2;
            }

            if (maxBracketNumbers > 1)
            {
                result = Priority.WellSupport;
                if (bracketsExistsCount > 0)
                {
                    result = Priority.PerfectlySupport;
                }
            }

            return(result);
        }