protected override TableDefinition Content(ReportData reportData, Dictionary<string, string> options)
        {
            TableDefinition back = new TableDefinition();
            List<string> rowData = new List<string>();
            string numberFormat = "N0";

            if (null != reportData && null != reportData.CurrentSnapshot && reportData.CurrentSnapshot.CostComplexityResults != null)
            {

                #region Selected Snapshot

                double? nbArtifactLow = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                    Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(),
                    Constants.CostComplexity.CostComplexityArtifacts_Low.GetHashCode());
                double? nbArtifactAve = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                    Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(),
                    Constants.CostComplexity.CostComplexityArtifacts_Average.GetHashCode());
                double? nbArtifactHigh = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                    Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(),
                    Constants.CostComplexity.CostComplexityArtifacts_High.GetHashCode());
                double? nbArtifactVeryHigh = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                    Constants.QualityDistribution.CostComplexityDistribution.GetHashCode(),
                    Constants.CostComplexity.CostComplexityArtifacts_VeryHigh.GetHashCode());

                double? nbViolationLow = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                    Constants.QualityDistribution.DistributionOfDefectsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(),
                    Constants.DefectsToCriticalDiagnosticBasedMetricsPerCostComplexity.CostComplexityDefects_Low.GetHashCode());
                double? nbViolationAve = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                    Constants.QualityDistribution.DistributionOfDefectsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(),
                    Constants.DefectsToCriticalDiagnosticBasedMetricsPerCostComplexity.CostComplexityDefects_Average.GetHashCode());
                double? nbViolationHigh = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                    Constants.QualityDistribution.DistributionOfDefectsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(),
                    Constants.DefectsToCriticalDiagnosticBasedMetricsPerCostComplexity.CostComplexityDefects_High.GetHashCode());
                double? nbViolationVeryHigh = CastComplexityUtility.GetCostComplexityGrade(reportData.CurrentSnapshot,
                    Constants.QualityDistribution.DistributionOfDefectsToCriticalDiagnosticBasedMetricsPerCostComplexity.GetHashCode(),
                    Constants.DefectsToCriticalDiagnosticBasedMetricsPerCostComplexity.CostComplexityDefects_VeryHigh.GetHashCode());

                #endregion Selected Snapshot

                #region Data

                rowData.AddRange(new string[] { Labels.Complexity, Labels.Artifacts, Labels.WithViolations });
                rowData.AddRange(new string[] { Labels.CplxExtreme, nbArtifactVeryHigh.Value.ToString(numberFormat), nbViolationVeryHigh.Value.ToString(numberFormat) });
                rowData.AddRange(new string[] { Labels.CplxHigh, nbArtifactHigh.Value.ToString(numberFormat), nbViolationHigh.Value.ToString(numberFormat) });
                rowData.AddRange(new string[] { Labels.CplxAverage, nbArtifactAve.Value.ToString(numberFormat), nbViolationAve.Value.ToString(numberFormat) });
                rowData.AddRange(new string[] { Labels.CplxLow, nbArtifactLow.Value.ToString(numberFormat), nbViolationLow.Value.ToString(numberFormat) });

                #endregion Data

                back = new TableDefinition
                {
                    Data = rowData,
                    HasRowHeaders = false,
                    HasColumnHeaders = true,
                    NbColumns = 3,
                    NbRows = 4
                };
            }
            return back;
        }
