Пример #1
0
 /// <summary>
 /// Enum types are equal by primary key
 /// </summary>
 public bool Equals(MeasurementUnitType other)
 {
     if (other == null)
     {
         return(false);
     }
     return(other.MeasurementUnitTypeID == MeasurementUnitTypeID);
 }
Пример #2
0
 /// <summary>
 /// Constructor for building a new object with MinimalConstructor required fields, using objects whenever possible
 /// </summary>
 public PerformanceMeasure(string performanceMeasureDisplayName, MeasurementUnitType measurementUnitType, PerformanceMeasureType performanceMeasureType, bool swapChartAxes, bool canCalculateTotal, bool isAggregatable, PerformanceMeasureDataSourceType performanceMeasureDataSourceType) : this()
 {
     // Mark this as a new object by setting primary key with special value
     this.PerformanceMeasureID          = ModelObjectHelpers.MakeNextUnsavedPrimaryKeyValue();
     this.PerformanceMeasureDisplayName = performanceMeasureDisplayName;
     this.MeasurementUnitTypeID         = measurementUnitType.MeasurementUnitTypeID;
     this.PerformanceMeasureTypeID      = performanceMeasureType.PerformanceMeasureTypeID;
     this.SwapChartAxes     = swapChartAxes;
     this.CanCalculateTotal = canCalculateTotal;
     this.IsAggregatable    = isAggregatable;
     this.PerformanceMeasureDataSourceTypeID = performanceMeasureDataSourceType.PerformanceMeasureDataSourceTypeID;
 }
Пример #3
0
 /// <summary>
 /// Creates a "blank" object of this type and populates primitives with defaults
 /// </summary>
 public static PerformanceMeasure CreateNewBlank(MeasurementUnitType measurementUnitType, PerformanceMeasureType performanceMeasureType, PerformanceMeasureDataSourceType performanceMeasureDataSourceType)
 {
     return(new PerformanceMeasure(default(string), measurementUnitType, performanceMeasureType, default(bool), default(bool), default(bool), performanceMeasureDataSourceType));
 }
