Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reportData"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            bool isDisplayShortHeader = (options != null && options.ContainsKey("HEADER") && "SHORT" == options["HEADER"]);

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

            rowData.AddRange(isDisplayShortHeader
                ? new[] { " ", Labels.TQICur, Labels.TQIPrev, Labels.Var }
                : new[] { " ", Labels.TQICurrent, Labels.TQIPrevious, Labels.Variation });

            var resultCurrentSnapshot  = BusinessCriteriaUtility.GetBusinessCriteriaGradesModules(reportData.CurrentSnapshot, false);
            var resultPreviousSnapshot = BusinessCriteriaUtility.GetBusinessCriteriaGradesModules(reportData.PreviousSnapshot, false);

            int count = 0;

            if (resultCurrentSnapshot != null)
            {
                if (resultPreviousSnapshot == null)
                {
                    resultPreviousSnapshot = new List <BusinessCriteriaDTO>();
                }

                var results = from current in resultCurrentSnapshot
                              join prev in resultPreviousSnapshot on current.Name equals prev.Name
                              into g
                              from subset in g.DefaultIfEmpty()
                              select new
                {
                    Name             = current.Name,
                    TqiCurrent       = current.TQI.HasValue ? current.TQI : (double?)null,
                    TqiPrevious      = subset != null ? subset.TQI : (double?)null,
                    PercentVariation = subset != null?MathUtility.GetVariationPercent(current.TQI, subset.TQI) : null
                };


                foreach (var result in results.OrderBy(_ => _.Name))
                {
                    rowData.AddRange(new[] {
                        result.Name,
                        result.TqiCurrent.HasValue  ? result.TqiCurrent.Value.ToString(_MetricFormat) : CastReporting.Domain.Constants.No_Value,
                        result.TqiPrevious.HasValue ? result.TqiPrevious.Value.ToString(_MetricFormat) : CastReporting.Domain.Constants.No_Value,
                        result.PercentVariation.HasValue ? TableBlock.FormatPercent(result.PercentVariation):CastReporting.Domain.Constants.No_Value,
                    });
                    count++;
                }
            }

            var resultTable = new TableDefinition {
                HasRowHeaders    = false,
                HasColumnHeaders = true,
                NbRows           = count + 1,
                NbColumns        = 4,
                Data             = rowData
            };

            return(resultTable);
        }
Example #2
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);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="reportData"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            int           nbLimitTop = 0;
            List <string> rowData    = new List <string>();

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

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

            if (null != reportData && null != reportData.CurrentSnapshot)
            {
                //Compute nb objectives
                Int32?nbObjectives = RulesViolationUtility.GetNbRuleWithViolations(reportData.CurrentSnapshot, Constants.RulesViolation.CriticalRulesViolation, 0, false);

                //Compute nb acchiveemnt for the whole applcation
                Int32?nbRuleWithViolations = RulesViolationUtility.GetNbRuleWithViolations(reportData.CurrentSnapshot, Constants.RulesViolation.CriticalRulesViolation, 0, true);
                Int32?nbAchievement        = (nbObjectives.HasValue && nbRuleWithViolations.HasValue) ? (nbObjectives.Value - nbRuleWithViolations.Value) : (Int32?)null;

                Double?achievementRatio = (nbAchievement.HasValue && nbObjectives.HasValue && nbObjectives.Value != 0) ? (Double)nbAchievement.Value / nbObjectives.Value : (Double?)null;

                //Compute nb acchiveemnt add in the last delivery
                Int32?nbAddedCriticalViolations = MeasureUtility.GetAddedCriticalViolations(reportData.CurrentSnapshot);
                if (!nbAddedCriticalViolations.HasValue)
                {
                    nbAddedCriticalViolations = 0;
                }
                Int32?nbAchievementAdded = (nbObjectives.HasValue && nbAddedCriticalViolations.HasValue) ? nbObjectives.Value - nbAddedCriticalViolations.Value : (Int32?)null;

                Double?achievementAddedRatio = (nbAchievementAdded.HasValue && nbObjectives.HasValue && nbObjectives.Value != 0) ? (Double)nbAchievementAdded.Value / nbObjectives.Value : (Double?)null;

                //BuildContent header
                rowData.AddRange(displayShortHeader ? new[] { " ", Labels.Obj, Labels.Achiev, Labels.AchievRatio }
                                                    : new[] { " ", Labels.Objectives, Labels.Achievement, Labels.AchievementRatio });


                //BuildContent "Entire Application" row
                rowData.AddRange(new string[] {
                    Labels.DeliveryWhole,
                    (nbObjectives.HasValue)?nbObjectives.Value.ToString(_MetricFormat):String.Empty,
                    (nbAchievement.HasValue)?nbAchievement.Value.ToString(_MetricFormat):String.Empty,
                    TableBlock.FormatPercent(MathUtility.GetRound(achievementRatio), false)
                });


                //BuildContent "Last Delivery" row
                rowData.AddRange(new string[] {
                    Labels.DeliveryLast,
                    (nbObjectives.HasValue)?nbObjectives.Value.ToString(_MetricFormat):String.Empty,
                    (nbAchievementAdded.HasValue)?nbAchievementAdded.Value.ToString(_MetricFormat):String.Empty,
                    TableBlock.FormatPercent(MathUtility.GetRound(achievementAddedRatio), false)
                });
            }

            TableDefinition resultTable = new TableDefinition
            {
                HasRowHeaders    = false,
                HasColumnHeaders = true,
                NbRows           = 3,
                NbColumns        = 4,
                Data             = rowData
            };


            return(resultTable);
        }
