/// <summary> /// X result column value for category value key /// </summary> /// <param name="xCategoryValueKey">X category value key</param> /// <returns>Returns simple x result column value for category value key</returns> public AnalysisProcessingSimpleXResultColumnValue XResultColumnValueForCategoryValueKey(string xCategoryValueKey) { AnalysisProcessingSimpleXResultColumnValue resultValue; if (this.xResults == null) { resultValue = new AnalysisProcessingSimpleXResultColumnValue(); this.xResults = new Dictionary <string, object> { { xCategoryValueKey, resultValue } }; } else { resultValue = this.xResults.ValueOrDefault(xCategoryValueKey) as AnalysisProcessingSimpleXResultColumnValue; if (resultValue == null) { resultValue = new AnalysisProcessingSimpleXResultColumnValue(); this.xResults.SetObjectForKey(resultValue, xCategoryValueKey); } } return(resultValue); }
/// <inheritdoc/> public override bool ApplyRowXCategoryValueArraySumLine(ICrmDataSourceRow dataSourceRow, List <object> xCategoryValueArray, bool sumLine) { var v = dataSourceRow.RawValueAtIndex(this.SourceField.QueryResultFieldIndex); var recordIdentification = $"{this.YCategoryValue.Key}:{dataSourceRow.RecordIdentificationAtIndex(this.queryTableIndex)}"; if (this.appliedRecordIdentifications.ValueOrDefault(recordIdentification) != null) { return(false); } this.appliedRecordIdentifications[recordIdentification] = 1; double doubleValue = v.ToDouble(); if (this.WeightField != null) { var weightValue = dataSourceRow.RawValueAtIndex(this.WeightField.QueryResultFieldIndex); doubleValue *= weightValue.ToDouble(); } if (this.CurrencyField != null) { string currencyValue = dataSourceRow.RawValueAtIndex(this.CurrencyField.QueryResultFieldIndex); doubleValue = this.ProcessingResultColumn.ProcessingContext.AdjustValueForCurrency(doubleValue, currencyValue); } if (this.AggregationType.Min) { if (this.count == 0 || this.aggregatedValue > doubleValue) { this.aggregatedValue = doubleValue; } } else if (this.AggregationType.Max) { if (this.aggregatedValue < doubleValue || this.count == 0) { this.aggregatedValue = doubleValue; } } else { this.aggregatedValue += doubleValue; } this.count++; if (xCategoryValueArray != null) { foreach (AnalysisProcessingXCategoryValue xCategoryValue in xCategoryValueArray) { AnalysisProcessingSimpleXResultColumnValue xResult = this.XResultColumnValueForCategoryValueKey(xCategoryValue.Key); if (this.AggregationType.Min) { if (this.count == 0 || xResult.AggregatedValue > doubleValue) { xResult.AggregatedValue = doubleValue; } } else if (this.AggregationType.Max) { if (xResult.AggregatedValue < doubleValue || this.count == 0) { xResult.AggregatedValue = doubleValue; } } else { xResult.AggregatedValue += doubleValue; } xResult.Count++; } } return(true); }