Esempio n. 1
0
        /// <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> {
                ""
            };

            //Set the table header
            rowData.AddRange(reportData.CurrentSnapshot.Technologies);

            //Set the result by module
            foreach (var mod in reportData.CurrentSnapshot.Modules)
            {
                var technologyLoc = MeasureUtility.GetSizingMeasureTechnologies(reportData.CurrentSnapshot, mod.Href, Constants.SizingInformations.CodeLineNumber.GetHashCode());

                rowData.Add(mod.Name);

                rowData.AddRange(reportData.CurrentSnapshot.Technologies.Select(techName => technologyLoc.FirstOrDefault(_ => _.Name == techName)).Select(result => (result != null) ? result.Value?.ToString(MetricFormat) : Constants.No_Value));
            }

            var resultTable = new TableDefinition
            {
                HasRowHeaders    = false,
                HasColumnHeaders = true,
                NbRows           = reportData.CurrentSnapshot.Modules.Count() + 1,
                NbColumns        = reportData.CurrentSnapshot.Technologies.Length + 1,
                Data             = rowData
            };

            return(resultTable);
        }
Esempio n. 2
0
        public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            #region METHODS

            if (reportData?.CurrentSnapshot == null)
            {
                return(null);
            }
            double?codeLineNumber    = MeasureUtility.GetCodeLineNumber(reportData.CurrentSnapshot);
            double?fileNumber        = MeasureUtility.GetFileNumber(reportData.CurrentSnapshot);
            double?classNumber       = MeasureUtility.GetClassNumber(reportData.CurrentSnapshot);
            double?sqlArtifactNumber = MeasureUtility.GetSqlArtifactNumber(reportData.CurrentSnapshot);
            double?tableNumber       = MeasureUtility.GetTableNumber(reportData.CurrentSnapshot);

            const string noData       = Constants.No_Value;
            const string metricFormat = "N0";
            var          rowData      = new List <string> {
                Labels.Name, Labels.Value
                , Labels.kLoC, (codeLineNumber / 1000)?.ToString(metricFormat) ?? noData
                , "  " + Labels.Files, fileNumber?.ToString(metricFormat) ?? noData
                , "  " + Labels.Classes, classNumber?.ToString(metricFormat) ?? noData
                , Labels.ArtifactsSQL, sqlArtifactNumber?.ToString(metricFormat) ?? noData
                , "  " + Labels.Tables, tableNumber?.ToString(metricFormat) ?? noData
            };
            var resultTable = new TableDefinition {
                HasRowHeaders    = false,
                HasColumnHeaders = true,
                NbRows           = 6,
                NbColumns        = 2,
                Data             = rowData
            };
            return(resultTable);
        }
Esempio n. 3
0
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            TableDefinition resultTable = null;

            if (null != reportData &&
                null != reportData.CurrentSnapshot)
            {
                double?automatedFPoints = MeasureUtility.GetAutomatedIFPUGFunction(reportData.CurrentSnapshot);
                double?decisionPoints   = MeasureUtility.GetDecisionPointsNumber(reportData.CurrentSnapshot);
                double?backFiredFPoints = MeasureUtility.GetBackfiredIFPUGFunction(reportData.CurrentSnapshot);

                const string metricFormat = "N0";
                var          rowData      = new List <string>()
                {
                    Labels.Name, Labels.Total
                    , Labels.AutomatedFP, (automatedFPoints.HasValue ?  automatedFPoints.Value.ToString(metricFormat) : CastReporting.Domain.Constants.No_Data)
                    , Labels.DecisionP, (decisionPoints.HasValue ?  (decisionPoints.Value).ToString(metricFormat) : CastReporting.Domain.Constants.No_Data)
                    , Labels.BackfiredFP, (backFiredFPoints.HasValue ?  (backFiredFPoints.Value).ToString(metricFormat) :CastReporting.Domain.Constants.No_Data)
                };
                resultTable = new TableDefinition
                {
                    HasRowHeaders    = false,
                    HasColumnHeaders = true,
                    NbRows           = 6,
                    NbColumns        = 2,
                    Data             = rowData
                };
            }
            return(resultTable);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            if (reportData?.CurrentSnapshot == null)
            {
                return(null);
            }
            double?automatedFPoints = MeasureUtility.GetAutomatedIFPUGFunction(reportData.CurrentSnapshot);
            double?decisionPoints   = MeasureUtility.GetDecisionPointsNumber(reportData.CurrentSnapshot);
            double?backFiredFPoints = MeasureUtility.GetBackfiredIFPUGFunction(reportData.CurrentSnapshot);

            const string metricFormat = "N0";
            var          rowData      = new List <string>()
            {
                Labels.Name, Labels.Total
                , Labels.AutomatedFP, automatedFPoints?.ToString(metricFormat) ?? Domain.Constants.No_Value
                , Labels.DecisionP, decisionPoints?.ToString(metricFormat) ?? Domain.Constants.No_Value
                , Labels.BackfiredFP, backFiredFPoints?.ToString(metricFormat) ?? Domain.Constants.No_Value
            };
            var resultTable = new TableDefinition
            {
                HasRowHeaders    = false,
                HasColumnHeaders = true,
                NbRows           = 4,
                NbColumns        = 2,
                Data             = rowData
            };

            return(resultTable);
        }
Esempio n. 6
0
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            #region METHODS
            TableDefinition resultTable = null;
            if (null != reportData &&
                null != reportData.CurrentSnapshot)
            {
                double?codeLineNumber    = MeasureUtility.GetCodeLineNumber(reportData.CurrentSnapshot);
                double?fileNumber        = MeasureUtility.GetFileNumber(reportData.CurrentSnapshot);
                double?classNumber       = MeasureUtility.GetClassNumber(reportData.CurrentSnapshot);
                double?sqlArtifactNumber = MeasureUtility.GetSqlArtifactNumber(reportData.CurrentSnapshot);
                double?tableNumber       = MeasureUtility.GetTableNumber(reportData.CurrentSnapshot);

                const string noData       = Constants.No_Data;
                const string metricFormat = "N0";
                var          rowData      = new List <string>()
                {
                    Labels.Name, Labels.Value
                    , Labels.kLoC, (codeLineNumber.HasValue ? (codeLineNumber.Value / 1000).ToString(metricFormat) : noData)
                    , "  " + Labels.Files, (fileNumber.HasValue ? (fileNumber.Value).ToString(metricFormat) : noData)
                    , "  " + Labels.Classes, (classNumber.HasValue ? (classNumber.Value).ToString(metricFormat) : noData)
                    , Labels.ArtifactsSQL, (sqlArtifactNumber.HasValue ? (sqlArtifactNumber.Value).ToString(metricFormat) : noData)
                    , "  " + Labels.Tables, (tableNumber.HasValue ? (tableNumber.Value).ToString(metricFormat) : noData)
                };
                resultTable = new TableDefinition {
                    HasRowHeaders    = false,
                    HasColumnHeaders = true,
                    NbRows           = 6,
                    NbColumns        = 2,
                    Data             = rowData
                };
            }
            return(resultTable);
        }
        public override string Content(ReportData reportData, Dictionary <string, string> options)
        {
            if (reportData?.CurrentSnapshot == null)
            {
                return(Domain.Constants.No_Value);
            }
            double?result = MeasureUtility.GetTechnicalDebtMetric(reportData.CurrentSnapshot);

            return(result.HasValue ? $"{result.Value:N0} {reportData.CurrencySymbol}" : Domain.Constants.No_Value);
        }
