public string CreateReportForActivityReportItem(ActivityReportItem ParentReportItem, int NestingLevel) { // // CREATE THE REPORT LINE ITEM FOR THE PARENT. // StringBuilder ReportBuilder = new StringBuilder(); ReportBuilder.AppendLine(CreateReportLineItem(ParentReportItem, NestingLevel)); // // CREATE A SUMMARY ELEMENT FOR EACH CHILD ACCORDING TO THE SPECIFIED CONFIGURATION. // ActivityReportItemListMap CreatedListMap = new ActivityReportItemListMap(); CreatedListMap.AddRange(ParentReportItem.ChildReportItems); string[] ChildActivityNames = ActivityNamesArrayFactory.CreateArrayOfUniqueActivityNames(ParentReportItem.ChildReportItems); // // CREATE THE AGGREGATE RECORD LINE ITEMS. // foreach (string ChildActivityName in ChildActivityNames) { // // GET THE LIST OF CHILD ACTIVITIES. // ActivityReportItemList ChildActivityList = CreatedListMap[ChildActivityName]; if (_ShowAllSummaries || ChildActivityList.Count > 1) { // // CREATE THE AGGREGATE RECORD. // ActivityReportAggregateItem CreatedAggregateItem = new ActivityReportAggregateItem(); CreatedAggregateItem.ActivityName = ChildActivityName; CreatedAggregateItem.Count = ChildActivityList.Count; CreatedAggregateItem.TotalDuration = ActivityReportItemCalculator.TotalDuration(ChildActivityList); CreatedAggregateItem.TotalDurationPercent = ActivityReportItemCalculator.TotalDurationPercent(ParentReportItem, ChildActivityList); CreatedAggregateItem.MaxDuration = ActivityReportItemCalculator.MaxDuration(ChildActivityList); CreatedAggregateItem.AvgDuration = ActivityReportItemCalculator.AvgDuration(ChildActivityList); CreatedAggregateItem.MinDuration = ActivityReportItemCalculator.MinDuration(ChildActivityList); // // CREATE THE LINE ITEM FOR THE AGGREGATE RECORD. // ReportBuilder.AppendLine(CreateLineItemForAggregate(CreatedAggregateItem, NestingLevel + 1)); } } // // CREATE THE REPORT LINE ITEMS FOR THE CHILD ACTIVITIES. // foreach (ActivityReportItem CurrentChildReportItem in ParentReportItem.ChildReportItems) { if (_ShowAllActivities || CurrentChildReportItem.ChildReportItems.Length > 0) { // // SHOW THE CHILD ACTIVITY IF IT'S FORCED TO BE SHOWN OR IF IT'S A PARENT ITSELF. // ReportBuilder.Append(CreateReportForActivityReportItem(CurrentChildReportItem, NestingLevel + 1)); } } return(ReportBuilder.ToString()); }
/// <summary> /// Creates the activity report element. /// </summary> public XmlElement CreateActivityReportElement(ActivityReportItem ParentReportItem) { // // CREATE THE ACTIVITY ELEMENT. // XmlElement ActivityReportElement = _MarkerReportDocument.CreateElement("Activity"); // // ACTIVITY NAME. // if (ParentReportItem.ActivityName != null) { ActivityReportElement.SetAttribute("Name", ParentReportItem.ActivityName); } // // TOTAL DURATION. // if (ParentReportItem.Duration != null) { ActivityReportElement.SetAttribute("Total", ParentReportItem.Duration.Value.ToString(MarkerReportFactoryDefaults.TimingDisplayFormatCode)); } // // HIDDEN DURATION. // if (ParentReportItem.HiddenDuration != null) { ActivityReportElement.SetAttribute("Hidden", ParentReportItem.HiddenDuration.Value.ToString(MarkerReportFactoryDefaults.TimingDisplayFormatCode)); } // // DESCRIPTION. // if (ParentReportItem.Desc != null) { ActivityReportElement.SetAttribute("Desc", ParentReportItem.Desc); } // // CREATE A SUMMARY ELEMENT FOR EACH CHILD ACCORDING TO THE SPECIFIED CONFIGURATION. // ActivityReportItemListMap CreatedListMap = new ActivityReportItemListMap(); CreatedListMap.AddRange(ParentReportItem.ChildReportItems); string[] ChildActivityNames = ActivityNamesArrayFactory.CreateArrayOfUniqueActivityNames(ParentReportItem.ChildReportItems); // // CREATE THE CHILD ACTIVITY SUMMARIES ELEMENT. // XmlElement ChildActivitySummariesElement = null; if (_ShowAllSummaries) { // // FORCE SHOW ALL SUMMARIES. // CREATE THE CHILD ACTIVITY SUMMARIES ELEMENT. // ChildActivitySummariesElement = _MarkerReportDocument.CreateElement("Summaries"); ChildActivitySummariesElement.SetAttribute("Count", ChildActivityNames.Length.ToString(MarkerReportFactoryDefaults.CountDisplayFormatCode)); ActivityReportElement.AppendChild(ChildActivitySummariesElement); } else { // // DO NOT FORCE SHOW ALL SUMMARIES. // BY DEFAULT, THIS CREATE A SUMMARY FOR ANY CHILD ACTIVITY WITH 2 OR MORE OCCURRENCES. // // // COUNT THE NUMBER OF CHILD ACTIVITY SUMMARIES WITH MULTIPLE CHILDREN. // int ChildActivitySummariesWithMultipleChildrenCount = 0; foreach (string ChildActivityName in ChildActivityNames) { // // GET THE LIST OF CHILD ACTIVITIES. // ChildActivitySummariesWithMultipleChildrenCount += CreatedListMap[ChildActivityName].Count > 1 ? 1 : 0; } if (ChildActivitySummariesWithMultipleChildrenCount > 0) { ChildActivitySummariesElement = _MarkerReportDocument.CreateElement("Summaries"); ChildActivitySummariesElement.SetAttribute("Count", ChildActivitySummariesWithMultipleChildrenCount.ToString(MarkerReportFactoryDefaults.CountDisplayFormatCode)); ActivityReportElement.AppendChild(ChildActivitySummariesElement); } } // // CREATE A SUMMARY RECORD FOR EACH CHILD ACTIVITY. // foreach (string ChildActivityName in ChildActivityNames) { // // GET THE LIST OF CHILD ACTIVITIES. // ActivityReportItemList ChildActivityList = CreatedListMap[ChildActivityName]; // // CREATE THE AGGREGATE RECORD. // if (_ShowAllSummaries || ChildActivityList.Count > 1) { ActivityReportAggregateItem CreatedAggregateItem = new ActivityReportAggregateItem(); CreatedAggregateItem.ActivityName = ChildActivityName; CreatedAggregateItem.Count = ChildActivityList.Count; CreatedAggregateItem.TotalDuration = ActivityReportItemCalculator.TotalDuration(ChildActivityList); CreatedAggregateItem.MaxDuration = ActivityReportItemCalculator.MaxDuration(ChildActivityList); CreatedAggregateItem.AvgDuration = ActivityReportItemCalculator.AvgDuration(ChildActivityList); CreatedAggregateItem.MinDuration = ActivityReportItemCalculator.MinDuration(ChildActivityList); // // CREATE THE SUMMARY ELEMENT FOR THE AGGREGATE RECORD. // XmlElement CreatedChildActivitySummaryElement = CreateActivityReportAggregateElementWithName(CreatedAggregateItem); // // ADD THE SUMMARY. // ChildActivitySummariesElement.AppendChild(CreatedChildActivitySummaryElement); } } // // CREATE THE CHILD ACTIVITIES ELEMENT. // XmlElement ChildActivitiesElement = _MarkerReportDocument.CreateElement("ChildActivities"); //ChildActivitiesElement.SetAttribute("Count", ParentReportItem.ChildReportItems.Length.ToString()); ActivityReportElement.AppendChild(ChildActivitiesElement); // // CREATE THE ITEMS FOR THE CHILDREN. // foreach (ActivityReportItem CurrentChildReportItem in ParentReportItem.ChildReportItems) { if (_ShowAllActivities || CurrentChildReportItem.ChildReportItems.Length > 0) { // // CREATE AND ADD THE CHILD REPORT ITEM TO THE CHILD ACTIVITIES ELEMENT // ChildActivitiesElement.AppendChild(CreateActivityReportElement(CurrentChildReportItem)); } } return(ActivityReportElement); }