protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { int nbResult = reportData.Parameter.NbResultDefault, tmpNb; if (null != options && options.ContainsKey("COUNT") && Int32.TryParse(options["COUNT"], out tmpNb) && tmpNb > 0) { nbResult = tmpNb; } if (reportData != null && reportData.CurrentSnapshot != null) { List <TechnologyResultDTO> technologyInfos = MeasureUtility.GetTechnoLoc(reportData.CurrentSnapshot, nbResult); List <string> rowData = new List <string>(); rowData.AddRange(new string[] { Labels.Name, Labels.LoC }); foreach (var elt in technologyInfos) { rowData.AddRange(new string[] { elt.Name, Convert.ToInt32(elt.Value).ToString() }); } TableDefinition resultTable = new TableDefinition { HasRowHeaders = true, HasColumnHeaders = false, NbRows = technologyInfos.Count + 1, NbColumns = 2, Data = rowData }; return(resultTable); } return(null); }
public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { #region METHODS int _intLocFlag = 0; int nbResult = reportData.Parameter.NbResultDefault; int nbTot = 0; int nb; if (null != options && options.ContainsKey("COUNT") && int.TryParse(options["COUNT"], out nb) && 0 < nb) { nbResult = nb; } if (null != options && options.ContainsKey("NOSIZE")) { _intLocFlag = 1; } List <string> rowData = new List <string>(); rowData.AddRange(_intLocFlag == 1 ? new[] { Labels.Name } : new[] { Labels.Name, Labels.LoC }); if (reportData.CurrentSnapshot?.Technologies != null) { var technologyInfos = MeasureUtility.GetTechnoLoc(reportData.CurrentSnapshot, nbResult); foreach (var elt in technologyInfos) { rowData.AddRange(_intLocFlag == 1 ? new[] { elt.Name } : new[] { elt.Name, elt.Value?.ToString("N0") }); } nbTot = technologyInfos.Count; } TableDefinition resultTable; if (_intLocFlag == 1) { resultTable = new TableDefinition { HasRowHeaders = false, HasColumnHeaders = true, NbRows = nbTot + 1, NbColumns = 1, Data = rowData }; } else { resultTable = new TableDefinition { HasRowHeaders = false, HasColumnHeaders = true, NbRows = nbTot + 1, NbColumns = 2, Data = rowData }; } return(resultTable); }
protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { TableDefinition resultTable = null; Boolean hasPrevious = reportData.PreviousSnapshot != null; List <TechnologyResultDTO> TechnologyResultCurrentSnapshot = new List <TechnologyResultDTO>(); List <TechnologyResultDTO> TechnologyResultPreviousSnapshot = new List <TechnologyResultDTO>(); List <EvolutionSnapshots> ResultCompartTecno = new List <EvolutionSnapshots>(); List <TechnologyResultDTO> TechnologyDecisionPointsResultCurrentSnapshot = new List <TechnologyResultDTO>(); List <TechnologyResultDTO> TechnologyDecisionPointsResultPreviousSnapshot = new List <TechnologyResultDTO>(); List <EvolutionSnapshots> ResultCompartTecnoDecisionPoints = new List <EvolutionSnapshots>(); List <TechnologyResultDTO> TechnologyClassesResultCurrentSnapshot = new List <TechnologyResultDTO>(); List <TechnologyResultDTO> TechnologyClassesResultPreviousSnapshot = new List <TechnologyResultDTO>(); List <EvolutionSnapshots> ResultCompartTecnoClasses = new List <EvolutionSnapshots>(); DataTable dtFinalRepository = new DataTable(); dtFinalRepository.Columns.Add("Name"); dtFinalRepository.Columns.Add("DecisionP"); dtFinalRepository.Columns.Add("KLOC"); dtFinalRepository.Columns.Add("Classes"); dtFinalRepository.AcceptChanges(); List <string> rowData = new List <string>(); rowData.AddRange(new string[] { Labels.Name, Labels.DecisionP, "kLOC's", "Objects" }); int nbLimitTop = 0; if (null == options || !options.ContainsKey("COUNT") || !Int32.TryParse(options["COUNT"], out nbLimitTop)) { nbLimitTop = reportData.Parameter.NbResultDefault; } #region LOC Evolution if (null != reportData && null != reportData.CurrentSnapshot) { TechnologyResultCurrentSnapshot = MeasureUtility.GetTechnoLoc(reportData.CurrentSnapshot, nbLimitTop); if (!hasPrevious) { #region Current Snapshot ResultCompartTecno = (from techLocC in TechnologyResultCurrentSnapshot select new EvolutionSnapshots() { name = techLocC.Name, curValue = techLocC.Value, preValue = null, evolValue = 0, }).ToList(); #endregion Current Snapshot } else { #region Previous Snapshot TechnologyResultPreviousSnapshot = MeasureUtility.GetTechnoLoc(reportData.PreviousSnapshot, nbLimitTop); ResultCompartTecno = (from techLocC in TechnologyResultCurrentSnapshot from techLocP in TechnologyResultPreviousSnapshot where techLocC.Name.Equals(techLocP.Name) && (techLocP != null) select new EvolutionSnapshots() { name = techLocC.Name, curValue = techLocC.Value, preValue = techLocP.Value, evolValue = techLocC.Value - techLocP.Value, }).ToList(); if (TechnologyResultPreviousSnapshot.Count != TechnologyResultCurrentSnapshot.Count) { ResultCompartTecno.AddRange((from ResultCompart in ResultCompartTecno from techLocC in TechnologyResultCurrentSnapshot where ResultCompartTecno.TrueForAll(_ => _.name != techLocC.Name) select new EvolutionSnapshots() { name = techLocC.Name, curValue = techLocC.Value, preValue = null, evolValue = null, })); ResultCompartTecno.AddRange((from ResultCompart in ResultCompartTecno from techLocP in TechnologyResultPreviousSnapshot where ResultCompartTecno.TrueForAll(_ => _.name != techLocP.Name) select new EvolutionSnapshots() { name = techLocP.Name, curValue = null, preValue = techLocP.Value, evolValue = null, })); } #endregion Previous Snapshot } } #endregion LOC Evolution #region Decision Points if (null != reportData && null != reportData.CurrentSnapshot) { TechnologyDecisionPointsResultCurrentSnapshot = MeasureUtility.GetTechnoComplexity(reportData.CurrentSnapshot, nbLimitTop); if (!hasPrevious) { #region Current Snapshot ResultCompartTecnoDecisionPoints = (from techLocC in TechnologyDecisionPointsResultCurrentSnapshot select new EvolutionSnapshots() { name = techLocC.Name, curValue = techLocC.Value, preValue = null, evolValue = 0, }).ToList(); #endregion Current Snapshot } else { #region Previous Snapshot TechnologyDecisionPointsResultPreviousSnapshot = MeasureUtility.GetTechnoComplexity(reportData.PreviousSnapshot, nbLimitTop); ResultCompartTecnoDecisionPoints = (from techLocC in TechnologyDecisionPointsResultCurrentSnapshot from techLocP in TechnologyDecisionPointsResultPreviousSnapshot where techLocC.Name.Equals(techLocP.Name) && (techLocP != null) select new EvolutionSnapshots() { name = techLocC.Name, curValue = techLocC.Value, preValue = techLocP.Value, evolValue = techLocC.Value - techLocP.Value, }).ToList(); if (TechnologyDecisionPointsResultPreviousSnapshot.Count != TechnologyDecisionPointsResultCurrentSnapshot.Count) { ResultCompartTecnoDecisionPoints.AddRange((from ResultCompart in ResultCompartTecnoDecisionPoints from techLocC in TechnologyDecisionPointsResultCurrentSnapshot where ResultCompartTecnoDecisionPoints.TrueForAll(_ => _.name != techLocC.Name) select new EvolutionSnapshots() { name = techLocC.Name, curValue = techLocC.Value, preValue = null, evolValue = null, })); ResultCompartTecnoDecisionPoints.AddRange((from ResultCompart in ResultCompartTecnoDecisionPoints from techLocP in TechnologyDecisionPointsResultPreviousSnapshot where ResultCompartTecnoDecisionPoints.TrueForAll(_ => _.name != techLocP.Name) select new EvolutionSnapshots() { name = techLocP.Name, curValue = null, preValue = techLocP.Value, evolValue = null, })); } #endregion Previous Snapshot } } #endregion Decision Points #region Classes if (null != reportData && null != reportData.CurrentSnapshot) { TechnologyClassesResultCurrentSnapshot = MeasureUtility.GetTechnoClasses(reportData.CurrentSnapshot, nbLimitTop); if (!hasPrevious) { #region Current Snapshot ResultCompartTecnoClasses = (from techLocC in TechnologyClassesResultCurrentSnapshot select new EvolutionSnapshots() { name = techLocC.Name, curValue = techLocC.Value, preValue = null, evolValue = 0, }).ToList(); #endregion Current Snapshot } else { #region Previous Snapshot TechnologyClassesResultPreviousSnapshot = MeasureUtility.GetTechnoComplexity(reportData.PreviousSnapshot, nbLimitTop); ResultCompartTecnoClasses = (from techLocC in TechnologyClassesResultCurrentSnapshot from techLocP in TechnologyClassesResultPreviousSnapshot where techLocC.Name.Equals(techLocP.Name) && (techLocP != null) select new EvolutionSnapshots() { name = techLocC.Name, curValue = techLocC.Value, preValue = techLocP.Value, evolValue = techLocC.Value - techLocP.Value, }).ToList(); if (TechnologyClassesResultPreviousSnapshot.Count != TechnologyClassesResultCurrentSnapshot.Count) { ResultCompartTecnoClasses.AddRange((from ResultCompart in ResultCompartTecnoClasses from techLocC in TechnologyClassesResultCurrentSnapshot where ResultCompartTecnoClasses.TrueForAll(_ => _.name != techLocC.Name) select new EvolutionSnapshots() { name = techLocC.Name, curValue = techLocC.Value, preValue = null, evolValue = null, })); ResultCompartTecnoClasses.AddRange((from ResultCompart in ResultCompartTecnoClasses from techLocP in TechnologyClassesResultPreviousSnapshot where ResultCompartTecnoClasses.TrueForAll(_ => _.name != techLocP.Name) select new EvolutionSnapshots() { name = techLocP.Name, curValue = null, preValue = techLocP.Value, evolValue = null, })); } #endregion Previous Snapshot } } #endregion Classes foreach (var item in ResultCompartTecno) { dtFinalRepository.Rows.Add(item.name, "", (item.evolValue.HasValue) ? FormatEvolution((Int32)item.evolValue.Value) : CastReporting.Domain.Constants.No_Value, ""); } dtFinalRepository.AcceptChanges(); foreach (var item in ResultCompartTecnoDecisionPoints) { for (int i = 0; i < dtFinalRepository.Rows.Count; i++) { if (dtFinalRepository.Rows[i]["Name"].ToString() == item.name.ToString()) { dtFinalRepository.Rows[i]["DecisionP"] = (item.evolValue.HasValue) ? FormatEvolution((Int32)item.evolValue.Value) : CastReporting.Domain.Constants.No_Value; break; } } } dtFinalRepository.AcceptChanges(); foreach (var item in ResultCompartTecnoClasses) { for (int i = 0; i < dtFinalRepository.Rows.Count; i++) { if (dtFinalRepository.Rows[i]["Name"].ToString() == item.name.ToString()) { dtFinalRepository.Rows[i]["Classes"] = (item.evolValue.HasValue) ? FormatEvolution((Int32)item.evolValue.Value) : CastReporting.Domain.Constants.No_Value; break; } } } dtFinalRepository.AcceptChanges(); for (int i = 0; i < dtFinalRepository.Rows.Count; i++) { rowData.AddRange(new string[] { dtFinalRepository.Rows[i]["Name"].ToString() , dtFinalRepository.Rows[i]["DecisionP"].ToString() , dtFinalRepository.Rows[i]["KLOC"].ToString() , dtFinalRepository.Rows[i]["Classes"].ToString() }); } //foreach (var item in ResultCompartTecno) //{ // rowData.AddRange(new string[] { // item.name // , "" // , (item.evolValue.HasValue) ? FormatEvolution((Int32)item.evolValue.Value) : CastReporting.Domain.Constants.No_Value // , "" // }); //} resultTable = new TableDefinition { HasRowHeaders = false, HasColumnHeaders = true, NbRows = nbLimitTop + 1, NbColumns = 4, Data = rowData }; return(resultTable); }
protected override string Content(ReportData reportData, Dictionary <string, string> options) { if (null != reportData && null != reportData.Applications) { Application[] AllApps = reportData.Applications; double? resultAllTechDebt = 0; double? AFPAll = 0; 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)) { double?result = MeasureUtility.GetTechnicalDebtMetric(snapshot); if (result == null) { result = 0.0; } resultAllTechDebt = resultAllTechDebt + result; break; } } } for (int j = 0; j < AllApps.Count(); j++) { int nbResult = 100; Application App = AllApps[j]; try { int nbSnapshotsEachApp = App.Snapshots.Count(); if (nbSnapshotsEachApp > 0) { foreach (Snapshot snapshot in App.Snapshots.OrderByDescending(_ => _.Annotation.Date.DateSnapShot)) { var technologyInfos = MeasureUtility.GetTechnoLoc(snapshot, nbResult); double?LOCSnap = 0; if (technologyInfos != null) { foreach (var elt in technologyInfos) { LOCSnap = LOCSnap + elt.Value; } } if (LOCSnap.HasValue) { AFPAll = AFPAll + LOCSnap; } else { LOCSnap = 0; } break; } } } catch (Exception ex) { return("Broken Central"); } } //handle 0 functions case if (resultAllTechDebt > 0 && AFPAll > 0) { double?FinalValue = (resultAllTechDebt / AllApps.Count()) / (AFPAll / AllApps.Count()); int intFinalValue = Convert.ToInt32(FinalValue); return(string.Format("{0:n0}", intFinalValue) + "$"); } else { return("NA"); } //return (result.HasValue ? String.Format("{0:N0} {1}", result.Value, reportData.CurrencySymbol) : CastReporting.Domain.Constants.No_Value); } return(CastReporting.Domain.Constants.No_Value); }
public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { bool hasPrevious = reportData.PreviousSnapshot != null; List <EvolutionSnapshots> _resultCompartTecno = null; List <string> rowData = new List <string>(); rowData.AddRange(new[] { Labels.Name, Labels.LoCCurrent, Labels.LoCPrevious, Labels.Evolution, Labels.EvolutionPercent }); int nbLimitTop; if (null == options || !options.ContainsKey("COUNT") || !int.TryParse(options["COUNT"], out nbLimitTop)) { nbLimitTop = reportData.Parameter.NbResultDefault; } if (reportData.CurrentSnapshot != null) { var _technologyResultCurrentSnapshot = MeasureUtility.GetTechnoLoc(reportData.CurrentSnapshot, nbLimitTop); if (!hasPrevious) { #region Current Snapshot _resultCompartTecno = (from cur in _technologyResultCurrentSnapshot select new EvolutionSnapshots { name = cur.Name, curValue = cur.Value, preValue = null, evolValue = null, }).ToList(); #endregion Current Snapshot } else { #region Previous Snapshot var _technologyResultPreviousSnapshot = MeasureUtility.GetTechnoLoc(reportData.PreviousSnapshot, nbLimitTop); _resultCompartTecno = (from cur in _technologyResultCurrentSnapshot from prev in _technologyResultPreviousSnapshot where prev != null && cur.Name == prev.Name select new EvolutionSnapshots { name = cur.Name, curValue = cur.Value, preValue = prev.Value, evolValue = cur.Value - prev.Value, }).ToList(); if (_technologyResultPreviousSnapshot.Count != _technologyResultCurrentSnapshot.Count) { _resultCompartTecno.AddRange(from cur in _technologyResultCurrentSnapshot where _resultCompartTecno.TrueForAll(_ => _.name != cur.Name) select new EvolutionSnapshots { name = cur.Name, curValue = cur.Value, preValue = null, evolValue = null, }); _resultCompartTecno.AddRange(from prev in _technologyResultPreviousSnapshot where _resultCompartTecno.TrueForAll(_ => _.name != prev.Name) select new EvolutionSnapshots { name = prev.Name, curValue = null, preValue = prev.Value, evolValue = -prev.Value, }); } #endregion Previous Snapshot } } int nbRows = 0; if (_resultCompartTecno != null) { foreach (var item in _resultCompartTecno.Take(nbLimitTop)) { rowData.AddRange(new[] { item.name , item.curValue?.ToString("N0") ?? Domain.Constants.No_Value , item.preValue?.ToString("N0") ?? Domain.Constants.No_Value , (item.evolValue.HasValue)? FormatEvolution((int)item.evolValue.Value) : Domain.Constants.No_Value , (item.evolValue.HasValue && item.preValue.HasValue && Math.Abs(item.preValue.Value) > 0) ? FormatPercent((item.evolValue.Value / item.preValue.Value)) : Domain.Constants.No_Value }); nbRows++; } } var resultTable = new TableDefinition { HasRowHeaders = false, HasColumnHeaders = true, NbRows = nbRows + 1, NbColumns = 5, Data = rowData }; return(resultTable); }
protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options) { TableDefinition resultTable = null; Boolean hasPrevious = reportData.PreviousSnapshot != null; List <TechnologyResultDTO> TechnologyResultCurrentSnapshot = null; List <TechnologyResultDTO> TechnologyResultPreviousSnapshot = null; List <EvolutionSnapshots> ResultCompartTecno = null; List <string> rowData = new List <string>(); rowData.AddRange(new string[] { Labels.Name, Labels.LoCCurrent, Labels.LoCPrevious, Labels.Evolution, Labels.EvolutionPercent }); int nbLimitTop = 0; if (null == options || !options.ContainsKey("COUNT") || !Int32.TryParse(options["COUNT"], out nbLimitTop)) { nbLimitTop = reportData.Parameter.NbResultDefault; } if (null != reportData && null != reportData.CurrentSnapshot) { TechnologyResultCurrentSnapshot = MeasureUtility.GetTechnoLoc(reportData.CurrentSnapshot, nbLimitTop); if (!hasPrevious) { #region Current Snapshot ResultCompartTecno = (from cur in TechnologyResultCurrentSnapshot select new EvolutionSnapshots() { name = cur.Name, curValue = cur.Value, preValue = null, evolValue = 0, }).ToList(); #endregion Current Snapshot } else { #region Previous Snapshot TechnologyResultPreviousSnapshot = MeasureUtility.GetTechnoLoc(reportData.PreviousSnapshot, nbLimitTop); ResultCompartTecno = (from cur in TechnologyResultCurrentSnapshot from prev in TechnologyResultPreviousSnapshot where prev != null && cur.Name == prev.Name select new EvolutionSnapshots() { name = cur.Name, curValue = cur.Value, preValue = prev.Value, evolValue = cur.Value - prev.Value, }).ToList(); if (TechnologyResultPreviousSnapshot.Count != TechnologyResultCurrentSnapshot.Count) { ResultCompartTecno.AddRange(from cur in TechnologyResultCurrentSnapshot where ResultCompartTecno.TrueForAll(_ => _.name != cur.Name) select new EvolutionSnapshots() { name = cur.Name, curValue = cur.Value, preValue = null, evolValue = null, }); ResultCompartTecno.AddRange(from prev in TechnologyResultPreviousSnapshot where ResultCompartTecno.TrueForAll(_ => _.name != prev.Name) select new EvolutionSnapshots() { name = prev.Name, curValue = 0, preValue = prev.Value, evolValue = -prev.Value, }); } #endregion Previous Snapshot } } int nbRows = 0; if (ResultCompartTecno != null) { foreach (var item in ResultCompartTecno.Take(nbLimitTop)) { rowData.AddRange(new string[] { item.name , (item.curValue.HasValue)? item.curValue.Value.ToString("N0") :CastReporting.Domain.Constants.No_Value , (item.preValue.HasValue)? item.preValue.Value.ToString("N0"):CastReporting.Domain.Constants.No_Value , (item.evolValue.HasValue)? FormatEvolution((Int32)item.evolValue.Value) : CastReporting.Domain.Constants.No_Value , (item.evolValue.HasValue && item.preValue.HasValue && item.preValue.Value != 0) ? FormatPercent((item.evolValue.Value / item.preValue.Value)) : CastReporting.Domain.Constants.No_Value }); nbRows++; } } resultTable = new TableDefinition { HasRowHeaders = false, HasColumnHeaders = true, NbRows = nbRows + 1, NbColumns = 5, Data = rowData }; return(resultTable); }