Пример #1
0
        XElement CreateActivityElement(ActivityEventBase evt, string name, params XAttribute[] attrs)
        {
            var e = CreateEventElement(evt, name, attrs.Concat(new[]
            {
                MakeNullableAttr(SC.Attr_ActivityId, evt.ActivityId),
                MakeNullableAttr(SC.Attr_Type, (int)evt.Type),
                evt.Status == ActivityStatus.Unspecified ? null : MakeNullableAttr(SC.Attr_Status, (int)evt.Status),
            }).ToArray());

            if (evt.Phases != null && evt.Phases.Count > 0)
            {
                foreach (var ph in evt.Phases)
                {
                    e.Add(new XElement(
                              SC.Elt_Phase,
                              new XAttribute(SC.Attr_Begin, ph.Begin.Ticks),
                              new XAttribute(SC.Attr_End, ph.End.Ticks),
                              new XAttribute(SC.Attr_Type, ph.Type),
                              new XAttribute(SC.Attr_DisplayName, ph.DisplayName)
                              ));
                }
            }
            ;
            return(e);
        }
Пример #2
0
        void HandleActivityEvent(ActivityEventBase evt, ActivityType type, string activityMatchingId = null)
        {
            var eventInfo = new EventInfo(evt, currentTimeOffsets);

            SetOrigin(eventInfo);
            if (evt.Type == ActivityEventType.Begin || evt.Type == ActivityEventType.PotentialBegin)
            {
                var activity = new StartedActivity()
                {
                    begin              = eventInfo,
                    beginOwner         = currentPostprocessorOutput,
                    type               = type,
                    activityMatchingId = activityMatchingId,
                    milestones         = new List <ActivityMilestone>(),
                    phases             = new List <ActivityPhase>(),
                    mayLackEnd         = evt.Type == ActivityEventType.PotentialBegin
                };
                startedActivities[evt.ActivityId] = activity;
                if (activity.status == ActivityStatus.Unspecified)
                {
                    activity.status = evt.Status;
                }
                AddPhases(activity, evt);
            }
            else if (evt.Type == ActivityEventType.End)
            {
                StartedActivity startedActivity;
                if (startedActivities.TryGetValue(evt.ActivityId, out startedActivity))
                {
                    AddPhases(startedActivity, evt);
                    if (startedActivity.status == ActivityStatus.Unspecified)
                    {
                        startedActivity.status = evt.Status;
                    }
                    YieldActivity(startedActivity, eventInfo, currentPostprocessorOutput, allowTakingEndsDisplayName: true);
                    startedActivities.Remove(evt.ActivityId);
                }
            }
            else if (evt.Type == ActivityEventType.Milestone)
            {
                StartedActivity startedActivity;
                if (startedActivities.TryGetValue(evt.ActivityId, out startedActivity))
                {
                    startedActivity.milestones.Add(new ActivityMilestone(
                                                       null,
                                                       currentPostprocessorOutput,
                                                       eventInfo.timestamp - origin,
                                                       evt.DisplayName,
                                                       evt.Trigger
                                                       ));
                    AddPhases(startedActivity, evt);
                }
            }
        }
Пример #3
0
 void AddPhases(StartedActivity startedActivity, ActivityEventBase evt)
 {
     if (evt.Phases != null && evt.Phases.Count > 0 && startedActivity.phases.Count == 0)
     {
         startedActivity.phases.AddRange(evt.Phases.Select(ph => new ActivityPhase(
                                                               null,
                                                               currentPostprocessorOutput,
                                                               startedActivity.begin.timestamp - origin + ph.Begin,
                                                               startedActivity.begin.timestamp - origin + ph.End,
                                                               ph.Type,
                                                               ph.DisplayName
                                                               )));
     }
 }