Browse Source

Aggregates works with CollectionDataSource

reports
Peter Forstmeier 12 years ago
parent
commit
839ce265d2
  1. 10
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionDataSource.cs
  2. 31
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Imports/ImportAggregates.cs
  3. 4
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs

10
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataManager/Listhandling/CollectionDataSource.cs

@ -45,6 +45,8 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling @@ -45,6 +45,8 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling
throw new ArgumentNullException("reportSettings");
baseList = CreateBaseList(list, elementType);
//test
CurrentList = baseList;
this.elementType = elementType;
this.reportSettings = reportSettings;
@ -71,7 +73,8 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling @@ -71,7 +73,8 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling
return availableFields;
}
}
//test
public IList <object> CurrentList {get;private set;}
public int Count {
get {
@ -88,8 +91,6 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling @@ -88,8 +91,6 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling
public void Sort()
{
// if ((reportSettings.SortColumnsCollection != null)) {
if (reportSettings.SortColumnsCollection.Count > 0) {
var sorted = SortInternal();
orderGroup = OrderGroup.Sorted;
@ -106,10 +107,9 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling @@ -106,10 +107,9 @@ namespace ICSharpCode.Reporting.DataManager.Listhandling
CurrentPosition = baseList.IndexOf(Current);
Console.WriteLine("asis CurrentPosition {0}",CurrentPosition);
}
// }
}
IEnumerable<object> SortInternal (){
IEnumerable<object> sortedList = null;
var sortProperty = listProperties.Find(reportSettings.SortColumnsCollection[0].ColumnName,true);

31
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Imports/ImportAggregates.cs

@ -1,18 +1,12 @@ @@ -1,18 +1,12 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using ICSharpCode.Reporting.DataManager.Listhandling;
using ICSharpCode.Reporting.DataSource;
using Irony.Interpreter;
using Irony.Interpreter.Ast;
namespace ICSharpCode.Reporting.Expressions.Irony.Imports
{
/// <summary>
@ -32,25 +26,18 @@ namespace ICSharpCode.Reporting.Expressions.Irony.Imports @@ -32,25 +26,18 @@ namespace ICSharpCode.Reporting.Expressions.Irony.Imports
var fieldName = childNodes[0].Evaluate(thread).ToString();
var dataSource = thread.GetDataSource();
// var curpos = dataSource.CurrentPosition;
// dataSource.CurrentPosition = 0;
if (FieldExist(dataSource.Current,fieldName)) {
do {
var current = dataSource.Current;
var property = current.ParsePropertyPath(fieldName);
var val = property.Evaluate(current);
var nextVal = TypeNormalizer.EnsureType<double>(val);
sum = sum + nextVal;
}
while (dataSource.MoveNext());
}
// dataSource.CurrentPosition = curpos;
if (FieldExist(dataSource.CurrentList[0],fieldName)) {
sum = dataSource.CurrentList.Sum(o => {
var pp = o.ParsePropertyPath(fieldName);
var value = pp.Evaluate(o);
return TypeNormalizer.EnsureType<double>(value);
});
}
return sum;
}
static bool FieldExist (object current,string fieldName) {
var property1 = current.ParsePropertyPath(fieldName);

4
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs

@ -39,8 +39,8 @@ namespace ICSharpCode.Reporting.PageBuilder @@ -39,8 +39,8 @@ namespace ICSharpCode.Reporting.PageBuilder
CreateDataSource();
base.BuildExportList();
BuildDetail();
base.BuildReportFooter();
base.AddPage(CurrentPage);
BuildReportFooter();
AddPage(CurrentPage);
UpdatePageInfo();
RunExpressions(ReportModel.ReportSettings,DataSource);

Loading…
Cancel
Save