Example #4
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);
        }
Example #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);
        }
Example #6
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);
        }
Example #7
0
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            TableDefinition resultTable  = null;
            const string    metricFormat = "N0";

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

                double?criticalViolation        = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesNumber);
                double?numCritPerFile           = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesPerFileNumber);
                string numCritPerFileIfNegative = string.Empty;
                if (numCritPerFile == -1)
                {
                    numCritPerFileIfNegative = "N/A";
                }
                else
                {
                    numCritPerFileIfNegative = (numCritPerFile.HasValue) ? numCritPerFile.Value.ToString("N2") : CastReporting.Domain.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 = string.Empty;
                if (numCritPerFilePrev == -1)
                {
                    numCritPerFilePrevIfNegative = "N/A";
                }
                else
                {
                    numCritPerFilePrevIfNegative = (numCritPerFilePrev.HasValue) ? numCritPerFilePrev.Value.ToString("N2") : CastReporting.Domain.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.HasValue) ?  criticalViolation.Value.ToString(metricFormat):  CastReporting.Domain.Constants.No_Value
                    , (criticalViolationPrev.HasValue) ? criticalViolationPrev.Value.ToString(metricFormat) : CastReporting.Domain.Constants.No_Value
                    , (criticalViolationEvolPerc.HasValue) ? TableBlock.FormatPercent(criticalViolationEvolPerc.Value): CastReporting.Domain.Constants.No_Value

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

                    , "  " + Labels.PerkLoC
                    , (numCritPerKLOC.HasValue)? numCritPerKLOC.Value.ToString("N2") : CastReporting.Domain.Constants.No_Value
                    , (numCritPerKLOCPrev.HasValue)? numCritPerKLOCPrev.Value.ToString("N2") : CastReporting.Domain.Constants.No_Value
                    , (numCritPerKLOCEvolPerc.HasValue) ? TableBlock.FormatPercent(numCritPerKLOCEvolPerc.Value) : CastReporting.Domain.Constants.No_Value

                    , Labels.ComplexObjects
                    , HighveryHighCostComplexityArtefacts.HasValue ? HighveryHighCostComplexityArtefacts.Value.ToString(metricFormat): CastReporting.Domain.Constants.No_Value
                    , HighveryHighCostComplexityArtefactsPrev.HasValue ? HighveryHighCostComplexityArtefactsPrev.Value.ToString(metricFormat) : CastReporting.Domain.Constants.No_Value
                    , HighveryHighCostComplexityArtefactsEvolPerc.HasValue ? TableBlock.FormatPercent(HighveryHighCostComplexityArtefactsEvolPerc.Value) : CastReporting.Domain.Constants.No_Value

                    , "  " + Labels.WithViolations
                    , HighveryHighCostComplexityViolations.HasValue ? HighveryHighCostComplexityViolations.Value.ToString(metricFormat): CastReporting.Domain.Constants.No_Value
                    , HighveryHighCostComplexityViolationsPrev.HasValue ? HighveryHighCostComplexityViolationsPrev.Value.ToString(metricFormat) : CastReporting.Domain.Constants.No_Value
                    , HighveryHighCostComplexityViolationsEvolPerc.HasValue ? TableBlock.FormatPercent(HighveryHighCostComplexityViolationsEvolPerc.Value) : CastReporting.Domain.Constants.No_Value
                };

                resultTable = new TableDefinition
                {
                    HasRowHeaders    = true,
                    HasColumnHeaders = false,
                    NbRows           = 6,
                    NbColumns        = 4,
                    Data             = rowData
                };
            }
            return(resultTable);
        }
