Пример #1
0
 public static void AppendScenarios(StringBuilder keyNameString, ContextProperty cp)
 {
     foreach (Scenario s in cp.Scenarios)
     {
         keyNameString.Append(InstanceUtils.BuildSegmentScenarioName(s)).Append(Environment.NewLine);
     }
 }
Пример #2
0
        public static void BuildSharedKeyParts(StringBuilder keyNameString, ContextProperty cp, bool includeEntityID)
        {
            if (includeEntityID)
            {
                keyNameString.Append(TraceUtility.FormatStringResource("DragonView.Data.EntityIDColon", cp.EntityValue));
                keyNameString.Append(Environment.NewLine);
            }

            foreach (Segment s in cp.Segments)
            {
                keyNameString.Append(InstanceUtils.BuildSegmentScenarioName(s)).Append(Environment.NewLine);
            }

            if (cp.PeriodType == Element.PeriodType.duration)
            {
                keyNameString.Append(string.Format("{0} - {1}",
                                                   cp.PeriodStartDate.ToString("d"),
                                                   cp.PeriodEndDate.ToString("d")));
            }
            else if (cp.PeriodType == Element.PeriodType.instant)
            {
                // instant
                keyNameString.Append(cp.PeriodStartDate.ToString("d"));
            }
            else             //forever
            {
                keyNameString.Append(TraceUtility.FormatStringResource("DragonView.Data.Forever"));
            }

            keyNameString.Append(Environment.NewLine);
        }
Пример #3
0
        /// <summary>
        /// Retrieve the currency code of this wrapper's underlying unit
        /// property.
        /// </summary>
        /// <returns>A string of the currency code.</returns>
        public string GetCurrencyCode()
        {
            if (this.UnderlyingUnitProperty == null)
            {
                return(string.Empty);
            }

            return(InstanceUtils.GetCurrencyCodeFromUnit(this.UnderlyingUnitProperty));
        }
Пример #4
0
        /// <summary>
        /// Unique method for generating the "generic" key of a column.  Test this method extensively before using.
        /// </summary>
        /// <returns></returns>
        public string BuildDateAndSegmentKey()
        {
            StringBuilder keyNameString = new StringBuilder();

            InstanceUtils.BuildSharedKeyParts(keyNameString, this.contextRef, false);
            InstanceUtils.AppendScenarios(keyNameString, this.contextRef);

            string key = keyNameString.ToString();

            return(key);
        }
Пример #5
0
        public void EvaluateRoundingLevels(ITraceMessenger messenger)
        {
            this.HasCustomUnits = false;
            Dictionary <UnitType, RoundingLevel> selectedRounding = new Dictionary <UnitType, RoundingLevel>();

            foreach (int unit in this.UnitDictionary.Keys)
            {
                UnitType ut = (UnitType)unit;
                selectedRounding[ut] = RoundingLevel.UnKnown;

                List <InstanceReportRow> unitRows = this.Rows.FindAll(row => row.Unit == ut);
                if (unitRows.Count == 0)
                {
                    continue;
                }

                if (!this.HasCustomUnits)
                {
                    switch (ut)
                    {
                    case UnitType.EPS:
                    case UnitType.ExchangeRate:
                    case UnitType.Monetary:
                    case UnitType.Shares:
                        break;

                    default:
                        this.HasCustomUnits = true;
                        break;
                    }
                }

                foreach (InstanceReportRow row in unitRows)
                {
                    if (row.MyPrecision == null)
                    {
                        continue;
                    }

                    //Numeric data that is Nill for all values will not have a precision
                    //defined, so we don't want to include these rows in our processing logic
                    if (row.IsNumericDataNil())
                    {
                        continue;
                    }

                    RoundingLevel currentRounding = InstanceUtils.GetRoundingLevelFromPrecision(row.MyPrecision);
                    selectedRounding[ut] = this.SelectRoundingLevel(row.Unit, selectedRounding[row.Unit], currentRounding, row.ElementName, messenger);

                    if (selectedRounding[ut] > RoundingLevel.NoRounding)
                    {
                        double factor = Math.Pow(10, row.MyPrecision.NumberOfDigits * -1);
                        foreach (Cell cell in row.Cells)
                        {
                            if (cell.IsNil)
                            {
                                continue;
                            }

                            if (!cell.HasData || cell.NumericAmount == 0)
                            {
                                continue;
                            }

                            if (Math.Abs((double)cell.NumericAmount) < factor)
                            {
                                selectedRounding[row.Unit] = RoundingLevel.NoRounding;
                                break;
                            }
                        }
                    }

                    if (selectedRounding[row.Unit] == RoundingLevel.NoRounding)
                    {
                        break;
                    }
                }
            }

            this.MonetaryRoundingLevel = RoundingLevel.UnKnown;
            if (selectedRounding.ContainsKey(UnitType.Monetary))
            {
                this.MonetaryRoundingLevel = selectedRounding[UnitType.Monetary];
            }

            this.SharesRoundingLevel = RoundingLevel.UnKnown;
            if (selectedRounding.ContainsKey(UnitType.Shares))
            {
                this.SharesRoundingLevel = selectedRounding[UnitType.Shares];
            }

            this.PerShareRoundingLevel = RoundingLevel.UnKnown;
            if (selectedRounding.ContainsKey(UnitType.EPS))
            {
                this.PerShareRoundingLevel = selectedRounding[UnitType.EPS];
            }

            this.ExchangeRateRoundingLevel = RoundingLevel.UnKnown;
            if (selectedRounding.ContainsKey(UnitType.ExchangeRate))
            {
                this.ExchangeRateRoundingLevel = selectedRounding[UnitType.ExchangeRate];
            }
        }
