Exemplo n.º 1
0
        protected override string Content(ReportData reportData, Dictionary <string, string> options)
        {
            if (null != reportData && null != reportData.CurrentSnapshot)
            {
                return(SnapshotUtility.GetSnapshotVersionNumber(reportData.CurrentSnapshot));
            }

            return(CastReporting.Domain.Constants.No_Value);
        }
Exemplo n.º 2
0
        protected override string Content(ReportData reportData, Dictionary <string, string> options)
        {
            string res = string.Empty;

            if (null != reportData && null != reportData.CurrentSnapshot)
            {
                DateTime?d = SnapshotUtility.GetSnapshotDate(reportData.CurrentSnapshot);
                if (d.HasValue)
                {
                    res = d.Value.ToString(Labels.FORMAT_SHORT_DATE);
                }
            }

            return(string.IsNullOrEmpty(res) ? CastReporting.Domain.Constants.No_Value : res);
        }
Exemplo n.º 3
0
        public override string Content(ReportData reportData, Dictionary <string, string> options)
        {
            string res = string.Empty;

            if (reportData?.PreviousSnapshot == null)
            {
                return(string.IsNullOrEmpty(res) ? Domain.Constants.No_Value : res);
            }
            DateTime?d = SnapshotUtility.GetSnapshotDate(reportData.PreviousSnapshot);

            if (d.HasValue)
            {
                res = d.Value.ToString(Labels.FORMAT_LONG_DATE);
            }

            return(string.IsNullOrEmpty(res) ? Domain.Constants.No_Value : res);
        }
Exemplo n.º 4
0
        public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            string prevSnapshotLabel = string.Empty;
            BusinessCriteriaDTO prevSnapshotBCResult = null;

            if (reportData?.CurrentSnapshot == null)
            {
                return(null);
            }
            string currSnapshotLabel = SnapshotUtility.GetSnapshotVersionNumber(reportData.CurrentSnapshot);
            BusinessCriteriaDTO _currSnapshotBcdto = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(reportData.CurrentSnapshot, true);

            if (reportData.PreviousSnapshot != null)
            {
                prevSnapshotLabel    = SnapshotUtility.GetSnapshotVersionNumber(reportData.PreviousSnapshot);
                prevSnapshotBCResult = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(reportData.PreviousSnapshot, true);
            }
            else
            {
                Snapshot _previousSnapshot = reportData.Application.Snapshots?.FirstOrDefault(_ => _.Annotation.Date.DateSnapShot < reportData.CurrentSnapshot.Annotation.Date.DateSnapShot);
                if (_previousSnapshot != null)
                {
                    prevSnapshotLabel    = SnapshotUtility.GetSnapshotVersionNumber(_previousSnapshot);
                    prevSnapshotBCResult = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(_previousSnapshot, true);
                }
            }


            var rowData = new List <string> {
                null, currSnapshotLabel
            };

            if (prevSnapshotBCResult != null)
            {
                rowData.Add(prevSnapshotLabel ?? Constants.No_Value);
            }


            #region Transferability
            rowData.Add(Labels.Trans);
            rowData.Add(_currSnapshotBcdto.Transferability.ToString());
            if (prevSnapshotBCResult != null)
            {
                rowData.Add(prevSnapshotBCResult.Transferability.ToString());
            }
            #endregion Transferability

            #region Changeability
            rowData.Add(Labels.Chang);
            rowData.Add(_currSnapshotBcdto.Changeability.ToString());
            if (prevSnapshotBCResult != null)
            {
                rowData.Add(prevSnapshotBCResult.Changeability.ToString());
            }
            #endregion Changeability

            #region Robustness
            rowData.Add(Labels.Robu);
            rowData.Add(_currSnapshotBcdto.Robustness.ToString());
            if (prevSnapshotBCResult != null)
            {
                rowData.Add(prevSnapshotBCResult.Robustness.ToString());
            }
            #endregion Robustness

            #region Performance
            rowData.Add(Labels.Efcy);
            rowData.Add(_currSnapshotBcdto.Performance.ToString());
            if (prevSnapshotBCResult != null)
            {
                rowData.Add(prevSnapshotBCResult.Performance.ToString());
            }
            #endregion Performance

            #region Security
            rowData.Add(Labels.Secu);
            rowData.Add(_currSnapshotBcdto.Security.ToString());
            if (prevSnapshotBCResult != null)
            {
                rowData.Add(prevSnapshotBCResult.Security.ToString());
            }
            #endregion Security

            TableDefinition resultTable = new TableDefinition
            {
                HasRowHeaders    = true,
                HasColumnHeaders = true,
                NbRows           = 6,
                NbColumns        = prevSnapshotBCResult != null ? 3 : 2,
                Data             = rowData
            };

            return(resultTable);
        }
