public IEnumerable <Interval> TransformWithCustomTransformer(IEnumerable <IDEEvent> events,
                                                                     IEventToIntervalTransformer <Interval> transformer)
        {
            events = _fixer.FixAndFilter(events);

            _logger.Info(@"Transforming event stream with {0} ...", transformer.GetType().Name);

            var currentEventTime = DateTimeOffset.MinValue;
            var i = 0;

            foreach (var e in events)
            {
                i++;
                if (i % 500 == 0)
                {
                    Console.Write('.');
                }
                if (i % 50000 == 0)
                {
                    Console.WriteLine();
                }

                if (TransformerUtils.EventHasNoTimeData(e))
                {
                    continue;
                }

                var version = new KaVEVersion(e.KaVEVersion);
                if (version.ReleaseNumber < _firstVersionToInclude)
                {
                    continue;
                }

                Asserts.IsLessOrEqual(currentEventTime, e.TriggeredAt.GetValueOrDefault());

                currentEventTime = e.TriggeredAt.GetValueOrDefault();

                transformer.ProcessEvent(e);
            }
            Console.WriteLine();
            _logger.Info("--> Done processing {0} events...", i);

            return(transformer.SignalEndOfEventStream());
        }
Esempio n. 2
0
        private string CreateString(IEnumerable <IDEEvent> events)
        {
            events = _eventFixer.FixAndFilter(events);
            var sb = new StringBuilder();

            foreach (var e in events)
            {
                var hasArtificialEndDate = e.TerminatedAt == e.TriggeredAt;
                var start = e.TriggeredAt.HasValue ? e.TriggeredAt.Value.ToString("HH:mm:ss") : "--:--:--";
                var end   = e.TerminatedAt.HasValue && !hasArtificialEndDate
                    ? e.TerminatedAt.Value.ToString("HH:mm:ss")
                    : "";

                var duration = e.Duration.HasValue && !hasArtificialEndDate
                    ? "{0:0.0s}".FormatEx(e.Duration.Value.TotalMilliseconds / 1000)
                    : "";
                var file = e.ActiveDocument != null ? e.ActiveDocument.FileName : "";
                sb.AppendLine("{0}  {4,8} {1,6}  {2,-50} {3}".FormatEx(start, duration, Print(e), file, end));
            }
            return(sb.ToString());
        }