Пример #6
0
        public string GetSegmentsString(bool includeScenarios, bool includePromotedLabels, bool includePrevReportScenario, bool includeAdjustmentLabel, bool includeCurrency, string reportName)
        {
            StringBuilder sbSegment = new StringBuilder();

            int    idxLastParen   = reportName.LastIndexOf('(');
            string promotedLabels = idxLastParen > 0 ? reportName.Substring(idxLastParen) : string.Empty;

            for (int index = 0; index < this.Segments.Count; index++)
            {
                Segment s = this.Segments[index] as Segment;

                string strSegment = InstanceUtils.BuildSegmentScenarioName(s);
                if (includePromotedLabels ||
                    !promotedLabels.Contains(strSegment))
                {
                    if (!includePrevReportScenario &&
                        s.DimensionInfo != null &&
                        s.DimensionInfo.dimensionId == InstanceUtils._ScenarioAxis &&
                        s.DimensionInfo.Id == InstanceUtils._ScenarioAsPreviouslyReport)
                    {
                        //If the caller does not want to include the "As Previously Reported" scenario in the label
                        //and we are on that scenario, we need to skip it
                        continue;
                    }

                    if (!includeAdjustmentLabel &&
                        s.DimensionInfo != null &&
                        s.DimensionInfo.dimensionId == InstanceUtils._ScenarioAxis &&
                        s.DimensionInfo.Id == InstanceUtils._ScenarioAdjustment)
                    {
                        //If the caller does not want to include the "Adjustment" scenario in the label
                        //and we are on that scenario, we need to skip it
                        continue;
                    }

                    //Not the first value appended to the string, append the delimeter
                    if (sbSegment.Length > 0)
                    {
                        sbSegment.Append(" | ");
                    }

                    sbSegment.Append(strSegment);
                }
            }

            if (includeScenarios &&
                this.hasScenarios)
            {
                for (int index = 0; index < this.Scenarios.Count; index++)
                {
                    Scenario s = this.Scenarios[index] as Scenario;

                    string strScenario = InstanceUtils.BuildSegmentScenarioName(s);
                    if (includePromotedLabels ||
                        !reportName.Contains(strScenario))
                    {
                        if (!includePrevReportScenario &&
                            s.DimensionInfo != null &&
                            s.DimensionInfo.dimensionId == InstanceUtils._ScenarioAxis &&
                            s.DimensionInfo.Id == InstanceUtils._ScenarioAsPreviouslyReport)
                        {
                            //If the caller does not want to include the "As Previously Reported" scenario in the label
                            //and we are on that scenario, we need to skip it
                            continue;
                        }

                        if (!includeAdjustmentLabel &&
                            s.DimensionInfo != null &&
                            s.DimensionInfo.dimensionId == InstanceUtils._ScenarioAxis &&
                            s.DimensionInfo.Id == InstanceUtils._ScenarioAdjustment)
                        {
                            //If the caller does not want to include the "Adjustment" scenario in the label
                            //and we are on that scenario, we need to skip it
                            continue;
                        }

                        //Not the first value appended to the string, append the delimeter
                        if (sbSegment.Length > 0)
                        {
                            sbSegment.Append(" | ");
                        }

                        sbSegment.Append(strScenario);
                    }
                }
            }
            if (includeCurrency)
            {
                string curCode = InstanceUtils.GetCurrencyCodeFromMCU(this.MCU);
                sbSegment.Append(curCode);
            }

            return(sbSegment.ToString());
        }