Exemplo n.º 5
0
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            int count = 0;

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

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


            #region Fetch SnapshotsPF

            if (reportData != null && reportData.Applications != null && reportData.snapshots != null)
            {
                Application[] AllApps = reportData.Applications;
                for (int j = 0; j < AllApps.Count(); j++)
                {
                    Application App = AllApps[j];

                    int nbSnapshotsEachApp = App.Snapshots.Count();
                    if (nbSnapshotsEachApp > 0)
                    {
                        foreach (Snapshot snapshot in App.Snapshots.OrderByDescending(_ => _.Annotation.Date.DateSnapShot))
                        {
                            Snapshot[] BuiltSnapshots = reportData.snapshots;

                            foreach (Snapshot BuiltSnapshot in BuiltSnapshots)
                            {
                                if (snapshot == BuiltSnapshot)
                                {
                                    string currSnapshotLabel = SnapshotUtility.GetSnapshotVersionNumber(BuiltSnapshot);
                                    BusinessCriteriaDTO currSnapshotBisCriDTO = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(BuiltSnapshot, false);
                                    double?strCurrentTQI = currSnapshotBisCriDTO.TQI.HasValue ? MathUtility.GetRound(currSnapshotBisCriDTO.TQI.Value) : 0;

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

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

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

                                    count++;
                                }
                            }

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

                    count++;
                }
            }
            #endregion Fetch SnapshotsPF



            TableDefinition resultTable = new TableDefinition
            {
                HasRowHeaders    = false,
                HasColumnHeaders = true,
                NbRows           = count + 1,
                NbColumns        = 4,
                Data             = rowData
            };
            return(resultTable);
        }
Exemplo n.º 6
0
 public override string Content(ReportData reportData, Dictionary <string, string> options)
 {
     return(reportData?.CurrentSnapshot != null?SnapshotUtility.GetSnapshotVersionNumber(reportData.CurrentSnapshot) ?? Domain.Constants.No_Value : Domain.Constants.No_Value);
 }
Exemplo n.º 7
0
        public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            const string    metricFormat       = "N2";
            TableDefinition resultTable        = null;
            bool            displayShortHeader = (options != null && options.ContainsKey("HEADER") && "SHORT" == options["HEADER"]);

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

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


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


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


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

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

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

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



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

            rowData.AddRange(displayShortHeader ? new[] { "", Labels.Prog, Labels.Arch, Labels.Doc } : new[] { "", Labels.ProgrammingPractices, Labels.ArchitecturalDesign, Labels.Documentation });

            rowData.AddRange(
                new[]
            {
                currSnapshotLabel,
                currProgrammingPracticesValue?.ToString(metricFormat) ?? Domain.Constants.No_Value,
                currArchitecturalDesignValue?.ToString(metricFormat) ?? Domain.Constants.No_Value,
                currDocumentationValue?.ToString(metricFormat) ?? Domain.Constants.No_Value
            });
            if (hasPreviousSnapshot)
            {
                rowData.AddRange(
                    new[]
                {
                    prevSnapshotLabel,
                    prevProgrammingPracticesValue?.ToString(metricFormat) ?? Domain.Constants.No_Value,
                    prevArchitecturalDesignValue?.ToString(metricFormat) ?? Domain.Constants.No_Value,
                    prevDocumentationValue?.ToString(metricFormat) ?? Domain.Constants.No_Value,
                    Labels.Variation,
                    varProgrammingPractices.HasValue ? FormatPercent(varProgrammingPractices.Value): Domain.Constants.No_Value,
                    varArchitecturalDesign.HasValue ? FormatPercent(varArchitecturalDesign.Value): Domain.Constants.No_Value,
                    varDocumentation.HasValue ? FormatPercent(varDocumentation.Value): Domain.Constants.No_Value
                });
            }
            resultTable = new TableDefinition
            {
                HasRowHeaders    = false,
                HasColumnHeaders = true,
                NbRows           = hasPreviousSnapshot ? 4 : 2,
                NbColumns        = 4,
                Data             = rowData
            };
            return(resultTable);
        }
