示例#1
0
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            var results = RulesViolationUtility.GetStatViolation(reportData.CurrentSnapshot);

            int  param        = 0;
            bool showPrevious = false;

            if (reportData.PreviousSnapshot != null && null != options && options.ContainsKey("SHOW_PREVIOUS") && Int32.TryParse(options["SHOW_PREVIOUS"], out param))
            {
                showPrevious = (param != 0);
            }

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

            int nbRows = 0;

            rowData.AddRange(new[] {
                " ",
                Labels.TQI,
                Labels.Robu,
                Labels.Efcy,
                Labels.Secu,
                Labels.Trans,
                Labels.Chang
            });
            nbRows++;

            var busCrit = new Constants.BusinessCriteria[] {
                Constants.BusinessCriteria.TechnicalQualityIndex,
                Constants.BusinessCriteria.Robustness,
                Constants.BusinessCriteria.Performance,
                Constants.BusinessCriteria.Security,
                Constants.BusinessCriteria.Transferability,
                Constants.BusinessCriteria.Changeability
            };

            var curVersion = new int[busCrit.Length];
            var added      = new int[busCrit.Length];
            var removed    = new int[busCrit.Length];

            foreach (var resultModule in results)
            {
                if (resultModule != null)
                {
                    for (int i = 0; i < busCrit.Length; i++)
                    {
                        var crit = busCrit[i];
                        if (resultModule[crit] != null)
                        {
                            if (resultModule[crit].Total.HasValue)
                            {
                                curVersion[i] += resultModule[crit].Total.Value;
                            }
                            if (resultModule[crit].Added.HasValue)
                            {
                                added[i] += resultModule[crit].Added.Value;
                            }
                            if (resultModule[crit].Removed.HasValue)
                            {
                                removed[i] += resultModule[crit].Removed.Value;
                            }
                        }
                    }
                }
            }

            rowData.Add(Labels.VersionCurrent);
            foreach (var curValue in curVersion)
            {
                rowData.Add(curValue.ToString());
            }
            nbRows++;

            rowData.Add("   " + Labels.ViolationsAdded);
            foreach (var addValue in added)
            {
                rowData.Add(TableBlock.FormatEvolution(addValue));
            }
            nbRows++;

            rowData.Add("   " + Labels.ViolationsRemoved);
            foreach (var remValue in removed)
            {
                rowData.Add(TableBlock.FormatEvolution(-remValue));
            }
            nbRows++;

            if (showPrevious)
            {
                var prevVersion = new int[busCrit.Length];

                results = RulesViolationUtility.GetStatViolation(reportData.PreviousSnapshot);
                foreach (var resultModule in results)
                {
                    if (resultModule != null)
                    {
                        for (int i = 0; i < busCrit.Length; i++)
                        {
                            var crit = busCrit[i];
                            if (resultModule[crit] != null && resultModule[crit].Total.HasValue)
                            {
                                prevVersion[i] += resultModule[crit].Total.Value;
                            }
                        }
                    }
                }

                rowData.Add(Labels.VersionPrevious);
                foreach (var prevValue in prevVersion)
                {
                    rowData.Add(prevValue.ToString());
                }
                nbRows++;
            }

            var resultTable = new TableDefinition {
                HasRowHeaders    = false,
                HasColumnHeaders = true,
                NbRows           = nbRows,
                NbColumns        = busCrit.Length + 1,
                Data             = rowData
            };


            return(resultTable);
        }