Example #8
0
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            TableDefinition resultTable = null;
            List <string>   rowData = new List <string>();
            int             count = reportData.Parameter.NbResultDefault, nbRows = 0, nbColumns = 0, nb = 0;

            IList <string> strMetricId = ((options != null && options.ContainsKey("PAR")) ? options["PAR"] : string.Empty).Split(',');

            if (null != options && options.ContainsKey("COUNT") && Int32.TryParse(options["COUNT"], out nb) && 0 < nb)
            {
                count = nb;
            }

            if (null != reportData && null != reportData.CurrentSnapshot)
            {
                //Result of current snapshot
                var technicalCriteriasResults = BusinessCriteriaUtility.GetTechnicalCriteriasByBusinessCriterias(reportData.CurrentSnapshot, strMetricId, count);
                technicalCriteriasResults = technicalCriteriasResults.Take(count).ToList();

                //Result of previous snapshot
                IEnumerable <TechnicalCriteriaResultDTO> prevTechnicalCriteriasResults = null; //new List<TechnicalCriteriaResultDTO>();
                if (reportData.PreviousSnapshot != null)
                {
                    prevTechnicalCriteriasResults = BusinessCriteriaUtility.GetTechnicalCriteriasByBusinessCriterias(reportData.PreviousSnapshot, strMetricId, count);
                }

                if (prevTechnicalCriteriasResults != null)
                {
                    nbColumns = 3;

                    rowData.AddRange(new[] {
                        Labels.TechnicalCriterionName,
                        Labels.Grade,
                        Labels.Evolution
                    });

                    foreach (var grade in technicalCriteriasResults)
                    {
                        rowData.Add(grade.Name);
                        rowData.Add((grade.Grade.HasValue) ? grade.Grade.Value.ToString("N2") : Constants.No_Value);


                        var prevGrade = (from pgrade in prevTechnicalCriteriasResults
                                         where pgrade.Key == grade.Key
                                         select pgrade).FirstOrDefault();

                        string evol = Constants.No_Value;
                        if (prevGrade != null)
                        {
                            double?variation = MathUtility.GetVariationPercent(grade.Grade, prevGrade.Grade);
                            evol = (variation.HasValue) ? TableBlock.FormatPercent(variation) : Constants.No_Value;
                        }

                        rowData.Add(evol);
                        nbRows++;
                    }
                }
                else
                {
                    nbColumns = 2;

                    rowData.AddRange(new[] {
                        Labels.TechnicalCriterionName,
                        Labels.Grade
                    });

                    foreach (var grade in technicalCriteriasResults)
                    {
                        rowData.Add(grade.Name);
                        rowData.Add((grade.Grade.HasValue) ? grade.Grade.Value.ToString("N2") : Constants.No_Value);
                        nbRows++;
                    }
                }
            }

            resultTable = new TableDefinition {
                HasRowHeaders    = false,
                HasColumnHeaders = true,
                NbRows           = nbRows,
                NbColumns        = nbColumns,
                Data             = rowData
            };
            return(resultTable);
        }
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            int             rowCount    = 0;
            int             nbLimitTop  = 0;
            int             order       = 0;
            List <string>   rowData     = new List <string>();
            TableDefinition resultTable = null;
            List <RuleVariationResultDTO> variationRules = new List <RuleVariationResultDTO>();
            //List<RuleVariationResultDTO> improvmentRules = new List<RuleVariationResultDTO>();
            //List<RuleVariationResultDTO> degradationRules = new List<RuleVariationResultDTO>();
            //List<RuleVariationResultDTO> selected_elements = new List<RuleVariationResultDTO>();
            IEnumerable <RuleVariationResultDTO> selected_elements;

            rowData.AddRange(new string[] {
                Labels.RuleName,
                Labels.ViolationsCurrent,
                Labels.ViolationsPrevious,
                Labels.Evolution,
                Labels.Grade,
                Labels.GradeEvolution
            });

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

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

            if (reportData != null && reportData.CurrentSnapshot != null && metricId.HasValue)
            {
                var currentCriticalRulesViolation = RulesViolationUtility.GetAllRuleViolations(reportData.CurrentSnapshot,
                                                                                               Constants.RulesViolation.All,
                                                                                               (Constants.BusinessCriteria)metricId,
                                                                                               true);


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


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

                        //Compute the varioation
                        double?variationVal   = (item.TotalFailed.HasValue && previousVal.HasValue) ? (item.TotalFailed.Value - previousVal.Value) : (double?)null;
                        double?variationGrade = (item.TotalFailed.HasValue && previousVal.HasValue) ? (item.Grade.Value - previousGrade.Value) : (double?)null;

                        variationRules.Add(new RuleVariationResultDTO {
                            Rule = new RuleDetailsDTO {
                                Name = item.Rule.Name, Key = item.Rule.Key
                            },
                            CurrentNbViolations  = (item.TotalFailed.HasValue) ? item.TotalFailed.Value : -1,
                            PreviousNbViolations = (previousitem != null && previousitem.TotalFailed.HasValue) ? previousitem.TotalFailed.Value : -1,
                            Evolution            = (variationVal.HasValue && previousVal.HasValue && previousVal > 0) ? variationVal / previousVal : double.NaN,
                            Grade          = (item.Grade.HasValue) ? item.Grade.Value : double.NaN,
                            GradeEvolution = (variationGrade.HasValue && previousGrade.HasValue && previousGrade > 0) ? variationGrade / previousGrade : double.NaN
                        });
                    }

                    switch (order)
                    {
                    default:
                    case 0:
                    {
                        selected_elements = variationRules.OrderByDescending(_ => _.Rule.CompoundedWeight * (4 - _.Grade.Value)).Take(nbLimitTop);
                        break;
                    }

                    case 1:
                    {
                        selected_elements = variationRules.Where(_ => _.GradeEvolution >= 0).OrderByDescending(_ => _.GradeEvolution).Take(nbLimitTop);
                        break;
                    }

                    case 2:
                    {
                        selected_elements = variationRules.Where(_ => _.GradeEvolution < 0).OrderBy(_ => _.GradeEvolution).Take(nbLimitTop);
                        break;
                    }
                    }
                    ;

                    foreach (var varRule in selected_elements)
                    {
                        rowData.AddRange(new string[]
                        {
                            varRule.Rule.Name
                            , (varRule.CurrentNbViolations.HasValue && varRule.CurrentNbViolations.Value != -1)? varRule.CurrentNbViolations.Value.ToString("N0"): CastReporting.Domain.Constants.No_Value
                            , (varRule.PreviousNbViolations.HasValue && varRule.PreviousNbViolations.Value != -1)? varRule.PreviousNbViolations.Value.ToString("N0"): CastReporting.Domain.Constants.No_Value
                            , (varRule.Evolution.HasValue && !double.IsNaN(varRule.Evolution.Value)) ? TableBlock.FormatPercent(varRule.Evolution.Value) : Constants.No_Value
                            , (varRule.Grade.HasValue && !double.IsNaN(varRule.Grade.Value)) ? varRule.Grade.Value.ToString("N2"):CastReporting.Domain.Constants.No_Value
                            , (varRule.GradeEvolution.HasValue && !double.IsNaN(varRule.GradeEvolution.Value)) ? TableBlock.FormatPercent(varRule.GradeEvolution.Value) : Constants.No_Value
                        }
                                         );
                        rowCount++;
                    }
                }
                else
                {
                    rowData.AddRange(new string[] {
                        Labels.NoItem,
                        string.Empty,
                        string.Empty,
                        string.Empty,
                        string.Empty
                    });
                    rowCount = 1;
                }
            }

            resultTable = new TableDefinition {
                HasRowHeaders    = false,
                HasColumnHeaders = true,
                NbRows           = rowCount + 1,
                NbColumns        = 6,
                Data             = rowData
            };
            return(resultTable);
        }
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            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);
        }