Exemplo n.º 8
0
        public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            string[] qidList  = options.GetOption("ID")?.Split('|');
            string   _version = options.GetOption("SNAPSHOT", "BOTH");

            var rowData = new List <string> {
                null
            };

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

            if (_version == "CURRENT" || _version == "BOTH")
            {
                string currSnapshotLabel = SnapshotUtility.GetSnapshotVersionNumber(reportData.CurrentSnapshot);
                rowData.Add(currSnapshotLabel);
            }

            if (reportData.PreviousSnapshot != null && (_version == "PREVIOUS" || _version == "BOTH"))
            {
                string prevSnapshotLabel = SnapshotUtility.GetSnapshotVersionNumber(reportData.PreviousSnapshot);
                rowData.Add(prevSnapshotLabel ?? Constants.No_Value);
            }

            int nbRow = 0;

            if (qidList != null)
            {
                foreach (string qid in qidList)
                {
                    int    id = int.Parse(qid.Trim());
                    string qidName;
                    double?curRes;
                    double?prevRes;

                    switch (_version)
                    {
                    case "CURRENT":
                        qidName = BusinessCriteriaUtility.GetMetricName(reportData.CurrentSnapshot, id, true);
                        if (string.IsNullOrEmpty(qidName))
                        {
                            continue;
                        }
                        rowData.Add(qidName);
                        curRes = BusinessCriteriaUtility.GetMetricValue(reportData.CurrentSnapshot, id);
                        rowData.Add(curRes?.ToString() ?? Constants.Zero);
                        nbRow++;
                        break;

                    case "PREVIOUS":
                        if (reportData.PreviousSnapshot != null)
                        {
                            qidName = BusinessCriteriaUtility.GetMetricName(reportData.PreviousSnapshot, id, true);
                            if (string.IsNullOrEmpty(qidName))
                            {
                                continue;
                            }
                            rowData.Add(qidName);
                            prevRes = BusinessCriteriaUtility.GetMetricValue(reportData.PreviousSnapshot, id);
                            rowData.Add(prevRes?.ToString() ?? Constants.Zero);
                            nbRow++;
                        }
                        break;

                    default:
                        qidName = BusinessCriteriaUtility.GetMetricName(reportData.CurrentSnapshot, id, true);
                        if (string.IsNullOrEmpty(qidName))
                        {
                            continue;
                        }
                        rowData.Add(qidName);
                        curRes = BusinessCriteriaUtility.GetMetricValue(reportData.CurrentSnapshot, id);
                        rowData.Add(curRes?.ToString() ?? Constants.Zero);
                        if (reportData.PreviousSnapshot != null)
                        {
                            prevRes = BusinessCriteriaUtility.GetMetricValue(reportData.PreviousSnapshot, id);
                            rowData.Add(prevRes?.ToString() ?? Constants.Zero);
                        }
                        nbRow++;
                        break;
                    }
                }
            }

            int nbCol = (_version == "CURRENT" || _version == "PREVIOUS") ? 2 : 3;

            if ((_version == "BOTH" || _version == "PREVIOUS") && reportData.PreviousSnapshot == null)
            {
                nbCol--;
            }

            TableDefinition resultTable = new TableDefinition
            {
                HasRowHeaders    = true,
                HasColumnHeaders = true,
                NbRows           = nbRow + 1,
                NbColumns        = nbCol,
                Data             = rowData
            };

            return(resultTable);
        }