示例#2
0
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            int             rowCount    = 0;
            int             nbLimitTop  = 0;
            List <string>   rowData     = new List <string>();
            TableDefinition resultTable = null;
            List <RuleViolationsVariationResultDTO>        variationRules = new List <RuleViolationsVariationResultDTO>();
            IEnumerable <RuleViolationsVariationResultDTO> selectedRules;

            rowData.AddRange(new string[] {
                Labels.RuleName,
                Labels.Current,
                Labels.Previous,
                Labels.Evolution,
                Labels.EvolutionPercent
            });

            Int32?metricId = (options != null && options.ContainsKey("BC-ID")) ? Convert.ToInt32(options["BC-ID"]) : (Int32?)null;

            if (metricId == null)
            {
                metricId = (options != null && options.ContainsKey("PAR")) ? Convert.ToInt32(options["PAR"]) : (Int32?)null;
            }

            if (options == null || !options.ContainsKey("COUNT") || !Int32.TryParse(options["COUNT"], out nbLimitTop))
            {
                nbLimitTop = reportData.Parameter.NbResultDefault;
            }

            if (reportData != null && reportData.CurrentSnapshot != null)
            {
                if (!metricId.HasValue)
                {
                    metricId = 0;
                }

                var currentCriticalRulesViolation = RulesViolationUtility.GetAllRuleViolations(reportData.CurrentSnapshot,
                                                                                               Constants.RulesViolation.CriticalRulesViolation,
                                                                                               (Constants.BusinessCriteria)metricId,
                                                                                               true);


                var previousCriticalRulesViolation = (reportData.PreviousSnapshot != null) ? RulesViolationUtility.GetAllRuleViolations(reportData.PreviousSnapshot,
                                                                                                                                        Constants.RulesViolation.CriticalRulesViolation,
                                                                                                                                        (Constants.BusinessCriteria)metricId,
                                                                                                                                        false)
                                                                                           : null;


                if (currentCriticalRulesViolation != null)
                {
                    rowCount += currentCriticalRulesViolation.Count;
                    foreach (var item in currentCriticalRulesViolation)
                    {
                        //Get previous value
                        var    previousitem = (previousCriticalRulesViolation != null) ? previousCriticalRulesViolation.FirstOrDefault(_ => _.Rule.Key == item.Rule.Key) : null;
                        double?previousval  = (previousitem != null && previousitem.TotalFailed.HasValue) ? previousitem.TotalFailed.Value : (double?)null;

                        //Compute the varioation
                        double?variation = (item.TotalFailed.HasValue && previousval.HasValue) ? (item.TotalFailed.Value - previousval.Value) : (double?)null;

                        variationRules.Add(new RuleViolationsVariationResultDTO
                        {
                            Rule = new RuleDetailsDTO {
                                Name = item.Rule.Name, Key = item.Rule.Key
                            },
                            CurrentNbViolations  = (item.TotalFailed.HasValue) ? item.TotalFailed.Value : -1,
                            PreviousNbViolations = (previousitem != null && previousitem.TotalFailed.HasValue) ? previousitem.TotalFailed.Value : -1,
                            Variation            = (variation.HasValue) ? variation : double.NaN,
                            Ratio = (variation.HasValue && previousval.HasValue && previousval > 0) ? variation / previousval : double.NaN
                        });
                    }
                    selectedRules = variationRules.OrderByDescending(_ => _.Ratio).Take(nbLimitTop);
                    foreach (var varRule in selectedRules)
                    {
                        rowData.AddRange(new string[]
                        {
                            varRule.Rule.Name
                            , (varRule.CurrentNbViolations.HasValue && varRule.CurrentNbViolations.Value != -1)? varRule.CurrentNbViolations.Value.ToString("N0"): CastReporting.Domain.Constants.No_Value
                            , (varRule.PreviousNbViolations.HasValue && varRule.PreviousNbViolations.Value != -1)? varRule.PreviousNbViolations.Value.ToString("N0"): CastReporting.Domain.Constants.No_Value
                            , (varRule.Variation.HasValue && !double.IsNaN(varRule.Variation.Value))? TableBlock.FormatEvolution((Int32)varRule.Variation.Value):CastReporting.Domain.Constants.No_Value
                            , (varRule.Ratio.HasValue && !double.IsNaN(varRule.Ratio.Value)) ? TableBlock.FormatPercent(varRule.Ratio.Value) : CastReporting.Domain.Constants.No_Value
                        }
                                         );
                    }
                }
                else
                {
                    rowData.AddRange(new string[] {
                        Labels.NoItem,
                        string.Empty,
                        string.Empty,
                        string.Empty,
                        string.Empty
                    });
                    rowCount = 1;
                }
            }

            resultTable = new TableDefinition {
                HasRowHeaders    = false,
                HasColumnHeaders = true,
                NbRows           = rowCount + 1,
                NbColumns        = 5,
                Data             = rowData
            };
            return(resultTable);
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reportData"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            TableDefinition back  = new TableDefinition();
            int             parId = -1;

            Constants.QualityDistribution distributionId;
            List <string> rowData = new List <string>();

            double?previousHigVal = null;
            double?previousVhiVal = null;
            double?previousHttVal = null;

            if (null != options && options.ContainsKey("PAR") && Int32.TryParse(options["PAR"], out parId) && Enum.IsDefined(typeof(Constants.QualityDistribution), parId))
            {
                distributionId = (Constants.QualityDistribution)parId;
            }
            else
            {
                distributionId = Constants.QualityDistribution.CostComplexityDistribution;
            }

            if (null != reportData)
            {
                #region Selected Snapshot

                double?selectedLowVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                                     distributionId.GetHashCode(),
                                                                                     Constants.CyclomaticComplexity.ComplexityArtifacts_Low.GetHashCode());
                double?selectedAveVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                                     distributionId.GetHashCode(),
                                                                                     Constants.CyclomaticComplexity.ComplexityArtifacts_Moderate.GetHashCode());
                double?selectedHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                                     distributionId.GetHashCode(),
                                                                                     Constants.CyclomaticComplexity.ComplexityArtifacts_High.GetHashCode());
                double?selectedVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                                     distributionId.GetHashCode(),
                                                                                     Constants.CyclomaticComplexity.ComplexityArtifacts_VeryHigh.GetHashCode());



                double?selectedTotal  = (selectedLowVal.HasValue && selectedAveVal.HasValue && selectedHigVal.HasValue && selectedVhiVal.HasValue) ? selectedLowVal.Value + selectedAveVal.Value + selectedHigVal.Value + selectedVhiVal.Value : (double?)null;
                double?selectedHttVal = (selectedHigVal.HasValue && selectedVhiVal.HasValue) ? selectedHigVal.Value + selectedVhiVal.Value : (double?)null;

                #endregion Selected Snapshot

                #region Previous Snapshot

                if (reportData.PreviousSnapshot != null)
                {
                    previousHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot,
                                                                                  distributionId.GetHashCode(),
                                                                                  Constants.CyclomaticComplexity.ComplexityArtifacts_High.GetHashCode());
                    previousVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot,
                                                                                  distributionId.GetHashCode(),
                                                                                  Constants.CyclomaticComplexity.ComplexityArtifacts_VeryHigh.GetHashCode());

                    previousHttVal = previousHigVal.HasValue && previousVhiVal.HasValue ? previousHigVal.Value + previousVhiVal.Value : (double?)null;
                }

                #endregion Previous Snapshot

                #region Data
                Int32?variation = (selectedHttVal.HasValue && previousHttVal.HasValue) ? (Int32)(selectedHttVal - previousHttVal) : (Int32?)null;

                string distributionName = CastComplexityUtility.GetCostComplexityName(reportData.CurrentSnapshot, distributionId.GetHashCode());

                rowData.AddRange(new string[] { distributionName, Labels.Current, Labels.Previous, Labels.Evol, Labels.TotalPercent });
                rowData.AddRange(new string[]
                                 { Labels.ComplexityHighAndVeryHigh
                                   , selectedHttVal.HasValue? selectedHttVal.Value.ToString(_MetricFormat) : Constants.No_Value
                                   , previousHttVal.HasValue ? previousHttVal.Value.ToString(_MetricFormat) : Constants.No_Value
                                   , variation.HasValue? TableBlock.FormatEvolution((Int32)variation.Value): Constants.No_Value
                                   , (selectedHttVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0)? TableBlock.FormatPercent(selectedHttVal.Value / selectedTotal.Value, false): Constants.No_Value });


                #endregion Data

                back = new TableDefinition
                {
                    Data             = rowData,
                    HasRowHeaders    = false,
                    HasColumnHeaders = true,
                    NbColumns        = 5,
                    NbRows           = 2
                };
            }

            return(back);
        }
