Browse Source

Grouping with TableStrategy.cs

pull/15/head^2
peterforstmeier 15 years ago
parent
commit
2dfb2c5693
  1. 26
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/ChildNavigator.cs
  2. 6
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/ListStrategy/BaseListStrategy.cs
  3. 5
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/ListStrategy/CollectionStrategy.cs
  4. 55
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/ListStrategy/TableStrategy.cs
  5. 5
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Interfaces/IDataViewStrategy.cs

26
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/ChildNavigator.cs

@ -67,16 +67,36 @@ namespace ICSharpCode.Reports.Core
return dataStore.AvailableFields; 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) public void Fill(ReportItemCollection collection)
{ {
var ss = this.indexList[this.indexList.CurrentPosition].ListIndex; var position = this.indexList[this.indexList.CurrentPosition].ListIndex;
var current = dataStore.CurrentFromPosition(ss); var current = dataStore.CurrentFromPosition(position);
//var current = dataStore.FillDataRow(position);
dataStore.Fill(position,collection);
/*
foreach (IDataItem item in collection) foreach (IDataItem item in collection)
{ {
FillInternal(current, item); FillInternal(current, item);
} }
*/
} }

6
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) public virtual void Fill(IDataItem item)
{ {
} }

5
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/DataManager/ListStrategy/CollectionStrategy.cs

@ -198,6 +198,11 @@ namespace ICSharpCode.Reports.Core {
#endregion #endregion
public override void Fill(int position,ReportItemCollection collection)
{
// base.Fill(collection);
}
public override void Fill(IDataItem item) public override void Fill(IDataItem item)
{ {

55
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.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Data; using System.Data;
using System.Linq;
namespace ICSharpCode.Reports.Core 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) public override void Fill(IDataItem item)
{ {
DataRow row = this.Current as DataRow; DataRow row = this.Current as DataRow;
if (row != null) { if (row != null)
{
this.FillInternal (row,item);
/*
BaseImageItem bi = item as BaseImageItem; BaseImageItem bi = item as BaseImageItem;
if (bi != null) { if (bi != null)
{
using (System.IO.MemoryStream memStream = new System.IO.MemoryStream()){ using (System.IO.MemoryStream memStream = new System.IO.MemoryStream()){
Byte[] val = row[bi.ColumnName] as Byte[]; Byte[] val = row[bi.ColumnName] as Byte[];
if (val != null) { if (val != null) {
@ -57,12 +75,39 @@ namespace ICSharpCode.Reports.Core
bi.Image = image; bi.Image = image;
} }
} }
} else { } else
{
if (item != null) { 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(); item.DBValue = row[item.ColumnName].ToString();
return; return;
} }
}
} }
} }
@ -86,11 +131,9 @@ namespace ICSharpCode.Reports.Core
if ((base.ReportSettings.SortColumnsCollection != null)) { if ((base.ReportSettings.SortColumnsCollection != null)) {
if (base.ReportSettings.SortColumnsCollection.Count > 0) { if (base.ReportSettings.SortColumnsCollection.Count > 0) {
base.IndexList = this.BuildSortIndex (ReportSettings.SortColumnsCollection); base.IndexList = this.BuildSortIndex (ReportSettings.SortColumnsCollection);
//base.IsSorted = true;
} else { } else {
// if we have no sorting, we build the indexlist as well // if we have no sorting, we build the indexlist as well
base.IndexList = this.IndexBuilder(ReportSettings.SortColumnsCollection); base.IndexList = this.IndexBuilder(ReportSettings.SortColumnsCollection);
//base.IsSorted = false;
} }
} }
} }

5
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Interfaces/IDataViewStrategy.cs

@ -14,10 +14,13 @@ namespace ICSharpCode.Reports.Core{
void Bind(); void Bind();
void Fill (int position,ReportItemCollection collection);
//rausnehmen
void Fill (IDataItem item); void Fill (IDataItem item);
IndexList IndexList {get;set;} IndexList IndexList {get;set;}
//test
object CurrentFromPosition(int pos); object CurrentFromPosition(int pos);
CurrentItemsCollection FillDataRow(); CurrentItemsCollection FillDataRow();

Loading…
Cancel
Save