/// <summary> /// Recupera os resultados das agregações. /// </summary> /// <param name="functions"></param> /// <returns></returns> public AggregateResultCollection GetAggregateResults(IEnumerable <AggregateFunction> functions) { if (functions == null) { throw new ArgumentNullException("functions"); } AggregateResultCollection instance = new AggregateResultCollection(); if (this.AggregateFunctionsProjection != null) { IDictionary <string, object> propertyValues = ExtractPropertyValues(this.AggregateFunctionsProjection); IEnumerable <AggregateResult> collection = CreateAggregateResultsForPropertyValues(functions, propertyValues); instance.AddRange(collection); } return(instance); }
/// <summary> /// Gets the aggregate results generated for the given aggregate functions. /// </summary> /// <value>The aggregate results for the provided aggregate functions.</value> /// <exception cref="ArgumentNullException"><c>functions</c> is null.</exception> public AggregateResultCollection GetAggregateResults(IEnumerable<AggregateFunction> functions) { if (functions == null) { throw new ArgumentNullException("functions"); } var resultCollection = new AggregateResultCollection(); if (this.AggregateFunctionsProjection == null) { return resultCollection; } var propertyValues = ExtractPropertyValues(AggregateFunctionsProjection); var results = CreateAggregateResultsForPropertyValues(functions, propertyValues); resultCollection.AddRange(results); return resultCollection; }
/// <summary> /// Gets the aggregate results generated for the given aggregate functions. /// </summary> /// <value>The aggregate results for the provided aggregate functions.</value> /// <exception cref="ArgumentNullException"><c>functions</c> is null.</exception> public AggregateResultCollection GetAggregateResults(IEnumerable <AggregateFunction> functions) { if (functions == null) { throw new ArgumentNullException("functions"); } var resultCollection = new AggregateResultCollection(); if (this.AggregateFunctionsProjection == null) { return(resultCollection); } var propertyValues = ExtractPropertyValues(AggregateFunctionsProjection); var results = CreateAggregateResultsForPropertyValues(functions, propertyValues); resultCollection.AddRange(results); return(resultCollection); }
/// <summary> /// Updates aggregate results with calculated values. /// </summary> /// <param name="results">The aggregate result collection.</param> public void SetAggregateResults(AggregateResultCollection results) { if (!IsAttached || results == null) return; var group = _groupInfo.Target as QueryableCollectionViewGroup; if (group != null) { var aggregateFunctions = ((GridViewColumn)_column.Target).DataControl.Columns.Cast<GridViewColumn>() .SelectMany(x => x.AggregateFunctions) .ToDictionary(x => x.FunctionName, x => x); if (!aggregateFunctions.Any()) return; foreach (var result in results) { var functionName = AggregateHelper.BuildFunctionName(result.ColumnName, result.SummaryType); AggregateFunction func; aggregateFunctions.TryGetValue(functionName, out func); var aggregateResult = group.AggregateResults.FirstOrDefault(x => x.FunctionName == functionName); if (func == null) { if (aggregateResult != null) group.AggregateResults.Remove(aggregateResult); continue; } if (aggregateResult == null) AddAggregateResult(group, result, func); else aggregateResult.FormattedValue = result.Value; } _aggregateResults = group.AggregateResults.ToList(); RefreshGroupFooter(); } }
/// <summary> /// Applies post-processing to result values and generates Empty results /// for those aggregates not having the corresponding result retrieved. /// </summary> /// <param name="source">The source collection of aggregate results.</param> /// <param name="aggregateDefinitions">The corresponfing aggregate definitions.</param> /// <returns>AggregateResultCollection</returns> private static AggregateResultCollection AdjustAggregateResults(AggregateResultCollection source, IEnumerable<AggregateDefinition> aggregateDefinitions) { var resultList = source.ToList(); var aggregates = aggregateDefinitions.ToList(); if (resultList.Count == 0) { foreach (var aggrDef in aggregates) { resultList.Add( AggregateResult.CreateEmpty( aggrDef.ColumnName, aggrDef.SummaryType )); } } else { foreach (var result in resultList) { var aggrDef = aggregates.FirstOrDefault( x => x.ColumnName == result.ColumnName && x.SummaryType == result.SummaryType); if (aggrDef != null) aggregates.Remove(aggrDef); } if (aggregates.Any()) { foreach (var aggrDef in aggregates) { resultList.Add( AggregateResult.CreateEmpty( aggrDef.ColumnName, aggrDef.SummaryType )); } } } return new AggregateResultCollection(resultList); }
public AggregationCompletedEventArgs(AggregateResultCollection results, IList<AggregateDefinition> aggregateDefinitions, Exception error) { AggregateResults = results; AggregateDefinitions = aggregateDefinitions; Error = error; }