public override string Content(ReportData reportData, Dictionary <string, string> options)
        {
            if (reportData?.CurrentSnapshot == null)
            {
                return(Domain.Constants.No_Value);
            }
            double?result = MeasureUtility.GetTechnicalDebtMetric(reportData.CurrentSnapshot);

            return(result.HasValue ? $"{result.Value:N0} {reportData.CurrencySymbol}" : Domain.Constants.No_Value);
        }
Exemple #2
0
 protected override string Content(ReportData reportData, Dictionary <string, string> options)
 {
     if (null != reportData &&
         null != reportData.CurrentSnapshot)
     {
         double?result = MeasureUtility.GetTechnicalDebtMetric(reportData.CurrentSnapshot);
         return(result.HasValue ? String.Format("{0:N0} {1}", result.Value, reportData.CurrencySymbol) : CastReporting.Domain.Constants.No_Value);
     }
     return(CastReporting.Domain.Constants.No_Value);
 }
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            TableDefinition resultTable = null;

            string numberFormat = "N0";

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

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

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


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

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

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

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

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

            return(resultTable);
        }
        public override string Content(ReportData reportData, Dictionary <string, string> options)
        {
            if (reportData?.Applications == null)
            {
                return(Constants.No_Value);
            }
            Application[] _allApps     = reportData.Applications;
            double?       _allTechDebt = 0;
            double?       _allLoc      = 0;

            foreach (Application _app in _allApps)
            {
                try
                {
                    Snapshot _snapshot = _app.Snapshots.OrderByDescending(_ => _.Annotation.Date.DateSnapShot).First();
                    if (_snapshot == null)
                    {
                        continue;
                    }
                    double?result = MeasureUtility.GetTechnicalDebtMetric(_snapshot);
                    if (result != null)
                    {
                        _allTechDebt = _allTechDebt + result;
                    }

                    double?_locSnap = MeasureUtility.GetCodeLineNumber(_snapshot);
                    if (_locSnap != null)
                    {
                        _allLoc = _allLoc + _locSnap;
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.Instance.LogInfo(ex.Message);
                    LogHelper.Instance.LogInfo(Labels.NoSnapshot);
                }
            }

            if (!(_allTechDebt > 0) || !(_allLoc > 0))
            {
                return(Labels.NoData);
            }
            double?finalValue = _allTechDebt / _allLoc;

            return($"{finalValue.Value:N0} {reportData.CurrencySymbol}");
        }
Exemple #5
0
        protected override string Content(ReportData reportData, Dictionary <string, string> options)
        {
            if (null != reportData && null != reportData.Applications)
            {
                Application[] AllApps           = reportData.Applications;
                double?       resultAllTechDebt = 0;
                double?       AFPAll            = 0;

                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))
                        {
                            double?result = MeasureUtility.GetTechnicalDebtMetric(snapshot);
                            if (result == null)
                            {
                                result = 0.0;
                            }
                            resultAllTechDebt = resultAllTechDebt + result;
                            break;
                        }
                    }
                }

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

                    try
                    {
                        int nbSnapshotsEachApp = App.Snapshots.Count();
                        if (nbSnapshotsEachApp > 0)
                        {
                            foreach (Snapshot snapshot in App.Snapshots.OrderByDescending(_ => _.Annotation.Date.DateSnapShot))
                            {
                                var    technologyInfos = MeasureUtility.GetTechnoLoc(snapshot, nbResult);
                                double?LOCSnap         = 0;

                                if (technologyInfos != null)
                                {
                                    foreach (var elt in technologyInfos)
                                    {
                                        LOCSnap = LOCSnap + elt.Value;
                                    }
                                }

                                if (LOCSnap.HasValue)
                                {
                                    AFPAll = AFPAll + LOCSnap;
                                }
                                else
                                {
                                    LOCSnap = 0;
                                }
                                break;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        return("Broken Central");
                    }
                }

                //handle 0 functions case
                if (resultAllTechDebt > 0 && AFPAll > 0)
                {
                    double?FinalValue    = (resultAllTechDebt / AllApps.Count()) / (AFPAll / AllApps.Count());
                    int    intFinalValue = Convert.ToInt32(FinalValue);
                    return(string.Format("{0:n0}", intFinalValue) + "$");
                }
                else
                {
                    return("NA");
                }
                //return (result.HasValue ? String.Format("{0:N0} {1}", result.Value, reportData.CurrencySymbol) : CastReporting.Domain.Constants.No_Value);
            }
            return(CastReporting.Domain.Constants.No_Value);
        }
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            int count = 0;

            var rowData = new List <String>();

            rowData.AddRange(new string[] {
                " ",
                Labels.DebtRemoved + " (" + reportData.CurrencySymbol + ")",
                Labels.DebtAdded + " (" + reportData.CurrencySymbol + ")",
                Labels.Debt + " (" + reportData.CurrencySymbol + ")"
            });

            #region Fetch Snapshots
            int nbSnapshots = (reportData != null && reportData.Application != null) ? reportData.Application.Snapshots.Count() : 0;
            if (nbSnapshots > 0)
            {
                foreach (Snapshot snapshot in reportData.Application.Snapshots.OrderBy(_ => _.Annotation.Date.DateSnapShot))
                {
                    double?prevDoubleSnapshotDate   = snapshot.Annotation.Date.DateSnapShot.HasValue ? snapshot.Annotation.Date.DateSnapShot.Value.ToOADate() : 0;
                    double?prevRemovedTechDebtValue = MeasureUtility.GetRemovedTechDebtMetric(snapshot);
                    double?prevAddedTechDebtValue   = MeasureUtility.GetAddedTechDebtMetric(snapshot);
                    double?prevTotalTechDebtValue   = MeasureUtility.GetTechnicalDebtMetric(snapshot);
                    rowData.AddRange(new string[] {
                        prevDoubleSnapshotDate.GetValueOrDefault().ToString(),
                        prevRemovedTechDebtValue.GetValueOrDefault().ToString(),
                        prevAddedTechDebtValue.GetValueOrDefault().ToString(),
                        prevTotalTechDebtValue.GetValueOrDefault().ToString(),
                    });
                }
                count = nbSnapshots;
            }
            #endregion Previous Snapshots

            #region just 1 snapshot
            if (reportData.Application != null &&
                reportData.Application.Snapshots != null &&
                nbSnapshots == 1 &&
                reportData.CurrentSnapshot != null)
            {
                double?prevDoubleSnapshotDate   = reportData.CurrentSnapshot.Annotation.Date.DateSnapShot.HasValue ? reportData.CurrentSnapshot.Annotation.Date.DateSnapShot.Value.ToOADate() : 0;
                double?prevRemovedTechDebtValue = MeasureUtility.GetRemovedTechDebtMetric(reportData.CurrentSnapshot);
                double?prevAddedTechDebtValue   = MeasureUtility.GetAddedTechDebtMetric(reportData.CurrentSnapshot);
                double?prevTotalTechDebtValue   = MeasureUtility.GetTechnicalDebtMetric(reportData.CurrentSnapshot);
                rowData.AddRange(new string[] {
                    prevDoubleSnapshotDate.GetValueOrDefault().ToString(),
                    prevRemovedTechDebtValue.GetValueOrDefault().ToString(),
                    prevAddedTechDebtValue.GetValueOrDefault().ToString(),
                    prevTotalTechDebtValue.GetValueOrDefault().ToString(),
                });
                count = count + 1;
            }
            #endregion just 1 snapshot



            TableDefinition resultTable = new TableDefinition {
                HasRowHeaders    = true,
                HasColumnHeaders = false,
                NbRows           = count + 1,
                NbColumns        = 4,
                Data             = rowData,
                GraphOptions     = null
            };
            return(resultTable);
        }
        public override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            var rowData = new List <string>();

            rowData.AddRange(new[] {
                " ",
                Labels.DebtRemoved + " (" + reportData.CurrencySymbol + ")",
                Labels.DebtAdded + " (" + reportData.CurrencySymbol + ")",
                Labels.Debt + " (" + reportData.CurrencySymbol + ")"
            });

            DataTable dtDates = new DataTable();

            dtDates.Columns.Add("Quarter", typeof(int));
            dtDates.Columns.Add("Year", typeof(int));
            dtDates.Columns.Add("RemovedTechnicalDebt", typeof(double));
            dtDates.Columns.Add("AddedTechnicalDebt", typeof(double));
            dtDates.Columns.Add("TotalTechnicalDebt", typeof(double));
            dtDates.AcceptChanges();

            #region Fetch SnapshotsPF

            if (reportData.Applications != null && reportData.Snapshots != null)
            {
                Snapshot[] _allSnapshots = reportData.Snapshots;

                int      generateQuater = 6;
                DateTime _dateNow       = DateTime.Now;
                int      currentYear    = _dateNow.Year;
                int      currentQuater  = DateUtil.GetQuarter(_dateNow);

                for (int i = generateQuater; i > 0; i--)
                {
                    DataRow dr = dtDates.NewRow();
                    dr["Quarter"] = currentQuater;
                    dr["Year"]    = currentYear;
                    dtDates.Rows.InsertAt(dr, 0);
                    currentYear   = DateUtil.GetPreviousQuarterYear(currentQuater, currentYear);
                    currentQuater = DateUtil.GetPreviousQuarter(currentQuater);
                }

                for (int i = 0; i < dtDates.Rows.Count; i++)
                {
                    double?_removedTechnicalDebt = 0;
                    double?_addedTechnicalDebt   = 0;
                    double?_totalTechnicalDebt   = 0;

                    if (_allSnapshots.Length > 0)
                    {
                        foreach (Snapshot snapshot in _allSnapshots.OrderBy(_ => _.Annotation.Date.DateSnapShot))
                        {
                            if (snapshot.Annotation.Date.DateSnapShot == null)
                            {
                                continue;
                            }
                            DateTime _snapshotDate = Convert.ToDateTime(snapshot.Annotation.Date.DateSnapShot.Value);

                            int intQuarter = Convert.ToInt32(dtDates.Rows[i]["Quarter"]);
                            int intYear    = Convert.ToInt32(dtDates.Rows[i]["Year"]);

                            int intSnapshotQuarter = DateUtil.GetQuarter(_snapshotDate);
                            int intSnapshotYear    = _snapshotDate.Year;

                            if (intQuarter != intSnapshotQuarter || intYear != intSnapshotYear)
                            {
                                continue;
                            }
                            _removedTechnicalDebt = _removedTechnicalDebt + MeasureUtility.GetRemovedTechDebtMetric(snapshot);
                            _addedTechnicalDebt   = _addedTechnicalDebt + MeasureUtility.GetAddedTechDebtMetric(snapshot);
                            _totalTechnicalDebt   = _totalTechnicalDebt + MeasureUtility.GetTechnicalDebtMetric(snapshot);
                        }
                    }

                    dtDates.Rows[i]["RemovedTechnicalDebt"] = _removedTechnicalDebt * -1;
                    dtDates.Rows[i]["AddedTechnicalDebt"]   = _addedTechnicalDebt;
                    dtDates.Rows[i]["TotalTechnicalDebt"]   = _totalTechnicalDebt;
                }

                for (int i = 0; i < dtDates.Rows.Count; i++)
                {
                    string strQuarter = dtDates.Rows[i]["Year"] + " Q" + dtDates.Rows[i]["Quarter"];
                    rowData.Add(strQuarter);
                    rowData.Add(dtDates.Rows[i]["RemovedTechnicalDebt"].ToString());
                    rowData.Add(dtDates.Rows[i]["AddedTechnicalDebt"].ToString());
                    rowData.Add(dtDates.Rows[i]["TotalTechnicalDebt"].ToString());
                }
            }
            #endregion Fetch SnapshotsPF

            TableDefinition resultTable = new TableDefinition
            {
                HasRowHeaders    = true,
                HasColumnHeaders = false,
                NbRows           = dtDates.Rows.Count + 1,
                NbColumns        = 4,
                Data             = rowData,
                GraphOptions     = null
            };
            return(resultTable);
        }
        protected override TableDefinition Content(ReportData reportData, Dictionary <string, string> options)
        {
            var rowData = new List <String>();

            rowData.AddRange(new string[] {
                " ",
                Labels.DebtRemoved + " (" + reportData.CurrencySymbol + ")",
                Labels.DebtAdded + " (" + reportData.CurrencySymbol + ")",
                Labels.Debt + " (" + reportData.CurrencySymbol + ")"
            });

            DataTable dtDates = new DataTable();

            dtDates.Columns.Add("Quarter", typeof(int));
            dtDates.Columns.Add("Year", typeof(int));
            dtDates.Columns.Add("RemovedTechnicalDebt", typeof(double));
            dtDates.Columns.Add("AddedTechnicalDebt", typeof(double));
            dtDates.Columns.Add("TotalTechnicalDebt", typeof(double));
            dtDates.AcceptChanges();

            #region Fetch SnapshotsPF

            if (reportData != null && reportData.Applications != null && reportData.snapshots != null)
            {
                DateTime DateNow = DateTime.Now;
                //DateTime DateNow = Convert.ToDateTime("03 01 2014");
                Application[] AllApps        = reportData.Applications;
                Snapshot[]    AllSnapshots   = reportData.snapshots;
                int           generateQuater = 6;
                int           currentYear    = DateNow.Year;
                int           currentQuater  = GetQuarter(DateNow);
                for (int i = generateQuater; i > 0; i--)
                {
                    DataRow dr = dtDates.NewRow();
                    dr["Quarter"] = currentQuater;
                    dr["Year"]    = currentYear;
                    dtDates.Rows.InsertAt(dr, 0);
                    //dtDates.Rows.Add(currentQuater, currentYear);
                    if (--currentQuater == 0)
                    {
                        currentQuater = 4;
                        currentYear--;
                    }
                }

                double?RemovedTechnicalDebt = 0;
                double?AddedTechnicalDebt   = 0;
                double?TotalTechnicalDebt   = 0;

                for (int i = 0; i < dtDates.Rows.Count; i++)
                {
                    RemovedTechnicalDebt = 0;
                    AddedTechnicalDebt   = 0;
                    TotalTechnicalDebt   = 0;

                    if (AllSnapshots.Count() > 0)
                    {
                        foreach (Snapshot snapshot in AllSnapshots.OrderBy(_ => _.Annotation.Date.DateSnapShot))
                        {
                            DateTime SnapshotDate = Convert.ToDateTime(snapshot.Annotation.Date.DateSnapShot.Value);

                            int intQuarter = Convert.ToInt32(dtDates.Rows[i]["Quarter"]);
                            int intYear    = Convert.ToInt32(dtDates.Rows[i]["Year"]);

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

                            if (intQuarter == intSnapshotQuarter && intYear == intSnapshotYear)
                            {
                                RemovedTechnicalDebt = RemovedTechnicalDebt + MeasureUtility.GetRemovedTechDebtMetric(snapshot);
                                AddedTechnicalDebt   = AddedTechnicalDebt + MeasureUtility.GetAddedTechDebtMetric(snapshot);
                                TotalTechnicalDebt   = TotalTechnicalDebt + MeasureUtility.GetTechnicalDebtMetric(snapshot);
                            }
                        }
                    }

                    if (RemovedTechnicalDebt > 0)
                    {
                        RemovedTechnicalDebt = RemovedTechnicalDebt * -1;
                    }

                    if (RemovedTechnicalDebt != null)
                    {
                        dtDates.Rows[i]["RemovedTechnicalDebt"] = RemovedTechnicalDebt;
                    }
                    else
                    {
                        dtDates.Rows[i]["RemovedTechnicalDebt"] = 0.0;
                    }

                    if (AddedTechnicalDebt != null)
                    {
                        dtDates.Rows[i]["AddedTechnicalDebt"] = AddedTechnicalDebt;
                    }
                    else
                    {
                        dtDates.Rows[i]["AddedTechnicalDebt"] = 0.0;
                    }

                    if (TotalTechnicalDebt != null)
                    {
                        dtDates.Rows[i]["TotalTechnicalDebt"] = TotalTechnicalDebt;
                    }
                    else
                    {
                        dtDates.Rows[i]["TotalTechnicalDebt"] = 0.0;
                    }
                }

                for (int i = 0; i < dtDates.Rows.Count; i++)
                {
                    string strQuarter = dtDates.Rows[i]["Year"].ToString() + " Q" + dtDates.Rows[i]["Quarter"].ToString();
                    rowData.AddRange(new string[] {
                        strQuarter,
                        dtDates.Rows[i]["RemovedTechnicalDebt"].ToString(),
                        dtDates.Rows[i]["AddedTechnicalDebt"].ToString(),
                        dtDates.Rows[i]["TotalTechnicalDebt"].ToString(),
                    });
                }
            }
            #endregion Fetch SnapshotsPF



            TableDefinition resultTable = new TableDefinition
            {
                HasRowHeaders    = true,
                HasColumnHeaders = false,
                NbRows           = dtDates.Rows.Count + 1,
                NbColumns        = 4,
                Data             = rowData,
                GraphOptions     = null
            };
            return(resultTable);
        }
        protected override string Content(ReportData reportData, Dictionary <string, string> options)
        {
            if (null != reportData && null != reportData.Applications)
            {
                Application[] AllApps           = reportData.Applications;
                double?       resultAllTechDebt = 0;
                double?       AFPAll            = 0;

                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))
                        {
                            double?result = MeasureUtility.GetTechnicalDebtMetric(snapshot);
                            if (result == null)
                            {
                                result = 0.0;
                            }

                            resultAllTechDebt = resultAllTechDebt + result;
                            break;
                        }
                    }
                }

                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))
                        {
                            double?resultAFPDF = MeasureUtility.GetAfpMetricDF(snapshot);
                            double?resultAFPTF = MeasureUtility.GetAfpMetricTF(snapshot);

                            if (resultAFPDF == null)
                            {
                                resultAFPDF = 0.0;
                            }
                            if (resultAFPTF == null)
                            {
                                resultAFPTF = 0.0;
                            }

                            double?result = resultAFPDF + resultAFPTF;

                            AFPAll = AFPAll + result;
                            break;
                        }
                    }
                }
                //handle 0 functions case
                if (resultAllTechDebt > 0 && AFPAll > 0)
                {
                    double?FinalValue    = (resultAllTechDebt / AllApps.Count()) / (AFPAll / AllApps.Count());
                    int    intFinalValue = Convert.ToInt32(FinalValue);
                    return(string.Format("{0:n0}", intFinalValue) + "$");
                }
                else
                {
                    return("NA");
                }
                //return (result.HasValue ? String.Format("{0:N0} {1}", result.Value, reportData.CurrencySymbol) : CastReporting.Domain.Constants.No_Value);
            }
            return(CastReporting.Domain.Constants.No_Value);
        }