示例#4
0
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            TableDefinition resultTable = null;
            bool            hasPrevious = reportData.PreviousSnapshot != null;

            if (null != reportData &&
                null != reportData.CurrentSnapshot)
            {
                #region CastComputing

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

                double?codeLineNumberPrev    = MeasureUtility.GetCodeLineNumber(reportData.PreviousSnapshot);
                double?fileNumberPrev        = MeasureUtility.GetFileNumber(reportData.PreviousSnapshot);
                double?classNumberPrev       = MeasureUtility.GetClassNumber(reportData.PreviousSnapshot);
                double?sqlArtifactNumberPrev = MeasureUtility.GetSqlArtifactNumber(reportData.PreviousSnapshot);
                double?tableNumberPrev       = MeasureUtility.GetTableNumber(reportData.PreviousSnapshot);



                double?codeLineNumberEvol    = MathUtility.GetEvolution(codeLineNumber, codeLineNumberPrev);
                double?fileNumberEvol        = MathUtility.GetEvolution(fileNumber, fileNumberPrev);
                double?classNumberEvol       = MathUtility.GetEvolution(classNumber, classNumberPrev);
                double?sqlArtifactNumberEvol = MathUtility.GetEvolution(sqlArtifactNumber, sqlArtifactNumberPrev);
                double?tableNumberEvol       = MathUtility.GetEvolution(tableNumber, tableNumberPrev);


                double?codeLineNumberPercent    = MathUtility.GetPercent(codeLineNumberEvol, codeLineNumberPrev);
                double?fileNumberPercent        = MathUtility.GetPercent(fileNumberEvol, fileNumberPrev);
                double?classNumberPercent       = MathUtility.GetPercent(classNumberEvol, classNumberPrev);
                double?sqlArtifactNumberPercent = MathUtility.GetPercent(sqlArtifactNumberEvol, sqlArtifactNumberPrev);
                double?tableNumberPercent       = MathUtility.GetPercent(tableNumberEvol, tableNumberPrev);

                #endregion CastComputing

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

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

                    , Labels.LoC
                    , codeLineNumber.HasValue?  codeLineNumber.Value.ToString(metricFormat):noData
                    , codeLineNumberPrev.HasValue? codeLineNumberPrev.Value.ToString(metricFormat) : noData
                    , hasPrevious? TableBlock.FormatEvolution((Int32)codeLineNumberEvol.Value) : noData
                    , (codeLineNumberPercent.HasValue)? TableBlock.FormatPercent(codeLineNumberPercent.Value): noData

                    , "   " + Labels.Files
                    , fileNumber.HasValue? fileNumber.Value.ToString(metricFormat) :noData
                    , fileNumberPrev.HasValue? fileNumberPrev.Value.ToString(metricFormat) : noData
                    , hasPrevious? TableBlock.FormatEvolution((Int32)fileNumberEvol.Value) : noData
                    , (fileNumberPercent.HasValue)? TableBlock.FormatPercent(fileNumberPercent.Value): noData

                    , "   " + Labels.Classes
                    , classNumber.HasValue?  classNumber.Value.ToString(metricFormat): noData
                    , classNumberPrev.HasValue? classNumberPrev.Value.ToString(metricFormat) : noData
                    , hasPrevious? TableBlock.FormatEvolution((Int32)classNumberEvol.Value) : noData
                    , (classNumberPercent.HasValue)? TableBlock.FormatPercent(classNumberPercent.Value): noData

                    , Labels.ArtifactsSQL
                    , sqlArtifactNumber.HasValue? sqlArtifactNumber.Value.ToString(metricFormat) : noData
                    , sqlArtifactNumberPrev.HasValue? sqlArtifactNumberPrev.Value.ToString(metricFormat) : noData
                    , hasPrevious? TableBlock.FormatEvolution((Int32)sqlArtifactNumberEvol.Value) : noData
                    , (sqlArtifactNumberPercent.HasValue)? TableBlock.FormatPercent(sqlArtifactNumberPercent.Value): noData

                    , "   " + Labels.Tables
                    , tableNumber.HasValue? tableNumber.Value.ToString(metricFormat): noData
                    , tableNumberPrev.HasValue? tableNumberPrev.Value.ToString(metricFormat) : noData
                    , hasPrevious? TableBlock.FormatEvolution((Int32)tableNumberEvol.Value) : noData
                    , (tableNumberPercent.HasValue)? TableBlock.FormatPercent(tableNumberPercent.Value): noData
                };

                resultTable = new TableDefinition
                {
                    HasRowHeaders    = false,
                    HasColumnHeaders = true,
                    NbRows           = 6,
                    NbColumns        = 5,
                    Data             = rowData
                };
            }
            return(resultTable);
        }