Esempio n. 8
0
 protected override string Content(ReportData reportData, Dictionary <string, string> options)
 {
     if (null != reportData &&
         null != reportData.CurrentSnapshot)
     {
         double?result = MeasureUtility.GetAddedFunctionPoint(reportData.CurrentSnapshot) + MeasureUtility.GetModifiedFunctionPoint(reportData.CurrentSnapshot) + MeasureUtility.GetDeletedFunctionPoint(reportData.CurrentSnapshot);
         return(result.HasValue ? result.Value.ToString("N0") : CastReporting.Domain.Constants.No_Value);
     }
     return(CastReporting.Domain.Constants.No_Value);
 }
Esempio n. 9
0
        public override string Content(ReportData reportData, Dictionary <string, string> options)
        {
            if (reportData?.CurrentSnapshot == null)
            {
                return(Domain.Constants.No_Value);
            }
            double?result = MeasureUtility.GetModifiedFunctionPoint(reportData.CurrentSnapshot);

            return(result?.ToString("N0") ?? Domain.Constants.No_Value);
        }
Esempio n. 10
0
 protected override string Content(ReportData reportData, Dictionary <string, string> options)
 {
     if (null != reportData &&
         null != reportData.CurrentSnapshot)
     {
         double?result = MeasureUtility.GetTechnicalDebtMetric(reportData.CurrentSnapshot);
         return(result.HasValue ? String.Format("{0:N0} {1}", result.Value, reportData.CurrencySymbol) : CastReporting.Domain.Constants.No_Value);
     }
     return(CastReporting.Domain.Constants.No_Value);
 }
Esempio n. 11
0
        public override string Content(ReportData reportData, Dictionary <string, string> options)
        {
            if (reportData?.CurrentSnapshot == null)
            {
                return(Domain.Constants.No_Value);
            }
            double?codeLineNumber = MeasureUtility.GetCodeLineNumber(reportData.CurrentSnapshot);

            return(codeLineNumber.HasValue ? GetApplicationQualification(reportData, codeLineNumber.Value) : Domain.Constants.No_Value);
        }
Esempio n. 12
0
        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);
        }
Esempio n. 13
0
        public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            int count = 0;

            List <string> rowData = new List <string>();

            rowData.AddRange(new[] {
                Labels.TQI,
                Labels.ViolationsCritical + "/" + Labels.kLoC,
                Labels.AutomatedFP,
                Labels.Application
            });

            #region Fetch SnapshotsPF

            if (reportData?.Applications != null && reportData.Snapshots != null)
            {
                Application[] _allApps = reportData.Applications;
                foreach (Application _app in _allApps)
                {
                    Snapshot _snapshot = _app.Snapshots.OrderByDescending(_ => _.Annotation.Date.DateSnapShot).First();

                    BusinessCriteriaDTO currSnapshotBisCriDTO = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(_snapshot, false);
                    double?strCurrentTQI   = currSnapshotBisCriDTO.TQI ?? 0;
                    double?_numCritPerKloc = MeasureUtility.GetSizingMeasure(_snapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesPerKLOCNumber);
                    double?result          = MeasureUtility.GetAutomatedIFPUGFunction(_snapshot);

                    rowData.Add(strCurrentTQI.GetValueOrDefault().ToString("N2"));
                    rowData.Add(_numCritPerKloc.GetValueOrDefault().ToString("N2"));
                    rowData.Add(result.GetValueOrDefault().ToString(CultureInfo.CurrentCulture));
                    rowData.Add(_app.Name);

                    count++;
                }

                if (reportData.Applications.Length == 1)
                {
                    rowData.AddRange(new[] { "0", "0", "0", "" });

                    count++;
                }
            }
            #endregion Fetch SnapshotsPF

            TableDefinition resultTable = new TableDefinition
            {
                HasRowHeaders    = false,
                HasColumnHeaders = true,
                NbRows           = count + 1,
                NbColumns        = 4,
                Data             = rowData
            };
            return(resultTable);
        }
Esempio n. 14
0
 protected override string Content(ReportData reportData, Dictionary <string, string> options)
 {
     if (null != reportData &&
         null != reportData.CurrentSnapshot)
     {
         double?result = MeasureUtility.GetAfpMetricDF(reportData.CurrentSnapshot);
         result = Convert.ToInt32(result);
         return(result.HasValue ? result.ToString() : CastReporting.Domain.Constants.No_Value);
         //return (result.HasValue ? result.Value.ToString("N0") : CastReporting.Domain.Constants.No_Value);
     }
     return(CastReporting.Domain.Constants.No_Value);
 }
Esempio n. 15
0
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            TableDefinition resultTable = null;

            string numberFormat = "N0";

            bool displayShortHeader = (options != null && options.ContainsKey("HEADER") && "SHORT" == options["HEADER"]);

            List <string> rowData = new List <string>();

            if (null != reportData &&
                null != reportData.CurrentSnapshot)
            {
                //Build Debt row
                Double?technicalDebtBuild = MeasureUtility.GetTechnicalDebtMetric(reportData.CurrentSnapshot);
                rowData.AddRange(new string[] { Labels.Name, Labels.Value });
                rowData.AddRange(new string[] {
                    displayShortHeader?Labels.Debt: Labels.TechnicalDebt + " (" + reportData.CurrencySymbol + ")",
                    technicalDebtBuild.HasValue? technicalDebtBuild.Value.ToString(numberFormat):CastReporting.Domain.Constants.No_Value,
                });


                //Build Debt added row
                Double?technicalDebtadded = MeasureUtility.SumDeltaIndicator(reportData.CurrentSnapshot, reportData.PreviousSnapshot, reportData.Application, Constants.SizingInformations.AddedViolationsTechnicalDebt);

                rowData.AddRange(new string[] {
                    displayShortHeader?Labels.DebtAdded: Labels.TechnicalDebtAdded + " (" + reportData.CurrencySymbol + ")",
                    technicalDebtadded.HasValue? technicalDebtadded.Value.ToString(numberFormat) : CastReporting.Domain.Constants.No_Value,
                });

                //Build Debt removed row
                Double?technicalDebtremoved = MeasureUtility.SumDeltaIndicator(reportData.CurrentSnapshot, reportData.PreviousSnapshot, reportData.Application, Constants.SizingInformations.RemovedViolationsTechnicalDebt);

                rowData.AddRange(new string[] {
                    displayShortHeader?Labels.DebtRemoved: Labels.TechnicalDebtRemoved + " (" + reportData.CurrencySymbol + ")",
                    technicalDebtremoved.HasValue? technicalDebtremoved.Value.ToString(numberFormat):CastReporting.Domain.Constants.No_Value,
                });
            }

            //Build Table Definition
            resultTable = new TableDefinition
            {
                HasRowHeaders    = false,
                HasColumnHeaders = true,
                NbRows           = 3,
                NbColumns        = 2,
                Data             = rowData
            };

            return(resultTable);
        }