Пример #2
0
        protected override TableDefinition Content(ReportData reportData, Dictionary<string, string> options)
        {
            int nbResult = reportData.Parameter.NbResultDefault, tmpNb;
            if (null != options && options.ContainsKey("COUNT") && Int32.TryParse(options["COUNT"], out tmpNb) && tmpNb > 0)
            {
                nbResult = tmpNb;
            }

            if (reportData != null && reportData.CurrentSnapshot != null)
            {
                List<TechnologyResultDTO> technologyInfos = MeasureUtility.GetTechnoLoc(reportData.CurrentSnapshot, nbResult);

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

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

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

            return null ;
        }
Пример #3
0
        protected override TableDefinition Content(ReportData reportData, Dictionary<string, string> options)
        {
            TableDefinition resultTable = null;
            List<string> rowData = new List<string>();
            int nbRows = 0;
            rowData.Add("Ignored Applications");

            if (reportData.IgnoresApplications.Count() == 0)
            {
                rowData.Add("No Ignored Applications");
                nbRows++;
            }
            else
            {
                string[] DistinctArray = reportData.IgnoresApplications.Distinct().ToArray();
                for (int i = 0; i < DistinctArray.Count(); i++)
                {
                    rowData.Add(DistinctArray[i].ToString());
                }
                nbRows = DistinctArray.Count();
            }
            resultTable = new TableDefinition
            {
                HasRowHeaders = false,
                HasColumnHeaders = true,
                NbRows = nbRows + 1,
                NbColumns = 1,
                Data = rowData
            };

            return resultTable;
        }
Пример #4
0
        protected override TableDefinition Content(ReportData reportData, Dictionary<string, string> options)
        {
            int nbResult = reportData.Parameter.NbResultDefault, tmpNb;
            if (null != options && options.ContainsKey("COUNT") && Int32.TryParse(options["COUNT"], out tmpNb) && tmpNb > 0)
            {
                nbResult = tmpNb;
            }

             if (null != reportData && null != reportData.CurrentSnapshot)
             {
                 var moduleArtifacts = MeasureUtility.GetModulesMeasure(reportData.CurrentSnapshot, nbResult, Constants.SizingInformations.ArtifactNumber);

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

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

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

                 return resultTable;
             }

             return null;
        }
Пример #5
0
        protected override TableDefinition Content(ReportData reportData, Dictionary<string, string> options)
        {
            TableDefinition resultTable = null;
            if (null != reportData &&
                    null != reportData.CurrentSnapshot)
            {
                double? automatedFPoints = MeasureUtility.GetAutomatedIFPUGFunction(reportData.CurrentSnapshot);
                double? decisionPoints = MeasureUtility.GetDecisionPointsNumber(reportData.CurrentSnapshot);
                double? backFiredFPoints = MeasureUtility.GetBackfiredIFPUGFunction(reportData.CurrentSnapshot);

                const string metricFormat = "N0";
                var rowData = new List<string>()
                    {  Labels.Name, Labels.Total
                    , Labels.AutomatedFP, (automatedFPoints.HasValue ?  automatedFPoints.Value.ToString(metricFormat) : CastReporting.Domain.Constants.No_Data)
                    , Labels.DecisionP,( decisionPoints.HasValue ?  (decisionPoints.Value).ToString(metricFormat) : CastReporting.Domain.Constants.No_Data)
                    , Labels.BackfiredFP, (backFiredFPoints.HasValue ?  (backFiredFPoints.Value).ToString(metricFormat) :CastReporting.Domain.Constants.No_Data)
                    };
                resultTable = new TableDefinition
                {
                    HasRowHeaders = false,
                    HasColumnHeaders = true,
                    NbRows = 6,
                    NbColumns = 2,
                    Data = rowData
                };
            }
            return resultTable;
        }
Пример #6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="reportData"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        protected override TableDefinition Content(ReportData reportData, Dictionary<string, string> options)
        {
            TableDefinition resultTable = null;
            int nbTot = 0;
            bool displayShortHeader = (options != null && options.ContainsKey("HEADER") && "SHORT" == options["HEADER"]);
            List<string> rowData = new List<string>();
            rowData.AddRange(new string[] { Labels.ModuleName, Labels.LoC });

            if (null != reportData &&
                null != reportData.CurrentSnapshot &&
                null != reportData.CurrentSnapshot.Modules)
            {
               var result = reportData.CurrentSnapshot.SizingMeasuresResults.FirstOrDefault(v => v.Reference.Key == (int)Constants.SizingInformations.CodeLineNumber);

               if (result != null)
               {
                   foreach (var res in result.ModulesResult)
                   {
                       rowData.AddRange(new string[] { res.Module.Name, res.DetailResult.Value.ToString(_MetricFormat) });
                   }
                   nbTot = result.ModulesResult.Length;
               }
            }
               resultTable = new TableDefinition
            {
                HasRowHeaders = false,
                HasColumnHeaders = true,
                NbRows = nbTot + 1,
                NbColumns = 2,
                Data = rowData
            };
            return resultTable;
        }
Пример #7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="reportData"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        protected override TableDefinition Content(ReportData reportData, Dictionary<string, string> options)
        {
            TableDefinition resultTable = null;
            int nbTot = 0;
            bool displayShortHeader = (options != null && options.ContainsKey("HEADER") && "SHORT" == options["HEADER"]);
            List<string> rowData = new List<string>();
            Int32? metricId = (options != null && options.ContainsKey("ID")) ? Convert.ToInt32(options["ID"]) : (Int32?)null;

            if (null != reportData &&
                null != reportData.CurrentSnapshot && metricId.HasValue) {
                var result = reportData.CurrentSnapshot.BusinessCriteriaResults.FirstOrDefault(r => r.Reference.Key == metricId);

                if (result != null) {
                    string value = Text(metricId.Value);
                    rowData.AddRange(new string[] { Labels.Techno, value });
                    foreach (var res in result.TechnologyResult) {
                        rowData.AddRange(new string[] { res.Technology, res.DetailResult.Grade.ToString(_MetricFormat) });
                    }
                    nbTot = result.ModulesResult.Length;
                }
            }
            resultTable = new TableDefinition {
                HasRowHeaders = false,
                HasColumnHeaders = true,
                NbRows = nbTot + 1,
                NbColumns = 2,
                Data = rowData
            };
            return resultTable;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="reportData"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        protected override TableDefinition Content(ReportData reportData, Dictionary<string, string> options)
        {
            string strRuleId = (options != null && options.ContainsKey("RULID")) ? options["RULID"] : null;

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

            var rule = reportData.RuleExplorer.GetSpecificRule(reportData.Application.DomainId, strRuleId);
            var currentviolation = reportData.RuleExplorer.GetRulesViolations(reportData.CurrentSnapshot.Href, strRuleId).FirstOrDefault();
            Int32? failedChecks = null;

            if (currentviolation != null && currentviolation.ApplicationResults.Any()) {
                failedChecks = currentviolation.ApplicationResults[0].DetailResult.ViolationRatio.FailedChecks;
            }

            if (rule != null) {
                rowData.AddRange(new string[] {
                                rule.Name, null,
                    Labels.Rationale, string.IsNullOrWhiteSpace(rule.Rationale) ? Constants.No_Value : rule.Rationale,
                    Labels.Description, rule.Description,
                    Labels.Remediation, string.IsNullOrWhiteSpace(rule.Remediation) ? Constants.No_Value : rule.Remediation,
                    Labels.ViolationsCount, (failedChecks != null && failedChecks.HasValue) ? failedChecks.Value.ToString("N0") : Constants.No_Value,
                            });
            }

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

            return back;
        }
Пример #9
0
 public static void ApplyContent(ReportData client, OpenXmlPartContainer container, BlockItem block, TableDefinition content, Dictionary<string, string> options)
 {
     var contentblock = GetTableContentBlock(client, block);
     if (null != contentblock)
     {
         UpdateBlock(client, container, contentblock, content, options);
     }
 }
Пример #10
0
        protected override TableDefinition Content(ReportData reportData, Dictionary<string, string> options)
        {
            TableDefinition resultTable = null;

            string numberFormat = "N0";

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

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

            if (null != reportData &&
                  null != reportData.CurrentSnapshot)
            {

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

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

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

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

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

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

            return resultTable;
        }
Пример #11
0
        protected override TableDefinition Content(ReportData reportData, Dictionary<string, string> options)
        {
            TableDefinition resultTable = null;

            int nbLimitTop = -1;
            if (null == options || !options.ContainsKey("COUNT") || !Int32.TryParse(options["COUNT"], out nbLimitTop))
            {
                nbLimitTop = -1;
            }

            IEnumerable<IfpugFunction> functions = reportData.SnapshotExplorer.GetIfpugFunctions(reportData.CurrentSnapshot.Href, nbLimitTop);
            List<string> rowData = new List<string>();
            //List<string> rowData = new List<string>(new string[] { Labels.IFPUG_ElementType, Labels.ObjectName, Labels.IFPUG_NoOfFPs, Labels.IFPUG_FPDetails, Labels.IFPUG_ObjectType, Labels.ModuleName, Labels.Technology });
            int nbRows = 0;

            if (functions != null && functions.Any())
            {
                IEnumerable<IfpugFunction> exportedList = (nbLimitTop <= 0) ? functions : functions.Take(nbLimitTop);
                foreach (var ifpugFunction in exportedList)
                {
                    if (ifpugFunction.ElementType == "Data Function")
                    {
                        rowData.Add(string.IsNullOrEmpty(ifpugFunction.ObjectName) ? " " : ifpugFunction.ObjectName);
                        rowData.Add(string.IsNullOrEmpty(ifpugFunction.NoOfFPs) ? " " : ifpugFunction.NoOfFPs);
                        rowData.Add(string.IsNullOrEmpty(ifpugFunction.FPDetails) ? " " : ifpugFunction.FPDetails);
                        rowData.Add(string.IsNullOrEmpty(ifpugFunction.ObjectType) ? " " : ifpugFunction.ObjectType);
                        rowData.Add(string.IsNullOrEmpty(ifpugFunction.ModuleName) ? " " : ifpugFunction.ModuleName);
                        rowData.Add(string.IsNullOrEmpty(ifpugFunction.Technology) ? " " : ifpugFunction.Technology);
                        nbRows += 1;
                    }
                }
            }
            else
            {
                rowData.AddRange(new string[] { Labels.NoItem, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty });
            }

            resultTable = new TableDefinition
            {
                HasRowHeaders = false,
                HasColumnHeaders = true,
                NbRows = nbRows + 1,
                NbColumns = 6,
                Data = rowData
            };

            return resultTable;
        }
Пример #12
0
        protected override TableDefinition Content(ReportData reportData, Dictionary<string, string> options)
        {
            List<string> rowData = new List<string>();

            rowData.AddRange(new[] {
                Labels.Rule,
                Labels.ViolationsStill,
                Labels.ViolationsNew
            });

            int actionPlanCount = (reportData != null && reportData.CurrentSnapshot != null && reportData.CurrentSnapshot.ActionsPlan != null)
                ? reportData.CurrentSnapshot.ActionsPlan.Count()
                : 0;
            if (actionPlanCount > 0) {
                foreach (var ActionPlan in reportData.CurrentSnapshot.ActionsPlan) {
                    rowData.AddRange
                        (new string[] { ActionPlan.RulePattern.Name
                            , ActionPlan.PendingIssues.ToString("N0")
                            , ActionPlan.AddedIssues.ToString("N0")
                            });
                }
            } else {
                rowData.AddRange(new string[] {
                    Labels.NoItem,
                    string.Empty,
                    string.Empty
                });
                actionPlanCount = 1;
            }

            TableDefinition resultTable = new TableDefinition {
                HasRowHeaders = false,
                HasColumnHeaders = true,
                NbRows = actionPlanCount + 1,
                NbColumns = 3,
                Data = rowData
            };
            return resultTable;
        }
Пример #13
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="reportData"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        protected override TableDefinition Content(ReportData reportData, Dictionary<string, string> options)
        {
            List<string> rowData = new List<string>();
            rowData.AddRange(new[] { Labels.Statistics, Labels.Current, Labels.Previous });

            Double? currentTqi= BusinessCriteriaUtility.GetSnapshotBusinessCriteriaGrade(reportData.CurrentSnapshot, Domain.Constants.BusinessCriteria.TechnicalQualityIndex, true);
            Double? previousTqi = BusinessCriteriaUtility.GetSnapshotBusinessCriteriaGrade(reportData.PreviousSnapshot, Domain.Constants.BusinessCriteria.TechnicalQualityIndex, true);

            rowData.AddRange(new[] { Labels.TQI,
                                       currentTqi.HasValue ? currentTqi.Value.ToString(_MetricFormat): String.Empty,
                                       previousTqi.HasValue ? previousTqi.Value.ToString(_MetricFormat):CastReporting.Domain.Constants.No_Value});

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

            return resultTable;
        }
Пример #14
0
        protected override TableDefinition Content(ReportData reportData, Dictionary<string, string> options)
        {
            TableDefinition resultTable = null;
            bool displayShortHeader = (options != null && options.ContainsKey("HEADER") && "SHORT" == options["HEADER"]);

            if (null != reportData &&
                null != reportData.CurrentSnapshot &&
                null != reportData.CurrentSnapshot.Modules)
            {
                List<string> rowData = reportData.CurrentSnapshot.Modules.Select(x => x.Name).ToList();

                rowData.Insert(0, Labels.ModuleName);

                resultTable = new TableDefinition
                {
                    HasRowHeaders = false,
                    HasColumnHeaders = true,
                    NbRows = rowData.Count,
                    NbColumns = 1,
                    Data = rowData
                };
            }
            return resultTable;
        }
Пример #15
0
        protected override TableDefinition Content(ReportData reportData, Dictionary<string, string> options)
        {
            TableDefinition resultTable = null;

            int nbLimitTop = -1;
            if (null == options || !options.ContainsKey("COUNT") || !Int32.TryParse(options["COUNT"], out nbLimitTop))
            {
                nbLimitTop = -1;
            }
            string type = null;
            if (null != options && options.ContainsKey("TYPE"))
            {
                type = options["TYPE"] ?? string.Empty;
                type = type.Trim();
                if (type.ToUpper() == "ADDED")
                {
                    type = "Added";
                }
                else if (type.ToUpper() == "DELETED")
                {
                    type = "Deleted";
                }
                else if (type.ToUpper() == "MODIFIED")
                {
                    type = "Modified";
                }
            }
            bool displayHeader = (options == null || !options.ContainsKey("HEADER") || "NO" != options["HEADER"]);

            IEnumerable<IfpugFunction> functions = reportData.SnapshotExplorer.GetIfpugFunctionsEvolutions(reportData.CurrentSnapshot.Href, string.IsNullOrEmpty(type) ? nbLimitTop : -1);

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

            if (displayHeader)
            {
                rowData.AddRange(new string[] { Labels.ObjectName, Labels.IFPUG_NoOfFPs, Labels.IFPUG_ObjectType, Labels.ModuleName, Labels.Technology });
            }

            int nbRows = 0;

            if (functions != null && functions.Any())
            {
                var exportedList = functions;
                if (!string.IsNullOrEmpty(type))
                {
                    exportedList = exportedList.Where(f => f.ElementType.Contains(type));
                }
                if (nbLimitTop > 0)
                {
                    exportedList = exportedList.Take(nbLimitTop);
                }
                foreach (var ifpugFunctionevolution in exportedList)
                {
                    //rowData.Add(string.IsNullOrEmpty(ifpugFunctionevolution.ElementType) ? " " : ifpugFunctionevolution.ElementType);
                    rowData.Add(string.IsNullOrEmpty(ifpugFunctionevolution.ObjectName) ? " " : ifpugFunctionevolution.ObjectName);
                    rowData.Add(string.IsNullOrEmpty(ifpugFunctionevolution.NoOfFPs) ? " " : ifpugFunctionevolution.NoOfFPs);
                    //rowData.Add(string.IsNullOrEmpty(ifpugFunctionevolution.FPDetails) ? " " : ifpugFunctionevolution.FPDetails);
                    rowData.Add(string.IsNullOrEmpty(ifpugFunctionevolution.ObjectType) ? " " : ifpugFunctionevolution.ObjectType);
                    rowData.Add(string.IsNullOrEmpty(ifpugFunctionevolution.ModuleName) ? " " : ifpugFunctionevolution.ModuleName);
                    rowData.Add(string.IsNullOrEmpty(ifpugFunctionevolution.Technology) ? " " : ifpugFunctionevolution.Technology);
                    nbRows += 1;
                }
            }
            else
            {
                rowData.AddRange(new string[] { Labels.NoItem, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty });
            }
            resultTable = new TableDefinition
            {
                HasRowHeaders = false,
                HasColumnHeaders = true,
                NbRows = nbRows + 1,
                NbColumns = 5,
                Data = rowData
            };

            return resultTable;
        }
Пример #16
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;
        }
        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;
        }
Пример #18
0
        protected override TableDefinition Content(ReportData reportData, Dictionary<string, string> options)
        {
            TableDefinition resultTable = null;
            Boolean hasPrevious = reportData.PreviousSnapshot != null;

            List<TechnologyResultDTO> TechnologyResultCurrentSnapshot = new List<TechnologyResultDTO>();
            List<TechnologyResultDTO> TechnologyResultPreviousSnapshot = new List<TechnologyResultDTO>();
            List<EvolutionSnapshots> ResultCompartTecno = new List<EvolutionSnapshots>();

            List<TechnologyResultDTO> TechnologyDecisionPointsResultCurrentSnapshot = new List<TechnologyResultDTO>();
            List<TechnologyResultDTO> TechnologyDecisionPointsResultPreviousSnapshot = new List<TechnologyResultDTO>();
            List<EvolutionSnapshots> ResultCompartTecnoDecisionPoints = new List<EvolutionSnapshots>();

            List<TechnologyResultDTO> TechnologyClassesResultCurrentSnapshot = new List<TechnologyResultDTO>();
            List<TechnologyResultDTO> TechnologyClassesResultPreviousSnapshot = new List<TechnologyResultDTO>();
            List<EvolutionSnapshots> ResultCompartTecnoClasses = new List<EvolutionSnapshots>();

            DataTable dtFinalRepository = new DataTable();
            dtFinalRepository.Columns.Add("Name");
            dtFinalRepository.Columns.Add("DecisionP");
            dtFinalRepository.Columns.Add("KLOC");
            dtFinalRepository.Columns.Add("Classes");
            dtFinalRepository.AcceptChanges();

            List<string> rowData = new List<string>();
            rowData.AddRange(new string[] {
                Labels.Name,
                Labels.DecisionP,
                "kLOC's",
                "Objects"
            });
            int nbLimitTop = 0;
            if (null == options || !options.ContainsKey("COUNT") || !Int32.TryParse(options["COUNT"], out nbLimitTop))
            {
                nbLimitTop = reportData.Parameter.NbResultDefault;
            }

            #region LOC Evolution
            if (null != reportData && null != reportData.CurrentSnapshot)
            {
                TechnologyResultCurrentSnapshot = MeasureUtility.GetTechnoLoc(reportData.CurrentSnapshot, nbLimitTop);

                if (!hasPrevious)
                {

                    #region Current Snapshot
                    ResultCompartTecno = (from techLocC in TechnologyResultCurrentSnapshot
                                          select new EvolutionSnapshots()
                                          {
                                              name = techLocC.Name,
                                              curValue = techLocC.Value,
                                              preValue = null,
                                              evolValue = 0,

                                          }).ToList();
                    #endregion Current Snapshot

                }
                else
                {

                    #region Previous Snapshot
                    TechnologyResultPreviousSnapshot = MeasureUtility.GetTechnoLoc(reportData.PreviousSnapshot, nbLimitTop);

                    ResultCompartTecno = (from techLocC in TechnologyResultCurrentSnapshot
                                          from techLocP in TechnologyResultPreviousSnapshot
                                          where techLocC.Name.Equals(techLocP.Name) && (techLocP != null)
                                          select new EvolutionSnapshots()
                                          {
                                              name = techLocC.Name,
                                              curValue = techLocC.Value,
                                              preValue = techLocP.Value,
                                              evolValue = techLocC.Value - techLocP.Value,

                                          }).ToList();

                    if (TechnologyResultPreviousSnapshot.Count != TechnologyResultCurrentSnapshot.Count)
                    {
                        ResultCompartTecno.AddRange((from ResultCompart in ResultCompartTecno
                                                     from techLocC in TechnologyResultCurrentSnapshot
                                                     where ResultCompartTecno.TrueForAll(_ => _.name != techLocC.Name)
                                                     select new EvolutionSnapshots()
                                                     {
                                                         name = techLocC.Name,
                                                         curValue = techLocC.Value,
                                                         preValue = null,
                                                         evolValue = null,
                                                     }));

                        ResultCompartTecno.AddRange((from ResultCompart in ResultCompartTecno
                                                     from techLocP in TechnologyResultPreviousSnapshot
                                                     where ResultCompartTecno.TrueForAll(_ => _.name != techLocP.Name)
                                                     select new EvolutionSnapshots()
                                                     {
                                                         name = techLocP.Name,
                                                         curValue = null,
                                                         preValue = techLocP.Value,
                                                         evolValue = null,
                                                     }));
                    }
                    #endregion Previous Snapshot

                }
            }
            #endregion LOC Evolution

            #region Decision Points
            if (null != reportData && null != reportData.CurrentSnapshot)
            {
                TechnologyDecisionPointsResultCurrentSnapshot = MeasureUtility.GetTechnoComplexity(reportData.CurrentSnapshot, nbLimitTop);

                if (!hasPrevious)
                {

                    #region Current Snapshot
                    ResultCompartTecnoDecisionPoints = (from techLocC in TechnologyDecisionPointsResultCurrentSnapshot
                                                        select new EvolutionSnapshots()
                                                        {
                                                            name = techLocC.Name,
                                                            curValue = techLocC.Value,
                                                            preValue = null,
                                                            evolValue = 0,

                                                        }).ToList();
                    #endregion Current Snapshot

                }
                else
                {

                    #region Previous Snapshot
                    TechnologyDecisionPointsResultPreviousSnapshot = MeasureUtility.GetTechnoComplexity(reportData.PreviousSnapshot, nbLimitTop);

                    ResultCompartTecnoDecisionPoints = (from techLocC in TechnologyDecisionPointsResultCurrentSnapshot
                                                        from techLocP in TechnologyDecisionPointsResultPreviousSnapshot
                                                        where techLocC.Name.Equals(techLocP.Name) && (techLocP != null)
                                                        select new EvolutionSnapshots()
                                                        {
                                                            name = techLocC.Name,
                                                            curValue = techLocC.Value,
                                                            preValue = techLocP.Value,
                                                            evolValue = techLocC.Value - techLocP.Value,

                                                        }).ToList();

                    if (TechnologyDecisionPointsResultPreviousSnapshot.Count != TechnologyDecisionPointsResultCurrentSnapshot.Count)
                    {
                        ResultCompartTecnoDecisionPoints.AddRange((from ResultCompart in ResultCompartTecnoDecisionPoints
                                                                   from techLocC in TechnologyDecisionPointsResultCurrentSnapshot
                                                                   where ResultCompartTecnoDecisionPoints.TrueForAll(_ => _.name != techLocC.Name)
                                                                   select new EvolutionSnapshots()
                                                                   {
                                                                       name = techLocC.Name,
                                                                       curValue = techLocC.Value,
                                                                       preValue = null,
                                                                       evolValue = null,
                                                                   }));

                        ResultCompartTecnoDecisionPoints.AddRange((from ResultCompart in ResultCompartTecnoDecisionPoints
                                                                   from techLocP in TechnologyDecisionPointsResultPreviousSnapshot
                                                                   where ResultCompartTecnoDecisionPoints.TrueForAll(_ => _.name != techLocP.Name)
                                                                   select new EvolutionSnapshots()
                                                                   {
                                                                       name = techLocP.Name,
                                                                       curValue = null,
                                                                       preValue = techLocP.Value,
                                                                       evolValue = null,
                                                                   }));
                    }
                    #endregion Previous Snapshot

                }
            }
            #endregion Decision Points

            #region Classes
            if (null != reportData && null != reportData.CurrentSnapshot)
            {
                TechnologyClassesResultCurrentSnapshot = MeasureUtility.GetTechnoClasses(reportData.CurrentSnapshot, nbLimitTop);

                if (!hasPrevious)
                {

                    #region Current Snapshot
                    ResultCompartTecnoClasses = (from techLocC in TechnologyClassesResultCurrentSnapshot
                                                 select new EvolutionSnapshots()
                                                 {
                                                     name = techLocC.Name,
                                                     curValue = techLocC.Value,
                                                     preValue = null,
                                                     evolValue = 0,

                                                 }).ToList();
                    #endregion Current Snapshot

                }
                else
                {

                    #region Previous Snapshot
                    TechnologyClassesResultPreviousSnapshot = MeasureUtility.GetTechnoComplexity(reportData.PreviousSnapshot, nbLimitTop);

                    ResultCompartTecnoClasses = (from techLocC in TechnologyClassesResultCurrentSnapshot
                                                 from techLocP in TechnologyClassesResultPreviousSnapshot
                                                 where techLocC.Name.Equals(techLocP.Name) && (techLocP != null)
                                                 select new EvolutionSnapshots()
                                                 {
                                                     name = techLocC.Name,
                                                     curValue = techLocC.Value,
                                                     preValue = techLocP.Value,
                                                     evolValue = techLocC.Value - techLocP.Value,

                                                 }).ToList();

                    if (TechnologyClassesResultPreviousSnapshot.Count != TechnologyClassesResultCurrentSnapshot.Count)
                    {
                        ResultCompartTecnoClasses.AddRange((from ResultCompart in ResultCompartTecnoClasses
                                                            from techLocC in TechnologyClassesResultCurrentSnapshot
                                                            where ResultCompartTecnoClasses.TrueForAll(_ => _.name != techLocC.Name)
                                                            select new EvolutionSnapshots()
                                                            {
                                                                name = techLocC.Name,
                                                                curValue = techLocC.Value,
                                                                preValue = null,
                                                                evolValue = null,
                                                            }));

                        ResultCompartTecnoClasses.AddRange((from ResultCompart in ResultCompartTecnoClasses
                                                            from techLocP in TechnologyClassesResultPreviousSnapshot
                                                            where ResultCompartTecnoClasses.TrueForAll(_ => _.name != techLocP.Name)
                                                            select new EvolutionSnapshots()
                                                            {
                                                                name = techLocP.Name,
                                                                curValue = null,
                                                                preValue = techLocP.Value,
                                                                evolValue = null,
                                                            }));
                    }
                    #endregion Previous Snapshot

                }
            }
            #endregion Classes

            foreach (var item in ResultCompartTecno)
            {
                dtFinalRepository.Rows.Add(item.name, "", (item.evolValue.HasValue) ? FormatEvolution((Int32)item.evolValue.Value) : CastReporting.Domain.Constants.No_Value, "");
            }
            dtFinalRepository.AcceptChanges();

            foreach (var item in ResultCompartTecnoDecisionPoints)
            {
                for (int i = 0; i < dtFinalRepository.Rows.Count; i++)
                {
                    if (dtFinalRepository.Rows[i]["Name"].ToString() == item.name.ToString())
                    {
                        dtFinalRepository.Rows[i]["DecisionP"] = (item.evolValue.HasValue) ? FormatEvolution((Int32)item.evolValue.Value) : CastReporting.Domain.Constants.No_Value;
                        break;
                    }
                }
            }
            dtFinalRepository.AcceptChanges();

            foreach (var item in ResultCompartTecnoClasses)
            {
                for (int i = 0; i < dtFinalRepository.Rows.Count; i++)
                {
                    if (dtFinalRepository.Rows[i]["Name"].ToString() == item.name.ToString())
                    {
                        dtFinalRepository.Rows[i]["Classes"] = (item.evolValue.HasValue) ? FormatEvolution((Int32)item.evolValue.Value) : CastReporting.Domain.Constants.No_Value;
                        break;
                    }
                }
            }

            dtFinalRepository.AcceptChanges();

            for (int i = 0; i < dtFinalRepository.Rows.Count; i++)
            {
                rowData.AddRange(new string[] {
                    dtFinalRepository.Rows[i]["Name"].ToString()
                    , dtFinalRepository.Rows[i]["DecisionP"].ToString()
                    , dtFinalRepository.Rows[i]["KLOC"].ToString()
                    , dtFinalRepository.Rows[i]["Classes"].ToString()
                });
            }
            //foreach (var item in ResultCompartTecno)
            //{
            //    rowData.AddRange(new string[] {
            //        item.name
            //        , ""
            //        , (item.evolValue.HasValue) ? FormatEvolution((Int32)item.evolValue.Value) : CastReporting.Domain.Constants.No_Value
            //        , ""
            //    });
            //}

            resultTable = new TableDefinition
            {
                HasRowHeaders = false,
                HasColumnHeaders = true,
                NbRows = nbLimitTop + 1,
                NbColumns = 4,
                Data = rowData
            };
            return resultTable;
        }
Пример #19
0
        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;
        }
