protected void pivotIndicador_ItemNeedCalculation(object sender, Telerik.Web.UI.PivotGridCalculationEventArgs e) { if (e.DataField == "Indicador") { AggregateValue TotalRenovada = e.GetAggregateValue("TotalRenovada"); AggregateValue TotalRefinanciada = e.GetAggregateValue("TotalRefinanciada"); AggregateValue DeudaTotal = e.GetAggregateValue("DeudaTotal"); if (TotalRenovada != null && TotalRefinanciada != null && DeudaTotal != null) { decimal val_TotalRenovada = (decimal)TotalRenovada.GetValue(); decimal val_TotalRefinanciada = (decimal)TotalRefinanciada.GetValue(); decimal val_DeudaTotal = (decimal)DeudaTotal.GetValue(); if (val_DeudaTotal == 0) { e.CalculatedValue = new DoubleAggregateValue(0); } else { double resultado = Convert.ToDouble(((val_TotalRenovada + val_TotalRefinanciada) / val_DeudaTotal) * 100); e.CalculatedValue = new DoubleAggregateValue(resultado); } } } }
/// <inheritdoc /> protected override void MergeOverride(AggregateValue childAggregate) { AverageAggregate averageChildAggregate = (AverageAggregate)childAggregate; this.sum += averageChildAggregate.sum; this.count += averageChildAggregate.count; }
public static TryCatch <SingleGroupAggregator> TryCreate( IReadOnlyDictionary <string, AggregateOperator?> aggregateAliasToAggregateType, IReadOnlyList <string> orderedAliases, string continuationToken) { CosmosObject aliasToContinuationToken; if (continuationToken != null) { if (!CosmosElement.TryParse(continuationToken, out aliasToContinuationToken)) { return(TryCatch <SingleGroupAggregator> .FromException( new MalformedContinuationTokenException( $"{nameof(SelectListAggregateValues)} continuation token is malformed: {continuationToken}."))); } } else { aliasToContinuationToken = null; } Dictionary <string, AggregateValue> groupingTable = new Dictionary <string, AggregateValue>(); foreach (KeyValuePair <string, AggregateOperator?> aliasToAggregate in aggregateAliasToAggregateType) { string alias = aliasToAggregate.Key; AggregateOperator?aggregateOperator = aliasToAggregate.Value; string aliasContinuationToken; if (aliasToContinuationToken != null) { if (!(aliasToContinuationToken[alias] is CosmosString parsedAliasContinuationToken)) { return(TryCatch <SingleGroupAggregator> .FromException( new MalformedContinuationTokenException( $"{nameof(SelectListAggregateValues)} continuation token is malformed: {continuationToken}."))); } aliasContinuationToken = parsedAliasContinuationToken.Value; } else { aliasContinuationToken = null; } TryCatch <AggregateValue> tryCreateAggregateValue = AggregateValue.TryCreate( aggregateOperator, aliasContinuationToken); if (tryCreateAggregateValue.Succeeded) { groupingTable[alias] = tryCreateAggregateValue.Result; } else { return(TryCatch <SingleGroupAggregator> .FromException(tryCreateAggregateValue.Exception)); } } return(TryCatch <SingleGroupAggregator> .FromResult(new SelectListAggregateValues(groupingTable, orderedAliases))); }
public static void Write(DryadLinqBinaryWriter writer, AggregateValue <T> aggVal) { writer.Write(aggVal.Count); if (aggVal.Count > 0) { serializer.Write(writer, aggVal.Value); } }
protected override void MergeOverride(AggregateValue childAggregate) { ListAggregate agg = childAggregate as ListAggregate; foreach (var item in agg.items) { this.items.Add(item); } }
private SelectValueAggregateValues(AggregateValue aggregateValue) { if (aggregateValue == null) { throw new ArgumentNullException(nameof(AggregateValue)); } this.aggregateValue = aggregateValue; }
/// <inheritdoc /> protected override void MergeOverride(AggregateValue childAggregate) { VarianceAggregateBase standardDeviationChildAggregate = (VarianceAggregateBase)childAggregate; foreach (double value in standardDeviationChildAggregate.values) { this.values.Add(value); } }
public static void Read(DryadLinqBinaryReader reader, out AggregateValue <T> aggVal) { long cnt = reader.ReadInt64(); T val = default(T); if (cnt > 0) { val = serializer.Read(reader); } aggVal = new AggregateValue <T>(val, cnt); }
public static SelectListAggregateValues Create(IReadOnlyDictionary <string, AggregateOperator?> aggregateAliasToAggregateType) { Dictionary <string, AggregateValue> groupingTable = new Dictionary <string, AggregateValue>(); foreach (KeyValuePair <string, AggregateOperator?> aliasToAggregate in aggregateAliasToAggregateType) { string alias = aliasToAggregate.Key; AggregateOperator?aggregateOperator = aliasToAggregate.Value; groupingTable[alias] = AggregateValue.Create(aggregateOperator); } return(new SelectListAggregateValues(groupingTable)); }
protected override AggregateValue GetValue(IAggregateSummaryValues aggregateSummaryValues) { AggregateValue aggregateValue = aggregateSummaryValues.GetAggregateValue("Canada"); if (aggregateValue.IsError()) { return(AggregateValue.ErrorAggregateValue); } var value = aggregateValue.ConvertOrDefault <double>() > 500 ? 500 : 0; return(new DoubleAggregateValue(value)); }
public override void AddValues(CosmosElement values) { if (!(values is CosmosObject payload)) { throw new ArgumentException("values is not an object."); } foreach (KeyValuePair <string, AggregateValue> aliasAndValue in this.aliasToValue) { string alias = aliasAndValue.Key; AggregateValue aggregateValue = aliasAndValue.Value; aggregateValue.AddValue(payload[alias]); } }
/// <inheritdoc /> protected internal override void FormatTotals(IReadOnlyList <TotalValue> valueFormatters, IAggregateResultProvider results) { double accumulation = 0; foreach (var valueFormatter in valueFormatters) { AggregateValue value = valueFormatter.Value; if (value != null) { accumulation += Convert.ToDouble(value.GetValue(), CultureInfo.InvariantCulture); } valueFormatter.FormattedValue = new ConstantValueAggregate(accumulation); } }
public static SelectListAggregateValues Create( CosmosQueryClient cosmosQueryClient, IReadOnlyDictionary <string, AggregateOperator?> aggregateAliasToAggregateType, IReadOnlyList <string> orderedAliases, string continuationToken) { CosmosObject aliasToContinuationToken; if (continuationToken != null) { if (!CosmosElement.TryParse(continuationToken, out aliasToContinuationToken)) { throw cosmosQueryClient.CreateBadRequestException( $"{nameof(SelectListAggregateValues)} continuation token is malformed: {continuationToken}."); } } else { aliasToContinuationToken = null; } Dictionary <string, AggregateValue> groupingTable = new Dictionary <string, AggregateValue>(); foreach (KeyValuePair <string, AggregateOperator?> aliasToAggregate in aggregateAliasToAggregateType) { string alias = aliasToAggregate.Key; AggregateOperator?aggregateOperator = aliasToAggregate.Value; string aliasContinuationToken; if (aliasToContinuationToken != null) { if (!(aliasToContinuationToken[alias] is CosmosString parsedAliasContinuationToken)) { throw cosmosQueryClient.CreateBadRequestException( $"{nameof(SelectListAggregateValues)} continuation token is malformed: {continuationToken}."); } aliasContinuationToken = parsedAliasContinuationToken.Value; } else { aliasContinuationToken = null; } groupingTable[alias] = AggregateValue.Create(aggregateOperator, aliasContinuationToken); } return(new SelectListAggregateValues(groupingTable, orderedAliases)); }
protected override void MergeOverride(AggregateValue childAggregate) { if (this.Function == null) { return; } var userAggregate = childAggregate as UserAggregateValue; if (userAggregate == null) { return; } this.Function.Merge(userAggregate.Function); }
public override CosmosElement GetResult() { List <KeyValuePair <string, CosmosElement> > aliasToElement = new List <KeyValuePair <string, CosmosElement> >(); foreach (string alias in this.orderedAliases) { AggregateValue aggregateValue = this.aliasToValue[alias]; if (aggregateValue.Result != null) { KeyValuePair <string, CosmosElement> kvp = new KeyValuePair <string, CosmosElement>(alias, aggregateValue.Result); aliasToElement.Add(kvp); } } return(CosmosObject.Create(aliasToElement)); }
public override CosmosElement GetResult() { Dictionary <string, CosmosElement> aliasToElement = new Dictionary <string, CosmosElement>(); foreach (KeyValuePair <string, AggregateValue> aliasAndValue in this.aliasToValue) { string alias = aliasAndValue.Key; AggregateValue aggregateValue = aliasAndValue.Value; if (aggregateValue.Result != null) { aliasToElement[alias] = aggregateValue.Result; } } return(CosmosObject.Create(aliasToElement)); }
public override CosmosElement GetResult() { Dictionary <string, CosmosElement> dictionary = new Dictionary <string, CosmosElement>(capacity: this.orderedAliases.Count); List <string> keys = new List <string>(this.orderedAliases.Count); foreach (string alias in this.orderedAliases) { AggregateValue aggregateValue = this.aliasToValue[alias]; if (aggregateValue.Result != null) { dictionary[alias] = aggregateValue.Result; keys.Add(alias); } } return(new OrderedCosmosObject(dictionary, keys)); }
// This is the IQueryProvider.Execute() method used for execution // when a single value is produced (rather than an enumerable) public override TResult Execute <TResult>(Expression expression) { MethodCallExpression callExpr = expression as MethodCallExpression; if (callExpr == null) { throw new ArgumentException(String.Format(SR.ExpressionMustBeMethodCall, DryadLinqExpression.Summarize(expression)), "expression"); } string methodName = callExpr.Method.Name; if (methodName == "FirstOrDefault" || methodName == "SingleOrDefault" || methodName == "LastOrDefault") { Type elemType = typeof(AggregateValue <>).MakeGenericType(expression.Type); Type qType = typeof(DryadLinqQuery <>).MakeGenericType(elemType); AggregateValue <TResult> res = ((IEnumerable <AggregateValue <TResult> >) Activator.CreateInstance( qType, BindingFlags.NonPublic | BindingFlags.Instance, null, new object[] { this, expression }, CultureInfo.CurrentCulture )).Single(); if (res.Count == 0) { return(default(TResult)); } return(res.Value); } else { Type qType = typeof(DryadLinqQuery <>).MakeGenericType(expression.Type); return(((IEnumerable <TResult>)Activator.CreateInstance( qType, BindingFlags.NonPublic | BindingFlags.Instance, null, new object[] { this, expression }, CultureInfo.CurrentCulture )).Single()); } }
public static SelectValueAggregateValues Create(AggregateOperator?aggregateOperator, string continuationToken) { AggregateValue aggregateValue = AggregateValue.Create(aggregateOperator, continuationToken); return(new SelectValueAggregateValues(aggregateValue)); }
/// <inheritdoc /> protected override void MergeOverride(AggregateValue childAggregate) { this.product *= ((ProductAggregate)childAggregate).product; }
/// <inheritdoc /> protected override void MergeOverride(AggregateValue childAggregate) { this.max = Math.Max(this.max, ((MaxAggregate)childAggregate).max); }
public static SelectValueAggregateValues Create(AggregateOperator?aggregateOperator) { AggregateValue aggregateValue = AggregateValue.Create(aggregateOperator); return(new SelectValueAggregateValues(aggregateValue)); }
protected override void MergeOverride(AggregateValue childAggregate) { throw new NotImplementedException(); }
/// <inheritdoc /> protected override void MergeOverride(AggregateValue childAggregate) { this.sum += ((SumAggregate)childAggregate).sum; }
public static TryCatch <SingleGroupAggregator> TryCreate(AggregateOperator?aggregateOperator, CosmosElement continuationToken) { return(AggregateValue.TryCreate(aggregateOperator, continuationToken) .Try((aggregateValue) => (SingleGroupAggregator) new SelectValueAggregateValues(aggregateValue))); }
/// <inheritdoc /> protected override void MergeOverride(AggregateValue childAggregate) { this.min = Math.Min(this.min, ((MinAggregate)childAggregate).min); }
/// <inheritdoc /> protected override void MergeOverride(AggregateValue childAggregate) { this.count += ((CountAggregate)childAggregate).count; }
/// <summary> /// Aggregate value tostring /// </summary> public override string ToString() { return(AggregateValue.ToString()); }