Esempio n. 16
0
        protected override string Content(ReportData reportData, Dictionary <string, string> options)
        {
            if (null != reportData &&
                null != reportData.CurrentSnapshot)
            {
                double?codeLineNumber = MeasureUtility.GetCodeLineNumber(reportData.CurrentSnapshot);

                if (codeLineNumber.HasValue)
                {
                    return(GetApplicationQualification(reportData, codeLineNumber.Value));
                }
            }
            return(CastReporting.Domain.Constants.No_Value);
        }
Esempio n. 17
0
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            #region Required Options
            string moduleIdstr = (options != null && options.ContainsKey("M") ? options["M"] : string.Empty);
            int    moduleId;
            if (string.IsNullOrWhiteSpace(moduleIdstr) || !Int32.TryParse(moduleIdstr, out moduleId))
            {
                moduleId = -1;
            }

            #endregion Required Options

            List <String> rowData = new List <String>();
            rowData.AddRange(new string[] { Labels.TechnicalDebt + " (" + reportData.CurrencySymbol + ")", Labels.TQI, Labels.Size });

            if (reportData != null && reportData.CurrentSnapshot != null)
            {
                double?TQIValue      = 0;
                double?TechDebtValue = 0;
                double?COLValue      = 0;

                if (moduleId > 0)
                {
                    TQIValue      = BusinessCriteriaUtility.GetBusinessCriteriaModuleGrade(reportData.CurrentSnapshot, moduleId, Constants.BusinessCriteria.TechnicalQualityIndex, true);
                    TechDebtValue = MeasureUtility.GetModuleMeasureGrade(reportData.CurrentSnapshot, moduleId, Constants.SizingInformations.TechnicalDebt);
                    COLValue      = MeasureUtility.GetModuleMeasureGrade(reportData.CurrentSnapshot, moduleId, Constants.SizingInformations.CodeLineNumber);
                }
                else
                {
                    TQIValue      = BusinessCriteriaUtility.GetSnapshotBusinessCriteriaGrade(reportData.CurrentSnapshot, Constants.BusinessCriteria.TechnicalQualityIndex, true);
                    TechDebtValue = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.TechnicalDebt);
                    COLValue      = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.CodeLineNumber);
                }

                rowData.Add(TQIValue.GetValueOrDefault().ToString());
                rowData.Add(TechDebtValue.GetValueOrDefault().ToString());
                rowData.Add(COLValue.GetValueOrDefault().ToString());
            }

            TableDefinition resultTable = new TableDefinition
            {
                HasRowHeaders    = false,
                HasColumnHeaders = true,
                NbRows           = 2,
                NbColumns        = 3,
                Data             = rowData
            };
            return(resultTable);
        }
        public override string Content(ReportData reportData, Dictionary <string, string> options)
        {
            if (reportData?.Applications == null)
            {
                return(Constants.No_Value);
            }
            Application[] _allApps     = reportData.Applications;
            double?       _allTechDebt = 0;
            double?       _allLoc      = 0;

            foreach (Application _app in _allApps)
            {
                try
                {
                    Snapshot _snapshot = _app.Snapshots.OrderByDescending(_ => _.Annotation.Date.DateSnapShot).First();
                    if (_snapshot == null)
                    {
                        continue;
                    }
                    double?result = MeasureUtility.GetTechnicalDebtMetric(_snapshot);
                    if (result != null)
                    {
                        _allTechDebt = _allTechDebt + result;
                    }

                    double?_locSnap = MeasureUtility.GetCodeLineNumber(_snapshot);
                    if (_locSnap != null)
                    {
                        _allLoc = _allLoc + _locSnap;
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.Instance.LogInfo(ex.Message);
                    LogHelper.Instance.LogInfo(Labels.NoSnapshot);
                }
            }

            if (!(_allTechDebt > 0) || !(_allLoc > 0))
            {
                return(Labels.NoData);
            }
            double?finalValue = _allTechDebt / _allLoc;

            return($"{finalValue.Value:N0} {reportData.CurrencySymbol}");
        }
Esempio n. 19
0
        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 (null != reportData && null != reportData.CurrentSnapshot)
            {
                var moduleArtifacts = MeasureUtility.GetModulesMeasure(reportData.CurrentSnapshot, nbResult, Constants.SizingInformations.ArtifactNumber);

                List <string> rowData = new List <string>();
                rowData.AddRange(new string[] { Labels.Name, Labels.Artifacts });

                foreach (var mod in moduleArtifacts)
                {
                    rowData.AddRange(new string[] { mod.Name, Convert.ToInt32(mod.Value).ToString() });
                }


                TableDefinition resultTable = new TableDefinition
                {
                    HasRowHeaders    = true,
                    HasColumnHeaders = false,
                    NbRows           = moduleArtifacts.Count + 1,
                    NbColumns        = 2,
                    Data             = rowData
                };

                return(resultTable);
            }

            return(null);
        }
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            int count = 0;

            List <String> rowData = new List <String>();

            //var rowData = new List<String>();
            rowData.AddRange(new string[] {
                Labels.TQI,
                Labels.ViolationsCritical + "/" + Labels.kLoC,
                Labels.AutomatedFP,
                Labels.Application
            });


            #region Fetch SnapshotsPF

            if (reportData != null && reportData.Applications != null && reportData.snapshots != null)
            {
                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 currSnapshotLabel = SnapshotUtility.GetSnapshotVersionNumber(BuiltSnapshot);
                                    BusinessCriteriaDTO currSnapshotBisCriDTO = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(BuiltSnapshot, false);
                                    double?strCurrentTQI = currSnapshotBisCriDTO.TQI.HasValue ? MathUtility.GetRound(currSnapshotBisCriDTO.TQI.Value) : 0;

                                    double?numCritPerKLOC = MeasureUtility.GetSizingMeasure(BuiltSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesPerKLOCNumber);

                                    //double? result = MeasureUtility.GetAddedFunctionPoint(BuiltSnapshot) + MeasureUtility.GetModifiedFunctionPoint(BuiltSnapshot) + MeasureUtility.GetDeletedFunctionPoint(BuiltSnapshot);
                                    double?result = MeasureUtility.GetAfpMetricDF(BuiltSnapshot) + MeasureUtility.GetAfpMetricTF(BuiltSnapshot);

                                    rowData.AddRange(new string[] {
                                        strCurrentTQI.GetValueOrDefault().ToString(),
                                        numCritPerKLOC.GetValueOrDefault().ToString(),
                                        result.GetValueOrDefault().ToString(),
                                        App.Name.ToString()
                                    });

                                    count++;
                                }
                            }

                            break;
                        }
                    }
                }
                if (reportData.Applications.Count() == 1)
                {
                    rowData.AddRange(new string[] { "0", "0", "0", "" });

                    count++;
                }
            }
            #endregion Fetch SnapshotsPF



            TableDefinition resultTable = new TableDefinition
            {
                HasRowHeaders    = false,
                HasColumnHeaders = true,
                NbRows           = count + 1,
                NbColumns        = 4,
                Data             = rowData
            };
            return(resultTable);
        }
        public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            if (reportData?.CurrentSnapshot == null)
            {
                return(null);
            }

            double?criticalViolation = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesNumber);
            double?numCritPerFile    = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesPerFileNumber);
            double?_numCritPerKloc   = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesPerKLOCNumber);

            double?veryHighCostComplexityViolations = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.
                                                                                                   QualityDistribution.DistributionOfViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(),
                                                                                                   Constants.ViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.ComplexityViolations_VeryHigh.GetHashCode());

            double?highCostComplexityViolations = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                                               Constants.QualityDistribution.DistributionOfViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(),
                                                                                               Constants.ViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.ComplexityViolations_HighCost.GetHashCode());

            double?veryHighCostComplexityArtefacts = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                                                  Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(),
                                                                                                  Constants.CostComplexity.CostComplexityArtifacts_VeryHigh.GetHashCode());

            double?highCostComplexityArtefacts = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                                              Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(),
                                                                                              Constants.CostComplexity.CostComplexityArtifacts_High.GetHashCode());


            double?nbComplexityArtefacts          = MathUtility.GetSum(veryHighCostComplexityArtefacts, highCostComplexityArtefacts);
            double?nbComplexityArtefactsViolation = MathUtility.GetSum(veryHighCostComplexityViolations, highCostComplexityViolations);



            const string metricFormat          = "N0";
            const string metricFormatPrecision = "N2";

            string numCritPerFileIfNegative;

            // ReSharper disable once CompareOfFloatsByEqualityOperator -- special case
            if (numCritPerFile == -1)
            {
                numCritPerFileIfNegative = Constants.No_Value;
            }
            else
            {
                numCritPerFileIfNegative = numCritPerFile?.ToString(metricFormatPrecision) ?? Constants.No_Value;
            }

            var rowData = new List <string>()
            {
                Labels.Name
                , Labels.Value

                , Labels.ViolationsCritical
                , criticalViolation?.ToString(metricFormat) ?? Constants.No_Value

                , "  " + Labels.PerFile
                , numCritPerFileIfNegative

                , "  " + Labels.PerkLoC
                , _numCritPerKloc?.ToString(metricFormatPrecision) ?? Constants.No_Value

                , Labels.ComplexObjects
                , nbComplexityArtefacts?.ToString(metricFormat) ?? Constants.No_Value

                , "  " + Labels.WithViolations
                , nbComplexityArtefactsViolation?.ToString(metricFormat) ?? Constants.No_Value
            };

            var resultTable = new TableDefinition
            {
                HasRowHeaders    = true,
                HasColumnHeaders = false,
                NbRows           = 6,
                NbColumns        = 2,
                Data             = rowData
            };

            return(resultTable);
        }
