|
|
|
@ -8,6 +8,8 @@
@@ -8,6 +8,8 @@
|
|
|
|
|
// </autogenerated>
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
using System; |
|
|
|
|
using System.Collections; |
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
using System.Data; |
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -19,12 +21,14 @@ using System.Data;
@@ -19,12 +21,14 @@ using System.Data;
|
|
|
|
|
///</remarks>
|
|
|
|
|
|
|
|
|
|
namespace SharpReportCore { |
|
|
|
|
public class TableStrategy : BaseListStrategy { |
|
|
|
|
// public delegate void IndexerDelegate(int i,object[] values);
|
|
|
|
|
public class TableStrategy : BaseListStrategy,IEnumerable<BaseComparer> { |
|
|
|
|
|
|
|
|
|
DataTable table; |
|
|
|
|
DataView view = new DataView(); |
|
|
|
|
DataRowView row; |
|
|
|
|
|
|
|
|
|
#region Constructor
|
|
|
|
|
|
|
|
|
|
public TableStrategy(DataTable table,ReportSettings reportSettings):base(reportSettings) { |
|
|
|
|
if (table == null) { |
|
|
|
@ -34,12 +38,12 @@ namespace SharpReportCore {
@@ -34,12 +38,12 @@ namespace SharpReportCore {
|
|
|
|
|
view = this.table.DefaultView; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region Building the Index list
|
|
|
|
|
|
|
|
|
|
private void BuildSortIndex(SharpIndexCollection arrayList,ColumnCollection col) { |
|
|
|
|
|
|
|
|
|
#region Building Index list
|
|
|
|
|
|
|
|
|
|
private SharpIndexCollection BuildSortIndex(ColumnCollection col) { |
|
|
|
|
SharpIndexCollection arrayList = new SharpIndexCollection(); |
|
|
|
|
try { |
|
|
|
|
for (int rowIndex = 0; rowIndex < this.view.Count; rowIndex++){ |
|
|
|
|
DataRowView rowItem = this.view[rowIndex]; |
|
|
|
@ -65,25 +69,22 @@ namespace SharpReportCore {
@@ -65,25 +69,22 @@ namespace SharpReportCore {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
arrayList.Sort(); |
|
|
|
|
return arrayList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// if we have no sorting, we build the indexlist as well, so we don't need to
|
|
|
|
|
//check each time we reasd data if we have to go directly or by IndexList
|
|
|
|
|
private void BuildPlainIndex(SharpIndexCollection arrayList,ColumnCollection col) { |
|
|
|
|
try { |
|
|
|
|
for (int rowIndex = 0; rowIndex < this.view.Count; rowIndex++){ |
|
|
|
|
object[] values = new object[1]; |
|
|
|
|
|
|
|
|
|
// We insert only the RowNr as a dummy value
|
|
|
|
|
values[0] = rowIndex; |
|
|
|
|
arrayList.Add(new BaseComparer(col, rowIndex, values)); |
|
|
|
|
} |
|
|
|
|
} catch (Exception) { |
|
|
|
|
throw ; |
|
|
|
|
|
|
|
|
|
// if we have no sorting, we build the indexlist as well
|
|
|
|
|
|
|
|
|
|
private SharpIndexCollection IndexBuilder(IndexerDelegate indexer,ColumnCollection col) { |
|
|
|
|
SharpIndexCollection arrayList = new SharpIndexCollection(); |
|
|
|
|
for (int rowIndex = 0; rowIndex < this.view.Count; rowIndex++){ |
|
|
|
|
object[] values = new object[1]; |
|
|
|
|
BaseComparer bc = indexer(col,rowIndex,values); |
|
|
|
|
arrayList.Add(bc); |
|
|
|
|
} |
|
|
|
|
return arrayList; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Grouping
|
|
|
|
@ -94,7 +95,10 @@ namespace SharpReportCore {
@@ -94,7 +95,10 @@ namespace SharpReportCore {
|
|
|
|
|
|
|
|
|
|
if (base.ReportSettings.GroupColumnsCollection != null) { |
|
|
|
|
if (base.ReportSettings.GroupColumnsCollection.Count > 0) { |
|
|
|
|
this.BuildSortIndex (groupedArray,base.ReportSettings.GroupColumnsCollection); |
|
|
|
|
groupedArray = this.BuildSortIndex (base.ReportSettings.GroupColumnsCollection); |
|
|
|
|
//
|
|
|
|
|
// SharpReportCore.IndexerDelegate sort = new SharpReportCore.IndexerDelegate(BaseListStrategy.SortedIndexBuilder);
|
|
|
|
|
// groupedArray = this.IndexBuilder(sort,base.ReportSettings.GroupColumnsCollection);
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -131,6 +135,22 @@ namespace SharpReportCore {
@@ -131,6 +135,22 @@ namespace SharpReportCore {
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region IEnumerable
|
|
|
|
|
|
|
|
|
|
IEnumerator IEnumerable.GetEnumerator(){ |
|
|
|
|
System.Console.WriteLine("TableStrategy:IEnumerable.GetEnumerator()"); |
|
|
|
|
return((IEnumerable<BaseComparer>)this).GetEnumerator(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
IEnumerator<BaseComparer> IEnumerable<BaseComparer>.GetEnumerator() |
|
|
|
|
{ |
|
|
|
|
System.Console.WriteLine("\tTableStrategy:IEnumerable<BaseComparer>.GetEnumerator()"); |
|
|
|
|
IEnumerable<BaseComparer> e = (IEnumerable<BaseComparer>)base.IndexList; |
|
|
|
|
return e.GetEnumerator(); |
|
|
|
|
} |
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region IEnumerator
|
|
|
|
|
public override bool MoveNext(){ |
|
|
|
@ -177,13 +197,14 @@ namespace SharpReportCore {
@@ -177,13 +197,14 @@ namespace SharpReportCore {
|
|
|
|
|
base.Sort(); |
|
|
|
|
if ((base.ReportSettings.SortColumnCollection != null)) { |
|
|
|
|
if (base.ReportSettings.SortColumnCollection.Count > 0) { |
|
|
|
|
this.BuildSortIndex (base.IndexList, |
|
|
|
|
base.ReportSettings.SortColumnCollection); |
|
|
|
|
|
|
|
|
|
base.IndexList = this.BuildSortIndex (base.ReportSettings.SortColumnCollection); |
|
|
|
|
|
|
|
|
|
// SharpReportCore.IndexerDelegate sort = new SharpReportCore.IndexerDelegate(BaseListStrategy.SortedIndexBuilder);
|
|
|
|
|
// base.IndexList = this.IndexBuilder(sort,base.ReportSettings.SortColumnCollection);
|
|
|
|
|
base.IsSorted = true; |
|
|
|
|
} else { |
|
|
|
|
this.BuildPlainIndex(base.IndexList, |
|
|
|
|
base.ReportSettings.SortColumnCollection); |
|
|
|
|
SharpReportCore.IndexerDelegate unsort = new SharpReportCore.IndexerDelegate(BaseListStrategy.PlainIndexBuilder); |
|
|
|
|
base.IndexList = this.IndexBuilder(unsort,base.ReportSettings.SortColumnCollection); |
|
|
|
|
base.IsSorted = false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -209,7 +230,6 @@ namespace SharpReportCore {
@@ -209,7 +230,6 @@ namespace SharpReportCore {
|
|
|
|
|
baseDataItem.DbValue = row[baseDataItem.ColumnName].ToString(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} catch (Exception) { |
|
|
|
|
throw; |
|
|
|
|
} |
|
|
|
|