示例#5
0
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            TableDefinition result  = new TableDefinition();
            List <string>   rowData = new List <string>();
            int             parId;

            Constants.QualityDistribution distributionId;


            double?selectedLowVal   = null;
            double?selectedAveVal   = null;
            double?selectedHigVal   = null;
            double?selectedVhiVal   = null;
            double?selectedTotal    = null;
            double?previousLowVal   = null;
            double?previousAveVal   = null;
            double?previousHigVal   = null;
            double?previousVhiVal   = null;
            string distributionName = Constants.No_Value;

            if (null != options && options.ContainsKey("PAR") && Int32.TryParse(options["PAR"], out parId) && Enum.IsDefined(typeof(Constants.QualityDistribution), parId))
            {
                distributionId = (Constants.QualityDistribution)parId;
            }
            else
            {
                distributionId = Constants.QualityDistribution.CostComplexityDistribution;
            }


            if (null != reportData && null != reportData.CurrentSnapshot)
            {
                #region Selected Snapshot

                selectedLowVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                              distributionId.GetHashCode(),
                                                                              Constants.CyclomaticComplexity.ComplexityArtifacts_Low.GetHashCode());
                selectedAveVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                              distributionId.GetHashCode(),
                                                                              Constants.CyclomaticComplexity.ComplexityArtifacts_Moderate.GetHashCode());
                selectedHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                              distributionId.GetHashCode(),
                                                                              Constants.CyclomaticComplexity.ComplexityArtifacts_High.GetHashCode());
                selectedVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                              distributionId.GetHashCode(),
                                                                              Constants.CyclomaticComplexity.ComplexityArtifacts_VeryHigh.GetHashCode());


                if (selectedLowVal.HasValue && selectedAveVal.HasValue && selectedHigVal.HasValue && selectedVhiVal.HasValue)
                {
                    selectedTotal = selectedLowVal + selectedAveVal + selectedHigVal + selectedVhiVal;
                }

                #endregion Selected Snapshot

                #region Previous Snapshot


                if (reportData.PreviousSnapshot != null)
                {
                    previousLowVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot,
                                                                                  distributionId.GetHashCode(),
                                                                                  Constants.CyclomaticComplexity.ComplexityArtifacts_Low.GetHashCode());
                    previousAveVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot,
                                                                                  distributionId.GetHashCode(),
                                                                                  Constants.CyclomaticComplexity.ComplexityArtifacts_Moderate.GetHashCode());
                    previousHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot,
                                                                                  distributionId.GetHashCode(),
                                                                                  Constants.CyclomaticComplexity.ComplexityArtifacts_High.GetHashCode());
                    previousVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot,
                                                                                  distributionId.GetHashCode(),
                                                                                  Constants.CyclomaticComplexity.ComplexityArtifacts_VeryHigh.GetHashCode());
                }

                #endregion Previous Snapshot

                #region Data
                distributionName = CastComplexityUtility.GetCostComplexityName(reportData.CurrentSnapshot, distributionId.GetHashCode());

                rowData.AddRange(new string[] { distributionName, Labels.Current, Labels.Previous, Labels.Evol, Labels.EvolPercent, Labels.TotalPercent });

                rowData.AddRange(new string[]
                                 { Labels.ComplexityLow
                                   , selectedLowVal.HasValue ? selectedLowVal.Value.ToString("N0"):Constants.No_Value
                                   , previousLowVal.HasValue ? previousLowVal.Value.ToString("N0") : Constants.No_Value
                                   , (selectedLowVal.HasValue && previousLowVal.HasValue) ? TableBlock.FormatEvolution((Int32)(selectedLowVal.Value - previousLowVal.Value)): Constants.No_Value
                                   , (selectedLowVal.HasValue && previousLowVal.HasValue && previousLowVal.Value != 0)? TableBlock.FormatPercent((selectedLowVal - previousLowVal) / previousLowVal)
                                                                                                      : Constants.No_Value
                                   , (selectedLowVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0)?TableBlock.FormatPercent(selectedLowVal / selectedTotal, false): Constants.No_Value });

                rowData.AddRange(new string[]
                                 { Labels.ComplexityAverage
                                   , selectedAveVal.HasValue ? selectedAveVal.Value.ToString("N0"): Constants.No_Value
                                   , previousAveVal.HasValue ? previousAveVal.Value.ToString("N0") : Constants.No_Value
                                   , (selectedAveVal.HasValue && previousAveVal.HasValue) ? TableBlock.FormatEvolution((Int32)(selectedAveVal.Value - previousAveVal.Value)) : Constants.No_Value
                                   , (selectedAveVal.HasValue && previousAveVal.HasValue && previousAveVal.Value != 0)? TableBlock.FormatPercent((selectedAveVal - previousAveVal) / previousAveVal)
                                                                                                      : Constants.No_Value
                                   , (selectedAveVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0)?TableBlock.FormatPercent(selectedAveVal / selectedTotal, false): Constants.No_Value });

                rowData.AddRange(new string[]
                                 { Labels.ComplexityHigh
                                   , selectedHigVal.Value.ToString("N0")
                                   , previousHigVal.HasValue ? previousHigVal.Value.ToString("N0") : Constants.No_Value
                                   , previousHigVal.HasValue ? TableBlock.FormatEvolution((Int32)(selectedHigVal.Value - previousHigVal.Value)): Constants.No_Value
                                   , (selectedHigVal.HasValue && previousHigVal.HasValue && previousHigVal.Value != 0)? TableBlock.FormatPercent((selectedHigVal - previousHigVal) / previousHigVal)
                                                                                                      : Constants.No_Value
                                   , (selectedHigVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0)?TableBlock.FormatPercent(selectedHigVal / selectedTotal, false): Constants.No_Value });

                rowData.AddRange(new string[]
                                 { Labels.ComplexityExtreme
                                   , selectedVhiVal.HasValue? selectedVhiVal.Value.ToString("N0"): Constants.No_Value
                                   , previousVhiVal.HasValue ? previousVhiVal.Value.ToString("N0") : Constants.No_Value
                                   , (selectedVhiVal.HasValue && previousVhiVal.HasValue) ? TableBlock.FormatEvolution((Int32)(selectedVhiVal.Value - previousVhiVal.Value)): Constants.No_Value
                                   , (selectedVhiVal.HasValue && previousVhiVal.HasValue && previousVhiVal.Value != 0)? TableBlock.FormatPercent((selectedVhiVal - previousVhiVal) / previousVhiVal)
                                                                                                      : Constants.No_Value
                                   , (selectedVhiVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0)?TableBlock.FormatPercent(selectedVhiVal / selectedTotal, false): Constants.No_Value });

                #endregion Data

                result = new TableDefinition
                {
                    Data             = rowData,
                    HasRowHeaders    = false,
                    HasColumnHeaders = true,
                    NbColumns        = 6,
                    NbRows           = 5
                };
            }
            return(result);
        }
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            TableDefinition back           = new TableDefinition();
            List <string>   rowData        = new List <string>();
            double?         previousHigVal = null;
            double?         previousVhiVal = null;
            double?         previousHttVal = null;

            if (null != reportData)
            {
                #region Selected Snapshot
                double?selectedLowVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                                     Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(),
                                                                                     Constants.CostComplexity.CostComplexityArtifacts_Low.GetHashCode());
                double?selectedAveVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                                     Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(),
                                                                                     Constants.CostComplexity.CostComplexityArtifacts_Average.GetHashCode());
                double?selectedHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                                     Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(),
                                                                                     Constants.CostComplexity.CostComplexityArtifacts_High.GetHashCode());
                double?selectedVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                                     Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(),
                                                                                     Constants.CostComplexity.CostComplexityArtifacts_VeryHigh.GetHashCode());

                double?selectedTotal  = (selectedLowVal.HasValue && selectedAveVal.HasValue && selectedHigVal.HasValue && selectedVhiVal.HasValue)?selectedLowVal.Value + selectedAveVal.Value + selectedHigVal.Value + selectedVhiVal.Value : (double?)null;
                double?selectedHttVal = (selectedHigVal.HasValue && selectedVhiVal.HasValue)?selectedHigVal.Value + selectedVhiVal.Value:(double?)null;

                #endregion Selected Snapshot

                #region Previous Snapshot

                if (reportData.PreviousSnapshot != null)
                {
                    previousHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot,
                                                                                  Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(),
                                                                                  Constants.CostComplexity.CostComplexityArtifacts_High.GetHashCode());
                    previousVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot,
                                                                                  Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(),
                                                                                  Constants.CostComplexity.CostComplexityArtifacts_VeryHigh.GetHashCode());
                    previousHttVal = previousHigVal.HasValue && previousVhiVal.HasValue ? previousHigVal.Value + previousVhiVal.Value : (double?)null;
                }
                #endregion Previous Snapshot

                #region Data
                Int32?variation = (selectedHttVal.HasValue && previousHttVal.HasValue) ? (Int32)(selectedHttVal - previousHttVal) : (Int32?)null;


                rowData.AddRange(new string[] { Labels.Complexity, Labels.Current, Labels.Previous, Labels.Evol, Labels.TotalPercent });

                rowData.AddRange(new string[]
                                 { Labels.ComplexityHighAndVeryHigh
                                   , selectedHttVal.HasValue? selectedHttVal.Value.ToString(_MetricFormat) : Constants.No_Value
                                   , previousHttVal.HasValue ? previousHttVal.Value.ToString(_MetricFormat) : Constants.No_Value
                                   , variation.HasValue? TableBlock.FormatEvolution((Int32)variation.Value): Constants.No_Value
                                   , (selectedHttVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0)? TableBlock.FormatPercent(selectedHttVal.Value / selectedTotal.Value, false): Constants.No_Value });
                #endregion Data

                back = new TableDefinition
                {
                    Data             = rowData,
                    HasRowHeaders    = false,
                    HasColumnHeaders = true,
                    NbColumns        = 5,
                    NbRows           = 2
                };
            }


            return(back);
        }