Esempio n. 22
0
        public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            TableDefinition resultTable = null;

            if (reportData?.CurrentSnapshot == null)
            {
                return(resultTable);
            }

            #region Declarations

            double?automatedFPoints = MeasureUtility.GetAutomatedIFPUGFunction(reportData.CurrentSnapshot);
            double?decisionPoints   = MeasureUtility.GetDecisionPointsNumber(reportData.CurrentSnapshot);
            double?backFiredFPoints = MeasureUtility.GetBackfiredIFPUGFunction(reportData.CurrentSnapshot);

            double?automatedFPointsPrev = MeasureUtility.GetAutomatedIFPUGFunction(reportData.PreviousSnapshot);
            double?decisionPointsPrev   = MeasureUtility.GetDecisionPointsNumber(reportData.PreviousSnapshot);
            double?backFiredFPointsPrev = MeasureUtility.GetBackfiredIFPUGFunction(reportData.PreviousSnapshot);

            double?automatedFPointsEvol = MathUtility.GetEvolution(automatedFPoints, automatedFPointsPrev);
            double?decisionPointsEvol   = MathUtility.GetEvolution(decisionPoints, decisionPointsPrev);
            double?backFiredFPointsEvol = MathUtility.GetEvolution(backFiredFPoints, backFiredFPointsPrev);

            double?automatedFPointsPercent = MathUtility.GetPercent(automatedFPointsEvol, automatedFPointsPrev);
            double?decisionPointsPercent   = MathUtility.GetPercent(decisionPointsEvol, decisionPointsPrev);
            double?backFiredFPointsPercent = MathUtility.GetPercent(backFiredFPointsEvol, backFiredFPointsPrev);

            bool hasPrevious = (reportData.PreviousSnapshot != null);

            #endregion

            const string noData       = Constants.No_Value;
            const string metricFormat = "N0";

            var rowData = new List <string>
            {
                Labels.Name, Labels.Current, Labels.Previous, Labels.Evolution, Labels.EvolutionPercent

                , Labels.AutomatedFP
                , automatedFPoints?.ToString(metricFormat) ?? noData
                , (hasPrevious && automatedFPointsPrev.HasValue)?  automatedFPointsPrev.Value.ToString(metricFormat) : noData
                , (hasPrevious && automatedFPointsEvol.HasValue)? FormatEvolution((int)automatedFPointsEvol.Value) : noData
                , (automatedFPointsPercent.HasValue)? FormatPercent(automatedFPointsPercent.Value): noData
                , Labels.DecisionP
                , decisionPoints?.ToString(metricFormat) ?? noData
                , (hasPrevious && decisionPointsPrev.HasValue)? decisionPointsPrev.Value.ToString(metricFormat) : noData
                , (hasPrevious && decisionPointsEvol.HasValue)? FormatEvolution((int)decisionPointsEvol.Value) : noData
                , (decisionPointsPercent.HasValue)? FormatPercent(decisionPointsPercent.Value): noData
                , Labels.BackfiredFP
                , backFiredFPoints?.ToString(metricFormat) ?? noData
                , (hasPrevious && backFiredFPointsPrev.HasValue)? backFiredFPointsPrev.Value.ToString(metricFormat) : noData
                , (hasPrevious && backFiredFPointsEvol.HasValue)? FormatEvolution((int)Math.Round(backFiredFPointsEvol.Value, 0)) : noData
                , (backFiredFPointsPercent.HasValue)? FormatPercent(backFiredFPointsPercent.Value): noData
            };

            resultTable = new TableDefinition
            {
                HasRowHeaders    = false,
                HasColumnHeaders = true,
                NbRows           = 4,
                NbColumns        = 5,
                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);
        }
