Permalink
Browse files

Grouping with TableStrategy.cs

  • Loading branch information...
1 parent 88ae3c1 commit 2dfb2c569359956e82c294ff2c1038acff0445fd @PeterForstmeier PeterForstmeier committed Feb 25, 2011
@@ -67,16 +67,36 @@ public int CurrentRow
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);
}
+ */
}
@@ -231,6 +231,12 @@ public virtual void Bind()
}
+ public virtual void Fill(int position,ReportItemCollection collection)
+ {
+ throw new NotImplementedException();
+ }
+
+
public virtual void Fill(IDataItem item)
{
}
@@ -198,6 +198,11 @@ public override void Bind()
#endregion
+ public override void Fill(int position,ReportItemCollection collection)
+ {
+// base.Fill(collection);
+ }
+
public override void Fill(IDataItem item)
{
@@ -6,6 +6,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
+using System.Linq;
namespace ICSharpCode.Reports.Core
{
@@ -39,12 +40,29 @@ public override void Bind()
}
+ 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 @@ public override void Fill(IDataItem item)
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 @@ public override void Sort()
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;
}
}
}
@@ -14,10 +14,13 @@ public interface IDataViewStrategy:IEnumerator,IDisposable{
void Bind();
+ void Fill (int position,ReportItemCollection collection);
+
+ //rausnehmen
void Fill (IDataItem item);
IndexList IndexList {get;set;}
- //test
+
object CurrentFromPosition(int pos);
CurrentItemsCollection FillDataRow();

0 comments on commit 2dfb2c5

Please sign in to comment.