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 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); }