public void Add(ActivityReportItem ActivityReportItemParam)
        {
            if (!ContainsKey(ActivityReportItemParam.ActivityName))
            {
                this[ActivityReportItemParam.ActivityName] = new ActivityReportItemList();
            }

            this[ActivityReportItemParam.ActivityName].Add(ActivityReportItemParam);
        }
        public static double?TotalDurationPercent(ActivityReportItem ParentReportItem, IEnumerable <ActivityReportItem> ActivityReportItems)
        {
            if (ParentReportItem.Duration == null || ParentReportItem.Duration.Value == 0d)
            {
                return(null);
            }

            return(TotalDuration(ActivityReportItems) / ParentReportItem.Duration.Value);
        }
        public static double?HiddenDurationPercent(ActivityReportItem ParentReportItem)
        {
            double?HiddenDurationTime = HiddenDuration(ParentReportItem);

            if (HiddenDurationTime == null)
            {
                return(null);
            }

            double TotalDurationCalc = TotalDuration(ParentReportItem.ChildReportItems);

            if (TotalDurationCalc > 0d)
            {
                return(HiddenDurationTime.Value / TotalDurationCalc);
            }

            return(null);
        }
        public static double?HiddenDuration(ActivityReportItem ParentReportItem)
        {
            if (ParentReportItem.Duration == null)
            {
                return(null);
            }

            double HiddenDuration = ParentReportItem.Duration.Value;

            foreach (ActivityReportItem CurrentChildReportItem in ParentReportItem.ChildReportItems)
            {
                if (CurrentChildReportItem.Duration != null)
                {
                    HiddenDuration -= CurrentChildReportItem.Duration.Value;
                }
            }

            return(HiddenDuration);
        }
        public static ActivityReportItem CreateReportItemForStartPoint(ActivityPoint CurrentStartPoint, ActivityPointStack NormalizedPointStackParam)
        {
            //
            // PULL THE CURRENT END POINT FROM THE STACK.
            //
            ActivityPoint EndPoint = PullActivityPointEnd(CurrentStartPoint, NormalizedPointStackParam);

            //
            // CREATE THE REPORT ITEM.
            //
            ActivityReportItem CurrentReportItem = new ActivityReportItem();

            CurrentReportItem.ActivityName = CurrentStartPoint.ActivityName;
            CurrentReportItem.StartPoint   = CurrentStartPoint;
            CurrentReportItem.EndPoint     = EndPoint;
            CurrentReportItem.Duration     = DurationCalculator.CalcDuration(CurrentStartPoint, EndPoint);

            //
            // CREATE THE ARRAY OF CHILD REPORT ITEMS.
            //
            List <ActivityReportItem> ChildReportItemList = new List <ActivityReportItem>();

            while (NormalizedPointStackParam.IsNotEmpty)
            {
                //
                // THE NEXT POINT WILL ALWAYS BE A START POINT.
                //
                ActivityPoint NextStartPoint = NormalizedPointStackParam.Pop();

                //
                // CHECK IF THE NEXT START POINT OCCURS AFTER THE END POINT OF THIS REPORT ITEM.
                //
                if (CurrentReportItem.EndPoint.SequenceNumber < NextStartPoint.SequenceNumber)
                {
                    //
                    // THE NEXT START POINT OCCURS AFTER THE CURRENT REPORT ITEM ENDS.
                    // WE ARE DONE BUILDING THE LIST OF CHILD ACTIVITY ITEMS.
                    //

                    //
                    // PUT THE NEXT START POINT BACK ON THE STACK.
                    //
                    NormalizedPointStackParam.Push(NextStartPoint);

                    //
                    // THE LIST OF CHILD ACTIVITY ITEMS IS NOW COMPLETE.  GET OUT OF HERE.
                    //
                    break;
                }

                //
                // BUILD THE REPORT ITEM FOR THE NEXT START POINT.
                // THIS IS ALWAYS A CHILD REPORT ITEM.
                //
                ActivityReportItem NextReportItem = CreateReportItemForStartPoint(NextStartPoint, NormalizedPointStackParam);
                ChildReportItemList.Add(NextReportItem);
            }

            CurrentReportItem.ChildReportItems = ChildReportItemList.ToArray();

            //
            // NOW THAT THIS REPORT ITEM HAS ALL OF ITS CHILDREN WE CAN CALCULATE THE HIDDEN PROCESSING TIME.
            //
            CurrentReportItem.HiddenDuration        = ActivityReportItemCalculator.HiddenDuration(CurrentReportItem);
            CurrentReportItem.HiddenDurationPercent = ActivityReportItemCalculator.HiddenDurationPercent(CurrentReportItem);
            return(CurrentReportItem);
        }