Exemplo n.º 9
0
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            TableDefinition resultTable = null;
            int             nbLimitTop  = 0;
            string          dataSource  = string.Empty;

            int metricId;

            #region Item ALT
            if (options == null ||
                !options.ContainsKey("ALT") ||
                !int.TryParse(options["ALT"], out metricId))
            {
                metricId = reportData.Parameter.NbResultDefault;
            }
            #endregion Item ALT

            #region Item Count
            if (options == null ||
                !options.ContainsKey("COUNT") ||
                !int.TryParse(options["COUNT"], out nbLimitTop))
            {
                nbLimitTop = reportData.Parameter.NbResultDefault;
            }
            #endregion Item Count

            List <string> rowData = new List <string>();
            int           nbRows  = 0;

            if (reportData.Applications != null && reportData.snapshots != null)
            {
                if (metricId == 60012)
                {
                    rowData.AddRange(new string[] { Labels.Application, Labels.ViolationsCritical, Labels.Changeability, Labels.SnapshotDate });
                }
                else if (metricId == 60014)
                {
                    rowData.AddRange(new string[] { Labels.Application, Labels.ViolationsCritical, Labels.Efficiency, Labels.SnapshotDate });
                }
                else if (metricId == 60013)
                {
                    rowData.AddRange(new string[] { Labels.Application, Labels.ViolationsCritical, Labels.Robustness, Labels.SnapshotDate });
                }
                else if (metricId == 60016)
                {
                    rowData.AddRange(new string[] { Labels.Application, Labels.ViolationsCritical, Labels.Security, Labels.SnapshotDate });
                }
                else if (metricId == 60017)
                {
                    rowData.AddRange(new string[] { Labels.Application, Labels.ViolationsCritical, Labels.TQI, Labels.SnapshotDate });
                }
                else if (metricId == 60011)
                {
                    rowData.AddRange(new string[] { Labels.Application, Labels.ViolationsCritical, Labels.Transferability, Labels.SnapshotDate });
                }



                DataTable dt = new DataTable();
                dt.Columns.Add("AppName", typeof(string));
                dt.Columns.Add("CV", typeof(double));
                dt.Columns.Add("Efficiency", typeof(double));
                dt.Columns.Add("LastAnalysis", typeof(string));


                Application[] AllApps = reportData.Applications;
                for (int j = 0; j < AllApps.Count(); j++)
                {
                    Application App = AllApps[j];

                    int nbSnapshotsEachApp = App.Snapshots.Count();
                    if (nbSnapshotsEachApp > 0)
                    {
                        foreach (Snapshot snapshot in App.Snapshots.OrderByDescending(_ => _.Annotation.Date.DateSnapShot))
                        {
                            Snapshot[] BuiltSnapshots = reportData.snapshots;

                            foreach (Snapshot BuiltSnapshot in BuiltSnapshots)
                            {
                                if (snapshot == BuiltSnapshot)
                                {
                                    string strAppName = App.Name;
                                    double?CV         = 0;
                                    var    results    = RulesViolationUtility.GetStatViolation(BuiltSnapshot);
                                    foreach (var resultModule in results.OrderBy(_ => _.ModuleName))
                                    {
                                        CV = CV + ((resultModule != null && resultModule[(Constants.BusinessCriteria)metricId].Total.HasValue) ?
                                                   resultModule[(Constants.BusinessCriteria)metricId].Total.Value : 0);
                                    }

                                    string currSnapshotLabel = SnapshotUtility.GetSnapshotVersionNumber(BuiltSnapshot);
                                    BusinessCriteriaDTO currSnapshotBisCriDTO = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(BuiltSnapshot, false);

                                    double?strCurrentEfficiency = 0;


                                    if (metricId == 60012)
                                    {
                                        strCurrentEfficiency = currSnapshotBisCriDTO.Changeability.HasValue ? currSnapshotBisCriDTO.Changeability.Value : 0;
                                    }
                                    else if (metricId == 60014)
                                    {
                                        strCurrentEfficiency = currSnapshotBisCriDTO.Performance.HasValue ? currSnapshotBisCriDTO.Performance.Value : 0;
                                    }
                                    else if (metricId == 60013)
                                    {
                                        strCurrentEfficiency = currSnapshotBisCriDTO.Robustness.HasValue ? currSnapshotBisCriDTO.Robustness.Value : 0;
                                    }
                                    else if (metricId == 60016)
                                    {
                                        strCurrentEfficiency = currSnapshotBisCriDTO.Security.HasValue ? currSnapshotBisCriDTO.Security.Value : 0;
                                    }
                                    else if (metricId == 60017)
                                    {
                                        strCurrentEfficiency = currSnapshotBisCriDTO.TQI.HasValue ? currSnapshotBisCriDTO.TQI.Value : 0;
                                    }
                                    else if (metricId == 60011)
                                    {
                                        strCurrentEfficiency = currSnapshotBisCriDTO.Transferability.HasValue ? currSnapshotBisCriDTO.Transferability.Value : 0;
                                    }

                                    string strLastAnalysis = Convert.ToDateTime(BuiltSnapshot.Annotation.Date.DateSnapShot.Value).ToString("MMM dd yyyy");

                                    dt.Rows.Add(strAppName, CV, strCurrentEfficiency, strLastAnalysis);


                                    //            rowData.AddRange
                                    //(new string[] { strAppName.ToString()
                                    //    , CV.ToString()
                                    //    , strCurrentEfficiency.GetValueOrDefault().ToString()
                                    //    , strLastAnalysis.ToString()
                                    //    });

                                    nbRows++;

                                    break;
                                }
                            }
                            break;
                        }
                    }
                    continue;
                }

                DataView dv = dt.DefaultView;
                dv.Sort = "Efficiency";
                DataTable dtSorted = dv.ToTable();

                if (nbRows < nbLimitTop)
                {
                    nbLimitTop = nbRows;
                }

                for (int i = 0; i < nbLimitTop; i++)
                {
                    rowData.AddRange
                        (new string[] {
                        dtSorted.Rows[i]["AppName"].ToString()
                        , dtSorted.Rows[i]["CV"].ToString()
                        , string.Format("{0:0.00}", Convert.ToDouble(dtSorted.Rows[i]["Efficiency"]))
                        , dtSorted.Rows[i]["LastAnalysis"].ToString()
                    });
                }
            }

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

            return(resultTable);
        }