示例#7
0
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            TableDefinition back = new TableDefinition();

            bool   hasPreviousSnapshot = (null != reportData.PreviousSnapshot);
            double?selectedLowVal      = null;
            double?selectedAveVal      = null;
            double?selectedHigVal      = null;
            double?selectedVhiVal      = null;
            double?selectedTotal       = null;
            double?previousLowVal      = null;
            double?previousAveVal      = null;
            double?previousHigVal      = null;
            double?previousVhiVal      = null;


            if (null != reportData && null != reportData.CurrentSnapshot)
            {
                #region Selected Snapshot

                selectedLowVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                              Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(),
                                                                              Constants.CostComplexity.CostComplexityArtifacts_Low.GetHashCode());
                selectedAveVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                              Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(),
                                                                              Constants.CostComplexity.CostComplexityArtifacts_Average.GetHashCode());
                selectedHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                              Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(),
                                                                              Constants.CostComplexity.CostComplexityArtifacts_High.GetHashCode());
                selectedVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                              Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(),
                                                                              Constants.CostComplexity.CostComplexityArtifacts_VeryHigh.GetHashCode());

                selectedTotal = 0;
                if (selectedLowVal.HasValue)
                {
                    selectedTotal += selectedLowVal;
                }
                if (selectedAveVal.HasValue)
                {
                    selectedTotal += selectedAveVal;
                }
                if (selectedHigVal.HasValue)
                {
                    selectedTotal += selectedHigVal;
                }
                if (selectedVhiVal.HasValue)
                {
                    selectedTotal += selectedVhiVal;
                }

                #endregion Selected Snapshot

                #region Previous Snapshot
                if (hasPreviousSnapshot)
                {
                    previousLowVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot,
                                                                                  Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(),
                                                                                  Constants.CostComplexity.CostComplexityArtifacts_Low.GetHashCode());
                    previousAveVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot,
                                                                                  Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(),
                                                                                  Constants.CostComplexity.CostComplexityArtifacts_Average.GetHashCode());
                    previousHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot,
                                                                                  Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(),
                                                                                  Constants.CostComplexity.CostComplexityArtifacts_High.GetHashCode());
                    previousVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot,
                                                                                  Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(),
                                                                                  Constants.CostComplexity.CostComplexityArtifacts_VeryHigh.GetHashCode());
                }

                #endregion Previous Snapshot

                #region Data
                List <string> rowData = new List <string>();
                rowData.AddRange(new string[] { Labels.Complexity, Labels.Current, Labels.Previous, Labels.Evol, Labels.EvolPercent, Labels.TotalPercent });

                const string noData = Constants.No_Data;

                rowData.AddRange(new string[]
                                 { Labels.ComplexityLow
                                   , selectedLowVal.HasValue ? selectedLowVal.Value.ToString("N0") : noData
                                   , previousLowVal.HasValue ? previousLowVal.Value.ToString("N0") : noData
                                   , (selectedLowVal.HasValue && previousLowVal.HasValue) ? TableBlock.FormatEvolution((Int32)(selectedLowVal.Value - previousLowVal.Value)) : noData
                                   , (selectedLowVal.HasValue && previousLowVal.HasValue && previousLowVal.Value != 0)? TableBlock.FormatPercent((selectedLowVal - previousLowVal) / previousLowVal)
                                                                                                      : noData
                                   , (selectedLowVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0)?TableBlock.FormatPercent(selectedLowVal / selectedTotal, false): noData });

                rowData.AddRange(new string[]
                                 { Labels.ComplexityAverage
                                   , selectedAveVal.HasValue ? selectedAveVal.Value.ToString("N0"):noData
                                   , previousAveVal.HasValue ? previousAveVal.Value.ToString("N0") : noData
                                   , (selectedAveVal.HasValue && previousAveVal.HasValue) ? TableBlock.FormatEvolution((Int32)(selectedAveVal.Value - previousAveVal.Value)) : noData
                                   , (selectedAveVal.HasValue && previousAveVal.HasValue && previousAveVal.Value != 0)? TableBlock.FormatPercent((selectedAveVal - previousAveVal) / previousAveVal)
                                                                                                      : noData
                                   , (selectedAveVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0)?TableBlock.FormatPercent(selectedAveVal / selectedTotal, false): noData });

                rowData.AddRange(new string[]
                                 { Labels.ComplexityHigh
                                   , selectedHigVal.HasValue ? selectedHigVal.Value.ToString("N0"): noData
                                   , previousHigVal.HasValue ? previousHigVal.Value.ToString("N0") : noData
                                   , (selectedHigVal.HasValue && previousHigVal.HasValue) ? TableBlock.FormatEvolution((Int32)(selectedHigVal.Value - previousHigVal.Value)) : noData
                                   , (selectedHigVal.HasValue && previousHigVal.HasValue && previousHigVal.Value != 0)? TableBlock.FormatPercent((selectedHigVal - previousHigVal) / previousHigVal)
                                                                                                      : noData
                                   , (selectedHigVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0)?TableBlock.FormatPercent(selectedHigVal / selectedTotal, false): noData });

                rowData.AddRange(new string[]
                                 { Labels.ComplexityVeryHigh
                                   , selectedVhiVal.HasValue ? selectedVhiVal.Value.ToString("N0"): noData
                                   , previousVhiVal.HasValue ? previousVhiVal.Value.ToString("N0") : noData
                                   , previousVhiVal.HasValue ? TableBlock.FormatEvolution((Int32)(selectedVhiVal.Value - previousVhiVal.Value)): noData
                                   , (selectedVhiVal.HasValue && previousVhiVal.HasValue && previousVhiVal.Value != 0)? TableBlock.FormatPercent((selectedVhiVal - previousVhiVal) / previousVhiVal)
                                                                                                      : noData
                                   , (selectedVhiVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0)?TableBlock.FormatPercent(selectedVhiVal / selectedTotal, false): noData });

                #endregion Data

                back = new TableDefinition
                {
                    HasRowHeaders    = false,
                    HasColumnHeaders = true,
                    Data             = rowData,
                    NbColumns        = 6,
                    NbRows           = 5
                };
            }

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

            if (null != reportData &&
                null != reportData.CurrentSnapshot)
            {
                #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_Data;
                const string metricFormat = "N0";

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

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

                resultTable = new TableDefinition
                {
                    HasRowHeaders    = false,
                    HasColumnHeaders = true,
                    NbRows           = 6,
                    NbColumns        = 5,
                    Data             = rowData
                };
            }
            return(resultTable);
        }