Пример #20
0
        private static void UpdateWordBlock(ReportData client, OpenXmlPartContainer container, OpenXmlElement block, TableDefinition content, Dictionary<string, string> options)
        {
            if (null != content && block is OXW.Table)
            {
                OXW.Table table = ((OXW.Table)block).CloneNode(true) as OXW.Table;

                OXW.TableRow headerRowTemplate = table.Descendants<OXW.TableRow>().First().CloneNode(true) as OXW.TableRow;
                OXW.TableRow contentRowTemplate = table.Descendants<OXW.TableRow>().Skip(1).First().CloneNode(true) as OXW.TableRow;

                #region Column number management
                OXW.TableGrid tablegrid = table.Descendants<OXW.TableGrid>().FirstOrDefault();
                if (null != tablegrid)
                {
                    List<OXW.GridColumn> columns = tablegrid.Descendants<OXW.GridColumn>().ToList();
                    if (null != columns && content.NbColumns != columns.Count)
                    {
                        if (content.NbColumns < columns.Count)
                        {
                            for (int i = columns.Count - 1, lim = content.NbColumns - 1; i > lim; i--)
                            {
                                tablegrid.RemoveChild<OXW.GridColumn>(columns[i]);
                            }
                        }
                        else
                        {
                            for (int i = 0, lim = content.NbColumns - columns.Count; i < lim; i++)
                            {
                                tablegrid.AppendChild<OXW.GridColumn>(new OXW.GridColumn() { Width = "1000" });
                            }
                        }
                    }
                }
                #endregion Column number management

                ModifyWordRowTextContent(headerRowTemplate, string.Empty);
                ModifyWordRowTextContent(contentRowTemplate, string.Empty);

                int idx = 0;
                int nbrow = 0;
                List<OXW.TableCell> headerCells = headerRowTemplate.Descendants<OXW.TableCell>().Select(_ => _.CloneNode(true) as OXW.TableCell).ToList();
                List<OXW.TableCell> contentCells = contentRowTemplate.Descendants<OXW.TableCell>().Select(_ => _.CloneNode(true) as OXW.TableCell).ToList();
                headerRowTemplate.RemoveAllChildren<OXW.TableCell>();
                OXW.TableRow row = headerRowTemplate;
                int headerCellsCount = headerCells.Count;
                int contentCellsCount = headerCells.Count;

                table.RemoveAllChildren<OXW.TableRow>();
                foreach (var item in content.Data)
                {
                    if (null != item)
                    {
                        OXW.TableCell cell = null;
                        if (content.HasColumnHeaders && 0 == nbrow)
                        {
                            cell = headerCells[idx % headerCellsCount].CloneNode(true) as OXW.TableCell;
                        }
                        else
                        {
                            cell = contentCells[idx % contentCellsCount].CloneNode(true) as OXW.TableCell;
                        }
                        ModifyWordCellTextContent(cell, item);
                        row.Append(cell);
                    }

                    idx = ++idx % content.NbColumns;
                    if (0 == idx)
                    {
                        if (null != row)
                        {
                            table.Append(row);
                            nbrow++;
                        }
                        row = contentRowTemplate.CloneNode(true) as OXW.TableRow;
                        row.RemoveAllChildren<OXW.TableCell>();
                    }
                }
                var blockSdt = block.Ancestors<OXW.SdtBlock>().First();
                blockSdt.Parent.ReplaceChild(table, blockSdt);
            }
            else
            {
                LogHelper.Instance.LogErrorFormat("Impossible to load data in Table block with a block source of type \"{0}\"", null != block ? block.GetType().ToString() : "null");
            }
        }
        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;
        }