Exemplo n.º 10
0
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            #region METHODS
            TableDefinition resultTable = null;

            string metricFormat = "N2";

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

            int param = 0;

            bool showEvol = false;
            if (options != null && options.ContainsKey("SHOW_EVOL") && int.TryParse(options["SHOW_EVOL"], out param))
            {
                showEvol = (param != 0);
            }

            bool showEvolPercent = true;
            if (options != null && options.ContainsKey("SHOW_EVOL_PERCENT") && int.TryParse(options["SHOW_EVOL_PERCENT"], out param))
            {
                showEvolPercent = (param != 0);
            }

            if (null != reportData &&
                null != reportData.CurrentSnapshot &&
                null != reportData.CurrentSnapshot.BusinessCriteriaResults)
            {
                bool hasPreviousSnapshot = null != reportData.PreviousSnapshot;

                #region currSnapshot
                string currSnapshotLabel = SnapshotUtility.GetSnapshotVersionNumber(reportData.CurrentSnapshot);
                BusinessCriteriaDTO currSnapshotBisCriDTO = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(reportData.CurrentSnapshot, false);
                #endregion  currSnapshot

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

                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 });
                rowData.AddRange(
                    new[] {
                    currSnapshotLabel,
                    currSnapshotBisCriDTO.TQI.HasValue ? currSnapshotBisCriDTO.TQI.Value.ToString(metricFormat) : Constants.No_Value,
                    currSnapshotBisCriDTO.Robustness.HasValue ? currSnapshotBisCriDTO.Robustness.Value.ToString(metricFormat) : Constants.No_Value,
                    currSnapshotBisCriDTO.Performance.HasValue ? currSnapshotBisCriDTO.Performance.Value.ToString(metricFormat) : Constants.No_Value,
                    currSnapshotBisCriDTO.Security.HasValue ? currSnapshotBisCriDTO.Security.Value.ToString(metricFormat) : Constants.No_Value,
                    currSnapshotBisCriDTO.Transferability.HasValue ? currSnapshotBisCriDTO.Transferability.Value.ToString(metricFormat) : Constants.No_Value,
                    currSnapshotBisCriDTO.Changeability.HasValue ? currSnapshotBisCriDTO.Changeability.Value.ToString(metricFormat) : Constants.No_Value
                });

                if (hasPreviousSnapshot)
                {
                    #region variation
                    BusinessCriteriaDTO BusinessCriteriaGradesEvol        = hasPreviousSnapshot ? (currSnapshotBisCriDTO - prevSnapshotBisCriDTO) : null;
                    BusinessCriteriaDTO BusinessCriteriaGradesEvolPercent = hasPreviousSnapshot ? (BusinessCriteriaGradesEvol / prevSnapshotBisCriDTO) : null;
                    #endregion  variation

                    rowData.AddRange(
                        new[] {
                        prevSnapshotLabel,
                        prevSnapshotBisCriDTO.TQI.HasValue?prevSnapshotBisCriDTO.TQI.Value.ToString(metricFormat):Constants.No_Value,
                        prevSnapshotBisCriDTO.Robustness.HasValue?prevSnapshotBisCriDTO.Robustness.Value.ToString(metricFormat):Constants.No_Value,
                        prevSnapshotBisCriDTO.Performance.HasValue?prevSnapshotBisCriDTO.Performance.Value.ToString(metricFormat):Constants.No_Value,
                        prevSnapshotBisCriDTO.Security.HasValue?prevSnapshotBisCriDTO.Security.Value.ToString(metricFormat):Constants.No_Value,
                        prevSnapshotBisCriDTO.Transferability.HasValue?prevSnapshotBisCriDTO.Transferability.Value.ToString(metricFormat):Constants.No_Value,
                        prevSnapshotBisCriDTO.Changeability.HasValue?prevSnapshotBisCriDTO.Changeability.Value.ToString(metricFormat):Constants.No_Value,
                    });

                    if (showEvol)
                    {
                        rowData.AddRange(
                            new[] {
                            Labels.Evol,
                            BusinessCriteriaGradesEvol.TQI.HasValue ? FormatEvolution(BusinessCriteriaGradesEvol.TQI.Value) : Constants.No_Value,
                            BusinessCriteriaGradesEvol.Robustness.HasValue ? FormatEvolution(BusinessCriteriaGradesEvol.Robustness.Value) : Constants.No_Value,
                            BusinessCriteriaGradesEvol.Performance.HasValue ? FormatEvolution(BusinessCriteriaGradesEvol.Performance.Value) : Constants.No_Value,
                            BusinessCriteriaGradesEvol.Security.HasValue ? FormatEvolution(BusinessCriteriaGradesEvol.Security.Value) : Constants.No_Value,
                            BusinessCriteriaGradesEvol.Transferability.HasValue ? FormatEvolution(BusinessCriteriaGradesEvol.Transferability.Value) : Constants.No_Value,
                            BusinessCriteriaGradesEvol.Changeability.HasValue ? FormatEvolution(BusinessCriteriaGradesEvol.Changeability.Value) : Constants.No_Value
                        });
                    }

                    if (showEvolPercent)
                    {
                        rowData.AddRange(
                            new[] {
                            Labels.EvolPercent,
                            BusinessCriteriaGradesEvolPercent.TQI.HasValue ? FormatPercent(BusinessCriteriaGradesEvolPercent.TQI.Value) : Constants.No_Value,
                            BusinessCriteriaGradesEvolPercent.Robustness.HasValue ? FormatPercent(BusinessCriteriaGradesEvolPercent.Robustness.Value) : Constants.No_Value,
                            BusinessCriteriaGradesEvolPercent.Performance.HasValue ? FormatPercent(BusinessCriteriaGradesEvolPercent.Performance.Value) : Constants.No_Value,
                            BusinessCriteriaGradesEvolPercent.Security.HasValue ? FormatPercent(BusinessCriteriaGradesEvolPercent.Security.Value) : Constants.No_Value,
                            BusinessCriteriaGradesEvolPercent.Transferability.HasValue ? FormatPercent(BusinessCriteriaGradesEvolPercent.Transferability.Value) : Constants.No_Value,
                            BusinessCriteriaGradesEvolPercent.Changeability.HasValue ? FormatPercent(BusinessCriteriaGradesEvolPercent.Changeability.Value) : Constants.No_Value
                        });
                    }
                }

                resultTable = new TableDefinition {
                    HasRowHeaders    = false,
                    HasColumnHeaders = true,
                    NbRows           = hasPreviousSnapshot ? 4 : 2,
                    NbColumns        = 7,
                    Data             = rowData
                };
            }
            return(resultTable);
        }
