Example #1
0
        void HandleEndOfTimelineEvent()
        {
            foreach (var startedActivity in startedActivities)
            {
                if (startedActivity.Value.mayLackEnd)
                {
                    continue;
                }
                YieldActivity(startedActivity.Value, endOfTimelineEventInfo.Value, startedActivity.Value.beginOwner, allowTakingEndsDisplayName: false);
            }
            startedActivities.Clear();

            var evt = endOfTimelineEventInfo.Value.evt as EndOfTimelineEvent;

            if (evt != null && !string.IsNullOrEmpty(evt.DisplayName))
            {
                timelineDisplayName = shortNames.ResolveShortNamesMurkup(evt.DisplayName);
            }
        }
Example #2
0
        void UpdateCachedContent()
        {
            var messagingEvents  = new Dictionary <A.Node, IEnumerable <M.Event> >();
            var eventToLogSource = new Dictionary <M.Event, ILogSource>();
            var nodeInfos        = new Dictionary <A.Node, Node>();
            var sourceNames      = logSourceNamesProvider.GetSourcesSequenceDiagramNames(
                outputs.Select(output => output.LogSource),
                outputs.Select(output => new {
                LogSource = output.LogSource,
                SuggestedRoleInstanceName =
                    output.Events
                    .OfType <M.MetadataEvent>()
                    .Where(e => e.Key == M.MetadataKeys.RoleInstanceName)
                    .Select(e => e.Value)
                    .FirstOrDefault(),
                SuggestedRoleName =
                    output.Events
                    .OfType <M.MetadataEvent>()
                    .Where(e => e.Key == M.MetadataKeys.RoleName)
                    .Select(e => e.Value)
                    .FirstOrDefault()
            })
                .Where(x => x.SuggestedRoleInstanceName != null)
                .ToDictionary(x => x.LogSource, x => new LogSourceNames()
            {
                RoleInstanceName = shortNames.ResolveShortNamesMurkup(x.SuggestedRoleInstanceName),
                RoleName         = x.SuggestedRoleName
            })
                );
            var groups =
                outputs
                .GroupBy(output => output.RotatedLogPartToken, new PartsOfSameLogEqualityComparer())
                .Select(group => new RotatedLogGroup(group, sourceNames))
                .ToArray();

            Func <A.Message, Message> makeMessageInfo = msg =>
            {
                var node = nodeInfos[msg.Node];
                return(new Message()
                {
                    Event = msg.Event,
                    Direction = msg.Direction,
                    LogSource = eventToLogSource[msg.Event],
                    Node = node,
                    Timestamp = node.TimeOffsets.Get(msg.Timestamp)
                });
            };

            foreach (var group in groups)
            {
                messagingEvents.Add(group.AnalysisNode, group.Outputs.SelectMany(x => x.Events));
                nodeInfos.Add(group.AnalysisNode, group.Node);
                foreach (var output in group.Outputs)
                {
                    foreach (var e in output.Events)
                    {
                        eventToLogSource[e] = output.LogSource;
                    }
                }
            }

            A.IInternodeMessagesDetector internodeMessagesDetector = new A.InternodeMessagesDetector();
            var detectedUnpairedMessages  = new List <A.Message>();
            var detectedInternodeMessages = internodeMessagesDetector.DiscoverInternodeMessages(
                messagingEvents, int.MaxValue, detectedUnpairedMessages);

            internodeMessages = ImmutableArray.CreateRange(detectedInternodeMessages.Select(m => new InternodeMessage()
            {
                IncomingMessage     = makeMessageInfo(m.IncomingMessage),
                OutgoingMessage     = makeMessageInfo(m.OutgoingMessage),
                OutgoingMessageId   = m.OutgoingMessage.Key.MessageId,
                OutgoingMessageType = m.OutgoingMessage.Key.Type
            }));

            unpairedMessages = ImmutableArray.CreateRange(detectedUnpairedMessages.Select(makeMessageInfo));

            timelineComments = ImmutableArray.CreateRange(
                from g in groups
                from output in g.Outputs
                from commentEvt in output.TimelineComments
                let commentTime = (commentEvt.Trigger as ITriggerTime)?.Timestamp
                                  where commentTime != null
                                  select new TimelineComment()
            {
                Event     = commentEvt,
                Node      = g.Node,
                Timestamp = g.Node.TimeOffsets.Get(commentTime.Value),
                LogSource = output.LogSource
            }
                );

            stateComments = ImmutableArray.CreateRange(
                from g in groups
                from output in g.Outputs
                from commentEvt in output.StateComments
                let commentTime = (commentEvt.Trigger as ITriggerTime)?.Timestamp
                                  where commentTime != null
                                  select new StateComment()
            {
                Event     = commentEvt,
                Node      = g.Node,
                Timestamp = g.Node.TimeOffsets.Get(commentTime.Value),
                LogSource = output.LogSource
            }
                );

            metadataEntries = ImmutableArray.CreateRange(
                from g in groups
                from output in g.Outputs
                from metaEvent in output.Events.OfType <M.MetadataEvent>()
                select new MetadataEntry()
            {
                Event     = metaEvent,
                Node      = g.Node,
                LogSource = output.LogSource
            }
                );

            changeNotification.Post();
        }