Esempio n. 24
0
        public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            double minValy = short.MaxValue;
            double maxValy = 0;
            double stepV;
            int    count = 0;

            bool hasVerticalZoom = options.ContainsKey("ZOOM");

            if (!options.ContainsKey("ZOOM") || !double.TryParse(options["ZOOM"], out stepV))
            {
                stepV = 1;
            }


            var rowData = new List <string>();

            rowData.AddRange(new[] {
                " ",
                Labels.Prog,
                Labels.Arch,
                Labels.Doc,
                Labels.LoC
            });


            #region Previous Snapshots

            var nbSnapshots = reportData?.Application.Snapshots?.Count() ?? 0;
            if (nbSnapshots > 0)
            {
                var _snapshots = reportData?.Application?.Snapshots?.OrderBy(_ => _.Annotation.Date.DateSnapShot);
                if (_snapshots != null)
                {
                    foreach (Snapshot snapshot in _snapshots)
                    {
                        BusinessCriteriaDTO bcGrade = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(snapshot, true);
                        double?locValue             = MeasureUtility.GetCodeLineNumber(snapshot);
                        string prevSnapshotDate     = snapshot.Annotation.Date.DateSnapShot?.ToOADate().ToString(CultureInfo.CurrentCulture) ?? string.Empty;
                        rowData.Add(prevSnapshotDate);
                        rowData.Add(bcGrade.ProgrammingPractices.GetValueOrDefault().ToString(CultureInfo.CurrentCulture));
                        rowData.Add(bcGrade.ArchitecturalDesign.GetValueOrDefault().ToString(CultureInfo.CurrentCulture));
                        rowData.Add(bcGrade.Documentation.GetValueOrDefault().ToString(CultureInfo.CurrentCulture));
                        rowData.Add(locValue.GetValueOrDefault().ToString(CultureInfo.CurrentCulture));

                        List <double> values = new List <double>
                        {
                            bcGrade.ProgrammingPractices.GetValueOrDefault(),
                                      bcGrade.ArchitecturalDesign.GetValueOrDefault(),
                                      bcGrade.Documentation.GetValueOrDefault()
                        };
                        minValy = Math.Min(minValy, values.Min());
                        maxValy = Math.Max(maxValy, values.Max());
                    }
                }
                count = nbSnapshots;
            }
            #endregion Previous Snapshots

            #region just 1 snapshot
            if (nbSnapshots == 1)
            {
                BusinessCriteriaDTO bcGrade = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(reportData?.CurrentSnapshot, true);
                double?locValue             = MeasureUtility.GetCodeLineNumber(reportData?.CurrentSnapshot);
                string prevSnapshotDate     = reportData?.CurrentSnapshot.Annotation.Date.DateSnapShot?.ToOADate().ToString(CultureInfo.CurrentCulture) ?? string.Empty;
                rowData.AddRange
                    (new[] { prevSnapshotDate
                             , bcGrade.ProgrammingPractices.GetValueOrDefault().ToString(CultureInfo.CurrentCulture)
                             , bcGrade.ArchitecturalDesign.GetValueOrDefault().ToString(CultureInfo.CurrentCulture)
                             , bcGrade.Documentation.GetValueOrDefault().ToString(CultureInfo.CurrentCulture)
                             , locValue.GetValueOrDefault().ToString(CultureInfo.CurrentCulture) });

                List <double> values = new List <double>()
                {
                    bcGrade.ProgrammingPractices.GetValueOrDefault(),
                              bcGrade.ArchitecturalDesign.GetValueOrDefault(),
                              bcGrade.Documentation.GetValueOrDefault()
                };
                minValy = Math.Min(minValy, values.Min());
                maxValy = Math.Max(maxValy, values.Max());
                count   = count + 1;
            }
            #endregion just 1 snapshot


            #region Graphic Options
            GraphOptions graphOptions = null;
            if (hasVerticalZoom)
            {
                graphOptions = new GraphOptions()
                {
                    AxisConfiguration = new AxisDefinition()
                };
                graphOptions.AxisConfiguration.VerticalAxisMinimal = MathUtility.GetVerticalMinValue(minValy, stepV);
                graphOptions.AxisConfiguration.VerticalAxisMaximal = MathUtility.GetVerticalMaxValue(maxValy, stepV);
            }
            #endregion Graphic Options

            TableDefinition resultTable = new TableDefinition {
                HasRowHeaders    = true,
                HasColumnHeaders = false,
                NbRows           = count + 1,
                NbColumns        = 5,
                Data             = rowData,
                GraphOptions     = graphOptions
            };


            return(resultTable);
        }
        public override string Content(ReportData reportData, Dictionary <string, string> options)
        {
            string _metricFormat = options.GetOption("FORMAT", "N2");
            string _params       = options.GetOption("PARAMS", string.Empty);
            string _expr         = options.GetOption("EXPR", string.Empty);
            string _aggregator   = options.GetOption("AGGREGATOR", "AVERAGE");

            string[] lstParams = _params.Split(' ');

            if (string.IsNullOrEmpty(_params))
            {
                return(Labels.NoData);
            }
            if (reportData?.Applications == null)
            {
                return(Labels.NoData);
            }
            Application[] _allApps  = reportData.Applications;
            string[]      strValues = new string[_allApps.Length];

            for (int k = 0; k < _allApps.Length; k++)
            {
                Application _app        = _allApps[k];
                string      _appExpr    = _expr;
                Snapshot    currentSnap = _app.Snapshots.OrderByDescending(_ => _.Annotation.Date.DateSnapShot).First();
                if (currentSnap == null)
                {
                    continue;
                }
                for (int i = 0; i < lstParams.Length; i += 2)
                {
                    string param = lstParams[i + 1];
                    double?paramValue;

                    switch (lstParams[i])
                    {
                    case "SZ":
                        int sizingId = int.Parse(options.GetOption(lstParams[i + 1], "0"));
                        if (sizingId == 0)
                        {
                            paramValue = null;
                            break;
                        }
                        paramValue = MeasureUtility.GetSizingMeasure(currentSnap, sizingId);
                        break;

                    case "QR":
                        int qrId = int.Parse(options.GetOption(lstParams[i + 1], "0"));
                        if (qrId == 0)
                        {
                            paramValue = null;
                            break;
                        }
                        paramValue = BusinessCriteriaUtility.GetMetricValue(currentSnap, qrId);
                        break;

                    case "BF":
                        string bfId = options.GetOption(lstParams[i + 1], string.Empty);
                        if (string.IsNullOrEmpty(bfId))
                        {
                            paramValue = null;
                            break;
                        }
                        var bfValue = reportData.SnapshotExplorer.GetBackgroundFacts(currentSnap.Href, bfId).FirstOrDefault();
                        if (bfValue != null && bfValue.ApplicationResults.Any())
                        {
                            paramValue = bfValue.ApplicationResults[0].DetailResult.Value;
                        }
                        else
                        {
                            paramValue = null;
                        }
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                    if (paramValue != null)
                    {
                        _appExpr = _appExpr.Replace(param, paramValue.ToString());
                    }
                }
                DataTable dt = new DataTable();
                string    value;
                try
                {
                    value = double.Parse(dt.Compute(_appExpr, "").ToString()).ToString(_metricFormat);
                }
                catch (EvaluateException)
                {
                    value = null;
                }

                if (!string.IsNullOrEmpty(value))
                {
                    strValues[k] = value;
                }
                else
                {
                    strValues[k] = Labels.NoData;
                }
            }


            if (_aggregator == "SUM")
            {
                double sumValues = strValues.Where(val => val != Labels.NoData).Sum(val => double.Parse(val));
                return(sumValues.ToString(_metricFormat));
            }
            else
            {
                double sumValues = 0;
                int    nbValues  = 0;
                foreach (string val in strValues)
                {
                    if (val == Labels.NoData)
                    {
                        continue;
                    }
                    nbValues++;
                    sumValues += double.Parse(val);
                }
                if (nbValues == 0)
                {
                    return(Labels.NoData);
                }
                var avgValues = sumValues / nbValues;
                return(avgValues.ToString(_metricFormat));
            }
        }
Esempio n. 26
0
        public override string Content(ReportData reportData, Dictionary <string, string> options)
        {
            string _metricFormat = options.GetOption("FORMAT", "N2");
            string _params       = options.GetOption("PARAMS", string.Empty);
            string _expr         = options.GetOption("EXPR", string.Empty);
            string _snapshot     = options.GetOption("SNAPSHOT", "CURRENT");

            string[] lstParams     = _params.Split(' ');
            string   strParameters = string.Empty;

            object[] objValues = new object[lstParams.Length / 2];

            if (reportData?.CurrentSnapshot == null)
            {
                return(Labels.NoData);
            }
            if (string.IsNullOrEmpty(_params))
            {
                return(Labels.NoData);
            }
            int j = 0;

            for (int i = 0; i < lstParams.Length; i += 2)
            {
                if (i == 0)
                {
                    strParameters = "double " + lstParams[i + 1];
                }
                else
                {
                    strParameters = strParameters + ", double " + lstParams[i + 1];
                }

                switch (lstParams[i])
                {
                case "SZ":
                    int sizingId = int.Parse(options.GetOption(lstParams[i + 1], "0"));
                    if (sizingId == 0)
                    {
                        return(Labels.NoData);
                    }
                    double?sizingValue;
                    if (_snapshot.Equals("PREVIOUS") && null != reportData.PreviousSnapshot)
                    {
                        sizingValue = MeasureUtility.GetSizingMeasure(reportData.PreviousSnapshot, sizingId);
                    }
                    else
                    {
                        sizingValue = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, sizingId);
                    }
                    objValues[j] = sizingValue;
                    j++;
                    break;

                case "QR":
                    int qrId = int.Parse(options.GetOption(lstParams[i + 1], "0"));
                    if (qrId == 0)
                    {
                        return(Labels.NoData);
                    }
                    double?qrGrade;
                    if (_snapshot.Equals("PREVIOUS") && null != reportData.PreviousSnapshot)
                    {
                        qrGrade = BusinessCriteriaUtility.GetMetricValue(reportData.PreviousSnapshot, qrId);
                    }
                    else
                    {
                        qrGrade = BusinessCriteriaUtility.GetMetricValue(reportData.CurrentSnapshot, qrId);
                    }
                    objValues[j] = qrGrade;
                    j++;
                    break;

                case "BF":
                    string bfId = options.GetOption(lstParams[i + 1], string.Empty);
                    if (string.IsNullOrEmpty(bfId))
                    {
                        return(Labels.NoData);
                    }
                    Result bfValue;
                    if (_snapshot.Equals("PREVIOUS") && null != reportData.PreviousSnapshot)
                    {
                        bfValue = reportData.SnapshotExplorer.GetBackgroundFacts(reportData.PreviousSnapshot.Href, bfId).FirstOrDefault();
                    }
                    else
                    {
                        bfValue = reportData.SnapshotExplorer.GetBackgroundFacts(reportData.CurrentSnapshot.Href, bfId).FirstOrDefault();
                    }
                    if (bfValue != null && bfValue.ApplicationResults.Any())
                    {
                        objValues[j] = bfValue.ApplicationResults[0].DetailResult.Value;
                    }
                    else
                    {
                        return(Labels.NoData);
                    }
                    j++;
                    break;

                default:
                    return(Labels.NoData);
                }
            }

            string value = ExpressionEvaluator.Eval(strParameters, _expr, objValues, _metricFormat);

            return(value);
        }
