Exemplo n.º 1
0
        public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            int count = 0;

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

            rowData.AddRange(new[] {
                Labels.TQI,
                Labels.ViolationsCritical + "/" + Labels.kLoC,
                Labels.AutomatedFP,
                Labels.Application
            });

            #region Fetch SnapshotsPF

            if (reportData?.Applications != null && reportData.Snapshots != null)
            {
                Application[] _allApps = reportData.Applications;
                foreach (Application _app in _allApps)
                {
                    Snapshot _snapshot = _app.Snapshots.OrderByDescending(_ => _.Annotation.Date.DateSnapShot).First();

                    BusinessCriteriaDTO currSnapshotBisCriDTO = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(_snapshot, false);
                    double?strCurrentTQI   = currSnapshotBisCriDTO.TQI ?? 0;
                    double?_numCritPerKloc = MeasureUtility.GetSizingMeasure(_snapshot, Constants.SizingInformations.ViolationsToCriticalQualityRulesPerKLOCNumber);
                    double?result          = MeasureUtility.GetAutomatedIFPUGFunction(_snapshot);

                    rowData.Add(strCurrentTQI.GetValueOrDefault().ToString("N2"));
                    rowData.Add(_numCritPerKloc.GetValueOrDefault().ToString("N2"));
                    rowData.Add(result.GetValueOrDefault().ToString(CultureInfo.CurrentCulture));
                    rowData.Add(_app.Name);

                    count++;
                }

                if (reportData.Applications.Length == 1)
                {
                    rowData.AddRange(new[] { "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.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <returns></returns>
        public static BusinessCriteriaDTO operator /(BusinessCriteriaDTO left, BusinessCriteriaDTO right)
        {
            BusinessCriteriaDTO _getBusinessCriteriaGradesVartiation = new BusinessCriteriaDTO();

            if (left == null || right == null)
            {
                return(_getBusinessCriteriaGradesVartiation);
            }

            _getBusinessCriteriaGradesVartiation.TQI             = (right.TQI.Equals(0.00) ? 0 : left.TQI / right.TQI);
            _getBusinessCriteriaGradesVartiation.Robustness      = (right.Robustness.Equals(0.00) ? 0 : left.Robustness / right.Robustness);
            _getBusinessCriteriaGradesVartiation.Performance     = (right.Performance.Equals(0.00) ? 0 : left.Performance / right.Performance);
            _getBusinessCriteriaGradesVartiation.Security        = (right.Security.Equals(0.00) ? 0 : left.Security / right.Security);
            _getBusinessCriteriaGradesVartiation.Transferability = (right.Transferability.Equals(0.00) ? 0 : left.Transferability / right.Transferability);
            _getBusinessCriteriaGradesVartiation.Changeability   = (right.Changeability.Equals(0.00) ? 0 : left.Changeability / right.Changeability);
            return(_getBusinessCriteriaGradesVartiation);
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <returns></returns>
        public static BusinessCriteriaDTO operator -(BusinessCriteriaDTO left, BusinessCriteriaDTO right)
        {
            BusinessCriteriaDTO _getBusinessCriteriaGradesVartiation = new BusinessCriteriaDTO();

            if (left == null || right == null)
            {
                return(_getBusinessCriteriaGradesVartiation);
            }

            _getBusinessCriteriaGradesVartiation.TQI             = (left.TQI.HasValue && right.TQI.HasValue) ? left.TQI - right.TQI : null;
            _getBusinessCriteriaGradesVartiation.Robustness      = (left.Robustness.HasValue && right.Robustness.HasValue) ? left.Robustness - right.Robustness : null;
            _getBusinessCriteriaGradesVartiation.Performance     = (left.Performance.HasValue && right.Performance.HasValue) ? left.Performance - right.Performance : null;
            _getBusinessCriteriaGradesVartiation.Security        = (left.Security.HasValue && right.Security.HasValue) ? left.Security - right.Security : null;
            _getBusinessCriteriaGradesVartiation.Transferability = (left.Transferability.HasValue && right.Transferability.HasValue) ? left.Transferability - right.Transferability : null;
            _getBusinessCriteriaGradesVartiation.Changeability   = (left.Changeability.HasValue && right.Changeability.HasValue) ? left.Changeability - right.Changeability : null;
            return(_getBusinessCriteriaGradesVartiation);
        }
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 TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            double minValy = short.MaxValue;
            double maxValy = 0;
            double stepV;
            int    count = 0;

            bool hasVerticalZoom = options.ContainsKey("ZOOM");

            if (!options.ContainsKey("ZOOM") || !double.TryParse(options["ZOOM"], out stepV))
            {
                stepV = 1;
            }


            var rowData = new List <string>();

            rowData.AddRange(new[] {
                " ",
                Labels.Prog,
                Labels.Arch,
                Labels.Doc,
                Labels.LoC
            });


            #region Previous Snapshots

            var nbSnapshots = reportData?.Application.Snapshots?.Count() ?? 0;
            if (nbSnapshots > 0)
            {
                var _snapshots = reportData?.Application?.Snapshots?.OrderBy(_ => _.Annotation.Date.DateSnapShot);
                if (_snapshots != null)
                {
                    foreach (Snapshot snapshot in _snapshots)
                    {
                        BusinessCriteriaDTO bcGrade = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(snapshot, true);
                        double?locValue             = MeasureUtility.GetCodeLineNumber(snapshot);
                        string prevSnapshotDate     = snapshot.Annotation.Date.DateSnapShot?.ToOADate().ToString(CultureInfo.CurrentCulture) ?? string.Empty;
                        rowData.Add(prevSnapshotDate);
                        rowData.Add(bcGrade.ProgrammingPractices.GetValueOrDefault().ToString(CultureInfo.CurrentCulture));
                        rowData.Add(bcGrade.ArchitecturalDesign.GetValueOrDefault().ToString(CultureInfo.CurrentCulture));
                        rowData.Add(bcGrade.Documentation.GetValueOrDefault().ToString(CultureInfo.CurrentCulture));
                        rowData.Add(locValue.GetValueOrDefault().ToString(CultureInfo.CurrentCulture));

                        List <double> values = new List <double>
                        {
                            bcGrade.ProgrammingPractices.GetValueOrDefault(),
                                      bcGrade.ArchitecturalDesign.GetValueOrDefault(),
                                      bcGrade.Documentation.GetValueOrDefault()
                        };
                        minValy = Math.Min(minValy, values.Min());
                        maxValy = Math.Max(maxValy, values.Max());
                    }
                }
                count = nbSnapshots;
            }
            #endregion Previous Snapshots

            #region just 1 snapshot
            if (nbSnapshots == 1)
            {
                BusinessCriteriaDTO bcGrade = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(reportData?.CurrentSnapshot, true);
                double?locValue             = MeasureUtility.GetCodeLineNumber(reportData?.CurrentSnapshot);
                string prevSnapshotDate     = reportData?.CurrentSnapshot.Annotation.Date.DateSnapShot?.ToOADate().ToString(CultureInfo.CurrentCulture) ?? string.Empty;
                rowData.AddRange
                    (new[] { prevSnapshotDate
                             , bcGrade.ProgrammingPractices.GetValueOrDefault().ToString(CultureInfo.CurrentCulture)
                             , bcGrade.ArchitecturalDesign.GetValueOrDefault().ToString(CultureInfo.CurrentCulture)
                             , bcGrade.Documentation.GetValueOrDefault().ToString(CultureInfo.CurrentCulture)
                             , locValue.GetValueOrDefault().ToString(CultureInfo.CurrentCulture) });

                List <double> values = new List <double>()
                {
                    bcGrade.ProgrammingPractices.GetValueOrDefault(),
                              bcGrade.ArchitecturalDesign.GetValueOrDefault(),
                              bcGrade.Documentation.GetValueOrDefault()
                };
                minValy = Math.Min(minValy, values.Min());
                maxValy = Math.Max(maxValy, values.Max());
                count   = count + 1;
            }
            #endregion just 1 snapshot


            #region Graphic Options
            GraphOptions graphOptions = null;
            if (hasVerticalZoom)
            {
                graphOptions = new GraphOptions()
                {
                    AxisConfiguration = new AxisDefinition()
                };
                graphOptions.AxisConfiguration.VerticalAxisMinimal = MathUtility.GetVerticalMinValue(minValy, stepV);
                graphOptions.AxisConfiguration.VerticalAxisMaximal = MathUtility.GetVerticalMaxValue(maxValy, stepV);
            }
            #endregion Graphic Options

            TableDefinition resultTable = new TableDefinition {
                HasRowHeaders    = true,
                HasColumnHeaders = false,
                NbRows           = count + 1,
                NbColumns        = 5,
                Data             = rowData,
                GraphOptions     = graphOptions
            };


            return(resultTable);
        }
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
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            double minVVal = Int16.MaxValue;
            double maxVVal = 0;
            double stepV   = 0;
            int    count   = 0;

            bool hasVerticalZoom = options.ContainsKey("ZOOM");

            if (!options.ContainsKey("ZOOM") || !Double.TryParse(options["ZOOM"], out stepV))
            {
                stepV = 1;
            }

            var rowData = new List <String>();

            rowData.AddRange(new string[] {
                " ",
                Labels.Trans,
                Labels.Chang,
                Labels.Robu,
                Labels.Efcy,
                Labels.Secu,
                Labels.LoC
            });


            #region Fetch Snapshots
            int nbSnapshots = (reportData != null && reportData.Application.Snapshots != null) ? reportData.Application.Snapshots.Count() : 0;
            if (nbSnapshots > 0)
            {
                foreach (Snapshot snapshot in reportData.Application.Snapshots.OrderBy(_ => _.Annotation.Date))
                {
                    BusinessCriteriaDTO bcGrade = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(snapshot, true);
                    double?locValue             = MeasureUtility.GetCodeLineNumber(snapshot);
                    string snapshotDate         = snapshot.Annotation.Date.DateSnapShot.HasValue ? snapshot.Annotation.Date.DateSnapShot.Value.ToOADate().ToString()
                                                                                                : string.Empty;
                    rowData.AddRange(new string[] {
                        snapshotDate,
                        bcGrade.Transferability.GetValueOrDefault().ToString(),
                        bcGrade.Changeability.GetValueOrDefault().ToString(),
                        bcGrade.Robustness.GetValueOrDefault().ToString(),
                        bcGrade.Performance.GetValueOrDefault().ToString(),
                        bcGrade.Security.GetValueOrDefault().ToString(),
                        locValue.GetValueOrDefault().ToString(),
                    });
                    List <double> values = new List <double>()
                    {
                        bcGrade.Changeability.GetValueOrDefault(),
                                  bcGrade.Performance.GetValueOrDefault(),
                                  bcGrade.Robustness.GetValueOrDefault(),
                                  bcGrade.Security.GetValueOrDefault(),
                                  bcGrade.TQI.GetValueOrDefault(),
                                  bcGrade.Transferability.GetValueOrDefault()
                    };
                    minVVal = Math.Min(minVVal, values.Min());
                    maxVVal = Math.Max(maxVVal, values.Max());
                }
                count = nbSnapshots;
            }
            #endregion

            #region just 1 snapshot
            if (nbSnapshots == 1)
            {
                BusinessCriteriaDTO bcGrade = new BusinessCriteriaDTO();
                bcGrade = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(reportData.CurrentSnapshot, true);
                double?locValue     = MeasureUtility.GetCodeLineNumber(reportData.CurrentSnapshot);
                string snapshotDate = reportData.CurrentSnapshot.Annotation.Date.DateSnapShot.HasValue ? reportData.CurrentSnapshot.Annotation.Date.DateSnapShot.Value.ToOADate().ToString()
                                                                                                   : string.Empty;
                rowData.AddRange(new string[] {
                    snapshotDate,
                    bcGrade.Transferability.GetValueOrDefault().ToString(),
                    bcGrade.Changeability.GetValueOrDefault().ToString(),
                    bcGrade.Robustness.GetValueOrDefault().ToString(),
                    bcGrade.Performance.GetValueOrDefault().ToString(),
                    bcGrade.Security.GetValueOrDefault().ToString(),
                    locValue.GetValueOrDefault().ToString(),
                });
                List <double> values = new List <double>()
                {
                    bcGrade.Changeability.GetValueOrDefault(),
                              bcGrade.Performance.GetValueOrDefault(),
                              bcGrade.Robustness.GetValueOrDefault(),
                              bcGrade.Security.GetValueOrDefault(),
                              bcGrade.TQI.GetValueOrDefault(),
                              bcGrade.Transferability.GetValueOrDefault()
                };
                minVVal = Math.Min(minVVal, values.Min());
                maxVVal = Math.Max(maxVVal, values.Max());
                count   = count + 1;
            }
            #endregion just 1 snapshot



            #region Graphic Options
            GraphOptions graphOptions = null;
            if (hasVerticalZoom)
            {
                graphOptions = new GraphOptions()
                {
                    AxisConfiguration = new AxisDefinition()
                };
                graphOptions.AxisConfiguration.VerticalAxisMinimal = MathUtility.GetVerticalMinValue(minVVal, stepV);
                graphOptions.AxisConfiguration.VerticalAxisMaximal = MathUtility.GetVerticalMaxValue(maxVVal, stepV);
            }
            #endregion Graphic Options

            TableDefinition resultTable = new TableDefinition {
                HasRowHeaders    = true,
                HasColumnHeaders = false,
                NbRows           = count + 1,
                NbColumns        = 7,
                Data             = rowData,
                GraphOptions     = graphOptions
            };


            return(resultTable);
        }
        public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            string strTargets = options.GetOption("BF", string.Empty);
            string _strSla    = options.GetOption("SLA", string.Empty);

            List <string> rowData = new List <string>();
            List <double> _tagIds = new List <double>();
            List <double> _slAs   = new List <double>();

            if (!string.IsNullOrEmpty(strTargets))
            {
                string[] words = strTargets.Split(' ');
                _tagIds.AddRange(words.Select(word => Convert.ToDouble(word, System.Globalization.CultureInfo.InvariantCulture)));
            }

            if (!string.IsNullOrEmpty(_strSla))
            {
                string[] words = _strSla.Split(' ');
                _slAs.AddRange(words.Select(word => Convert.ToDouble(word, System.Globalization.CultureInfo.InvariantCulture)));
            }

            if (reportData.Applications != null && reportData.Snapshots != null)
            {
                int nbCurrentSnapshots  = 0;
                int nbPreviousSnapshots = 0;

                double?strCurrentArchDesignAll  = 0;
                double?strCurrentRobuAll        = 0;
                double?strCurrentSecuAll        = 0;
                double?strCurrentPerformanceAll = 0;
                double?strCurrentChangeAll      = 0;
                double?strCurrentTransferAll    = 0;
                double?strCurrentProgrammingAll = 0;
                double?strCurrentDocumentAll    = 0;

                double?strPreviousArchDesignAll  = 0;
                double?strPreviousRobuAll        = 0;
                double?strPreviousSecuAll        = 0;
                double?strPreviousPerformanceAll = 0;
                double?strPreviousChangeAll      = 0;
                double?strPreviousTransferAll    = 0;
                double?strPreviousProgrammingAll = 0;
                double?strPreviousDocumentAll    = 0;

                rowData.AddRange(new[] { Labels.BusinessCriterionName, Labels.PreviousScore, Labels.Target, Labels.CurrentScore, Labels.SLAViolations });

                Application[] _allApps = reportData.Applications;
                foreach (Application _app in _allApps)
                {
                    try
                    {
                        Snapshot _snapshot = _app.Snapshots.OrderByDescending(_ => _.Annotation.Date.DateSnapShot).First();
                        if (_snapshot != null)
                        {
                            nbCurrentSnapshots = nbCurrentSnapshots + 1;
                            BusinessCriteriaDTO currSnapshotBisCriDTO = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(_snapshot, false);

                            double?strCurrentArchDesign  = currSnapshotBisCriDTO.ArchitecturalDesign ?? 0;
                            double?strCurrentRobu        = currSnapshotBisCriDTO.Robustness ?? 0;
                            double?strCurrentSecu        = currSnapshotBisCriDTO.Security ?? 0;
                            double?strCurrentPerformance = currSnapshotBisCriDTO.Performance ?? 0;
                            double?strCurrentChange      = currSnapshotBisCriDTO.Changeability ?? 0;
                            double?strCurrentTransfer    = currSnapshotBisCriDTO.Transferability ?? 0;
                            double?strCurrentProgramming = currSnapshotBisCriDTO.ProgrammingPractices ?? 0;
                            double?strCurrentDocument    = currSnapshotBisCriDTO.Documentation ?? 0;

                            strCurrentArchDesignAll  = strCurrentArchDesignAll + strCurrentArchDesign;
                            strCurrentRobuAll        = strCurrentRobuAll + strCurrentRobu;
                            strCurrentSecuAll        = strCurrentSecuAll + strCurrentSecu;
                            strCurrentPerformanceAll = strCurrentPerformanceAll + strCurrentPerformance;
                            strCurrentChangeAll      = strCurrentChangeAll + strCurrentChange;
                            strCurrentTransferAll    = strCurrentTransferAll + strCurrentTransfer;
                            strCurrentProgrammingAll = strCurrentProgrammingAll + strCurrentProgramming;
                            strCurrentDocumentAll    = strCurrentDocumentAll + strCurrentDocument;
                        }

                        DateTime _dateNow        = DateTime.Now;
                        int      previousQuarter = DateUtil.GetPreviousQuarter(_dateNow);
                        int      previousYear    = DateUtil.GetPreviousQuarterYear(_dateNow);

                        Snapshot _previous = _app.Snapshots.Where(_ => _.Annotation.Date.DateSnapShot != null &&
                                                                  ((_.Annotation.Date.DateSnapShot.Value.Year <= previousYear && DateUtil.GetQuarter(_.Annotation.Date.DateSnapShot.Value) <= previousQuarter) || (_.Annotation.Date.DateSnapShot.Value.Year < previousYear)))
                                             .OrderByDescending(_ => _.Annotation.Date.DateSnapShot)
                                             .First();

                        if (_previous == null)
                        {
                            continue;
                        }
                        nbPreviousSnapshots = nbPreviousSnapshots + 1;
                        BusinessCriteriaDTO prevSnapshotBisCriDTO = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(_previous, false);

                        double?strPreviousArchDesign  = prevSnapshotBisCriDTO.ArchitecturalDesign.HasValue ? MathUtility.GetRound(prevSnapshotBisCriDTO.ArchitecturalDesign.Value) : 0;
                        double?strPreviousRobu        = prevSnapshotBisCriDTO.Robustness.HasValue ? MathUtility.GetRound(prevSnapshotBisCriDTO.Robustness.Value) : 0;
                        double?strPreviousSecu        = prevSnapshotBisCriDTO.Security.HasValue ? MathUtility.GetRound(prevSnapshotBisCriDTO.Security.Value) : 0;
                        double?strPreviousPerformance = prevSnapshotBisCriDTO.Performance.HasValue ? MathUtility.GetRound(prevSnapshotBisCriDTO.Performance.Value) : 0;
                        double?strPreviousChange      = prevSnapshotBisCriDTO.Changeability.HasValue ? MathUtility.GetRound(prevSnapshotBisCriDTO.Changeability.Value) : 0;
                        double?strPreviousTransfer    = prevSnapshotBisCriDTO.Transferability.HasValue ? MathUtility.GetRound(prevSnapshotBisCriDTO.Transferability.Value) : 0;
                        double?strPreviousProgramming = prevSnapshotBisCriDTO.ProgrammingPractices.HasValue ? MathUtility.GetRound(prevSnapshotBisCriDTO.ProgrammingPractices.Value) : 0;
                        double?strPreviousDocument    = prevSnapshotBisCriDTO.Documentation.HasValue ? MathUtility.GetRound(prevSnapshotBisCriDTO.Documentation.Value) : 0;

                        strPreviousArchDesignAll  = strPreviousArchDesignAll + strPreviousArchDesign;
                        strPreviousRobuAll        = strPreviousRobuAll + strPreviousRobu;
                        strPreviousSecuAll        = strPreviousSecuAll + strPreviousSecu;
                        strPreviousPerformanceAll = strPreviousPerformanceAll + strPreviousPerformance;
                        strPreviousChangeAll      = strPreviousChangeAll + strPreviousChange;
                        strPreviousTransferAll    = strPreviousTransferAll + strPreviousTransfer;
                        strPreviousProgrammingAll = strPreviousProgrammingAll + strPreviousProgramming;
                        strPreviousDocumentAll    = strPreviousDocumentAll + strPreviousDocument;
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Instance.LogInfo(ex.Message);
                        LogHelper.Instance.LogInfo(Labels.NoSnapshot);
                    }
                }

                strCurrentRobuAll        = strCurrentRobuAll / nbCurrentSnapshots;
                strCurrentSecuAll        = strCurrentSecuAll / nbCurrentSnapshots;
                strCurrentPerformanceAll = strCurrentPerformanceAll / nbCurrentSnapshots;
                strCurrentChangeAll      = strCurrentChangeAll / nbCurrentSnapshots;
                strCurrentTransferAll    = strCurrentTransferAll / nbCurrentSnapshots;
                strCurrentProgrammingAll = strCurrentProgrammingAll / nbCurrentSnapshots;
                strCurrentDocumentAll    = strCurrentDocumentAll / nbCurrentSnapshots;
                strCurrentArchDesignAll  = strCurrentArchDesignAll / nbCurrentSnapshots;

                if (_tagIds.Count == 8 && _slAs.Count == 2)
                {
                    double?lower = Math.Round(_slAs[0] / 100, 2);
                    double?upper = Math.Round(_slAs[1] / 100, 2);

                    string _robustnessSlaViol          = (_tagIds[0] - strCurrentRobuAll) / _tagIds[0] > upper ? Labels.Bad : (_tagIds[0] - strCurrentRobuAll) / _tagIds[0] > lower ? Labels.Acceptable : Labels.Good;
                    string _securitySlaViol            = (_tagIds[1] - strCurrentSecuAll) / _tagIds[1] > upper ? Labels.Bad : (_tagIds[1] - strCurrentSecuAll) / _tagIds[1] > lower ? Labels.Acceptable : Labels.Good;
                    string _performanceSlaViol         = (_tagIds[2] - strCurrentPerformanceAll) / _tagIds[2] > upper ? Labels.Bad : (_tagIds[2] - strCurrentPerformanceAll) / _tagIds[2] > lower ? Labels.Acceptable : Labels.Good;
                    string _changeabilitySlaViol       = (_tagIds[3] - strCurrentChangeAll) / _tagIds[3] > upper ? Labels.Bad : (_tagIds[3] - strCurrentChangeAll) / _tagIds[3] > lower ? Labels.Acceptable : Labels.Good;
                    string _transferabilitySlaViol     = (_tagIds[4] - strCurrentTransferAll) / _tagIds[4] > upper ? Labels.Bad : (_tagIds[4] - strCurrentTransferAll) / _tagIds[4] > lower ? Labels.Acceptable : Labels.Good;
                    string _programmingPracticeSlaViol = (_tagIds[5] - strCurrentProgrammingAll) / _tagIds[5] > upper ? Labels.Bad : (_tagIds[5] - strCurrentProgrammingAll) / _tagIds[5] > lower ? Labels.Acceptable : Labels.Good;
                    string _documentationSlaViol       = (_tagIds[6] - strCurrentDocumentAll) / _tagIds[6] > upper ? Labels.Bad : (_tagIds[6] - strCurrentDocumentAll) / _tagIds[6] > lower ? Labels.Acceptable : Labels.Good;
                    string _architectureSlaViol        = (_tagIds[7] - strCurrentArchDesignAll) / _tagIds[7] > upper ? Labels.Bad : (_tagIds[7] - strCurrentArchDesignAll) / _tagIds[7] > lower ? Labels.Acceptable : Labels.Good;

                    if (nbPreviousSnapshots != 0)
                    {
                        strPreviousArchDesignAll  = strPreviousArchDesignAll / nbPreviousSnapshots;
                        strPreviousRobuAll        = strPreviousRobuAll / nbPreviousSnapshots;
                        strPreviousSecuAll        = strPreviousSecuAll / nbPreviousSnapshots;
                        strPreviousPerformanceAll = strPreviousPerformanceAll / nbPreviousSnapshots;
                        strPreviousChangeAll      = strPreviousChangeAll / nbPreviousSnapshots;
                        strPreviousTransferAll    = strPreviousTransferAll / nbPreviousSnapshots;
                        strPreviousProgrammingAll = strPreviousProgrammingAll / nbPreviousSnapshots;
                        strPreviousDocumentAll    = strPreviousDocumentAll / nbPreviousSnapshots;

                        rowData.AddRange(new[] { Labels.Robustness, strPreviousRobuAll.Value.ToString("N2"), _tagIds[0].ToString("N2"), strCurrentRobuAll.Value.ToString("N2"), _robustnessSlaViol });
                        rowData.AddRange(new[] { Labels.Security, strPreviousSecuAll.Value.ToString("N2"), _tagIds[1].ToString("N2"), strCurrentSecuAll.Value.ToString("N2"), _securitySlaViol });
                        rowData.AddRange(new[] { Labels.Efficiency, strPreviousPerformanceAll.Value.ToString("N2"), _tagIds[2].ToString("N2"), strCurrentPerformanceAll.Value.ToString("N2"), _performanceSlaViol });
                        rowData.AddRange(new[] { Labels.Changeability, strPreviousChangeAll.Value.ToString("N2"), _tagIds[3].ToString("N2"), strCurrentChangeAll.Value.ToString("N2"), _changeabilitySlaViol });
                        rowData.AddRange(new[] { Labels.Transferability, strPreviousTransferAll.Value.ToString("N2"), _tagIds[4].ToString("N2"), strCurrentTransferAll.Value.ToString("N2"), _transferabilitySlaViol });
                        rowData.AddRange(new[] { Labels.ProgrammingPractices, strPreviousProgrammingAll.Value.ToString("N2"), _tagIds[5].ToString("N2"), strCurrentProgrammingAll.Value.ToString("N2"), _programmingPracticeSlaViol });
                        rowData.AddRange(new[] { Labels.Documentation, strPreviousDocumentAll.Value.ToString("N2"), _tagIds[6].ToString("N2"), strCurrentDocumentAll.Value.ToString("N2"), _documentationSlaViol });
                        rowData.AddRange(new[] { Labels.ArchitecturalDesign, strPreviousArchDesignAll.Value.ToString("N2"), _tagIds[7].ToString("N2"), strCurrentArchDesignAll.Value.ToString("N2"), _architectureSlaViol });
                    }
                    else
                    {
                        rowData.AddRange(new[] { Labels.Robustness, Constants.No_Data, _tagIds[0].ToString("N2"), strCurrentRobuAll.Value.ToString("N2"), _robustnessSlaViol });
                        rowData.AddRange(new[] { Labels.Security, Constants.No_Data, _tagIds[1].ToString("N2"), strCurrentSecuAll.Value.ToString("N2"), _securitySlaViol });
                        rowData.AddRange(new[] { Labels.Efficiency, Constants.No_Data, _tagIds[2].ToString("N2"), strCurrentPerformanceAll.Value.ToString("N2"), _performanceSlaViol });
                        rowData.AddRange(new[] { Labels.Changeability, Constants.No_Data, _tagIds[3].ToString("N2"), strCurrentChangeAll.Value.ToString("N2"), _changeabilitySlaViol });
                        rowData.AddRange(new[] { Labels.Transferability, Constants.No_Data, _tagIds[4].ToString("N2"), strCurrentTransferAll.Value.ToString("N2"), _transferabilitySlaViol });
                        rowData.AddRange(new[] { Labels.ProgrammingPractices, Constants.No_Data, _tagIds[5].ToString("N2"), strCurrentProgrammingAll.Value.ToString("N2"), _programmingPracticeSlaViol });
                        rowData.AddRange(new[] { Labels.Documentation, Constants.No_Data, _tagIds[6].ToString("N2"), strCurrentDocumentAll.Value.ToString("N2"), _documentationSlaViol });
                        rowData.AddRange(new[] { Labels.ArchitecturalDesign, Constants.No_Data, _tagIds[7].ToString("N2"), strCurrentArchDesignAll.Value.ToString("N2"), _architectureSlaViol });
                    }
                }
            }

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

            return(resultTable);
        }
Exemplo n.º 10
0
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            DataTable dtDates = new DataTable();

            dtDates.Columns.Add("Quarter", typeof(int));
            dtDates.Columns.Add("Year", typeof(int));
            dtDates.AcceptChanges();

            string strBackgroundFacts = "";
            string strSLA             = "";

            #region Item BF
            if (options != null && options.ContainsKey("BF"))
            {
                strBackgroundFacts = options["BF"];
            }
            #endregion Item BF

            #region Item SLA
            if (options != null && options.ContainsKey("SLA"))
            {
                strSLA = options["SLA"];
            }
            #endregion Item SLA

            TableDefinition resultTable = null;
            List <string>   rowData     = new List <string>();

            List <double> TagIds = new List <double>();
            List <double> SLAs   = new List <double>();

            if (strBackgroundFacts != "")
            {
                string[] words = strBackgroundFacts.Split(' ');
                foreach (string word in words)
                {
                    double result = Convert.ToDouble(word, System.Globalization.CultureInfo.InvariantCulture);
                    TagIds.Add(result);
                }
                //TagIds = strBackgroundFacts.Split(' ').Select(double.Parse).ToList();
            }

            if (strSLA != "")
            {
                string[] words = strSLA.Split(' ');
                foreach (string word in words)
                {
                    double result = Convert.ToDouble(word, System.Globalization.CultureInfo.InvariantCulture);
                    SLAs.Add(result);
                }
                //SLAs = strSLA.Split(' ').Select(double.Parse).ToList();
            }


            if (reportData.Applications != null && reportData.snapshots != null)
            {
                DateTime DateNow = DateTime.Now;
                //DateTime DateNow = Convert.ToDateTime("03 05 2014");
                int generateQuater = 2;
                int currentYear    = DateNow.Year;
                int currentQuater  = GetQuarter(DateNow);
                for (int i = generateQuater; i > 0; i--)
                {
                    dtDates.Rows.Add(currentQuater, currentYear);
                    if (--currentQuater == 0)
                    {
                        currentQuater = 4;
                        currentYear--;
                    }
                }


                double?strCurrentArchDesignAll  = 0;
                double?strCurrentRobuAll        = 0;
                double?strCurrentSecuAll        = 0;
                double?strCurrentPerformanceAll = 0;
                double?strCurrentChangeAll      = 0;
                double?strCurrentTransferAll    = 0;
                double?strCurrentProgrammingAll = 0;
                double?strCurrentDocumentAll    = 0;



                double?strPreviousArchDesignAll  = 0;
                double?strPreviousRobuAll        = 0;
                double?strPreviousSecuAll        = 0;
                double?strPreviousPerformanceAll = 0;
                double?strPreviousChangeAll      = 0;
                double?strPreviousTransferAll    = 0;
                double?strPreviousProgrammingAll = 0;
                double?strPreviousDocumentAll    = 0;


                double?strPreviousArchDesignAllT  = 0;
                double?strPreviousRobuAllT        = 0;
                double?strPreviousSecuAllT        = 0;
                double?strPreviousPerformanceAllT = 0;
                double?strPreviousChangeAllT      = 0;
                double?strPreviousTransferAllT    = 0;
                double?strPreviousProgrammingAllT = 0;
                double?strPreviousDocumentAllT    = 0;

                rowData.AddRange(new string[] { Labels.BusinessCriterionName, Labels.Previous, Labels.Target, Labels.Actual, Labels.SLAViolations });
                Snapshot      Current = 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)
                                {
                                    Current = BuiltSnapshot;
                                    BusinessCriteriaDTO currSnapshotBisCriDTO = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(BuiltSnapshot, false);

                                    double?strCurrentArchDesign  = currSnapshotBisCriDTO.ArchitecturalDesign.HasValue ? currSnapshotBisCriDTO.ArchitecturalDesign.Value : 0;
                                    double?strCurrentRobu        = currSnapshotBisCriDTO.Robustness.HasValue ? currSnapshotBisCriDTO.Robustness.Value : 0;
                                    double?strCurrentSecu        = currSnapshotBisCriDTO.Security.HasValue ? currSnapshotBisCriDTO.Security.Value : 0;
                                    double?strCurrentPerformance = currSnapshotBisCriDTO.Performance.HasValue ? currSnapshotBisCriDTO.Performance.Value : 0;
                                    double?strCurrentChange      = currSnapshotBisCriDTO.Changeability.HasValue ? currSnapshotBisCriDTO.Changeability.Value : 0;
                                    double?strCurrentTransfer    = currSnapshotBisCriDTO.Transferability.HasValue ? currSnapshotBisCriDTO.Transferability.Value : 0;
                                    double?strCurrentProgramming = currSnapshotBisCriDTO.ProgrammingPractices.HasValue ? currSnapshotBisCriDTO.ProgrammingPractices.Value : 0;
                                    double?strCurrentDocument    = currSnapshotBisCriDTO.Documentation.HasValue ? currSnapshotBisCriDTO.Documentation.Value : 0;

                                    strCurrentArchDesignAll  = strCurrentArchDesignAll + strCurrentArchDesign;
                                    strCurrentRobuAll        = strCurrentRobuAll + strCurrentRobu;
                                    strCurrentSecuAll        = strCurrentSecuAll + strCurrentSecu;
                                    strCurrentPerformanceAll = strCurrentPerformanceAll + strCurrentPerformance;
                                    strCurrentChangeAll      = strCurrentChangeAll + strCurrentChange;
                                    strCurrentTransferAll    = strCurrentTransferAll + strCurrentTransfer;
                                    strCurrentProgrammingAll = strCurrentProgrammingAll + strCurrentProgramming;
                                    strCurrentDocumentAll    = strCurrentDocumentAll + strCurrentDocument;


                                    break;
                                }
                            }
                            break;
                        }
                    }
                }

                // For Previous quarter last snapshot OR if snapshot in last quarter just take the last snapshot in the series
                int RemoveApp = 0;
                for (int j = 0; j < AllApps.Count(); j++)
                {
                    strPreviousArchDesignAllT  = 0;
                    strPreviousRobuAllT        = 0;
                    strPreviousSecuAllT        = 0;
                    strPreviousPerformanceAllT = 0;
                    strPreviousChangeAllT      = 0;
                    strPreviousTransferAllT    = 0;
                    strPreviousProgrammingAllT = 0;
                    strPreviousDocumentAllT    = 0;

                    int         intRecord = 0;
                    int         intFlag   = 0;
                    Application App       = AllApps[j];

                    int nbSnapshotsEachApp = App.Snapshots.Count();
                    if (nbSnapshotsEachApp > 0)
                    {
                        foreach (Snapshot snapshot in App.Snapshots.OrderByDescending(_ => _.Annotation.Date.DateSnapShot))
                        {
                            DateTime SnapshotDate = Convert.ToDateTime(snapshot.Annotation.Date.DateSnapShot.Value);
                            int      intQuarter   = Convert.ToInt32(dtDates.Rows[1]["Quarter"]);
                            int      intYear      = Convert.ToInt32(dtDates.Rows[1]["Year"]);

                            int intSnapshotQuarter = GetQuarter(SnapshotDate);
                            int intSnapshotYear    = SnapshotDate.Year;

                            if (intQuarter == intSnapshotQuarter && intYear == intSnapshotYear)
                            {
                                if (snapshot != Current)
                                {
                                    //snapshot exists in previous quarter
                                    intFlag = 1; //Flag to know that there was a snapshot in the previous quarter

                                    BusinessCriteriaDTO prevSnapshotBisCriDTO = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(snapshot, false);

                                    double?strPreviousArchDesign  = prevSnapshotBisCriDTO.ArchitecturalDesign.HasValue ? MathUtility.GetRound(prevSnapshotBisCriDTO.ArchitecturalDesign.Value) : 0;
                                    double?strPreviousRobu        = prevSnapshotBisCriDTO.Robustness.HasValue ? MathUtility.GetRound(prevSnapshotBisCriDTO.Robustness.Value) : 0;
                                    double?strPreviousSecu        = prevSnapshotBisCriDTO.Security.HasValue ? MathUtility.GetRound(prevSnapshotBisCriDTO.Security.Value) : 0;
                                    double?strPreviousPerformance = prevSnapshotBisCriDTO.Performance.HasValue ? MathUtility.GetRound(prevSnapshotBisCriDTO.Performance.Value) : 0;
                                    double?strPreviousChange      = prevSnapshotBisCriDTO.Changeability.HasValue ? MathUtility.GetRound(prevSnapshotBisCriDTO.Changeability.Value) : 0;
                                    double?strPreviousTransfer    = prevSnapshotBisCriDTO.Transferability.HasValue ? MathUtility.GetRound(prevSnapshotBisCriDTO.Transferability.Value) : 0;
                                    double?strPreviousProgramming = prevSnapshotBisCriDTO.ProgrammingPractices.HasValue ? MathUtility.GetRound(prevSnapshotBisCriDTO.ProgrammingPractices.Value) : 0;
                                    double?strPreviousDocument    = prevSnapshotBisCriDTO.Documentation.HasValue ? MathUtility.GetRound(prevSnapshotBisCriDTO.Documentation.Value) : 0;

                                    strPreviousArchDesignAll  = strPreviousArchDesignAll + strPreviousArchDesign;
                                    strPreviousRobuAll        = strPreviousRobuAll + strPreviousRobu;
                                    strPreviousSecuAll        = strPreviousSecuAll + strPreviousSecu;
                                    strPreviousPerformanceAll = strPreviousPerformanceAll + strPreviousPerformance;
                                    strPreviousChangeAll      = strPreviousChangeAll + strPreviousChange;
                                    strPreviousTransferAll    = strPreviousTransferAll + strPreviousTransfer;
                                    strPreviousProgrammingAll = strPreviousProgrammingAll + strPreviousProgramming;
                                    strPreviousDocumentAll    = strPreviousDocumentAll + strPreviousDocument;

                                    strPreviousArchDesignAllT  = strPreviousArchDesignAllT + strPreviousArchDesign;
                                    strPreviousRobuAllT        = strPreviousRobuAllT + strPreviousRobu;
                                    strPreviousSecuAllT        = strPreviousSecuAllT + strPreviousSecu;
                                    strPreviousPerformanceAllT = strPreviousPerformanceAllT + strPreviousPerformance;
                                    strPreviousChangeAllT      = strPreviousChangeAllT + strPreviousChange;
                                    strPreviousTransferAllT    = strPreviousTransferAllT + strPreviousTransfer;
                                    strPreviousProgrammingAllT = strPreviousProgrammingAllT + strPreviousProgramming;
                                    strPreviousDocumentAllT    = strPreviousDocumentAllT + strPreviousDocument;

                                    break;
                                }
                            }
                        }

                        if (intFlag == 0)
                        {
                            int nbSnapshotsEachApp1 = App.Snapshots.Count();
                            if (nbSnapshotsEachApp1 == 1)
                            {
                                RemoveApp++;
                            }
                            else
                            {
                                if (nbSnapshotsEachApp > 0)
                                {
                                    foreach (Snapshot snapshot in App.Snapshots.OrderByDescending(_ => _.Annotation.Date.DateSnapShot))
                                    {
                                        if (intRecord == 0)
                                        {
                                            intRecord = 1;
                                            continue;
                                        }
                                        BusinessCriteriaDTO prevSnapshotBisCriDTO = BusinessCriteriaUtility.GetBusinessCriteriaGradesSnapshot(snapshot, false);

                                        double?strPreviousArchDesign  = prevSnapshotBisCriDTO.ArchitecturalDesign.HasValue ? MathUtility.GetRound(prevSnapshotBisCriDTO.ArchitecturalDesign.Value) : 0;
                                        double?strPreviousRobu        = prevSnapshotBisCriDTO.Robustness.HasValue ? MathUtility.GetRound(prevSnapshotBisCriDTO.Robustness.Value) : 0;
                                        double?strPreviousSecu        = prevSnapshotBisCriDTO.Security.HasValue ? MathUtility.GetRound(prevSnapshotBisCriDTO.Security.Value) : 0;
                                        double?strPreviousPerformance = prevSnapshotBisCriDTO.Performance.HasValue ? MathUtility.GetRound(prevSnapshotBisCriDTO.Performance.Value) : 0;
                                        double?strPreviousChange      = prevSnapshotBisCriDTO.Changeability.HasValue ? MathUtility.GetRound(prevSnapshotBisCriDTO.Changeability.Value) : 0;
                                        double?strPreviousTransfer    = prevSnapshotBisCriDTO.Transferability.HasValue ? MathUtility.GetRound(prevSnapshotBisCriDTO.Transferability.Value) : 0;
                                        double?strPreviousProgramming = prevSnapshotBisCriDTO.ProgrammingPractices.HasValue ? MathUtility.GetRound(prevSnapshotBisCriDTO.ProgrammingPractices.Value) : 0;
                                        double?strPreviousDocument    = prevSnapshotBisCriDTO.Documentation.HasValue ? MathUtility.GetRound(prevSnapshotBisCriDTO.Documentation.Value) : 0;

                                        if (strPreviousArchDesignAllT == 0)
                                        {
                                            strPreviousArchDesignAll = strPreviousArchDesignAll + strPreviousArchDesign;
                                        }
                                        if (strPreviousRobuAllT == 0)
                                        {
                                            strPreviousRobuAll = strPreviousRobuAll + strPreviousRobu;
                                        }
                                        if (strPreviousSecuAllT == 0)
                                        {
                                            strPreviousSecuAll = strPreviousSecuAll + strPreviousSecu;
                                        }
                                        if (strPreviousPerformanceAllT == 0)
                                        {
                                            strPreviousPerformanceAll = strPreviousPerformanceAll + strPreviousPerformance;
                                        }
                                        if (strPreviousChangeAllT == 0)
                                        {
                                            strPreviousChangeAll = strPreviousChangeAll + strPreviousChange;
                                        }
                                        if (strPreviousTransferAllT == 0)
                                        {
                                            strPreviousTransferAll = strPreviousTransferAll + strPreviousTransfer;
                                        }
                                        if (strPreviousProgrammingAllT == 0)
                                        {
                                            strPreviousProgrammingAll = strPreviousProgrammingAll + strPreviousProgramming;
                                        }
                                        if (strPreviousDocumentAllT == 0)
                                        {
                                            strPreviousDocumentAll = strPreviousDocumentAll + strPreviousDocument;
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }



                if (strPreviousArchDesignAll > 0)
                {
                    strPreviousArchDesignAll = strPreviousArchDesignAll / (AllApps.Count() - RemoveApp);
                }

                if (strPreviousRobuAll > 0)
                {
                    strPreviousRobuAll = strPreviousRobuAll / (AllApps.Count() - RemoveApp);
                }

                if (strPreviousSecuAll > 0)
                {
                    strPreviousSecuAll = strPreviousSecuAll / (AllApps.Count() - RemoveApp);
                }

                if (strPreviousPerformanceAll > 0)
                {
                    strPreviousPerformanceAll = strPreviousPerformanceAll / (AllApps.Count() - RemoveApp);
                }

                if (strPreviousChangeAll > 0)
                {
                    strPreviousChangeAll = strPreviousChangeAll / (AllApps.Count() - RemoveApp);
                }

                if (strPreviousTransferAll > 0)
                {
                    strPreviousTransferAll = strPreviousTransferAll / (AllApps.Count() - RemoveApp);
                }

                if (strPreviousProgrammingAll > 0)
                {
                    strPreviousProgrammingAll = strPreviousProgrammingAll / (AllApps.Count() - RemoveApp);
                }

                if (strPreviousDocumentAll > 0)
                {
                    strPreviousDocumentAll = strPreviousDocumentAll / (AllApps.Count() - RemoveApp);
                }

                if (TagIds.Count == 8 && SLAs.Count == 2)
                {
                    int intArchitectureSLAViol        = 0;
                    int intRobustnessSLAViol          = 0;
                    int intSecuritySLAViol            = 0;
                    int intPerformanceSLAViol         = 0;
                    int intChangeabilitySLAViol       = 0;
                    int intTransferabilitySLAViol     = 0;
                    int intProgrammingPracticeSLAViol = 0;
                    int intDocumentationSLAViol       = 0;

                    //double? lower = MathUtility.GetRound(TagIds[0] / 100);
                    //double? upper = MathUtility.GetRound(TagIds[1] / 100);

                    double?lower = Math.Round((double)SLAs[0] / 100, 2);
                    double?upper = Math.Round((double)SLAs[1] / 100, 2);

                    intRobustnessSLAViol          = ((TagIds[0] - (strCurrentRobuAll / AllApps.Count())) / TagIds[0] > upper ? 0 : ((TagIds[0] - (strCurrentRobuAll / AllApps.Count())) / TagIds[0] > lower ? 50 : 100));
                    intSecuritySLAViol            = ((TagIds[1] - (strCurrentSecuAll / AllApps.Count())) / TagIds[1] > upper ? 0 : ((TagIds[1] - (strCurrentSecuAll / AllApps.Count())) / TagIds[1] > lower ? 50 : 100));
                    intChangeabilitySLAViol       = ((TagIds[2] - (strCurrentChangeAll / AllApps.Count())) / TagIds[2] > upper ? 0 : ((TagIds[2] - (strCurrentChangeAll / AllApps.Count())) / TagIds[2] > lower ? 50 : 100));
                    intTransferabilitySLAViol     = ((TagIds[3] - (strCurrentTransferAll / AllApps.Count())) / TagIds[3] > upper ? 0 : ((TagIds[3] - (strCurrentTransferAll / AllApps.Count())) / TagIds[3] > lower ? 50 : 100));
                    intProgrammingPracticeSLAViol = ((TagIds[4] - (strCurrentProgrammingAll / AllApps.Count())) / TagIds[4] > upper ? 0 : ((TagIds[4] - (strCurrentProgrammingAll / AllApps.Count())) / TagIds[4] > lower ? 50 : 100));
                    intDocumentationSLAViol       = ((TagIds[5] - (strCurrentDocumentAll / AllApps.Count())) / TagIds[5] > upper ? 0 : ((TagIds[5] - (strCurrentDocumentAll / AllApps.Count())) / TagIds[5] > lower ? 50 : 100));
                    intPerformanceSLAViol         = ((TagIds[6] - (strCurrentPerformanceAll / AllApps.Count())) / TagIds[6] > upper ? 0 : ((TagIds[6] - (strCurrentPerformanceAll / AllApps.Count())) / TagIds[6] > lower ? 50 : 100));
                    intArchitectureSLAViol        = ((TagIds[7] - (strCurrentArchDesignAll / AllApps.Count())) / TagIds[7] > upper ? 0 : ((TagIds[7] - (strCurrentArchDesignAll / AllApps.Count())) / TagIds[7] > lower ? 50 : 100));


                    string ArchitectureSLAViol        = "";
                    string RobustnessSLAViol          = "";
                    string SecuritySLAViol            = "";
                    string PerformanceSLAViol         = "";
                    string ChangeabilitySLAViol       = "";
                    string TransferabilitySLAViol     = "";
                    string ProgrammingPracticeSLAViol = "";
                    string DocumentationSLAViol       = "";

                    if (intArchitectureSLAViol == 100)
                    {
                        ArchitectureSLAViol = Labels.Good;
                    }
                    else if (intArchitectureSLAViol == 0)
                    {
                        ArchitectureSLAViol = Labels.Bad;
                    }
                    else
                    {
                        ArchitectureSLAViol = Labels.Acceptable;
                    }

                    if (intRobustnessSLAViol == 100)
                    {
                        RobustnessSLAViol = Labels.Good;
                    }
                    else if (intRobustnessSLAViol == 0)
                    {
                        RobustnessSLAViol = Labels.Bad;
                    }
                    else
                    {
                        RobustnessSLAViol = Labels.Acceptable;
                    }



                    if (intSecuritySLAViol == 100)
                    {
                        SecuritySLAViol = Labels.Good;
                    }
                    else if (intSecuritySLAViol == 0)
                    {
                        SecuritySLAViol = Labels.Bad;
                    }
                    else
                    {
                        SecuritySLAViol = Labels.Acceptable;
                    }



                    if (intPerformanceSLAViol == 100)
                    {
                        PerformanceSLAViol = Labels.Good;
                    }
                    else if (intPerformanceSLAViol == 0)
                    {
                        PerformanceSLAViol = Labels.Bad;
                    }
                    else
                    {
                        PerformanceSLAViol = Labels.Acceptable;
                    }



                    if (intChangeabilitySLAViol == 100)
                    {
                        ChangeabilitySLAViol = Labels.Good;
                    }
                    else if (intChangeabilitySLAViol == 0)
                    {
                        ChangeabilitySLAViol = Labels.Bad;
                    }
                    else
                    {
                        ChangeabilitySLAViol = Labels.Acceptable;
                    }



                    if (intTransferabilitySLAViol == 100)
                    {
                        TransferabilitySLAViol = Labels.Good;
                    }
                    else if (intTransferabilitySLAViol == 0)
                    {
                        TransferabilitySLAViol = Labels.Bad;
                    }
                    else
                    {
                        TransferabilitySLAViol = Labels.Acceptable;
                    }



                    if (intProgrammingPracticeSLAViol == 100)
                    {
                        ProgrammingPracticeSLAViol = Labels.Good;
                    }
                    else if (intProgrammingPracticeSLAViol == 0)
                    {
                        ProgrammingPracticeSLAViol = Labels.Bad;
                    }
                    else
                    {
                        ProgrammingPracticeSLAViol = Labels.Acceptable;
                    }



                    if (intDocumentationSLAViol == 100)
                    {
                        DocumentationSLAViol = Labels.Good;
                    }
                    else if (intDocumentationSLAViol == 0)
                    {
                        DocumentationSLAViol = Labels.Bad;
                    }
                    else
                    {
                        DocumentationSLAViol = Labels.Acceptable;
                    }

                    string PrevRobu   = "";
                    string PrevSecu   = "";
                    string PrevPerf   = "";
                    string PrevChange = "";
                    string PrevTrans  = "";
                    string PrevPP     = "";
                    string PrevDocu   = "";
                    string PrevArch   = "";

                    string CurrRobu   = "";
                    string CurrSecu   = "";
                    string CurrPerf   = "";
                    string CurrChange = "";
                    string CurrTrans  = "";
                    string CurrPP     = "";
                    string CurrDocu   = "";
                    string CurrArch   = "";

                    PrevRobu   = string.Format("{0:0.00}", strPreviousRobuAll);
                    PrevSecu   = string.Format("{0:0.00}", strPreviousSecuAll);
                    PrevPerf   = string.Format("{0:0.00}", strPreviousPerformanceAll);
                    PrevChange = string.Format("{0:0.00}", strPreviousChangeAll);
                    PrevTrans  = string.Format("{0:0.00}", strPreviousTransferAll);
                    PrevPP     = string.Format("{0:0.00}", strPreviousProgrammingAll);
                    PrevDocu   = string.Format("{0:0.00}", strPreviousDocumentAll);
                    PrevArch   = string.Format("{0:0.00}", strPreviousArchDesignAll);

                    CurrRobu   = string.Format("{0:0.00}", strCurrentRobuAll / AllApps.Count());
                    CurrSecu   = string.Format("{0:0.00}", strCurrentSecuAll / AllApps.Count());
                    CurrPerf   = string.Format("{0:0.00}", strCurrentPerformanceAll / AllApps.Count());
                    CurrChange = string.Format("{0:0.00}", strCurrentChangeAll / AllApps.Count());
                    CurrTrans  = string.Format("{0:0.00}", strCurrentTransferAll / AllApps.Count());
                    CurrPP     = string.Format("{0:0.00}", strCurrentProgrammingAll / AllApps.Count());
                    CurrDocu   = string.Format("{0:0.00}", strCurrentDocumentAll / AllApps.Count());
                    CurrArch   = string.Format("{0:0.00}", strCurrentArchDesignAll / AllApps.Count());

                    string Tag0 = string.Format("{0:0.00}", TagIds[0]);
                    string Tag1 = string.Format("{0:0.00}", TagIds[1]);
                    string Tag2 = string.Format("{0:0.00}", TagIds[2]);
                    string Tag3 = string.Format("{0:0.00}", TagIds[3]);
                    string Tag4 = string.Format("{0:0.00}", TagIds[4]);
                    string Tag5 = string.Format("{0:0.00}", TagIds[5]);
                    string Tag6 = string.Format("{0:0.00}", TagIds[6]);
                    string Tag7 = string.Format("{0:0.00}", TagIds[7]);


                    rowData.AddRange(new string[] { Labels.Robustness, PrevRobu, Tag0, CurrRobu, RobustnessSLAViol });
                    rowData.AddRange(new string[] { Labels.Security, PrevSecu, Tag1, CurrSecu, SecuritySLAViol });
                    rowData.AddRange(new string[] { Labels.Efficiency, PrevPerf, Tag2, CurrPerf, PerformanceSLAViol });
                    rowData.AddRange(new string[] { Labels.Changeability, PrevChange, Tag3, CurrChange, ChangeabilitySLAViol });
                    rowData.AddRange(new string[] { Labels.Transferability, PrevTrans, Tag4, CurrTrans, TransferabilitySLAViol });
                    rowData.AddRange(new string[] { Labels.ProgrammingPractices, PrevPP, Tag5, CurrPP, ProgrammingPracticeSLAViol });
                    rowData.AddRange(new string[] { Labels.Documentation, PrevDocu, Tag6, CurrDocu, DocumentationSLAViol });
                    rowData.AddRange(new string[] { Labels.ArchitecturalDesign, PrevArch, Tag7, CurrArch, ArchitectureSLAViol });
                }
                else
                {
                    rowData.AddRange(new string[] { Labels.ArchitecturalDesign, " ", " ", " ", (strCurrentArchDesignAll / AllApps.Count()).ToString() });
                    rowData.AddRange(new string[] { Labels.Robustness, " ", " ", " ", (strCurrentRobuAll / AllApps.Count()).ToString() });
                    rowData.AddRange(new string[] { Labels.Security, " ", " ", " ", (strCurrentSecuAll / AllApps.Count()).ToString() });
                    rowData.AddRange(new string[] { Labels.Efficiency, " ", " ", " ", (strCurrentPerformanceAll / AllApps.Count()).ToString() });
                    rowData.AddRange(new string[] { Labels.Changeability, " ", " ", " ", (strCurrentChangeAll / AllApps.Count()).ToString() });
                    rowData.AddRange(new string[] { Labels.Transferability, " ", " ", " ", (strCurrentTransferAll / AllApps.Count()).ToString() });
                    rowData.AddRange(new string[] { Labels.ProgrammingPractices, " ", " ", " ", (strCurrentProgrammingAll / AllApps.Count()).ToString() });
                    rowData.AddRange(new string[] { Labels.Documentation, " ", " ", " ", (strCurrentDocumentAll / AllApps.Count()).ToString() });
                }
            }



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

            return(resultTable);
        }
Exemplo n.º 11
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.º 12
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.º 13
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);
        }