Пример #4
0
        public static string FormattedDataTooltip(IReadOnlyCollection <IGrouping <Tuple <string, int>, PerformanceMeasureReportingPeriodSubcategoryOptionReportedValue> > groupedBySubcategoryOption,
                                                  PerformanceMeasureReportingPeriod performanceMeasureReportingPeriod,
                                                  MeasurementUnitType performanceMeasureMeasurementUnitType,
                                                  bool reverseTooltipOrder,
                                                  double?targetValue,
                                                  string targetValueDescription,
                                                  double?geospatialAreaTargetValue,
                                                  string geospatialAreaTargetValueDescription,
                                                  bool showCumulativeResults,
                                                  PerformanceMeasureReportingPeriod initialPerformanceMeasureReportingPeriod)
        {
            // shape data
            var calendarReportedYearValuesDictionary = new Dictionary <string, double>();
            var orderedSubCategoryOptions            = reverseTooltipOrder
                ? groupedBySubcategoryOption.OrderByDescending(x => x.Key.Item2)
                : groupedBySubcategoryOption.OrderBy(x => x.Key.Item2);

            orderedSubCategoryOptions.ForEach(x =>
            {
                double calendarYearReportedValue;
                if (showCumulativeResults)
                {
                    calendarYearReportedValue =
                        x.Where <PerformanceMeasureReportingPeriodSubcategoryOptionReportedValue>(pmrp => pmrp.PerformanceMeasureReportingPeriod.PerformanceMeasureReportingPeriodCalendarYear <=
                                                                                                  performanceMeasureReportingPeriod.PerformanceMeasureReportingPeriodCalendarYear)
                        .Sum(pmrp => pmrp.ReportedValue) ?? 0;
                }
                else
                {
                    calendarYearReportedValue =
                        x.Where <PerformanceMeasureReportingPeriodSubcategoryOptionReportedValue>(pmrp => pmrp.PerformanceMeasureReportingPeriod.PerformanceMeasureReportingPeriodCalendarYear ==
                                                                                                  performanceMeasureReportingPeriod.PerformanceMeasureReportingPeriodCalendarYear)
                        .Sum(pmrp => pmrp.ReportedValue) ?? 0;
                }
                calendarReportedYearValuesDictionary.Add(x.Key.Item1, calendarYearReportedValue);
            });

            var stringPrecision = new String('0', performanceMeasureMeasurementUnitType.NumberOfSignificantDigits);
            var prefix          = performanceMeasureMeasurementUnitType == MeasurementUnitType.Dollars ? "$" : null;

            // build html for tooltip
            var html = "<div class='googleTooltipDiv'>";

            html += $"<p><b>{performanceMeasureReportingPeriod.PerformanceMeasureReportingPeriodLabel}</b></p>";
            html += "<table class='table table-striped googleTooltipTable'>";
            foreach (KeyValuePair <string, double> calendarReportedYearValue in calendarReportedYearValuesDictionary)
            {
                var formattedValue = calendarReportedYearValue.Value.ToString($"#,###,###,##0.{stringPrecision}");


                html += $"<tr><td>{calendarReportedYearValue.Key}</td><td style='text-align: right'><b>{prefix ?? String.Empty}{formattedValue} {performanceMeasureMeasurementUnitType.LegendDisplayName ?? String.Empty}</b></td></tr>";
            }

            var formattedTotal = calendarReportedYearValuesDictionary.Sum(x => x.Value).ToString($"#,###,###,##0.{stringPrecision}");

            html += $"<tr class='googleTooltipTableTotalRow'><td>Total</td><td style='text-align: right'><b>{prefix ?? String.Empty}{formattedTotal} {performanceMeasureMeasurementUnitType.LegendDisplayName ?? String.Empty}</b></td></tr>";
            if (targetValue.HasValue && !string.IsNullOrWhiteSpace(targetValueDescription))
            {
                var formattedTarget = targetValue.Value.ToString($"#,###,###,##0.{stringPrecision}");
                html += $"<tr class='googleTooltipTableTotalRow'><td>{targetValueDescription}</td><td style='text-align: right'><b>{prefix ?? String.Empty}{formattedTarget} {performanceMeasureMeasurementUnitType.LegendDisplayName ?? String.Empty}</b></td></tr>";
            }
            if (geospatialAreaTargetValue.HasValue && !string.IsNullOrWhiteSpace(geospatialAreaTargetValueDescription))
            {
                var formattedTarget = geospatialAreaTargetValue.Value.ToString($"#,###,###,##0.{stringPrecision}");
                html += $"<tr class='googleTooltipTableTotalRow'><td>{geospatialAreaTargetValueDescription}</td><td style='text-align: right'><b>{prefix ?? String.Empty}{formattedTarget} {performanceMeasureMeasurementUnitType.LegendDisplayName ?? String.Empty}</b></td></tr>";
            }
            html += "</table></div>";

            return(html);
        }
        public static string FormattedDataTooltip(IReadOnlyCollection <IGrouping <Tuple <string, int>, PerformanceMeasureReportingPeriodSubcategoryOptionReportedValue> > groupedBySubcategoryOption, PerformanceMeasureReportingPeriod performanceMeasureReportingPeriod, MeasurementUnitType performanceMeasureMeasurementUnitType)
        {
            // shape data
            var calendarReportedYearValuesDictionary = new Dictionary <string, double>();

            groupedBySubcategoryOption.OrderBy(x => x.Key.Item2).ForEach(x =>
            {
                var calendarYearReportedValue = x.Where(isorv => isorv.PerformanceMeasureReportingPeriod.PerformanceMeasureReportingPeriodLabel == performanceMeasureReportingPeriod.PerformanceMeasureReportingPeriodLabel)
                                                .Sum(isorv => isorv.ReportedValue) ?? 0;
                calendarReportedYearValuesDictionary.Add(x.Key.Item1, calendarYearReportedValue);
            });
            var stringPrecision = new String('0', performanceMeasureMeasurementUnitType.NumberOfSignificantDigits);
            var prefix          = performanceMeasureMeasurementUnitType == MeasurementUnitType.Dollars ? "$" : null;

            // build html for tooltip
            var html = "<div class='googleTooltipDiv'>";

            html += $"<p><b>{performanceMeasureReportingPeriod.PerformanceMeasureReportingPeriodLabel}</b></p>";
            html += "<table class='table table-striped googleTooltipTable'>";
            foreach (KeyValuePair <string, double> calendarReportedYearValue in calendarReportedYearValuesDictionary)
            {
                var formattedValue = calendarReportedYearValue.Value.ToString($"#,###,###,##0.{stringPrecision}");


                html += $"<tr><td>{calendarReportedYearValue.Key}</td><td style='text-align: right'><b>{prefix ?? String.Empty}{formattedValue} {performanceMeasureMeasurementUnitType.LegendDisplayName ?? String.Empty}</b></td></tr>";
            }

            var formattedTotal = calendarReportedYearValuesDictionary.Sum(x => x.Value).ToString($"#,###,###,##0.{stringPrecision}");

            html += $"<tr class='googleTooltipTableTotalRow'><td>Total</td><td style='text-align: right'><b>{prefix ?? String.Empty}{formattedTotal} {performanceMeasureMeasurementUnitType.LegendDisplayName ?? String.Empty}</b></td></tr>";
            html += "</table></div>";

            return(html);
        }