Esempio n. 27
0
        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);
        }
Esempio n. 28
0
        public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            int count = 0;

            string[] qidList = options.GetOption("QID")?.Split('|');
            string[] sidList = options.GetOption("SID")?.Split('|');
            string[] bidList = options.GetOption("BID")?.Split('|');

            // we can add the header only after getting the data, because names are in the data
            var rowData = new List <string>();

            #region get Metric names

            Dictionary <string, string> names = new Dictionary <string, string>();

            if (qidList != null)
            {
                foreach (string id in qidList)
                {
                    if (names.Keys.Contains(id))
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(BusinessCriteriaUtility.GetMetricName(reportData.CurrentSnapshot, int.Parse(id))))
                    {
                        continue;
                    }
                    names[id] = BusinessCriteriaUtility.GetMetricName(reportData.CurrentSnapshot, int.Parse(id));
                }
            }
            if (sidList != null)
            {
                foreach (string id in sidList)
                {
                    if (names.Keys.Contains(id))
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(MeasureUtility.GetSizingMeasureName(reportData.CurrentSnapshot, int.Parse(id))))
                    {
                        continue;
                    }
                    names[id] = MeasureUtility.GetSizingMeasureName(reportData.CurrentSnapshot, int.Parse(id));
                }
            }

            // No background facts for technologies
            if (bidList != null)
            {
                foreach (string id in bidList)
                {
                    if (names.Keys.Contains(id))
                    {
                        continue;
                    }
                    Result bfResult = reportData.SnapshotExplorer.GetBackgroundFacts(reportData.CurrentSnapshot.Href, id, true, true).FirstOrDefault();
                    if (bfResult == null || !bfResult.ApplicationResults.Any())
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(bfResult.ApplicationResults[0].Reference.Name))
                    {
                        continue;
                    }
                    names[id] = bfResult.ApplicationResults[0].Reference.Name;
                }
            }

            rowData.Add(" ");
            rowData.AddRange(names.Values);

            #endregion

            int nbSnapshots = reportData?.Application.Snapshots?.Count() ?? 0;
            if (nbSnapshots > 0)
            {
                // ReSharper disable once PossibleNullReferenceException
                // ReSharper disable once AssignNullToNotNullAttribute
                foreach (Snapshot snapshot in reportData.Application.Snapshots.OrderBy(_ => _.Annotation.Date.DateSnapShot))
                {
                    rowData.Add(snapshot.Annotation.Date.DateSnapShot?.ToOADate().ToString(CultureInfo.CurrentCulture) ?? string.Empty);

                    Dictionary <string, string> values = new Dictionary <string, string>();
                    // iterate in QID
                    if (qidList != null)
                    {
                        foreach (string id in qidList)
                        {
                            if (!names.Keys.Contains(id))
                            {
                                continue;
                            }
                            ApplicationResult res     = reportData.SnapshotExplorer.GetQualityIndicatorResults(snapshot.Href, id.Trim())?.FirstOrDefault()?.ApplicationResults?.FirstOrDefault();
                            string            idValue = res?.DetailResult?.Grade?.ToString("N2") ?? Constants.Zero;
                            if (!values.Keys.Contains(id))
                            {
                                values.Add(id, idValue);
                            }
                        }
                    }

                    // iterate in SID
                    if (sidList != null)
                    {
                        foreach (string id in sidList)
                        {
                            if (!names.Keys.Contains(id))
                            {
                                continue;
                            }
                            ApplicationResult res     = reportData.SnapshotExplorer.GetSizingMeasureResults(snapshot.Href, id.Trim())?.FirstOrDefault()?.ApplicationResults?.FirstOrDefault();
                            string            idValue = res?.DetailResult?.Value?.ToString("F0") ?? Constants.Zero;
                            if (!values.Keys.Contains(id))
                            {
                                values.Add(id, idValue);
                            }
                        }
                    }

                    // iterate in BID
                    if (bidList != null)
                    {
                        foreach (string id in bidList)
                        {
                            if (!names.Keys.Contains(id))
                            {
                                continue;
                            }
                            ApplicationResult res = reportData.SnapshotExplorer.GetBackgroundFacts(snapshot.Href, id.Trim())?.FirstOrDefault()?.ApplicationResults?.FirstOrDefault();
                            // F0 as format to avoid the ',' that make graph build crash
                            string idValue = res?.DetailResult?.Value?.ToString("F0") ?? Constants.Zero;
                            if (!values.Keys.Contains(id))
                            {
                                values.Add(id, idValue);
                            }
                        }
                    }

                    rowData.AddRange(values.Values);
                }
                count = nbSnapshots;
            }

            #region just 1 snapshot
            // if there is only one snapshot, a fake snapshot is added with same data to have a line and not a point in the graph
            if (count == 1)
            {
                string[] range = new string[names.Count + 1];

                for (int k = 0; k < names.Count + 1; k++)
                {
                    range[k] = rowData[k + names.Count + 1];
                }

                rowData.AddRange(range);
                count = count + 1;
            }
            #endregion just 1 snapshot

            TableDefinition resultTable = new TableDefinition {
                HasRowHeaders    = true,
                HasColumnHeaders = false,
                NbRows           = count + 1,
                NbColumns        = names.Count + 1,
                Data             = rowData
            };


            return(resultTable);
        }
        public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            const string metricFormat = "N0";

            if (reportData?.CurrentSnapshot == null)
            {
                return(null);
            }

            #region currentSnapshot

            double?criticalViolation = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesNumber);
            double?numCritPerFile    = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesPerFileNumber);
            string numCritPerFileIfNegative;
            // ReSharper disable once CompareOfFloatsByEqualityOperator -- special case
            if (numCritPerFile == -1)
            {
                numCritPerFileIfNegative = Constants.No_Value;
            }
            else
            {
                numCritPerFileIfNegative = numCritPerFile?.ToString("N2") ?? Constants.No_Value;
            }
            double?_numCritPerKloc = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesPerKLOCNumber);

            double?veryHighCostComplexityViolations = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot, Constants.
                                                                                                   QualityDistribution.DistributionOfViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(),
                                                                                                   Constants.ViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.
                                                                                                   ComplexityViolations_VeryHigh.GetHashCode());
            double?highCostComplexityViolations = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                                               Constants.QualityDistribution.DistributionOfViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(),
                                                                                               Constants.ViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.ComplexityViolations_HighCost.GetHashCode());

            double?veryHighCostComplexityArtefacts = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                                                  Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(),
                                                                                                  Constants.CostComplexity.CostComplexityArtifacts_VeryHigh.GetHashCode());
            double?highCostComplexityArtefacts = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                                              Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(),
                                                                                              Constants.CostComplexity.CostComplexityArtifacts_High.GetHashCode());

            #endregion currentSnapshot


            #region PreviousSnapshot

            double?criticalViolationPrev = MeasureUtility.GetSizingMeasure(reportData.PreviousSnapshot,
                                                                           Constants.SizingInformations.ViolationsToCriticalQualityRulesNumber);

            double?numCritPerFilePrev = MeasureUtility.GetSizingMeasure(reportData.PreviousSnapshot,
                                                                        Constants.SizingInformations.ViolationsToCriticalQualityRulesPerFileNumber);
            string numCritPerFilePrevIfNegative;
            // ReSharper disable once CompareOfFloatsByEqualityOperator -- special case
            if (numCritPerFilePrev == -1)
            {
                numCritPerFilePrevIfNegative = Constants.No_Value;
            }
            else
            {
                numCritPerFilePrevIfNegative = numCritPerFilePrev?.ToString("N2") ?? Constants.No_Value;
            }

            double?_numCritPerKlocPrev = MeasureUtility.GetSizingMeasure(reportData.PreviousSnapshot,
                                                                         Constants.SizingInformations.ViolationsToCriticalQualityRulesPerKLOCNumber);

            double?veryHighCostComplexityViolationsPrev = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot,
                                                                                                       Constants.QualityDistribution.DistributionOfViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(),
                                                                                                       Constants.ViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.ComplexityViolations_VeryHigh.GetHashCode());

            double?highCostComplexityViolationsPrev = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot,
                                                                                                   Constants.QualityDistribution.DistributionOfViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(),
                                                                                                   Constants.ViolationsToCriticalDiagnosticBasedMetricsPerCostComplexity.ComplexityViolations_HighCost.GetHashCode());

            double?veryHighCostComplexityArtefactsPrev = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot,
                                                                                                      Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(),
                                                                                                      Constants.CostComplexity.CostComplexityArtifacts_VeryHigh.GetHashCode());

            double?highCostComplexityArtefactsPrev = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot,
                                                                                                  Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(),
                                                                                                  Constants.CostComplexity.CostComplexityArtifacts_High.GetHashCode());

            #endregion PreviousSnapshot
            #region SumMetric

            double?_highveryHighCostComplexityArtefacts      = MathUtility.GetSum(veryHighCostComplexityArtefacts, highCostComplexityArtefacts);
            double?_highveryHighCostComplexityViolations     = MathUtility.GetSum(veryHighCostComplexityViolations, highCostComplexityViolations);
            double?_highveryHighCostComplexityArtefactsPrev  = MathUtility.GetSum(veryHighCostComplexityArtefactsPrev, highCostComplexityArtefactsPrev);
            double?_highveryHighCostComplexityViolationsPrev = MathUtility.GetSum(veryHighCostComplexityViolationsPrev, highCostComplexityViolationsPrev);

            #endregion SumMetric

            #region evolutionPercMetric

            double?criticalViolationEvolPerc = MathUtility.GetVariationPercent(criticalViolation, criticalViolationPrev);
            double?numCritPerFileEvolPerc    = MathUtility.GetVariationPercent(numCritPerFile, numCritPerFilePrev);
            double?_numCritPerKlocEvolPerc   = MathUtility.GetVariationPercent(_numCritPerKloc, _numCritPerKlocPrev);
            double?_highveryHighCostComplexityViolationsEvolPerc = MathUtility.GetVariationPercent(_highveryHighCostComplexityViolations, _highveryHighCostComplexityViolationsPrev);
            double?_highveryHighCostComplexityArtefactsEvolPerc  = MathUtility.GetVariationPercent(_highveryHighCostComplexityArtefacts, _highveryHighCostComplexityArtefactsPrev);

            #endregion evolutionPercMetric

            var rowData = new List <string>()
            {
                Labels.Name
                , Labels.Current
                , Labels.Previous
                , Labels.EvolutionPercent
                , Labels.ViolationsCritical
                , criticalViolation?.ToString(metricFormat) ?? Constants.No_Value
                , criticalViolationPrev?.ToString(metricFormat) ?? Constants.No_Value
                , (criticalViolationEvolPerc.HasValue) ? FormatPercent(criticalViolationEvolPerc.Value): Constants.No_Value

                , "  " + Labels.PerFile
                , numCritPerFileIfNegative
                , numCritPerFilePrevIfNegative
                , (numCritPerFileEvolPerc.HasValue) ? FormatPercent(numCritPerFileEvolPerc.Value) : Constants.No_Value

                , "  " + Labels.PerkLoC
                , _numCritPerKloc?.ToString("N2") ?? Constants.No_Value
                , _numCritPerKlocPrev?.ToString("N2") ?? Constants.No_Value
                , (_numCritPerKlocEvolPerc.HasValue) ? FormatPercent(_numCritPerKlocEvolPerc.Value) : Constants.No_Value

                , Labels.ComplexObjects
                , _highveryHighCostComplexityArtefacts?.ToString(metricFormat) ?? Constants.No_Value
                , _highveryHighCostComplexityArtefactsPrev?.ToString(metricFormat) ?? Constants.No_Value
                , _highveryHighCostComplexityArtefactsEvolPerc.HasValue ? FormatPercent(_highveryHighCostComplexityArtefactsEvolPerc.Value) : Constants.No_Value

                , "  " + Labels.WithViolations
                , _highveryHighCostComplexityViolations?.ToString(metricFormat) ?? Constants.No_Value
                , _highveryHighCostComplexityViolationsPrev?.ToString(metricFormat) ?? Constants.No_Value
                , _highveryHighCostComplexityViolationsEvolPerc.HasValue ? FormatPercent(_highveryHighCostComplexityViolationsEvolPerc.Value) : Constants.No_Value
            };

            var resultTable = new TableDefinition
            {
                HasRowHeaders    = true,
                HasColumnHeaders = false,
                NbRows           = 6,
                NbColumns        = 4,
                Data             = rowData
            };
            return(resultTable);
        }
