public override string Content(ReportData reportData, Dictionary <string, string> options) { string strRuleId = options.GetOption("RULID", string.Empty); string _snapshot = options.GetOption("SNAPSHOT", "CURRENT"); if (reportData?.CurrentSnapshot == null || string.IsNullOrEmpty(strRuleId)) { return(Constants.No_Value); } Result violations; int? totalChecks = null; int? failedChecks = null; if (_snapshot == "PREVIOUS" && reportData.PreviousSnapshot != null) { violations = reportData.RuleExplorer.GetRulesViolations(reportData.PreviousSnapshot.Href, strRuleId).FirstOrDefault(); } else { violations = reportData.RuleExplorer.GetRulesViolations(reportData.CurrentSnapshot.Href, strRuleId).FirstOrDefault(); } // ReSharper disable once InvertIf if (violations != null && violations.ApplicationResults.Any()) { totalChecks = RulesViolationUtility.GetTotalChecks(violations); failedChecks = RulesViolationUtility.GetFailedChecks(violations); } return($"{failedChecks?.ToString("N0") ?? Constants.No_Value} / {totalChecks?.ToString("N0") ?? Constants.No_Value}"); }
/// <summary> /// /// </summary> /// <param name="reportData"></param> /// <param name="options"></param> /// <returns></returns> public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { string srBusinessCriterias = (options != null && options.ContainsKey("PAR")) ? options["PAR"] : null; int count; if (options == null || !options.ContainsKey("COUNT") || !int.TryParse(options["COUNT"], out count)) { count = -1; } if (string.IsNullOrWhiteSpace(srBusinessCriterias)) { return(null); } // Parse business criterias Ids List <int> businessCriteriasIds = new List <int>(); string[] parentMetrics = srBusinessCriterias.Split('|'); foreach (var metric in parentMetrics.Distinct()) { int metricId; if (int.TryParse(metric, out metricId)) { businessCriteriasIds.Add(metricId); } } //Build result List <string> rowData = new List <string>(); rowData.AddRange(new[] { Labels.Criticality, Labels.Weight, Labels.Grade, Labels.TechnicalCriterion, Labels.RuleName, Labels.ViolCount, Labels.TotalOk }); var results = RulesViolationUtility.GetNbViolationByRule(reportData.CurrentSnapshot, reportData.RuleExplorer, businessCriteriasIds, count); int nbRows = 0; foreach (var item in results) { rowData.Add(item.Rule.Critical ? "µ" : string.Empty); rowData.Add(item.Rule.CompoundedWeight.ToString()); rowData.Add(item.Grade?.ToString("N2")); rowData.Add(item.TechnicalCriteraiName); rowData.Add(item.Rule.Name); rowData.Add(item.TotalFailed.HasValue ? item.TotalFailed.Value.ToString("N0") : Constants.No_Value); rowData.Add(item.TotalChecks.HasValue ? item.TotalChecks.Value.ToString("N0") : Constants.No_Value); nbRows++; } TableDefinition resultTable = new TableDefinition { HasRowHeaders = false, HasColumnHeaders = true, NbRows = nbRows + 1, NbColumns = 7, Data = rowData }; return(resultTable); }
public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { int rowCount = 0; List <string> rowData = new List <string>(); rowData.AddRange(new[] { Labels.TechnicalCriterionName, Labels.ViolationsCount, Labels.TotalChecks, Labels.Grade }); #region Options int nbLimitTop; if (null == options || !options.ContainsKey("COUNT") || !int.TryParse(options["COUNT"], out nbLimitTop)) { nbLimitTop = reportData.Parameter.NbResultDefault; } int bcCriteriaId; if (null == options || !options.ContainsKey("PAR") || !int.TryParse(options["PAR"], out bcCriteriaId)) { throw new ArgumentException("Impossible to build TC_IMPROVEMENT_OPPORTUNITY : Need business criterion id."); } #endregion Options var technicalCriticalViolation = RulesViolationUtility.GetTechnicalCriteriaViolations(reportData.CurrentSnapshot, (Constants.BusinessCriteria)bcCriteriaId, nbLimitTop); if (technicalCriticalViolation != null) { foreach (var item in technicalCriticalViolation) { rowData.AddRange(new[] { item.Name , item.TotalFailed.HasValue ? item.TotalFailed.Value.ToString("N0") : Constants.No_Value , item.TotalChecks.HasValue ? item.TotalChecks.Value.ToString("N0") : Constants.No_Value , item.Grade?.ToString("N2") ?? Constants.No_Value } ); } rowCount = technicalCriticalViolation.Count; } TableDefinition resultTable = new TableDefinition { HasRowHeaders = false, HasColumnHeaders = true, NbRows = rowCount + 1, NbColumns = 4, Data = rowData }; return(resultTable); }
public override string Content(ReportData reportData, Dictionary <string, string> options) { #region Item BCID int metricId = options.GetIntOption("BCID", (int)Constants.BusinessCriteria.TechnicalQualityIndex); #endregion Item BCID if (reportData?.Applications == null || null == reportData.Snapshots) { return(Constants.No_Value); } double?_cv = 0; Application[] _allApps = reportData.Applications; foreach (Application _app in _allApps) { try { Snapshot _snapshot = _app.Snapshots.OrderByDescending(_ => _.Annotation.Date.DateSnapShot).First(); if (_snapshot == null) { continue; } int?_snapCv = RulesViolationUtility.GetBCEvolutionSummary(_snapshot, metricId).FirstOrDefault()?.TotalCriticalViolations; if (_snapCv != null) { _cv = _cv + _snapCv; } } catch (Exception ex) { LogHelper.Instance.LogInfo(ex.Message); LogHelper.Instance.LogInfo(Labels.NoSnapshot); } } return(_cv.Value.ToString("N0")); }
public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { int nbRows = 0; int nbLimitTop; List <string> rowData = new List <string>(); rowData.AddRange(new[] { Labels.RuleName, Labels.ViolationsCount }); int?metricId = ((options != null && options.ContainsKey("BC-ID")) ? int.Parse(options["BC-ID"]) : (int?)null) ?? ((options != null && options.ContainsKey("PAR")) ? int.Parse(options["PAR"]) : (int?)null); if (options == null || !options.ContainsKey("COUNT") || !int.TryParse(options["COUNT"], out nbLimitTop)) { nbLimitTop = reportData.Parameter.NbResultDefault; } if (reportData?.CurrentSnapshot != null) { if (!metricId.HasValue) { metricId = 0; } var _nonCriticalRulesViolation = RulesViolationUtility.GetRuleViolations(reportData.CurrentSnapshot, Constants.RulesViolation.NonCriticalRulesViolation, (Constants.BusinessCriteria)metricId, true, nbLimitTop); if (_nonCriticalRulesViolation != null && _nonCriticalRulesViolation.Any()) { foreach (var elt in _nonCriticalRulesViolation) { rowData.AddRange(new[] { elt.Rule.Name, elt.TotalFailed?.ToString("N0") }); } } else { rowData.AddRange(new[] { Labels.NoItem, string.Empty }); } if (_nonCriticalRulesViolation != null) { nbRows = _nonCriticalRulesViolation.Count; } } TableDefinition resultTable = new TableDefinition { HasRowHeaders = false, HasColumnHeaders = true, NbRows = nbRows + 1, NbColumns = 2, Data = rowData }; return(resultTable); }
public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { int rowCount = 0; int nbLimitTop; List <string> rowData = new List <string>(); List <RuleViolationsVariationResultDTO> variationRules = new List <RuleViolationsVariationResultDTO>(); rowData.AddRange(new[] { Labels.RuleName, Labels.Current, Labels.Previous, Labels.Evolution, Labels.EvolutionPercent }); int?metricId = ((options != null && options.ContainsKey("BC-ID")) ? int.Parse(options["BC-ID"]) : (int?)null) ?? ((options != null && options.ContainsKey("PAR")) ? int.Parse((options["PAR"])) : (int?)null); if (options == null || !options.ContainsKey("COUNT") || !int.TryParse(options["COUNT"], out nbLimitTop)) { nbLimitTop = reportData.Parameter.NbResultDefault; } if (reportData?.CurrentSnapshot != null) { if (!metricId.HasValue) { metricId = 0; } var currentNonCriticalRulesViolation = RulesViolationUtility.GetAllRuleViolations(reportData.CurrentSnapshot, Constants.RulesViolation.NonCriticalRulesViolation, (Constants.BusinessCriteria)metricId, true); var previousNonCriticalRulesViolation = (reportData.PreviousSnapshot != null) ? RulesViolationUtility.GetAllRuleViolations(reportData.PreviousSnapshot, Constants.RulesViolation.NonCriticalRulesViolation, (Constants.BusinessCriteria)metricId, false) : null; if (currentNonCriticalRulesViolation != null) { rowCount += currentNonCriticalRulesViolation.Count; foreach (var item in currentNonCriticalRulesViolation) { //Get previous value var previousitem = previousNonCriticalRulesViolation?.FirstOrDefault(_ => _.Rule.Key == item.Rule.Key); double?previousval = previousitem?.TotalFailed; //Compute the varioation double?variation = (item.TotalFailed.HasValue && previousval.HasValue) ? (item.TotalFailed.Value - previousval.Value) : (double?)null; variationRules.Add(new RuleViolationsVariationResultDTO { Rule = new RuleDetailsDTO { Name = item.Rule.Name, Key = item.Rule.Key }, CurrentNbViolations = item.TotalFailed ?? -1, PreviousNbViolations = previousitem?.TotalFailed ?? -1, Variation = variation ?? double.NaN, Ratio = (variation.HasValue && previousval > 0) ? variation / previousval : double.NaN }); } var selectedRules = variationRules.OrderByDescending(_ => _.Ratio).Take(nbLimitTop); foreach (var varRule in selectedRules) { rowData.AddRange(new[] { varRule.Rule.Name , (varRule.CurrentNbViolations.HasValue && varRule.CurrentNbViolations.Value != -1)? varRule.CurrentNbViolations.Value.ToString("N0"): Constants.No_Value , (varRule.PreviousNbViolations.HasValue && varRule.PreviousNbViolations.Value != -1)? varRule.PreviousNbViolations.Value.ToString("N0"): Constants.No_Value , (varRule.Variation.HasValue && !double.IsNaN(varRule.Variation.Value))? FormatEvolution((int)varRule.Variation.Value):Constants.No_Value , (varRule.Ratio.HasValue && !double.IsNaN(varRule.Ratio.Value)) ? FormatPercent(varRule.Ratio.Value) : Constants.No_Value } ); } } else { rowData.AddRange(new[] { Labels.NoItem, string.Empty, string.Empty, string.Empty, string.Empty }); rowCount = 1; } } var resultTable = new TableDefinition { HasRowHeaders = false, HasColumnHeaders = true, NbRows = rowCount + 1, NbColumns = 5, Data = rowData }; return(resultTable); }
public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { var results = RulesViolationUtility.GetStatViolation(reportData.CurrentSnapshot); List <string> rowData = new List <string>(); rowData.AddRange(new[] { " ", Labels.TQI, Labels.Robu, Labels.Efcy, Labels.Secu, Labels.Trans, Labels.Chang }); rowData.AddRange(new[] { Labels.Current, " ", " ", " ", " ", " ", " " }); foreach (var resultModule in results.OrderBy(_ => _.ModuleName)) { rowData.AddRange(new[] { resultModule.ModuleName, resultModule[Constants.BusinessCriteria.TechnicalQualityIndex]?.TotalCriticalViolations?.ToString(MetricFormat) ?? Constants.No_Value, resultModule[Constants.BusinessCriteria.Robustness]?.TotalCriticalViolations?.ToString(MetricFormat) ?? Constants.No_Value, resultModule[Constants.BusinessCriteria.Performance]?.TotalCriticalViolations?.ToString(MetricFormat) ?? Constants.No_Value, resultModule[Constants.BusinessCriteria.Security]?.TotalCriticalViolations?.ToString(MetricFormat) ?? Constants.No_Value, resultModule[Constants.BusinessCriteria.Transferability]?.TotalCriticalViolations?.ToString(MetricFormat) ?? Constants.No_Value, resultModule[Constants.BusinessCriteria.Changeability]?.TotalCriticalViolations?.ToString(MetricFormat) ?? Constants.No_Value, }); } rowData.AddRange(new[] { Labels.ViolationsAdded, " ", " ", " ", " ", " ", " " }); foreach (var resultModule in results.OrderBy(_ => _.ModuleName)) { rowData.AddRange(new[] { resultModule.ModuleName, resultModule[Constants.BusinessCriteria.TechnicalQualityIndex]?.AddedCriticalViolations?.ToString(MetricFormat) ?? Constants.No_Value, resultModule[Constants.BusinessCriteria.Robustness]?.AddedCriticalViolations?.ToString(MetricFormat) ?? Constants.No_Value, resultModule[Constants.BusinessCriteria.Performance]?.AddedCriticalViolations?.ToString(MetricFormat) ?? Constants.No_Value, resultModule[Constants.BusinessCriteria.Security]?.AddedCriticalViolations?.ToString(MetricFormat) ?? Constants.No_Value, resultModule[Constants.BusinessCriteria.Transferability]?.AddedCriticalViolations?.ToString(MetricFormat) ?? Constants.No_Value, resultModule[Constants.BusinessCriteria.Changeability]?.AddedCriticalViolations?.ToString(MetricFormat) ?? Constants.No_Value, }); } rowData.AddRange(new[] { Labels.ViolationsRemoved, " ", " ", " ", " ", " ", " " }); foreach (var resultModule in results.OrderBy(_ => _.ModuleName)) { rowData.AddRange(new[] { resultModule.ModuleName, resultModule[Constants.BusinessCriteria.TechnicalQualityIndex]?.RemovedCriticalViolations?.ToString(MetricFormat) ?? Constants.No_Value, resultModule[Constants.BusinessCriteria.Robustness]?.RemovedCriticalViolations?.ToString(MetricFormat) ?? Constants.No_Value, resultModule[Constants.BusinessCriteria.Performance]?.RemovedCriticalViolations?.ToString(MetricFormat) ?? Constants.No_Value, resultModule[Constants.BusinessCriteria.Security]?.RemovedCriticalViolations?.ToString(MetricFormat) ?? Constants.No_Value, resultModule[Constants.BusinessCriteria.Transferability]?.RemovedCriticalViolations?.ToString(MetricFormat) ?? Constants.No_Value, resultModule[Constants.BusinessCriteria.Changeability]?.RemovedCriticalViolations?.ToString(MetricFormat) ?? Constants.No_Value, }); } var resultTable = new TableDefinition { HasRowHeaders = false, HasColumnHeaders = true, NbRows = results.Count, NbColumns = 7, Data = rowData }; return(resultTable); }
protected override string Content(ReportData reportData, Dictionary <string, string> options) { int metricId; #region Item BCID if (options == null || !options.ContainsKey("BCID") || !int.TryParse(options["BCID"], out metricId)) { metricId = 0; } #endregion Item BCID if (null != reportData && null != reportData.Applications && null != reportData.snapshots) { double?CV = 0; Application[] AllApps = reportData.Applications; for (int j = 0; j < AllApps.Count(); j++) { Application App = AllApps[j]; int nbSnapshotsEachApp = App.Snapshots.Count(); if (nbSnapshotsEachApp > 0) { foreach (Snapshot snapshot in App.Snapshots.OrderByDescending(_ => _.Annotation.Date.DateSnapShot)) { Snapshot[] BuiltSnapshots = reportData.snapshots; foreach (Snapshot BuiltSnapshot in BuiltSnapshots) { if (snapshot == BuiltSnapshot) { //double? criticalViolation = MeasureUtility.GetSizingMeasure(BuiltSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesNumber); //var rulesViolation = RulesViolationUtility.GetRuleViolations(BuiltSnapshot, // Constants.RulesViolation.CriticalRulesViolation, // (Constants.BusinessCriteria)metricId, // true, // 100); //if (null != rulesViolation) //{ // foreach (var elt in rulesViolation) // { // CV = CV + elt.TotalFailed.Value; // } //} var results = RulesViolationUtility.GetStatViolation(BuiltSnapshot); foreach (var resultModule in results.OrderBy(_ => _.ModuleName)) { CV = CV + ((resultModule != null && resultModule[(Constants.BusinessCriteria)metricId].Total.HasValue) ? resultModule[(Constants.BusinessCriteria)metricId].Total.Value : 0); } break; } } break; } } } //return string.Format("{0:n0}", intFinalValue) + "%"; //return Convert.ToInt32(rulesViol).ToString(); return(string.Format("{0:n0}", Convert.ToInt32(CV))); } return(CastReporting.Domain.Constants.No_Value); }
public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { int metricId = options.GetIntOption("ALT", (int)Constants.BusinessCriteria.TechnicalQualityIndex); int nbLimitTop = options.GetIntOption("COUNT", reportData.Parameter.NbResultDefault); List <string> rowData = new List <string>(); int nbRows = 0; if (reportData.Applications == null || reportData.Snapshots == null) { return(null); } switch (metricId) { case 60012: rowData.AddRange(new[] { Labels.Application, Labels.ViolationsCritical, Labels.Changeability, Labels.SnapshotDate }); break; case 60014: rowData.AddRange(new[] { Labels.Application, Labels.ViolationsCritical, Labels.Efficiency, Labels.SnapshotDate }); break; case 60013: rowData.AddRange(new[] { Labels.Application, Labels.ViolationsCritical, Labels.Robustness, Labels.SnapshotDate }); break; case 60016: rowData.AddRange(new[] { Labels.Application, Labels.ViolationsCritical, Labels.Security, Labels.SnapshotDate }); break; case 60011: rowData.AddRange(new[] { Labels.Application, Labels.ViolationsCritical, Labels.Transferability, Labels.SnapshotDate }); break; case 60017: rowData.AddRange(new[] { Labels.Application, Labels.ViolationsCritical, Labels.TQI, Labels.SnapshotDate }); break; default: rowData.AddRange(new[] { Labels.Application, Labels.ViolationsCritical, Labels.TQI, Labels.SnapshotDate }); break; } DataTable dt = new DataTable(); dt.Columns.Add("AppName", typeof(string)); dt.Columns.Add("CV", typeof(double)); dt.Columns.Add("BizCritScore", typeof(double)); dt.Columns.Add("LastAnalysis", typeof(string)); Application[] _allApps = reportData.Applications; foreach (Application _app in _allApps) { try { Snapshot _snapshot = _app.Snapshots.OrderByDescending(_ => _.Annotation.Date.DateSnapShot).First(); if (_snapshot == null) { continue; } string strAppName = _app.Name; double?_cv = RulesViolationUtility.GetBCEvolutionSummary(_snapshot, metricId).FirstOrDefault().TotalCriticalViolations; double?strCurrentBCGrade = BusinessCriteriaUtility.GetSnapshotBusinessCriteriaGrade(_snapshot, (Constants.BusinessCriteria)metricId, false); string strLastAnalysis = Convert.ToDateTime(_snapshot.Annotation.Date.DateSnapShot.Value).ToString("MMM dd yyyy"); dt.Rows.Add(strAppName, _cv.Value, strCurrentBCGrade, strLastAnalysis); nbRows++; } catch (Exception ex) { LogHelper.Instance.LogInfo(ex.Message); LogHelper.Instance.LogInfo(Labels.NoSnapshot); } } DataView dv = dt.DefaultView; dv.Sort = "BizCritScore"; DataTable dtSorted = dv.ToTable(); if (nbRows < nbLimitTop) { nbLimitTop = nbRows; } for (int i = 0; i < nbLimitTop; i++) { rowData.AddRange (new[] { dtSorted.Rows[i]["AppName"].ToString() , $"{Convert.ToDouble(dtSorted.Rows[i]["CV"]):N0}" , $"{Convert.ToDouble(dtSorted.Rows[i]["BizCritScore"]):N2}" , dtSorted.Rows[i]["LastAnalysis"].ToString() }); } var resultTable = new TableDefinition { HasRowHeaders = false, HasColumnHeaders = true, NbRows = nbLimitTop + 1, NbColumns = 4, Data = rowData }; return(resultTable); }
public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { int metricId = options.GetIntOption("BCID", 60017); var rowData = new List <string>(); rowData.AddRange(new[] { " ", Labels.ViolationsCritical + " - " + Labels.ViolationsRemoved, Labels.ViolationsCritical + " - " + Labels.ViolationsAdded, Labels.ViolationsCritical + " - " + Labels.Total }); DataTable dtDates = new DataTable(); dtDates.Columns.Add("Quarter", typeof(int)); dtDates.Columns.Add("Year", typeof(int)); dtDates.Columns.Add("RemovedCritViol", typeof(double)); dtDates.Columns.Add("AddedCritViol", typeof(double)); dtDates.Columns.Add("TotalCritViol", typeof(double)); dtDates.AcceptChanges(); #region Fetch SnapshotsPF if (reportData?.Applications != null && reportData.Snapshots != null) { Snapshot[] _allSnapshots = reportData.Snapshots; int generateQuater = 6; DateTime _dateNow = DateTime.Now; int currentYear = _dateNow.Year; int currentQuater = DateUtil.GetQuarter(_dateNow); for (int i = generateQuater; i > 0; i--) { DataRow dr = dtDates.NewRow(); dr["Quarter"] = currentQuater; dr["Year"] = currentYear; dtDates.Rows.InsertAt(dr, 0); currentYear = DateUtil.GetPreviousQuarterYear(currentQuater, currentYear); currentQuater = DateUtil.GetPreviousQuarter(currentQuater); } for (int i = 0; i < dtDates.Rows.Count; i++) { double?_removedCritViol = 0; double?_addedCritViol = 0; double?_totalCritViol = 0; if (_allSnapshots.Length > 0) { foreach (Snapshot snapshot in _allSnapshots.OrderBy(_ => _.Annotation.Date.DateSnapShot)) { if (snapshot.Annotation.Date.DateSnapShot == null) { continue; } DateTime _snapshotDate = Convert.ToDateTime(snapshot.Annotation.Date.DateSnapShot.Value); int intQuarter = Convert.ToInt32(dtDates.Rows[i]["Quarter"]); int intYear = Convert.ToInt32(dtDates.Rows[i]["Year"]); int intSnapshotQuarter = DateUtil.GetQuarter(_snapshotDate); int intSnapshotYear = _snapshotDate.Year; if (intQuarter != intSnapshotQuarter || intYear != intSnapshotYear) { continue; } ViolationsStatisticsDTO results = RulesViolationUtility.GetBCEvolutionSummary(snapshot, metricId).First(); if (results == null) { continue; } _removedCritViol = _removedCritViol + results.RemovedCriticalViolations; _addedCritViol = _addedCritViol + results.AddedCriticalViolations; _totalCritViol = _totalCritViol + results.TotalCriticalViolations; } } dtDates.Rows[i]["RemovedCritViol"] = _removedCritViol * -1; dtDates.Rows[i]["AddedCritViol"] = _addedCritViol; dtDates.Rows[i]["TotalCritViol"] = _totalCritViol; } for (int i = 0; i < dtDates.Rows.Count; i++) { string strQuarter = dtDates.Rows[i]["Year"] + " Q" + dtDates.Rows[i]["Quarter"]; rowData.Add(strQuarter); rowData.Add(dtDates.Rows[i]["RemovedCritViol"].ToString()); rowData.Add(dtDates.Rows[i]["AddedCritViol"].ToString()); rowData.Add(dtDates.Rows[i]["TotalCritViol"].ToString()); } } #endregion Fetch SnapshotsPF TableDefinition resultTable = new TableDefinition { HasRowHeaders = true, HasColumnHeaders = false, NbRows = dtDates.Rows.Count + 1, NbColumns = 4, Data = rowData, GraphOptions = null }; return(resultTable); }
protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { TableDefinition resultTable = null; int nbLimitTop = 0; string dataSource = string.Empty; int metricId; #region Item ALT if (options == null || !options.ContainsKey("ALT") || !int.TryParse(options["ALT"], out metricId)) { metricId = reportData.Parameter.NbResultDefault; } #endregion Item ALT #region Item Count if (options == null || !options.ContainsKey("COUNT") || !int.TryParse(options["COUNT"], out nbLimitTop)) { nbLimitTop = reportData.Parameter.NbResultDefault; } #endregion Item Count List <string> rowData = new List <string>(); int nbRows = 0; if (reportData.Applications != null && reportData.snapshots != null) { if (metricId == 60012) { rowData.AddRange(new string[] { Labels.Application, Labels.ViolationsCritical, Labels.Changeability, Labels.SnapshotDate }); } else if (metricId == 60014) { rowData.AddRange(new string[] { Labels.Application, Labels.ViolationsCritical, Labels.Efficiency, Labels.SnapshotDate }); } else if (metricId == 60013) { rowData.AddRange(new string[] { Labels.Application, Labels.ViolationsCritical, Labels.Robustness, Labels.SnapshotDate }); } else if (metricId == 60016) { rowData.AddRange(new string[] { Labels.Application, Labels.ViolationsCritical, Labels.Security, Labels.SnapshotDate }); } else if (metricId == 60017) { rowData.AddRange(new string[] { Labels.Application, Labels.ViolationsCritical, Labels.TQI, Labels.SnapshotDate }); } else if (metricId == 60011) { rowData.AddRange(new string[] { Labels.Application, Labels.ViolationsCritical, Labels.Transferability, Labels.SnapshotDate }); } DataTable dt = new DataTable(); dt.Columns.Add("AppName", typeof(string)); dt.Columns.Add("CV", typeof(double)); dt.Columns.Add("Efficiency", typeof(double)); dt.Columns.Add("LastAnalysis", typeof(string)); Application[] AllApps = reportData.Applications; for (int j = 0; j < AllApps.Count(); j++) { Application App = AllApps[j]; int nbSnapshotsEachApp = App.Snapshots.Count(); if (nbSnapshotsEachApp > 0) { foreach (Snapshot snapshot in App.Snapshots.OrderByDescending(_ => _.Annotation.Date.DateSnapShot)) { Snapshot[] BuiltSnapshots = reportData.snapshots; foreach (Snapshot BuiltSnapshot in BuiltSnapshots) { if (snapshot == BuiltSnapshot) { string strAppName = App.Name; double?CV = 0; var results = RulesViolationUtility.GetStatViolation(BuiltSnapshot); foreach (var resultModule in results.OrderBy(_ => _.ModuleName)) { CV = CV + ((resultModule != null && resultModule[(Constants.BusinessCriteria)metricId].Total.HasValue) ? resultModule[(Constants.BusinessCriteria)metricId].Total.Value : 0); } string currSnapshotLabel = SnapshotUtility.GetSnapshotVersionNumber(BuiltSnapshot); BusinessCriteriaDTO currSnapshotBisCriDTO = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(BuiltSnapshot, false); double?strCurrentEfficiency = 0; if (metricId == 60012) { strCurrentEfficiency = currSnapshotBisCriDTO.Changeability.HasValue ? currSnapshotBisCriDTO.Changeability.Value : 0; } else if (metricId == 60014) { strCurrentEfficiency = currSnapshotBisCriDTO.Performance.HasValue ? currSnapshotBisCriDTO.Performance.Value : 0; } else if (metricId == 60013) { strCurrentEfficiency = currSnapshotBisCriDTO.Robustness.HasValue ? currSnapshotBisCriDTO.Robustness.Value : 0; } else if (metricId == 60016) { strCurrentEfficiency = currSnapshotBisCriDTO.Security.HasValue ? currSnapshotBisCriDTO.Security.Value : 0; } else if (metricId == 60017) { strCurrentEfficiency = currSnapshotBisCriDTO.TQI.HasValue ? currSnapshotBisCriDTO.TQI.Value : 0; } else if (metricId == 60011) { strCurrentEfficiency = currSnapshotBisCriDTO.Transferability.HasValue ? currSnapshotBisCriDTO.Transferability.Value : 0; } string strLastAnalysis = Convert.ToDateTime(BuiltSnapshot.Annotation.Date.DateSnapShot.Value).ToString("MMM dd yyyy"); dt.Rows.Add(strAppName, CV, strCurrentEfficiency, strLastAnalysis); // rowData.AddRange //(new string[] { strAppName.ToString() // , CV.ToString() // , strCurrentEfficiency.GetValueOrDefault().ToString() // , strLastAnalysis.ToString() // }); nbRows++; break; } } break; } } continue; } DataView dv = dt.DefaultView; dv.Sort = "Efficiency"; DataTable dtSorted = dv.ToTable(); if (nbRows < nbLimitTop) { nbLimitTop = nbRows; } for (int i = 0; i < nbLimitTop; i++) { rowData.AddRange (new string[] { dtSorted.Rows[i]["AppName"].ToString() , dtSorted.Rows[i]["CV"].ToString() , string.Format("{0:0.00}", Convert.ToDouble(dtSorted.Rows[i]["Efficiency"])) , dtSorted.Rows[i]["LastAnalysis"].ToString() }); } } resultTable = new TableDefinition { HasRowHeaders = false, HasColumnHeaders = true, NbRows = nbLimitTop + 1, NbColumns = 4, Data = rowData }; return(resultTable); }
public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { List <string> rowData = new List <string>(); List <CellAttributes> cellProps = new List <CellAttributes>(); int cellidx = 0; // cellProps will contains the properties of the cell (background color) linked to the data by position in the list stored with cellidx. List <string> metrics = options.GetOption("METRICS").Trim().Split('|').ToList(); bool critical; if (options == null || !options.ContainsKey("CRITICAL")) { critical = false; } else { critical = options.GetOption("CRITICAL").Equals("true"); } List <string> qualityRules = MetricsUtility.BuildRulesList(reportData, metrics, critical); rowData.Add(Labels.Violations); cellidx++; if (qualityRules.Count > 0) { const string bcId = "60017"; int nbLimitTop = options.GetIntOption("COUNT", 5); bool hasPreviousSnapshot = reportData.PreviousSnapshot != null; foreach (string _metric in qualityRules) { RuleDescription rule = reportData.RuleExplorer.GetSpecificRule(reportData.Application.DomainId, _metric); string ruleName = rule.Name; if (ruleName == null) { continue; } int metricId; if (!int.TryParse(_metric, out metricId)) { continue; } ViolStatMetricIdDTO violStats = RulesViolationUtility.GetViolStat(reportData.CurrentSnapshot, metricId); if (violStats == null) { continue; } // if no violations, do not display anything for this rule if (violStats.TotalViolations < 1) { continue; } rowData.Add(""); cellidx++; rowData.Add(Labels.ObjectsInViolationForRule + " " + ruleName); cellProps.Add(new CellAttributes(cellidx, Color.Gray, Color.White, "bold")); cellidx++; rowData.Add(Labels.ViolationsCount + ": " + violStats.TotalViolations); cellProps.Add(new CellAttributes(cellidx, Color.White)); cellidx++; if (!string.IsNullOrWhiteSpace(rule.Rationale)) { rowData.Add(Labels.Rationale + ": "); cellProps.Add(new CellAttributes(cellidx, Color.LightGray)); cellidx++; rowData.Add(rule.Rationale); cellProps.Add(new CellAttributes(cellidx, Color.White)); cellidx++; } rowData.Add(Labels.Description + ": "); cellProps.Add(new CellAttributes(cellidx, Color.LightGray)); cellidx++; rowData.Add(rule.Description); cellProps.Add(new CellAttributes(cellidx, Color.White)); cellidx++; if (!string.IsNullOrWhiteSpace(rule.Remediation)) { rowData.Add(Labels.Remediation + ": "); cellProps.Add(new CellAttributes(cellidx, Color.LightGray)); cellidx++; rowData.Add(rule.Remediation); cellProps.Add(new CellAttributes(cellidx, Color.White)); cellidx++; } IEnumerable <Violation> results = reportData.SnapshotExplorer.GetViolationsListIDbyBC(reportData.CurrentSnapshot.Href, _metric, bcId, nbLimitTop, "$all"); if (results == null) { continue; } var _violations = results as Violation[] ?? results.ToArray(); if (_violations.Length == 0) { continue; } int violation_counter = 0; string domainId = reportData.CurrentSnapshot.DomainId; string snapshotId = reportData.CurrentSnapshot.Id.ToString(); cellidx = MetricsUtility.PopulateViolationsBookmarks(reportData, _violations, violation_counter, rowData, cellidx, ruleName, cellProps, hasPreviousSnapshot, domainId, snapshotId, _metric); // Add empty lines for readability for (int i = 1; i < 5; i++) { rowData.Add(""); cellidx++; } } if (rowData.Count <= 1) { rowData.Add(Labels.NoViolation); } } else { rowData.Add(Labels.NoItem); } var table = new TableDefinition { HasRowHeaders = false, HasColumnHeaders = true, NbRows = rowData.Count, NbColumns = 1, Data = rowData, CellsAttributes = cellProps }; return(table); }
protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { int rowCount = 0; int nbLimitTop = 0; int order = 0; List <string> rowData = new List <string>(); TableDefinition resultTable = null; List <RuleVariationResultDTO> variationRules = new List <RuleVariationResultDTO>(); //List<RuleVariationResultDTO> improvmentRules = new List<RuleVariationResultDTO>(); //List<RuleVariationResultDTO> degradationRules = new List<RuleVariationResultDTO>(); //List<RuleVariationResultDTO> selected_elements = new List<RuleVariationResultDTO>(); IEnumerable <RuleVariationResultDTO> selected_elements; rowData.AddRange(new string[] { Labels.RuleName, Labels.ViolationsCurrent, Labels.ViolationsPrevious, Labels.Evolution, Labels.Grade, Labels.GradeEvolution }); Int32?metricId = (options != null && options.ContainsKey("PAR")) ? Convert.ToInt32(options["PAR"]) : (Int32?)null; if (options == null || !options.ContainsKey("COUNT") || !Int32.TryParse(options["COUNT"], out nbLimitTop)) { nbLimitTop = reportData.Parameter.NbResultDefault; } if (options == null || !options.ContainsKey("C") || !Int32.TryParse(options["C"], out order)) { order = 0; } if (reportData != null && reportData.CurrentSnapshot != null && metricId.HasValue) { var currentCriticalRulesViolation = RulesViolationUtility.GetAllRuleViolations(reportData.CurrentSnapshot, Constants.RulesViolation.All, (Constants.BusinessCriteria)metricId, true); var previousCriticalRulesViolation = (reportData.PreviousSnapshot != null) ? RulesViolationUtility.GetAllRuleViolations(reportData.PreviousSnapshot, Constants.RulesViolation.All, (Constants.BusinessCriteria)metricId, false) : null; if (currentCriticalRulesViolation != null) { foreach (var item in currentCriticalRulesViolation) { //Get previous value var previousitem = (previousCriticalRulesViolation != null) ? previousCriticalRulesViolation.FirstOrDefault(_ => _.Rule.Key == item.Rule.Key) : null; double?previousVal = (previousitem != null && previousitem.TotalFailed.HasValue) ? previousitem.TotalFailed.Value : (double?)null; double?previousGrade = (previousitem != null && previousitem.Grade.HasValue) ? previousitem.Grade.Value : (double?)null; //Compute the varioation double?variationVal = (item.TotalFailed.HasValue && previousVal.HasValue) ? (item.TotalFailed.Value - previousVal.Value) : (double?)null; double?variationGrade = (item.TotalFailed.HasValue && previousVal.HasValue) ? (item.Grade.Value - previousGrade.Value) : (double?)null; variationRules.Add(new RuleVariationResultDTO { Rule = new RuleDetailsDTO { Name = item.Rule.Name, Key = item.Rule.Key }, CurrentNbViolations = (item.TotalFailed.HasValue) ? item.TotalFailed.Value : -1, PreviousNbViolations = (previousitem != null && previousitem.TotalFailed.HasValue) ? previousitem.TotalFailed.Value : -1, Evolution = (variationVal.HasValue && previousVal.HasValue && previousVal > 0) ? variationVal / previousVal : double.NaN, Grade = (item.Grade.HasValue) ? item.Grade.Value : double.NaN, GradeEvolution = (variationGrade.HasValue && previousGrade.HasValue && previousGrade > 0) ? variationGrade / previousGrade : double.NaN }); } switch (order) { default: case 0: { selected_elements = variationRules.OrderByDescending(_ => _.Rule.CompoundedWeight * (4 - _.Grade.Value)).Take(nbLimitTop); break; } case 1: { selected_elements = variationRules.Where(_ => _.GradeEvolution >= 0).OrderByDescending(_ => _.GradeEvolution).Take(nbLimitTop); break; } case 2: { selected_elements = variationRules.Where(_ => _.GradeEvolution < 0).OrderBy(_ => _.GradeEvolution).Take(nbLimitTop); break; } } ; foreach (var varRule in selected_elements) { rowData.AddRange(new string[] { varRule.Rule.Name , (varRule.CurrentNbViolations.HasValue && varRule.CurrentNbViolations.Value != -1)? varRule.CurrentNbViolations.Value.ToString("N0"): CastReporting.Domain.Constants.No_Value , (varRule.PreviousNbViolations.HasValue && varRule.PreviousNbViolations.Value != -1)? varRule.PreviousNbViolations.Value.ToString("N0"): CastReporting.Domain.Constants.No_Value , (varRule.Evolution.HasValue && !double.IsNaN(varRule.Evolution.Value)) ? TableBlock.FormatPercent(varRule.Evolution.Value) : Constants.No_Value , (varRule.Grade.HasValue && !double.IsNaN(varRule.Grade.Value)) ? varRule.Grade.Value.ToString("N2"):CastReporting.Domain.Constants.No_Value , (varRule.GradeEvolution.HasValue && !double.IsNaN(varRule.GradeEvolution.Value)) ? TableBlock.FormatPercent(varRule.GradeEvolution.Value) : Constants.No_Value } ); rowCount++; } } else { rowData.AddRange(new string[] { Labels.NoItem, string.Empty, string.Empty, string.Empty, string.Empty }); rowCount = 1; } } resultTable = new TableDefinition { HasRowHeaders = false, HasColumnHeaders = true, NbRows = rowCount + 1, NbColumns = 6, Data = rowData }; return(resultTable); }
protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { int metricId; #region Item BCID if (options == null || !options.ContainsKey("BCID") || !int.TryParse(options["BCID"], out metricId)) { metricId = reportData.Parameter.NbResultDefault; } #endregion Item BCID var rowData = new List <String>(); rowData.AddRange(new string[] { " ", Labels.ViolationsCritical + " - " + Labels.ViolationsRemoved, Labels.ViolationsCritical + " - " + Labels.ViolationsAdded, Labels.ViolationsCritical + " - " + Labels.Total }); DataTable dtDates = new DataTable(); dtDates.Columns.Add("Quarter", typeof(int)); dtDates.Columns.Add("Year", typeof(int)); dtDates.Columns.Add("RemovedViol", typeof(double)); dtDates.Columns.Add("AddedViol", typeof(double)); dtDates.Columns.Add("TotalViol", typeof(double)); dtDates.AcceptChanges(); #region Fetch SnapshotsPF if (reportData != null && reportData.Applications != null && reportData.snapshots != null) { DateTime DateNow = DateTime.Now; //DateTime DateNow = Convert.ToDateTime("03 01 2014"); Application[] AllApps = reportData.Applications; Snapshot[] AllSnapshots = reportData.snapshots; int generateQuater = 6; int currentYear = DateNow.Year; int currentQuater = GetQuarter(DateNow); for (int i = generateQuater; i > 0; i--) { DataRow dr = dtDates.NewRow(); dr["Quarter"] = currentQuater; dr["Year"] = currentYear; dtDates.Rows.InsertAt(dr, 0); //dtDates.Rows.Add(currentQuater, currentYear); if (--currentQuater == 0) { currentQuater = 4; currentYear--; } } double?RemovedViol = 0; double?AddedViol = 0; double?TotalViol = 0; for (int i = 0; i < dtDates.Rows.Count; i++) { RemovedViol = 0; AddedViol = 0; TotalViol = 0; if (AllSnapshots.Count() > 0) { foreach (Snapshot snapshot in AllSnapshots.OrderBy(_ => _.Annotation.Date.DateSnapShot)) { DateTime SnapshotDate = Convert.ToDateTime(snapshot.Annotation.Date.DateSnapShot.Value); int intQuarter = Convert.ToInt32(dtDates.Rows[i]["Quarter"]); int intYear = Convert.ToInt32(dtDates.Rows[i]["Year"]); int intSnapshotQuarter = GetQuarter(SnapshotDate); int intSnapshotYear = SnapshotDate.Year; if (intQuarter == intSnapshotQuarter && intYear == intSnapshotYear) { var results = RulesViolationUtility.GetStatViolation(snapshot); foreach (var resultModule in results) { if (resultModule[(Constants.BusinessCriteria)metricId] != null) { int CriticalViolThisModulePerformanceTotal = (resultModule != null && resultModule[(Constants.BusinessCriteria)metricId].Total.HasValue) ? resultModule[(Constants.BusinessCriteria)metricId].Total.Value : 0; int CriticalViolThisModulePerformanceAdded = (resultModule != null && resultModule[(Constants.BusinessCriteria)metricId].Added.HasValue) ? resultModule[(Constants.BusinessCriteria)metricId].Added.Value : 0; int CriticalViolThisModulePerformanceRemoved = (resultModule != null && resultModule[(Constants.BusinessCriteria)metricId].Removed.HasValue) ? resultModule[(Constants.BusinessCriteria)metricId].Removed.Value : 0; RemovedViol = RemovedViol + CriticalViolThisModulePerformanceRemoved; AddedViol = AddedViol + CriticalViolThisModulePerformanceAdded; TotalViol = TotalViol + CriticalViolThisModulePerformanceTotal; } } } } } if (RemovedViol > 0) { RemovedViol = RemovedViol * -1; } dtDates.Rows[i]["RemovedViol"] = RemovedViol; dtDates.Rows[i]["AddedViol"] = AddedViol; dtDates.Rows[i]["TotalViol"] = TotalViol; } for (int i = 0; i < dtDates.Rows.Count; i++) { string strQuarter = dtDates.Rows[i]["Year"].ToString() + " Q" + dtDates.Rows[i]["Quarter"].ToString(); rowData.AddRange(new string[] { strQuarter, dtDates.Rows[i]["RemovedViol"].ToString(), dtDates.Rows[i]["AddedViol"].ToString(), dtDates.Rows[i]["TotalViol"].ToString(), }); } } #endregion Fetch SnapshotsPF TableDefinition resultTable = new TableDefinition { HasRowHeaders = true, HasColumnHeaders = false, NbRows = dtDates.Rows.Count + 1, NbColumns = 4, Data = rowData, GraphOptions = null }; return(resultTable); }
protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { var results = RulesViolationUtility.GetStatViolation(reportData.CurrentSnapshot); int param = 0; bool showPrevious = false; if (reportData.PreviousSnapshot != null && null != options && options.ContainsKey("SHOW_PREVIOUS") && Int32.TryParse(options["SHOW_PREVIOUS"], out param)) { showPrevious = (param != 0); } List <string> rowData = new List <string>(); int nbRows = 0; rowData.AddRange(new[] { " ", Labels.TQI, Labels.Robu, Labels.Efcy, Labels.Secu, Labels.Trans, Labels.Chang }); nbRows++; var busCrit = new Constants.BusinessCriteria[] { Constants.BusinessCriteria.TechnicalQualityIndex, Constants.BusinessCriteria.Robustness, Constants.BusinessCriteria.Performance, Constants.BusinessCriteria.Security, Constants.BusinessCriteria.Transferability, Constants.BusinessCriteria.Changeability }; var curVersion = new int[busCrit.Length]; var added = new int[busCrit.Length]; var removed = new int[busCrit.Length]; foreach (var resultModule in results) { if (resultModule != null) { for (int i = 0; i < busCrit.Length; i++) { var crit = busCrit[i]; if (resultModule[crit] != null) { if (resultModule[crit].Total.HasValue) { curVersion[i] += resultModule[crit].Total.Value; } if (resultModule[crit].Added.HasValue) { added[i] += resultModule[crit].Added.Value; } if (resultModule[crit].Removed.HasValue) { removed[i] += resultModule[crit].Removed.Value; } } } } } rowData.Add(Labels.VersionCurrent); foreach (var curValue in curVersion) { rowData.Add(curValue.ToString()); } nbRows++; rowData.Add(" " + Labels.ViolationsAdded); foreach (var addValue in added) { rowData.Add(TableBlock.FormatEvolution(addValue)); } nbRows++; rowData.Add(" " + Labels.ViolationsRemoved); foreach (var remValue in removed) { rowData.Add(TableBlock.FormatEvolution(-remValue)); } nbRows++; if (showPrevious) { var prevVersion = new int[busCrit.Length]; results = RulesViolationUtility.GetStatViolation(reportData.PreviousSnapshot); foreach (var resultModule in results) { if (resultModule != null) { for (int i = 0; i < busCrit.Length; i++) { var crit = busCrit[i]; if (resultModule[crit] != null && resultModule[crit].Total.HasValue) { prevVersion[i] += resultModule[crit].Total.Value; } } } } rowData.Add(Labels.VersionPrevious); foreach (var prevValue in prevVersion) { rowData.Add(prevValue.ToString()); } nbRows++; } var resultTable = new TableDefinition { HasRowHeaders = false, HasColumnHeaders = true, NbRows = nbRows, NbColumns = busCrit.Length + 1, 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); }
/// <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); }
public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { int rowCount = 0; List <string> rowData = new List <string>(); List <RuleViolationsVariationResultDTO> variationRules = new List <RuleViolationsVariationResultDTO>(); rowData.AddRange(new[] { Labels.Weight, Labels.Variation, Labels.RuleName }); List <string> bcIdsStr = options.GetOption("BCID", "60017").Split('|').ToList(); List <int> bcIds = bcIdsStr.Select(int.Parse).ToList(); // to get decrease by default bool increase = options.GetOption("VARIATION", "DECREASE").ToLower().Equals("increase"); // to get number by default bool percent = options.GetOption("DATA", "NUMBER").ToLower().Equals("percent"); int nbLimitTop = options.GetIntOption("COUNT", 50); if (reportData?.CurrentSnapshot != null) { List <RuleViolationResultDTO> currentCriticalRulesViolation = RulesViolationUtility.GetNbViolationByRule(reportData.CurrentSnapshot, reportData.RuleExplorer, bcIds, -1); List <RuleViolationResultDTO> previousCriticalRulesViolation = (reportData.PreviousSnapshot != null) ? RulesViolationUtility.GetNbViolationByRule(reportData.PreviousSnapshot, reportData.RuleExplorer, bcIds, -1) : null; if (currentCriticalRulesViolation != null && previousCriticalRulesViolation != null) { if (increase) { foreach (RuleViolationResultDTO item in currentCriticalRulesViolation) { RuleViolationResultDTO previousitem = previousCriticalRulesViolation.FirstOrDefault(_ => _.Rule.Key == item.Rule.Key); double?variation; if (previousitem != null) { if (item.TotalChecks != null && previousitem.TotalChecks != null) { variation = percent ? item.TotalFailed / (double)item.TotalChecks - previousitem.TotalFailed / (double)previousitem.TotalChecks : item.TotalFailed - previousitem.TotalFailed; if (variation <= 0) { continue; } } else { continue; } } else { if (item.TotalChecks != null) { variation = percent ? item.TotalFailed / (double)item.TotalChecks : item.TotalFailed; if (variation <= 0) { continue; } } else { continue; } } variationRules.Add(new RuleViolationsVariationResultDTO { Rule = new RuleDetailsDTO { Name = item.Rule.Name, Key = item.Rule.Key, CompoundedWeight = item.Rule.CompoundedWeight }, CurrentNbViolations = item.TotalFailed ?? -1, PreviousNbViolations = previousitem?.TotalFailed ?? -1, Variation = variation ?? double.NaN }); } } else { foreach (RuleViolationResultDTO previousitem in previousCriticalRulesViolation) { RuleViolationResultDTO item = currentCriticalRulesViolation.FirstOrDefault(_ => _.Rule.Key == previousitem.Rule.Key); double?variation; if (item != null) { if (previousitem.TotalChecks != null && item.TotalChecks != null) { variation = percent ? previousitem.TotalFailed / (double)previousitem.TotalChecks - item.TotalFailed / (double)item.TotalChecks : previousitem.TotalFailed - item.TotalFailed; if (variation <= 0) { continue; } } else { continue; } } else { if (previousitem.TotalChecks != null) { variation = percent ? previousitem.TotalFailed / (double)previousitem.TotalChecks : previousitem.TotalFailed; if (variation <= 0) { continue; } } else { continue; } } variationRules.Add(new RuleViolationsVariationResultDTO { Rule = new RuleDetailsDTO { Name = previousitem.Rule.Name, Key = previousitem.Rule.Key, CompoundedWeight = previousitem.Rule.CompoundedWeight }, CurrentNbViolations = item?.TotalFailed ?? -1, PreviousNbViolations = previousitem.TotalFailed ?? -1, Variation = variation ?? double.NaN }); } } List <RuleViolationsVariationResultDTO> selected_elements = nbLimitTop != -1 ? variationRules.OrderByDescending(_ => _.Variation).Take(nbLimitTop).ToList() : variationRules.OrderByDescending(_ => _.Variation).ToList(); if (selected_elements.Count <= 0) { rowData.AddRange(new[] { Labels.NoItem, string.Empty, string.Empty }); rowCount = 1; } else { foreach (RuleViolationsVariationResultDTO varRule in selected_elements) { rowData.AddRange(new[] { varRule.Rule.CompoundedWeight.ToString(), percent ? FormatPercent(varRule.Variation) : varRule.Variation.ToString(), varRule.Rule.Name } ); rowCount++; } } } else { rowData.AddRange(new[] { Labels.NoItem, string.Empty, string.Empty }); rowCount = 1; } } var resultTable = new TableDefinition { HasRowHeaders = false, HasColumnHeaders = true, NbRows = rowCount + 1, NbColumns = 3, Data = rowData }; return(resultTable); }
public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { int param; bool showPrevious = false; if (reportData.PreviousSnapshot != null && null != options && options.ContainsKey("SHOW_PREVIOUS") && int.TryParse(options["SHOW_PREVIOUS"], out param)) { showPrevious = (param != 0); } List <string> rowData = new List <string>(); int nbRows = 0; rowData.AddRange(new[] { " ", Labels.TQI, Labels.Robu, Labels.Efcy, Labels.Secu, Labels.Trans, Labels.Chang }); nbRows++; var busCrit = new[] { Constants.BusinessCriteria.TechnicalQualityIndex, Constants.BusinessCriteria.Robustness, Constants.BusinessCriteria.Performance, Constants.BusinessCriteria.Security, Constants.BusinessCriteria.Transferability, Constants.BusinessCriteria.Changeability }; var curVersion = new int[busCrit.Length]; var added = new int[busCrit.Length]; var removed = new int[busCrit.Length]; for (int i = 0; i < busCrit.Length; i++) { var resbc = RulesViolationUtility.GetViolStat(reportData.CurrentSnapshot, busCrit[i].GetHashCode()); if (resbc.TotalCriticalViolations != null) { curVersion[i] = resbc.TotalCriticalViolations.Value; } if (resbc.AddedCriticalViolations != null) { added[i] = resbc.AddedCriticalViolations.Value; } if (resbc.RemovedCriticalViolations != null) { removed[i] = resbc.RemovedCriticalViolations.Value; } } rowData.Add(Labels.VersionCurrent); rowData.AddRange(curVersion.Select(curValue => curValue.ToString("N0"))); nbRows++; rowData.Add(" " + Labels.ViolationsAdded); rowData.AddRange(added.Select(addValue => FormatEvolution(addValue))); nbRows++; rowData.Add(" " + Labels.ViolationsRemoved); rowData.AddRange(removed.Select(remValue => FormatEvolution(-remValue))); nbRows++; if (showPrevious) { var prevVersion = new int[busCrit.Length]; for (int i = 0; i < busCrit.Length; i++) { var resbc = RulesViolationUtility.GetViolStat(reportData.PreviousSnapshot, busCrit[i].GetHashCode()); if (resbc.TotalCriticalViolations != null) { prevVersion[i] = resbc.TotalCriticalViolations.Value; } } rowData.Add(Labels.VersionPrevious); rowData.AddRange(prevVersion.Select(prevValue => prevValue.ToString())); nbRows++; } var resultTable = new TableDefinition { HasRowHeaders = false, HasColumnHeaders = true, NbRows = nbRows, NbColumns = busCrit.Length + 1, Data = rowData }; return(resultTable); }
protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { List <string> rowData = new List <string>(); rowData.AddRange(new string[] { Labels.RuleName, Labels.ViolationsCount }); int nbRows = 0; int nbLimitTop = 0; Int32?metricId = (options != null && options.ContainsKey("BC-ID")) ? Convert.ToInt32(options["BC-ID"]) : (Int32?)null; if (metricId == null) { metricId = (options != null && options.ContainsKey("PAR")) ? Convert.ToInt32(options["PAR"]) : (Int32?)null; } if (null == options || !options.ContainsKey("COUNT") || !Int32.TryParse(options["COUNT"], out nbLimitTop)) { nbLimitTop = reportData.Parameter.NbResultDefault; } if (reportData != null && reportData.CurrentSnapshot != null) { if (!metricId.HasValue) { metricId = 0; } var rulesViolation = RulesViolationUtility.GetRuleViolations(reportData.CurrentSnapshot, Constants.RulesViolation.CriticalRulesViolation, (Constants.BusinessCriteria)metricId, true, nbLimitTop); if (null != rulesViolation) { foreach (var elt in rulesViolation) { rowData.AddRange(new string[] { elt.Rule.Name, elt.TotalFailed.Value.ToString("N0") }); } } else { rowData.AddRange(new string[] { Labels.NoItem, string.Empty }); } nbRows = rulesViolation.Count; } TableDefinition resultTable = new TableDefinition { HasRowHeaders = false, HasColumnHeaders = true, NbRows = nbRows + 1, NbColumns = 2, Data = rowData }; return(resultTable); }