/// <summary> /// /// </summary> /// <param name="reportData"></param> /// <param name="options"></param> /// <returns></returns> public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { List <string> rowData = new List <string>(); bool displayShortHeader = (options != null && options.ContainsKey("HEADER") && "SHORT" == options["HEADER"]); if (reportData?.CurrentSnapshot != null) { //Compute nb objectives int?nbObjectives = RulesViolationUtility.GetNbRuleWithViolations(reportData.CurrentSnapshot, Constants.RulesViolation.CriticalRulesViolation, 0, false); //Compute nb acchiveemnt for the whole applcation int?nbRuleWithViolations = RulesViolationUtility.GetNbRuleWithViolations(reportData.CurrentSnapshot, Constants.RulesViolation.CriticalRulesViolation, 0, true); int?nbAchievement = (nbObjectives.HasValue && nbRuleWithViolations.HasValue) ? (nbObjectives.Value - nbRuleWithViolations.Value) : (int?)null; double?achievementRatio = (nbAchievement.HasValue && nbObjectives.Value != 0) ? (double)nbAchievement.Value / nbObjectives.Value : (double?)null; //Compute nb acchiveemnt add in the last delivery int?nbAddedCriticalViolations = MeasureUtility.GetAddedCriticalViolations(reportData.CurrentSnapshot); if (!nbAddedCriticalViolations.HasValue) { nbAddedCriticalViolations = 0; } int?nbAchievementAdded = (nbObjectives.HasValue) ? nbObjectives.Value - nbAddedCriticalViolations.Value : (int?)null; double?achievementAddedRatio = (nbAchievementAdded.HasValue && nbObjectives.Value != 0) ? (double)nbAchievementAdded.Value / nbObjectives.Value : (double?)null; //BuildContent header rowData.AddRange(displayShortHeader ? new[] { " ", Labels.Obj, Labels.Achiev, Labels.AchievRatio } : new[] { " ", Labels.Objectives, Labels.Achievement, Labels.AchievementRatio }); //BuildContent "Entire Application" row rowData.AddRange(new[] { Labels.DeliveryWhole, nbObjectives?.ToString(MetricFormat) ?? string.Empty, nbAchievement?.ToString(MetricFormat) ?? string.Empty, FormatPercent(MathUtility.GetRound(achievementRatio), false) }); //BuildContent "Last Delivery" row rowData.AddRange(new[] { Labels.DeliveryLast, nbObjectives?.ToString(MetricFormat) ?? string.Empty, nbAchievementAdded?.ToString(MetricFormat) ?? string.Empty, FormatPercent(MathUtility.GetRound(achievementAddedRatio), false) }); } TableDefinition resultTable = new TableDefinition { HasRowHeaders = false, HasColumnHeaders = true, NbRows = 3, NbColumns = 4, Data = rowData }; return(resultTable); }
/// <summary> /// /// </summary> /// <param name="reportData"></param> /// <param name="options"></param> /// <returns></returns> protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { int nbLimitTop = 0; List <string> rowData = new List <string>(); bool displayShortHeader = (options != null && options.ContainsKey("HEADER") && "SHORT" == options["HEADER"]); if (options == null || !options.ContainsKey("COUNT") || !Int32.TryParse(options["COUNT"], out nbLimitTop)) { nbLimitTop = reportData.Parameter.NbResultDefault; } if (null != reportData && null != reportData.CurrentSnapshot) { //Compute nb objectives Int32?nbObjectives = RulesViolationUtility.GetNbRuleWithViolations(reportData.CurrentSnapshot, Constants.RulesViolation.CriticalRulesViolation, 0, false); //Compute nb acchiveemnt for the whole applcation Int32?nbRuleWithViolations = RulesViolationUtility.GetNbRuleWithViolations(reportData.CurrentSnapshot, Constants.RulesViolation.CriticalRulesViolation, 0, true); Int32?nbAchievement = (nbObjectives.HasValue && nbRuleWithViolations.HasValue) ? (nbObjectives.Value - nbRuleWithViolations.Value) : (Int32?)null; Double?achievementRatio = (nbAchievement.HasValue && nbObjectives.HasValue && nbObjectives.Value != 0) ? (Double)nbAchievement.Value / nbObjectives.Value : (Double?)null; //Compute nb acchiveemnt add in the last delivery Int32?nbAddedCriticalViolations = MeasureUtility.GetAddedCriticalViolations(reportData.CurrentSnapshot); if (!nbAddedCriticalViolations.HasValue) { nbAddedCriticalViolations = 0; } Int32?nbAchievementAdded = (nbObjectives.HasValue && nbAddedCriticalViolations.HasValue) ? nbObjectives.Value - nbAddedCriticalViolations.Value : (Int32?)null; Double?achievementAddedRatio = (nbAchievementAdded.HasValue && nbObjectives.HasValue && nbObjectives.Value != 0) ? (Double)nbAchievementAdded.Value / nbObjectives.Value : (Double?)null; //BuildContent header rowData.AddRange(displayShortHeader ? new[] { " ", Labels.Obj, Labels.Achiev, Labels.AchievRatio } : new[] { " ", Labels.Objectives, Labels.Achievement, Labels.AchievementRatio }); //BuildContent "Entire Application" row rowData.AddRange(new string[] { Labels.DeliveryWhole, (nbObjectives.HasValue)?nbObjectives.Value.ToString(_MetricFormat):String.Empty, (nbAchievement.HasValue)?nbAchievement.Value.ToString(_MetricFormat):String.Empty, TableBlock.FormatPercent(MathUtility.GetRound(achievementRatio), false) }); //BuildContent "Last Delivery" row rowData.AddRange(new string[] { Labels.DeliveryLast, (nbObjectives.HasValue)?nbObjectives.Value.ToString(_MetricFormat):String.Empty, (nbAchievementAdded.HasValue)?nbAchievementAdded.Value.ToString(_MetricFormat):String.Empty, TableBlock.FormatPercent(MathUtility.GetRound(achievementAddedRatio), false) }); } TableDefinition resultTable = new TableDefinition { HasRowHeaders = false, HasColumnHeaders = true, NbRows = 3, NbColumns = 4, Data = rowData }; return(resultTable); }