Esempio n. 30
0
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            double minVVal = Int16.MaxValue;
            double maxVVal = 0;
            double stepV   = 0;
            int    count   = 0;

            bool hasVerticalZoom = options.ContainsKey("ZOOM");

            if (!options.ContainsKey("ZOOM") || !Double.TryParse(options["ZOOM"], out stepV))
            {
                stepV = 1;
            }

            var rowData = new List <String>();

            rowData.AddRange(new string[] {
                " ",
                Labels.Trans,
                Labels.Chang,
                Labels.Robu,
                Labels.Efcy,
                Labels.Secu,
                Labels.LoC
            });


            #region Fetch Snapshots
            int nbSnapshots = (reportData != null && reportData.Application.Snapshots != null) ? reportData.Application.Snapshots.Count() : 0;
            if (nbSnapshots > 0)
            {
                foreach (Snapshot snapshot in reportData.Application.Snapshots.OrderBy(_ => _.Annotation.Date))
                {
                    BusinessCriteriaDTO bcGrade = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(snapshot, true);
                    double?locValue             = MeasureUtility.GetCodeLineNumber(snapshot);
                    string snapshotDate         = snapshot.Annotation.Date.DateSnapShot.HasValue ? snapshot.Annotation.Date.DateSnapShot.Value.ToOADate().ToString()
                                                                                                : string.Empty;
                    rowData.AddRange(new string[] {
                        snapshotDate,
                        bcGrade.Transferability.GetValueOrDefault().ToString(),
                        bcGrade.Changeability.GetValueOrDefault().ToString(),
                        bcGrade.Robustness.GetValueOrDefault().ToString(),
                        bcGrade.Performance.GetValueOrDefault().ToString(),
                        bcGrade.Security.GetValueOrDefault().ToString(),
                        locValue.GetValueOrDefault().ToString(),
                    });
                    List <double> values = new List <double>()
                    {
                        bcGrade.Changeability.GetValueOrDefault(),
                                  bcGrade.Performance.GetValueOrDefault(),
                                  bcGrade.Robustness.GetValueOrDefault(),
                                  bcGrade.Security.GetValueOrDefault(),
                                  bcGrade.TQI.GetValueOrDefault(),
                                  bcGrade.Transferability.GetValueOrDefault()
                    };
                    minVVal = Math.Min(minVVal, values.Min());
                    maxVVal = Math.Max(maxVVal, values.Max());
                }
                count = nbSnapshots;
            }
            #endregion

            #region just 1 snapshot
            if (nbSnapshots == 1)
            {
                BusinessCriteriaDTO bcGrade = new BusinessCriteriaDTO();
                bcGrade = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(reportData.CurrentSnapshot, true);
                double?locValue     = MeasureUtility.GetCodeLineNumber(reportData.CurrentSnapshot);
                string snapshotDate = reportData.CurrentSnapshot.Annotation.Date.DateSnapShot.HasValue ? reportData.CurrentSnapshot.Annotation.Date.DateSnapShot.Value.ToOADate().ToString()
                                                                                                   : string.Empty;
                rowData.AddRange(new string[] {
                    snapshotDate,
                    bcGrade.Transferability.GetValueOrDefault().ToString(),
                    bcGrade.Changeability.GetValueOrDefault().ToString(),
                    bcGrade.Robustness.GetValueOrDefault().ToString(),
                    bcGrade.Performance.GetValueOrDefault().ToString(),
                    bcGrade.Security.GetValueOrDefault().ToString(),
                    locValue.GetValueOrDefault().ToString(),
                });
                List <double> values = new List <double>()
                {
                    bcGrade.Changeability.GetValueOrDefault(),
                              bcGrade.Performance.GetValueOrDefault(),
                              bcGrade.Robustness.GetValueOrDefault(),
                              bcGrade.Security.GetValueOrDefault(),
                              bcGrade.TQI.GetValueOrDefault(),
                              bcGrade.Transferability.GetValueOrDefault()
                };
                minVVal = Math.Min(minVVal, values.Min());
                maxVVal = Math.Max(maxVVal, values.Max());
                count   = count + 1;
            }
            #endregion just 1 snapshot



            #region Graphic Options
            GraphOptions graphOptions = null;
            if (hasVerticalZoom)
            {
                graphOptions = new GraphOptions()
                {
                    AxisConfiguration = new AxisDefinition()
                };
                graphOptions.AxisConfiguration.VerticalAxisMinimal = MathUtility.GetVerticalMinValue(minVVal, stepV);
                graphOptions.AxisConfiguration.VerticalAxisMaximal = MathUtility.GetVerticalMaxValue(maxVVal, stepV);
            }
            #endregion Graphic Options

            TableDefinition resultTable = new TableDefinition {
                HasRowHeaders    = true,
                HasColumnHeaders = false,
                NbRows           = count + 1,
                NbColumns        = 7,
                Data             = rowData,
                GraphOptions     = graphOptions
            };


            return(resultTable);
        }