Exemplo n.º 11
0
        public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            string prevSnapshotLabel = string.Empty;
            BusinessCriteriaDTO prevSnapshotBCResult = null;

            if (reportData?.CurrentSnapshot == null)
            {
                return(null);
            }
            string currSnapshotLabel = SnapshotUtility.GetSnapshotVersionNumber(reportData.CurrentSnapshot);
            BusinessCriteriaDTO _currSnapshotBcdto = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(reportData.CurrentSnapshot, true);

            if (reportData.PreviousSnapshot != null)
            {
                prevSnapshotLabel    = SnapshotUtility.GetSnapshotVersionNumber(reportData.PreviousSnapshot);
                prevSnapshotBCResult = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(reportData.PreviousSnapshot, true);
            }
            else
            {
                Snapshot _previousSnapshot = reportData.Application.Snapshots?.FirstOrDefault(_ => _.Annotation.Date.DateSnapShot < reportData.CurrentSnapshot.Annotation.Date.DateSnapShot);
                if (_previousSnapshot != null)
                {
                    prevSnapshotLabel    = SnapshotUtility.GetSnapshotVersionNumber(_previousSnapshot);
                    prevSnapshotBCResult = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(_previousSnapshot, true);
                }
            }


            var rowData = new List <string> {
                null, currSnapshotLabel
            };

            if (prevSnapshotBCResult != null)
            {
                rowData.Add(prevSnapshotLabel ?? Constants.No_Value);
            }


            #region Programming Practices
            rowData.Add(Labels.Prog);
            rowData.Add(_currSnapshotBcdto.ProgrammingPractices.ToString());
            if (prevSnapshotBCResult != null)
            {
                rowData.Add(prevSnapshotBCResult.ProgrammingPractices.ToString());
            }
            #endregion Programming Practices

            #region Architectural Design
            rowData.Add(Labels.Arch);
            rowData.Add(_currSnapshotBcdto.ArchitecturalDesign.ToString());
            if (prevSnapshotBCResult != null)
            {
                rowData.Add(prevSnapshotBCResult.ArchitecturalDesign.ToString());
            }
            #endregion Architectural Design

            #region Documentation
            rowData.Add(Labels.Doc);
            rowData.Add(_currSnapshotBcdto.Documentation.ToString());
            if (prevSnapshotBCResult != null)
            {
                rowData.Add(prevSnapshotBCResult.Documentation.ToString());
            }
            #endregion Documentation


            TableDefinition resultTable = new TableDefinition
            {
                HasRowHeaders    = true,
                HasColumnHeaders = true,
                NbRows           = 4,
                NbColumns        = (prevSnapshotBCResult != null) ? 3 : 2,
                Data             = rowData
            };

            return(resultTable);
        }
        public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            string prop1      = options.GetOption("PROP1", "cyclomaticComplexity");
            string prop2      = options.GetOption("PROP2", "cyclomaticComplexity");
            string order1     = options.GetOption("ORDER1", "desc");
            string order2     = options.GetOption("ORDER2", "desc");
            int    nbLimitTop = options.GetIntOption("COUNT", 50);

            if (!order1.ToLower().Equals("asc") && !order1.ToLower().Equals("desc"))
            {
                order1 = "desc";
            }
            if (!order2.ToLower().Equals("asc") && !order2.ToLower().Equals("desc"))
            {
                order2 = "desc";
            }

            if (nbLimitTop == -1)
            {
                nbLimitTop = 50;
            }

            List <string> rowData = new List <string> {
                Labels.ObjectName
            };

            if (!VersionUtil.Is18Compatible(reportData.ServerVersion))
            {
                LogHelper.Instance.LogError("Bad version of RestAPI. Should be 1.8 at least for component TOP_COMPONENTS_BY_PROPERTIES");
                rowData.Add(Labels.NoData);
                return(new TableDefinition
                {
                    HasRowHeaders = false,
                    HasColumnHeaders = true,
                    NbRows = 2,
                    NbColumns = 1,
                    Data = rowData
                });
            }

            string _prop1Name = MetricsUtility.GetPropertyName(prop1);

            rowData.Add(_prop1Name);
            string _prop2Name = MetricsUtility.GetPropertyName(prop2);

            rowData.Add(_prop2Name);

            if (_prop1Name == string.Empty || _prop2Name == string.Empty)
            {
                rowData.AddRange(new List <string>()
                {
                    Labels.PropertiesNotAvailable, string.Empty, string.Empty
                });
                rowData.AddRange(new List <string>()
                {
                    "codeLines", string.Empty, string.Empty,
                    "commentedCodeLines", string.Empty, string.Empty,
                    "commentLines", string.Empty, string.Empty,
                    "coupling", string.Empty, string.Empty,
                    "fanIn", string.Empty, string.Empty,
                    "fanOut", string.Empty, string.Empty,
                    "cyclomaticComplexity", string.Empty, string.Empty,
                    "ratioCommentLinesCodeLines", string.Empty, string.Empty,
                    "halsteadProgramLength", string.Empty, string.Empty,
                    "halsteadProgramVocabulary", string.Empty, string.Empty,
                    "halsteadVolume", string.Empty, string.Empty,
                    "distinctOperators", string.Empty, string.Empty,
                    "distinctOperands", string.Empty, string.Empty,
                    "integrationComplexity", string.Empty, string.Empty,
                    "essentialComplexity", string.Empty, string.Empty
                });
                nbLimitTop = 16;
            }
            else
            {
                if (SnapshotUtility.IsLatestSnapshot(reportData.Application, reportData.CurrentSnapshot))
                {
                    List <ComponentWithProperties> components = reportData.SnapshotExplorer.GetComponentsByProperties(reportData.CurrentSnapshot.Href, 60017, prop1, prop2, order1, order2, nbLimitTop).ToList();
                    if (components.Count <= 0)
                    {
                        rowData.AddRange(new List <string> {
                            Labels.NoData, string.Empty, string.Empty
                        });
                    }
                    else
                    {
                        foreach (ComponentWithProperties _component in components)
                        {
                            rowData.Add(_component.Name);
                            rowData.Add(_component.GetPropertyValueString(prop1));
                            rowData.Add(_component.GetPropertyValueString(prop2));
                        }
                    }
                }
                else
                {
                    rowData.AddRange(new List <string> {
                        Labels.SnapshotNotTheLatestOne, string.Empty, string.Empty
                    });
                }
            }


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

            return(resultTable);
        }