Example #11
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);
        }
Example #12
0
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            string          metricFormat       = "N2";
            TableDefinition resultTable        = null;
            bool            displayShortHeader = (options != null && options.ContainsKey("HEADER") && "SHORT" == options["HEADER"]);

            if (null != reportData &&
                null != reportData.CurrentSnapshot &&
                null != reportData.CurrentSnapshot.BusinessCriteriaResults)
            {
                bool   hasPreviousSnapshot = null != reportData.PreviousSnapshot && null != reportData.PreviousSnapshot.BusinessCriteriaResults;
                string currSnapshotLabel   = SnapshotUtility.GetSnapshotVersionNumber(reportData.CurrentSnapshot);
                BusinessCriteriaDTO currSnapshotBisCriDTO = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(reportData.CurrentSnapshot, false);


                string prevSnapshotLabel = hasPreviousSnapshot ? SnapshotUtility.GetSnapshotVersionNumber(reportData.PreviousSnapshot) : CastReporting.Domain.Constants.No_Value;
                BusinessCriteriaDTO prevSnapshotBisCriDTO = hasPreviousSnapshot ? BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(reportData.PreviousSnapshot, false) : null;


                double?currProgrammingPracticesValue = null != currSnapshotBisCriDTO.ProgrammingPractices ? currSnapshotBisCriDTO.ProgrammingPractices : 1;
                double?currArchitecturalDesignValue  = null != currSnapshotBisCriDTO.ArchitecturalDesign ? currSnapshotBisCriDTO.ArchitecturalDesign : 1;
                double?currDocumentationValue        = null != currSnapshotBisCriDTO.Documentation ?currSnapshotBisCriDTO.Documentation : 1;


                double?prevProgrammingPracticesValue = hasPreviousSnapshot?prevSnapshotBisCriDTO.ProgrammingPractices : 0;
                double?prevArchitecturalDesignValue  = hasPreviousSnapshot ?prevSnapshotBisCriDTO.ArchitecturalDesign : 0;
                double?prevDocumentationValue        = hasPreviousSnapshot?prevSnapshotBisCriDTO.Documentation : 0;

                double?varProgrammingPractices = MathUtility.GetPercent(MathUtility.GetEvolution(currProgrammingPracticesValue.Value, prevProgrammingPracticesValue.Value),
                                                                        prevProgrammingPracticesValue.Value);

                double?varArchitecturalDesign = MathUtility.GetPercent(MathUtility.GetEvolution(currArchitecturalDesignValue.Value, prevArchitecturalDesignValue.Value),
                                                                       prevArchitecturalDesignValue.Value);

                double?varDocumentation = MathUtility.GetPercent(MathUtility.GetEvolution(currDocumentationValue.Value, prevDocumentationValue.Value),
                                                                 prevDocumentationValue.Value);



                List <string> rowData = new List <string>();
                if (displayShortHeader)
                {
                    rowData.AddRange(new[] { "", Labels.Prog, Labels.Arch, Labels.Doc });
                }
                else
                {
                    rowData.AddRange(new[] { "", Labels.ProgrammingPractices, Labels.ArchitecturalDesign, Labels.Documentation });
                }

                rowData.AddRange(
                    new[]
                {
                    currSnapshotLabel,
                    currProgrammingPracticesValue.HasValue? currProgrammingPracticesValue.Value.ToString(metricFormat): CastReporting.Domain.Constants.No_Value,
                    currArchitecturalDesignValue.HasValue? currArchitecturalDesignValue.Value.ToString(metricFormat): CastReporting.Domain.Constants.No_Value,
                    currDocumentationValue.HasValue? currDocumentationValue.Value.ToString(metricFormat): CastReporting.Domain.Constants.No_Value
                });
                if (hasPreviousSnapshot)
                {
                    rowData.AddRange(
                        new[]
                    {
                        prevSnapshotLabel,
                        prevProgrammingPracticesValue.HasValue? prevProgrammingPracticesValue.Value.ToString(metricFormat): CastReporting.Domain.Constants.No_Value,
                        prevArchitecturalDesignValue.HasValue?prevArchitecturalDesignValue.Value.ToString(metricFormat): CastReporting.Domain.Constants.No_Value,
                        prevDocumentationValue.HasValue?prevDocumentationValue.Value.ToString(metricFormat): CastReporting.Domain.Constants.No_Value,
                        Labels.Variation,
                        varProgrammingPractices.HasValue? TableBlock.FormatPercent(varProgrammingPractices.Value): CastReporting.Domain.Constants.No_Value,
                        varArchitecturalDesign.HasValue?TableBlock.FormatPercent(varArchitecturalDesign.Value): CastReporting.Domain.Constants.No_Value,
                        varDocumentation.HasValue?TableBlock.FormatPercent(varDocumentation.Value): CastReporting.Domain.Constants.No_Value
                    });
                }
                resultTable = new TableDefinition
                {
                    HasRowHeaders    = false,
                    HasColumnHeaders = true,
                    NbRows           = hasPreviousSnapshot ? 4 : 2,
                    NbColumns        = 4,
                    Data             = rowData
                };
            }
            return(resultTable);
        }
        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);
        }