コード例 #1
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);
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reportData"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            TableDefinition back = new TableDefinition();
            int             parId;

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

            double?previousHttVal = null;

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

            if (null == reportData)
            {
                return(back);
            }

            #region Selected Snapshot

            double?selectedLowVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                                 distributionId.GetHashCode(), "low");
            double?selectedAveVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                                 distributionId.GetHashCode(), "average");
            double?selectedHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                                 distributionId.GetHashCode(), "high");
            double?selectedVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                                 distributionId.GetHashCode(), "very_high");

            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)
            {
                var previousHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot,
                                                                                  distributionId.GetHashCode(), "high");
                var previousVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot,
                                                                                  distributionId.GetHashCode(), "very_high");

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

            #endregion Previous Snapshot

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

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

            rowData.AddRange(new[] { distributionName, Labels.Current, Labels.Previous, Labels.Evol, Labels.TotalPercent });
            rowData.AddRange(new[]
                             { Labels.ComplexityHighAndVeryHigh
                               , selectedHttVal?.ToString(MetricFormat) ?? Constants.No_Value
                               , previousHttVal?.ToString(MetricFormat) ?? Constants.No_Value
                               , variation.HasValue? FormatEvolution(variation.Value): Constants.No_Value
                               , (selectedHttVal.HasValue && selectedTotal.HasValue && selectedTotal.Value > 0)? 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);
        }
コード例 #3
0
        public 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?selectedTotal = null;

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


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

            #region Selected Snapshot

            var selectedLowVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                              distributionId.GetHashCode(), "low");
            var selectedAveVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                              distributionId.GetHashCode(), "average");
            var selectedHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                              distributionId.GetHashCode(), "high");
            var selectedVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                                                                              distributionId.GetHashCode(), "very_high");

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

            #endregion Selected Snapshot

            #region Previous Snapshot

            double?previousLowVal = null;
            double?previousAveVal = null;
            double?previousHigVal = null;
            double?previousVhiVal = null;

            if (reportData.PreviousSnapshot != null)
            {
                previousLowVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot,
                                                                              distributionId.GetHashCode(), "low");
                previousAveVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot,
                                                                              distributionId.GetHashCode(), "average");
                previousHigVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot,
                                                                              distributionId.GetHashCode(), "high");
                previousVhiVal = CastComplexityUtility.GetCostComplexityGrade(reportData.PreviousSnapshot,
                                                                              distributionId.GetHashCode(), "very_high");
            }

            #endregion Previous Snapshot

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

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

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

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

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

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

            #endregion Data

            result = new TableDefinition
            {
                Data             = rowData,
                HasRowHeaders    = false,
                HasColumnHeaders = true,
                NbColumns        = 6,
                NbRows           = 5
            };
            return(result);
        }
コード例 #4
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);
        }