From 2dfb2c569359956e82c294ff2c1038acff0445fd Mon Sep 17 00:00:00 2001 From: peterforstmeier Date: Fri, 25 Feb 2011 20:48:40 +0100 Subject: [PATCH] Grouping with TableStrategy.cs --- .../Project/DataManager/ChildNavigator.cs | 26 ++++++++- .../ListStrategy/BaseListStrategy.cs | 6 ++ .../ListStrategy/CollectionStrategy.cs | 5 ++ .../DataManager/ListStrategy/TableStrategy.cs | 55 +++++++++++++++++-- .../Project/Interfaces/IDataViewStrategy.cs | 5 +- 5 files changed, 87 insertions(+), 10 deletions(-) diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/ChildNavigator.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/ChildNavigator.cs index 38dfe9ccb7..6776226311 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/ChildNavigator.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/ChildNavigator.cs @@ -67,16 +67,36 @@ namespace ICSharpCode.Reports.Core return dataStore.AvailableFields; } } - + + /* + public void Fill(ReportItemCollection collection) + { + TableStrategy tableStrategy = store as TableStrategy; + foreach (var item in collection) { + IDataItem dataItem = item as IDataItem; + if (dataItem != null) { + CurrentItemsCollection currentItemsCollection = tableStrategy.FillDataRow(this.indexList[CurrentRow].ListIndex); + CurrentItem s = currentItemsCollection.FirstOrDefault(x => x.ColumnName == dataItem.ColumnName); + dataItem.DBValue = s.Value.ToString(); + } + + } + } + */ public void Fill(ReportItemCollection collection) { - var ss = this.indexList[this.indexList.CurrentPosition].ListIndex; - var current = dataStore.CurrentFromPosition(ss); + var position = this.indexList[this.indexList.CurrentPosition].ListIndex; + var current = dataStore.CurrentFromPosition(position); + + //var current = dataStore.FillDataRow(position); + dataStore.Fill(position,collection); + /* foreach (IDataItem item in collection) { FillInternal(current, item); } + */ } diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/ListStrategy/BaseListStrategy.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/ListStrategy/BaseListStrategy.cs index c5d9791865..233077cd7f 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/ListStrategy/BaseListStrategy.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/ListStrategy/BaseListStrategy.cs @@ -231,6 +231,12 @@ namespace ICSharpCode.Reports.Core { } + public virtual void Fill(int position,ReportItemCollection collection) + { + throw new NotImplementedException(); + } + + public virtual void Fill(IDataItem item) { } diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/ListStrategy/CollectionStrategy.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/ListStrategy/CollectionStrategy.cs index 46e352ac42..2384af96bf 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/ListStrategy/CollectionStrategy.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/ListStrategy/CollectionStrategy.cs @@ -198,6 +198,11 @@ namespace ICSharpCode.Reports.Core { #endregion + public override void Fill(int position,ReportItemCollection collection) + { +// base.Fill(collection); + } + public override void Fill(IDataItem item) { diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/ListStrategy/TableStrategy.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/ListStrategy/TableStrategy.cs index d3edc26c08..1515920a1d 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/ListStrategy/TableStrategy.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/ListStrategy/TableStrategy.cs @@ -6,6 +6,7 @@ using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Data; +using System.Linq; namespace ICSharpCode.Reports.Core { @@ -39,12 +40,29 @@ namespace ICSharpCode.Reports.Core } + public override void Fill(int position,ReportItemCollection collection) + { + DataRow row = this.table.Rows[position]; + foreach (var item in collection) { + IDataItem dataItem = item as IDataItem; + if (dataItem != null) { + FillInternal (row,dataItem); + } + } + } + + public override void Fill(IDataItem item) { DataRow row = this.Current as DataRow; - if (row != null) { + if (row != null) + { + + this.FillInternal (row,item); + /* BaseImageItem bi = item as BaseImageItem; - if (bi != null) { + if (bi != null) + { using (System.IO.MemoryStream memStream = new System.IO.MemoryStream()){ Byte[] val = row[bi.ColumnName] as Byte[]; if (val != null) { @@ -57,12 +75,39 @@ namespace ICSharpCode.Reports.Core bi.Image = image; } } - } else { + } else + { if (item != null) { + item.DBValue = row[item.ColumnName].ToString(); + return; + } + } + */ + } + } + + + void FillInternal (DataRow row,IDataItem item) + { + BaseImageItem bi = item as BaseImageItem; + if (bi != null) { + using (System.IO.MemoryStream memStream = new System.IO.MemoryStream()){ + Byte[] val = row[bi.ColumnName] as Byte[]; + if (val != null) { + if ((val[78] == 66) && (val[79] == 77)){ + memStream.Write(val, 78, val.Length - 78); + } else { + memStream.Write(val, 0, val.Length); + } + System.Drawing.Image image = System.Drawing.Image.FromStream(memStream); + bi.Image = image; + } + } + } else { + if (item != null) { item.DBValue = row[item.ColumnName].ToString(); return; } - } } } @@ -86,11 +131,9 @@ namespace ICSharpCode.Reports.Core if ((base.ReportSettings.SortColumnsCollection != null)) { if (base.ReportSettings.SortColumnsCollection.Count > 0) { base.IndexList = this.BuildSortIndex (ReportSettings.SortColumnsCollection); - //base.IsSorted = true; } else { // if we have no sorting, we build the indexlist as well base.IndexList = this.IndexBuilder(ReportSettings.SortColumnsCollection); - //base.IsSorted = false; } } } diff --git a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Interfaces/IDataViewStrategy.cs b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Interfaces/IDataViewStrategy.cs index 97bd63136d..2b89ceabc7 100644 --- a/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Interfaces/IDataViewStrategy.cs +++ b/src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Interfaces/IDataViewStrategy.cs @@ -14,10 +14,13 @@ namespace ICSharpCode.Reports.Core{ void Bind(); + void Fill (int position,ReportItemCollection collection); + + //rausnehmen void Fill (IDataItem item); IndexList IndexList {get;set;} - //test + object CurrentFromPosition(int pos); CurrentItemsCollection FillDataRow();