Пример #22
0
 private static void UpdateExcelBlock(ReportData client, OpenXmlPartContainer container, OpenXmlElement block, TableDefinition content, Dictionary<string, string> options)
 {
     // TODO : Finalize Excel alimentation
     throw new NotImplementedException();
 }
Пример #23
0
        private static void UpdatePowerPointBlock(ReportData client, OpenXmlPartContainer container, OpenXmlElement block, TableDefinition content, Dictionary<string, string> options)
        {
            if (null != content && block is OXP.GraphicFrame)
            {
                OXD.Table initTable = (OXD.Table)block.Descendants<OXD.Table>().FirstOrDefault();
                if (null != initTable)
                {
                    try
                    {
                        OXD.Table table = initTable.CloneNode(true) as OXD.Table;
                        OXD.TableRow headerRowTemplate = table.Descendants<OXD.TableRow>().First().CloneNode(true) as OXD.TableRow;
                        OXD.TableRow contentRowTemplate = table.Descendants<OXD.TableRow>().Skip(1).First().CloneNode(true) as OXD.TableRow;

                        ModifyPowerPointRowTextContent(headerRowTemplate, string.Empty);
                        ModifyPowerPointRowTextContent(contentRowTemplate, string.Empty);

                        #region Column Number Management
                        List<OXD.GridColumn> columns = table.TableGrid.Descendants<OXD.GridColumn>().ToList();
                        if (columns.Count < content.NbColumns)
                        {
                            int nbNewColumn = content.NbColumns - columns.Count;
                            for (int i = 0, lim = nbNewColumn; i < lim; i++)
                            {
                                AddNewGridColumn(table.TableGrid, headerRowTemplate, contentRowTemplate);
                            }
                        } else if (columns.Count > content.NbColumns) {
                            for (int i = content.NbColumns, lim = columns.Count; i < lim; i++) {
                                RemoveLastGridColumn(table.TableGrid);
                            }
                        }
                        #endregion Column Number Management

                        int idx = 0;
                        int nbrow = 0;
                        List<OXD.TableCell> headerCells = headerRowTemplate.Descendants<OXD.TableCell>().Select(_ => _.CloneNode(true) as OXD.TableCell).ToList();
                        List<OXD.TableCell> contentCells = contentRowTemplate.Descendants<OXD.TableCell>().Select(_ => _.CloneNode(true) as OXD.TableCell).ToList();
                        headerRowTemplate.RemoveAllChildren<OXD.TableCell>();
                        OXD.TableRow row = headerRowTemplate;

                        table.RemoveAllChildren<OXD.TableRow>();
                        foreach (var item in content.Data)
                        {
                            OXD.TableCell cell = null;
                            if (content.HasColumnHeaders && 0 == nbrow)
                            {
                                cell = headerCells[idx].CloneNode(true) as OXD.TableCell;
                            }
                            else
                            {
                                cell = contentCells[idx].CloneNode(true) as OXD.TableCell;
                            }
                            ModifyPowerPointCellTextContent(cell, item);

                            //row.Append(cell); => in office 2016, element <extLst> should absolutely be in the latest position in a row
                            row.InsertBefore<OXD.TableCell>(cell, row.Descendants<OXD.ExtensionList>().FirstOrDefault());

                            idx = ++idx % content.NbColumns;
                            if (0 == idx)
                            {
                                if (null != row)
                                {
                                    table.Append(row);
                                    nbrow++;
                                }
                                row = contentRowTemplate.CloneNode(true) as OXD.TableRow;
                                row.RemoveAllChildren<OXD.TableCell>();
                            }
                        }
                        initTable.Parent.ReplaceChild(table, initTable);
                    }
                    catch (Exception exception)
                    {
                        LogHelper.Instance.LogErrorFormat("An unhandled exception was thrown during table block content generation : '{0}'", exception.ToString());
                        if (null != initTable)
                        {
                            if (null != initTable.Descendants<OXD.TableRow>() && 1 > initTable.Descendants<OXD.TableRow>().Count())
                            {
                                foreach (var row in initTable.Descendants<OXD.TableRow>().Skip(1))
                                {
                                    ModifyPowerPointRowTextContent(row, string.Empty);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                LogHelper.Instance.LogErrorFormat("Impossible to load data in table block with a block source of type \"{0}\"", null != block ? block.GetType().ToString() : "null");
            }
        }
Пример #24
0
 private static void UpdateBlock(ReportData client, OpenXmlPartContainer container, OpenXmlElement block, TableDefinition content, Dictionary<string, string> options)
 {
     switch (client.ReportType)
     {
         case FormatType.Word: { UpdateWordBlock(client, container, block, content, options); } break;
         case FormatType.PowerPoint: { UpdatePowerPointBlock(client, container, block, content, options); } break;
         case FormatType.Excel: { UpdateExcelBlock(client, container, block, content, options); } break;
         default: break;
     }
 }
        protected override TableDefinition Content(ReportData reportData, Dictionary<string, string> options)
        {
            var results = RulesViolationUtility.GetStatViolation(reportData.CurrentSnapshot);
            List<string> rowData = new List<string>();
            rowData.AddRange(new[] { " ", Labels.TQI, Labels.Robu, Labels.Efcy, Labels.Secu, Labels.Trans, Labels.Chang });

            rowData.AddRange(new[] { Labels.Current, " ", " ", " ", " ", " ", " " });

            foreach (var resultModule in results.OrderBy(_ => _.ModuleName))
            {
               rowData.AddRange(new[] {
                          resultModule.ModuleName,
                          (resultModule !=null && resultModule[Constants.BusinessCriteria.TechnicalQualityIndex] != null && resultModule[Constants.BusinessCriteria.TechnicalQualityIndex].Total.HasValue)?
                          resultModule[Constants.BusinessCriteria.TechnicalQualityIndex].Total.Value.ToString(_MetricFormat) : Constants.No_Value,

                          (resultModule !=null && resultModule[Constants.BusinessCriteria.Robustness] != null  && resultModule[Constants.BusinessCriteria.Robustness].Total.HasValue)?
                          resultModule[Constants.BusinessCriteria.Robustness].Total.Value.ToString(_MetricFormat):Constants.No_Value ,

                          (resultModule !=null && resultModule[Constants.BusinessCriteria.Performance] != null  && resultModule[Constants.BusinessCriteria.Performance].Total.HasValue)?
                          resultModule[Constants.BusinessCriteria.Performance].Total.Value.ToString(_MetricFormat):Constants.No_Value ,

                          (resultModule !=null && resultModule[Constants.BusinessCriteria.Security] != null  && resultModule[Constants.BusinessCriteria.Security].Total.HasValue)?
                          resultModule[Constants.BusinessCriteria.Security].Total.Value.ToString(_MetricFormat):Constants.No_Value ,

                          (resultModule !=null && resultModule[Constants.BusinessCriteria.Transferability] != null  && resultModule[Constants.BusinessCriteria.Transferability].Total.HasValue)?
                          resultModule[Constants.BusinessCriteria.Transferability].Total.Value.ToString(_MetricFormat):Constants.No_Value ,

                          (resultModule !=null && resultModule[Constants.BusinessCriteria.Changeability] != null  && resultModule[Constants.BusinessCriteria.Changeability].Total.HasValue)?
                          resultModule[Constants.BusinessCriteria.Changeability].Total.Value.ToString(_MetricFormat):Constants.No_Value ,

                        });

            }
            rowData.AddRange(new[] { Labels.ViolationsAdded, " ", " ", " ", " ", " ", " " });

            foreach (var resultModule in results.OrderBy(_ => _.ModuleName))
            {
                rowData.AddRange(new[] {
                          resultModule.ModuleName,
                          (resultModule !=null && resultModule[Constants.BusinessCriteria.TechnicalQualityIndex] != null && resultModule[Constants.BusinessCriteria.TechnicalQualityIndex].Added.HasValue)?
                          resultModule[Constants.BusinessCriteria.TechnicalQualityIndex].Added.Value.ToString(_MetricFormat) : Constants.No_Value,

                          (resultModule !=null && resultModule[Constants.BusinessCriteria.Robustness] != null && resultModule[Constants.BusinessCriteria.Robustness].Added.HasValue)?
                          resultModule[Constants.BusinessCriteria.Robustness].Added.Value.ToString(_MetricFormat):Constants.No_Value ,

                          (resultModule !=null && resultModule[Constants.BusinessCriteria.Performance] != null && resultModule[Constants.BusinessCriteria.Performance].Added.HasValue)?
                          resultModule[Constants.BusinessCriteria.Performance].Added.Value.ToString(_MetricFormat):Constants.No_Value ,

                          (resultModule !=null && resultModule[Constants.BusinessCriteria.Security] != null && resultModule[Constants.BusinessCriteria.Security].Added.HasValue)?
                          resultModule[Constants.BusinessCriteria.Security].Added.Value.ToString(_MetricFormat):Constants.No_Value ,

                          (resultModule !=null && resultModule[Constants.BusinessCriteria.Transferability] != null && resultModule[Constants.BusinessCriteria.Transferability].Added.HasValue)?
                          resultModule[Constants.BusinessCriteria.Transferability].Added.Value.ToString(_MetricFormat):Constants.No_Value ,

                          (resultModule !=null && resultModule[Constants.BusinessCriteria.Changeability] != null && resultModule[Constants.BusinessCriteria.Changeability].Added.HasValue)?
                          resultModule[Constants.BusinessCriteria.Changeability].Added.Value.ToString(_MetricFormat):Constants.No_Value ,

                        });

            }
            rowData.AddRange(new[] { Labels.ViolationsRemoved, " ", " ", " ", " ", " ", " " });

            foreach (var resultModule in results.OrderBy(_ => _.ModuleName))
            {
                rowData.AddRange(new[] {
                          resultModule.ModuleName,
                          (resultModule !=null && resultModule[Constants.BusinessCriteria.TechnicalQualityIndex] !=null && resultModule[Constants.BusinessCriteria.TechnicalQualityIndex].Removed.HasValue)?
                          resultModule[Constants.BusinessCriteria.TechnicalQualityIndex].Removed.Value.ToString(_MetricFormat) : Constants.No_Value,

                          (resultModule !=null && resultModule[Constants.BusinessCriteria.Robustness] !=null && resultModule[Constants.BusinessCriteria.Robustness].Removed.HasValue)?
                          resultModule[Constants.BusinessCriteria.Robustness].Removed.Value.ToString(_MetricFormat):Constants.No_Value ,

                          (resultModule !=null && resultModule[Constants.BusinessCriteria.Performance] !=null && resultModule[Constants.BusinessCriteria.Performance].Removed.HasValue)?
                          resultModule[Constants.BusinessCriteria.Performance].Removed.Value.ToString(_MetricFormat):Constants.No_Value ,

                          (resultModule !=null && resultModule[Constants.BusinessCriteria.Security] !=null && resultModule[Constants.BusinessCriteria.Security].Removed.HasValue)?
                          resultModule[Constants.BusinessCriteria.Security].Removed.Value.ToString(_MetricFormat):Constants.No_Value ,

                          (resultModule !=null && resultModule[Constants.BusinessCriteria.Transferability] !=null && resultModule[Constants.BusinessCriteria.Transferability].Removed.HasValue)?
                          resultModule[Constants.BusinessCriteria.Transferability].Removed.Value.ToString(_MetricFormat):Constants.No_Value ,

                          (resultModule !=null && resultModule[Constants.BusinessCriteria.Changeability] !=null && resultModule[Constants.BusinessCriteria.Changeability].Removed.HasValue)?
                          resultModule[Constants.BusinessCriteria.Changeability].Removed.Value.ToString(_MetricFormat):Constants.No_Value ,

                        });

            }
            var resultTable = new TableDefinition
            {
                HasRowHeaders = false,
                HasColumnHeaders = true,
                NbRows = results.Count,
                NbColumns = 7,
                Data = rowData
            };

            return resultTable;
        }
Пример #26
0
        protected override TableDefinition Content(ReportData reportData, Dictionary<string, string> options)
        {
            TableDefinition back = null;
            List<string> rowData = new List<string>();
            int nbLimitTop = 0;
            List<int> bcId = new List<int>();
            int idx = -1;
            if (null == options || !options.ContainsKey("IDX") || !Int32.TryParse(options["IDX"], out idx))
            {
                idx = -1;
            }
            if (null == options || !options.ContainsKey("COUNT") || !Int32.TryParse(options["COUNT"], out nbLimitTop))
            {
                nbLimitTop = 10;
                if (idx >= 0 && nbLimitTop <= idx)
                    nbLimitTop = idx + 1;
            }

            bool displayHeader = (options == null || !options.ContainsKey("HEADER") || "NO" != options["HEADER"]);

            if (options != null && options.ContainsKey("PAR"))
            {
                foreach (var par in options["PAR"].Split('|'))
                {
                    int id;
                    if (Int32.TryParse(par, out id))
                    {
                        bcId.Add(id);
                    }
                }
            }
            if (bcId.Count == 0)
            {
                bcId.Add(Constants.BusinessCriteria.TechnicalQualityIndex.GetHashCode());
            }

            ApplicationResult bc = reportData.CurrentSnapshot.BusinessCriteriaResults.FirstOrDefault(_ => bcId.Contains(_.Reference.Key));

            var criticalRuleViolations = bc.CriticalRulesViolation.Where(_ => _.DetailResult != null && _.DetailResult.ViolationRatio != null).OrderByDescending(_ => _.DetailResult.ViolationRatio.FailedChecks).Take(nbLimitTop);
            if (idx >= 0)
                criticalRuleViolations = criticalRuleViolations.Skip(idx).Take(1);

            int nbRows = 0;

            foreach (var violation in criticalRuleViolations)
            {
                IEnumerable<CastReporting.Domain.MetricTopArtifact> metricTopArtefact = reportData.SnapshotExplorer.GetMetricTopArtefact(reportData.CurrentSnapshot.Href, violation.Reference.Key.ToString(), -1);

                int nbArtefactsDisp = 0;
                int nbArtefactsCount = 0;
                if (metricTopArtefact != null) {
                    nbArtefactsCount = metricTopArtefact.Count();
                    nbArtefactsDisp = Math.Min(nbLimitTop, nbArtefactsCount);
                }
                rowData.AddRange(new string[] { "Sample Violating Artefacts for Rule '" + violation.Reference.Name + "'", "# " + nbArtefactsDisp + " of " + nbArtefactsCount });
                nbRows++;

                if (metricTopArtefact != null && nbArtefactsDisp > 0)
                {
                    foreach (var metric in metricTopArtefact)
                    {
                        if (nbArtefactsDisp > 0)
                        {
                            rowData.AddRange(new string[] { metric.ObjectNameLocation, string.Empty });
                            nbRows++;
                            nbArtefactsDisp--;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                else
                {
                    rowData.AddRange(new string[] { Labels.NoItem, string.Empty });
                    nbRows++;
                }
            }

            if (nbRows == 0) {
                rowData.AddRange(new string[] { Labels.NoItem, string.Empty });
                nbRows++;
            }

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

            return back;
        }
        protected override TableDefinition Content(ReportData reportData, Dictionary<string, string> options)
        {
            int nbRows = 0;
            int nbLimitTop = 0;
            List<string> rowData = new List<string>();

            rowData.AddRange(new string[] {
                Labels.RuleName,
                Labels.ViolationsCount
            });

            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 NonCriticalRulesViolation = RulesViolationUtility.GetRuleViolations(reportData.CurrentSnapshot,
                                                                                        Constants.RulesViolation.NonCriticalRulesViolation,
                                                                                       (Constants.BusinessCriteria)metricId,
                                                                                       true,
                                                                                       nbLimitTop);

                if (NonCriticalRulesViolation != null && NonCriticalRulesViolation.Any()) {
                    foreach (var elt in NonCriticalRulesViolation) {
                        rowData.AddRange(new string[] { elt.Rule.Name, elt.TotalFailed.Value.ToString("N0") });
                    }
                } else {
                    rowData.AddRange(new string[] {
                        Labels.NoItem,
                        string.Empty
                    });
                }
                nbRows = NonCriticalRulesViolation.Count;
            }

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

            return resultTable;
        }
        protected override TableDefinition Content(ReportData reportData, Dictionary<string, string> options)
        {
            TableDefinition resultTable = null;
            if (reportData != null && reportData.CurrentSnapshot != null)
            {
                double? criticalViolation = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesNumber);
                double? numCritPerFile = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesPerFileNumber);
                double? numCritPerKLOC = MeasureUtility.GetSizingMeasure(reportData.CurrentSnapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesPerKLOCNumber);

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

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

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

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

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

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

                string numCritPerFileIfNegative = string.Empty;
                if (numCritPerFile == -1)
                    numCritPerFileIfNegative = "N/A";
                else
                    numCritPerFileIfNegative = (numCritPerFile.HasValue) ? numCritPerFile.Value.ToString(metricFormatPrecision) : Constants.No_Value;

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

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

                    , "  " + Labels.PerFile
                    , numCritPerFileIfNegative

                    , "  " + Labels.PerkLoC
                    , (numCritPerKLOC.HasValue)? numCritPerKLOC.Value.ToString(metricFormatPrecision):Constants.No_Value

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

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

                resultTable = new TableDefinition
                {
                    HasRowHeaders = true,
                    HasColumnHeaders = false,
                    NbRows = 6,
                    NbColumns = 2,
                    Data = rowData
                };
            }
            return resultTable;
        }
        /// <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;
        }
Пример #30
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="reportData"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        protected override TableDefinition Content(ReportData reportData, Dictionary<string, string> options)
        {
            string metricFormat = "N2";

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

            List<string> rowData = new List<string>();
            rowData.AddRange(displayShortHeader
                                ? new[] { " ", Labels.TQI, Labels.Robu, Labels.Efcy, Labels.Secu, Labels.Trans, Labels.Chang }
                                : new[] { " ", Labels.TQI, Labels.Robustness, Labels.Efficiency, Labels.Security, Labels.Transferability, Labels.Changeability });

            //Current snpashot
            var resultCurrentSnapshot = BusinessCriteriaUtility.GetBusinessCriteriaGradesModules(reportData.CurrentSnapshot, false);

            rowData.AddRange(new[] { reportData.CurrentSnapshot.ToString(), " ", " ", " ", " ", " ", " " });

            foreach(var  result in resultCurrentSnapshot.OrderBy(_ => _.Name))
            {
                rowData.AddRange(new[] {
                            result.Name,
                            (result.TQI != null && result.TQI.HasValue)? result.TQI.Value.ToString(metricFormat) : Constants.No_Value,
                            (result.Robustness != null && result.Robustness.HasValue)? result.Robustness.Value.ToString(metricFormat) : Constants.No_Value,
                            (result.Performance!= null && result.Performance.HasValue)? result.Performance.Value.ToString(metricFormat) : Constants.No_Value,
                            (result.Security != null && result.Security.HasValue) ? result.Security.Value.ToString(metricFormat) : Constants.No_Value,
                            (result.Transferability != null && result.Transferability.HasValue)? result.Transferability.Value.ToString(metricFormat) : Constants.No_Value,
                            (result.Changeability != null && result.Changeability.HasValue) ? result.Changeability.Value.ToString(metricFormat) : Constants.No_Value
                        });
            }

            nbRows += resultCurrentSnapshot.Count+2;

            //previous snpashot
            var resultPreviousSnapshot = BusinessCriteriaUtility.GetBusinessCriteriaGradesModules(reportData.PreviousSnapshot, false);

            if(resultPreviousSnapshot != null)
            {
                rowData.AddRange(new[] {" "," "," "," "," "," "," "});
                rowData.AddRange(new[] {  reportData.PreviousSnapshot.ToString(), " ", " ", " ", " ", " ", " " });

                foreach (var result in resultPreviousSnapshot.OrderBy(_ => _.Name))
                {
                    rowData.AddRange(new[] {
                                result.Name,
                            (result.TQI != null && result.TQI.HasValue)? result.TQI.Value.ToString(metricFormat) : Constants.No_Value,
                            (result.Robustness != null && result.Robustness.HasValue)? result.Robustness.Value.ToString(metricFormat) : Constants.No_Value,
                            (result.Performance!= null && result.Performance.HasValue)? result.Performance.Value.ToString(metricFormat) : Constants.No_Value,
                            (result.Security != null && result.Security.HasValue) ? result.Security.Value.ToString(metricFormat) : Constants.No_Value,
                            (result.Transferability != null && result.Transferability.HasValue)? result.Transferability.Value.ToString(metricFormat) : Constants.No_Value,
                            (result.Changeability != null && result.Changeability.HasValue) ? result.Changeability.Value.ToString(metricFormat) : Constants.No_Value
                            });
                }

                nbRows += resultPreviousSnapshot.Count+2;

                //Variation
                var variationList = (from current in resultCurrentSnapshot
                                    join previous in resultPreviousSnapshot
                                    on current.Name equals previous.Name
                                    select new
                                    {
                                        current.Name,
                                        Variation = (current - previous) / previous
                                    }).ToList();

                rowData.AddRange(new[] {" "," "," "," "," "," "," "});
                rowData.AddRange(new[] { Labels.Variation, " ", " ", " ", " ", " ", " " });

                foreach (var result in variationList.OrderBy(_ => _.Name))
                {
                    rowData.AddRange(new[] {
                                result.Name,
                                FormatPercent(result.Variation.TQI),
                                FormatPercent(result.Variation.Robustness),
                                FormatPercent(result.Variation.Performance),
                                FormatPercent(result.Variation.Security),
                                FormatPercent(result.Variation.Transferability),
                                FormatPercent(result.Variation.Changeability)
                            });
                }

                nbRows += variationList.Count+2;
            }

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

            return resultTable;
        }