Browse Source

Add Grouping (only one Column)to SharpReport, made some fixes from FxCOp

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1193 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Peter Forstmeier 20 years ago
parent
commit
1a5c72995e
  1. 14
      src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/BaseDesignerControl.cs
  2. 52
      src/AddIns/Misc/SharpReport/SharpReport/SharpReportManager.cs
  3. 1
      src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportDisplayBinding.cs
  4. 6
      src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportView.cs
  5. 38
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs
  6. 21
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportObject.cs
  7. 48
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseSection.cs
  8. 8
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseImageItem.cs
  9. 16
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseRectangleItem.cs
  10. 28
      src/AddIns/Misc/SharpReport/SharpReportCore/ConnectionObject.cs
  11. 4
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/Comparer/BaseComparer.cs
  12. 103
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/Comparer/GroupComparer.cs
  13. 97
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/Comparer/GroupSeperator.cs
  14. 4
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/Comparer/SortComparer.cs
  15. 250
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/DataManager.cs
  16. 56
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/ExtendedPropertyDescriptor.cs
  17. 45
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/IExtendedList.cs
  18. 41
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/IHierarchicalArray.cs
  19. 8
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/PropertyTypeHash.cs
  20. 383
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/SharpArrayList.cs
  21. 263
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/BaseListStrategy.cs
  22. 228
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/CollectionStrategy.cs
  23. 296
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/TableStrategy.cs
  24. 4
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/SqlQueryChecker.cs
  25. 4
      src/AddIns/Misc/SharpReport/SharpReportCore/Exceptions/MissingDataSourceException.cs
  26. 15
      src/AddIns/Misc/SharpReport/SharpReportCore/Globals/FontSingleton.cs
  27. 6
      src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalEnums.cs
  28. 7
      src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IDataContainer.cs
  29. 27
      src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IDataViewStrategy.cs
  30. 15
      src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IHierarchyInterfaces.cs
  31. 6
      src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IOutputStrategy.cs
  32. 15
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs
  33. 2
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/ReportDocument.cs
  34. 26
      src/AddIns/Misc/SharpReport/SharpReportCore/ReportModel.cs
  35. 66
      src/AddIns/Misc/SharpReport/SharpReportCore/ReportSettings.cs
  36. 9
      src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj
  37. 61
      src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportEngine.cs
  38. 30
      src/AddIns/Misc/SharpReport/SharpReportCore/Xml/XmlHelper.cs

14
src/AddIns/Misc/SharpReport/SharpReport/Designer/SectionControls/BaseDesignerControl.cs

@ -57,13 +57,10 @@ namespace SharpReport.Designer @@ -57,13 +57,10 @@ namespace SharpReport.Designer
#region overrides
protected override void Dispose(bool disposing ) {
if( disposing )
{
// if( components != null )
// components.Dispose();
if( disposing ){
this.reportControl = null;
this.ctrlRuler1 = null;
}
this.reportControl = null;
this.ctrlRuler1 = null;
base.Dispose( disposing );
}
@ -110,7 +107,10 @@ namespace SharpReport.Designer @@ -110,7 +107,10 @@ namespace SharpReport.Designer
public ReportModel ReportModel {
get {
reportModel.ReportSettings = reportControl.ReportSettings;
reportModel.SectionCollection = reportControl.SectionCollection;
reportModel.SectionCollection.Clear();
foreach (ReportSection section in reportControl.SectionCollection) {
reportModel.SectionCollection.Add (section);
}
return this.reportModel;
}

52
src/AddIns/Misc/SharpReport/SharpReport/SharpReportManager.cs

@ -73,7 +73,6 @@ namespace SharpReport{ @@ -73,7 +73,6 @@ namespace SharpReport{
/// <returns><see cref="ColumnCollection"</returns>
private ColumnCollection ReadColumnCollection() {
ColumnCollection columnCollecion = new ColumnCollection();
switch (baseDesignerControl.ReportModel.DataModel) {
case GlobalEnums.enmPushPullModel.FormSheet:
@ -88,13 +87,20 @@ namespace SharpReport{ @@ -88,13 +87,20 @@ namespace SharpReport{
if (base.ConnectionObject == null) {
base.ConnectionObject = this.BuildConnectionObject(baseDesignerControl.ReportModel.ReportSettings);
}
if (this.baseDesignerControl.ReportModel.DataModel.Equals(GlobalEnums.enmPushPullModel.PullData)){
using (DataManager dataManager = new DataManager(base.ConnectionObject,
baseDesignerControl.ReportModel.ReportSettings)) {
dataManager.DataBind();
columnCollecion = dataManager.AvailableFields;
try {
using (DataManager dataManager = new DataManager(base.ConnectionObject,
baseDesignerControl.ReportModel.ReportSettings)) {
dataManager.DataBind();
columnCollecion = dataManager.AvailableFields;
}
} catch (Exception e) {
throw e;
} finally {
System.Console.WriteLine("ReportManager:ReadColumnCollection in finally");
}
}
break;
@ -104,10 +110,7 @@ namespace SharpReport{ @@ -104,10 +110,7 @@ namespace SharpReport{
return columnCollecion;
}
private void AddItemsToSection (BaseSection section,ReportItemCollection collection) {
if ((section == null)|| (collection == null) ) {
@ -324,6 +327,7 @@ namespace SharpReport{ @@ -324,6 +327,7 @@ namespace SharpReport{
if (base.ConnectionObject == null) {
base.ConnectionObject = this.BuildConnectionObject(model.ReportSettings);
}
return base.AbstractRenderer(model);
}
@ -478,20 +482,22 @@ namespace SharpReport{ @@ -478,20 +482,22 @@ namespace SharpReport{
}
protected new void Dispose(bool disposing){
if (disposing) {
// Free other state (managed objects).
if (this.baseDesignerControl != null) {
this.baseDesignerControl.Dispose();
}
if (this.reportModel != null) {
this.reportModel.Dispose();
try {
if (disposing) {
// Free other state (managed objects).
if (this.baseDesignerControl != null) {
this.baseDesignerControl.Dispose();
}
if (this.reportModel != null) {
this.reportModel.Dispose();
}
}
} finally {
// Release unmanaged resources.
// Set large fields to null.
// Call Dispose on your base class.
base.Dispose();
}
// Release unmanaged resources.
// Set large fields to null.
// Call Dispose on your base class.
base.Dispose();
}
#endregion
}

1
src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportDisplayBinding.cs

@ -70,7 +70,6 @@ namespace SharpReportAddin { @@ -70,7 +70,6 @@ namespace SharpReportAddin {
return GlobalValues.IsValidPrinter();
}
public virtual ICSharpCode.SharpDevelop.Gui.IViewContent CreateContentForFile(string fileName) {
if (GlobalValues.IsValidPrinter() == true) {
SharpReportView view = new SharpReportView();

6
src/AddIns/Misc/SharpReport/SharpReportAddin/SharpReportView.cs

@ -502,7 +502,6 @@ namespace SharpReportAddin{ @@ -502,7 +502,6 @@ namespace SharpReportAddin{
public override void Load(string fileName){
try {
designerControl.ReportControl.ObjectSelected -= new EventHandler <EventArgs>(OnObjectSelected);
reportManager.LoadFromFile (fileName);
base.FileName = fileName;
designerControl.ReportModel.ReportSettings.FileName = fileName;
@ -511,10 +510,9 @@ namespace SharpReportAddin{ @@ -511,10 +510,9 @@ namespace SharpReportAddin{
PropertyPad.Grid.SelectedObject = designerControl.ReportModel.ReportSettings;
PropertyPad.Grid.Refresh();
}
this.designerControl.ReportModel.ReportSettings.AvailableFieldsCollection = reportManager.AvailableFieldsCollection;
} catch (Exception ) {
} catch (Exception e) {
MessageService.ShowError(e,"SharpReportView:Load");
throw ;
}
}

38
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportItem.cs

@ -98,15 +98,7 @@ namespace SharpReportCore { @@ -98,15 +98,7 @@ namespace SharpReportCore {
#endregion
#region System.IDisposable interface implementation
public virtual void Dispose() {
if(Disposed != null){
Disposed(this,EventArgs.Empty);
}
}
#endregion
#region Properties
@ -169,5 +161,33 @@ namespace SharpReportCore { @@ -169,5 +161,33 @@ namespace SharpReportCore {
#endregion
#region IDisposeable
public override void Dispose () {
Dispose(true);
GC.SuppressFinalize(this);
}
~BaseReportItem(){
Dispose(false);
}
protected override void Dispose(bool disposing) {
try {
if (disposing){
if (this.font != null){
this.font = null;
this.font.Dispose();
}
}
} finally {
if (this.Disposed != null) {
this.Disposed (this,EventArgs.Empty);
}
base.Dispose(disposing);
}
}
#endregion
}
}

21
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseReportObject.cs

@ -25,7 +25,8 @@ using System.Drawing; @@ -25,7 +25,8 @@ using System.Drawing;
/// </remarks>
namespace SharpReportCore {
public class BaseReportObject : IBaseRenderer,INotifyPropertyChanged {
public class BaseReportObject : IBaseRenderer,INotifyPropertyChanged,
IDisposable{
private string name;
private object parent;
@ -212,5 +213,23 @@ namespace SharpReportCore { @@ -212,5 +213,23 @@ namespace SharpReportCore {
}
#endregion
#region IDisposable
public virtual void Dispose () {
Dispose(true);
GC.SuppressFinalize(this);
}
~BaseReportObject(){
Dispose(false);
}
protected virtual void Dispose(bool disposing) {
if (disposing){
}
}
#endregion
}
}

48
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseSection.cs

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
// This code was generated by a tool.
// Runtime Version: 1.1.4322.2032
//
// Changes to this file may cause incorrect behavior and will be lost if
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------
@ -16,32 +16,56 @@ using System.ComponentModel; @@ -16,32 +16,56 @@ using System.ComponentModel;
/// created by - Forstmeier Helmut
/// created on - 01.09.2005 13:12:32
/// </remarks>
namespace SharpReportCore {
namespace SharpReportCore {
public class BaseSection : SharpReportCore.BaseReportObject {
private ReportItemCollection items;
public BaseSection(): this("") {
#region Constructors
public BaseSection(): base() {
this.Name = String.Empty;
}
public BaseSection (string sectionName) :base(){
this.Name = sectionName;
}
#endregion
#region System.IDisposable interface implementation
public void Dispose() {
for (int i = 0;i < items.Count ;i ++ ){
((BaseReportItem)items[i]).Dispose();
}
public override void Dispose () {
Dispose(true);
GC.SuppressFinalize(this);
}
~BaseSection(){
Dispose(false);
}
protected override void Dispose(bool disposing) {
try {
if (disposing){
if (this.items != null) {
this.items.Clear();
this.items = null;
}
}
} finally {
base.Dispose(disposing);
}
}
#endregion
#region properties
public BaseSection (string sectionName) :base(){
this.Name = sectionName;
items = new ReportItemCollection();
}
[Browsable(false)]
public ReportItemCollection Items{
get {
if (this.items == null) {
items = new ReportItemCollection();
}
return items;
}
}

8
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseImageItem.cs

@ -75,10 +75,10 @@ namespace SharpReportCore { @@ -75,10 +75,10 @@ namespace SharpReportCore {
}
}
public override void Dispose() {
base.Dispose();
this.image = null;
}
// public override void Dispose() {
// base.Dispose();
// this.image = null;
// }
public override string ToString() {
return "BaseImageItem";

16
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseRectangleItem.cs

@ -76,14 +76,14 @@ namespace SharpReportCore { @@ -76,14 +76,14 @@ namespace SharpReportCore {
#region System.IDisposable interface implementation
public override void Dispose() {
base.Dispose();
for (int i = 0; i < arrayList.Count;i ++ ) {
IComponent curObj = (IComponent)arrayList[i];
curObj.Dispose();
}
arrayList = null;
}
// public override void Dispose() {
// base.Dispose();
// for (int i = 0; i < arrayList.Count;i ++ ) {
// IComponent curObj = (IComponent)arrayList[i];
// curObj.Dispose();
// }
// arrayList = null;
// }
#endregion

28
src/AddIns/Misc/SharpReport/SharpReportCore/ConnectionObject.cs

@ -55,15 +55,33 @@ namespace SharpReportCore { @@ -55,15 +55,33 @@ namespace SharpReportCore {
}
}
#region IDisposeable
public void Dispose () {
Dispose(true);
GC.SuppressFinalize(this);
}
~ConnectionObject(){
Dispose(false);
}
public void Dispose(){
if (this.connection != null) {
if (this.connection.State == ConnectionState.Open) {
this.connection.Close();
protected virtual void Dispose(bool disposing) {
try{
if (disposing){
if (this.connection != null){
if (this.connection.State == ConnectionState.Open) {
this.connection.Close();
}
this.connection.Dispose();
}
}
this.connection.Dispose();
}
finally{
connection = null;
}
}
#endregion
}
}

4
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/Comparer/BaseComparer.cs

@ -33,13 +33,13 @@ namespace SharpReportCore { @@ -33,13 +33,13 @@ namespace SharpReportCore {
}
/// <summary>
/// TODO - add method description
/// Interface method from IComparable
/// </summary>
/// <remarks>
/// Interface method from IComparable
///
/// </remarks>
/// <param name='obj'>TODO - add parameter description</param>
/// <param name='obj'>a <see cref="BaseComparer"></see></param>
public virtual int CompareTo(object obj) {
return 0;
}

103
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/Comparer/GroupComparer.cs

@ -1,103 +0,0 @@ @@ -1,103 +0,0 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.1.4322.2032
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------
using System;
using System.Text;
using System.ComponentModel;
using SharpReportCore;
/// <summary>
/// TODO - Add class summary
/// </summary>
/// <remarks>
/// created by - Forstmeier Helmut
/// created on - 27.11.2005 14:59:28
/// </remarks>
namespace SharpReportCore {
public class GroupComparer : SharpReportCore.BaseComparer{
public GroupComparer(ColumnCollection owner, int listIndex, object[] values):
base(owner,listIndex,values) {
}
internal int CompareTo(GroupComparer value)
{
// we shouldn't get to this point
if (value == null)
throw new ArgumentNullException("value");
if (value.ObjectArray.Length != base.ObjectArray.Length)
throw new InvalidOperationException("Differnet size of compare data");
int compare = 0;
for (int index = 0; index < base.ObjectArray.Length; index++)
{
object leftValue = base.ObjectArray[index];
object rightValue = value.ObjectArray[index];
// Indizes sind hier deckungsgleich
GroupColumn groupColumn = (GroupColumn)base.ColumnCollection[index];
bool descending = (groupColumn.SortDirection == ListSortDirection.Descending);
// null means equl
if (leftValue == null || leftValue == System.DBNull.Value)
{
if (rightValue != null && rightValue != System.DBNull.Value)
{
return (descending) ? 1 : -1;
}
// Beide Null
continue;
}
if (rightValue == null || rightValue == System.DBNull.Value)
{
return (descending) ? -1 : 1;
}
if (leftValue.GetType() != rightValue.GetType())
throw new InvalidOperationException("Compare of different types is not supported");
if (leftValue.GetType() == typeof(string))
{
compare = String.Compare((string)leftValue, (string)rightValue,
!groupColumn.CaseSensitive, base.ColumnCollection.Culture);
}
else
{
compare = ((IComparable)leftValue).CompareTo(rightValue);
}
// Sind ungleich, tauschen je nach Richtung
if (compare != 0)
{
return (descending) ? -compare : compare;
}
}
// Gleich Werte, dann Index bercksichtigen
return this.ListIndex.CompareTo(value.ListIndex);
}
public override int CompareTo(object obj) {
base.CompareTo(obj);
return this.CompareTo((GroupComparer)obj);
}
}
}

97
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/Comparer/GroupSeperator.cs

@ -22,11 +22,11 @@ using SharpReportCore; @@ -22,11 +22,11 @@ using SharpReportCore;
/// </remarks>
namespace SharpReportCore {
public class GroupSeperator : SharpReportCore.GroupComparer,IHierarchyData {
public class GroupSeperator : SharpReportCore.BaseComparer,IHierarchyData {
private string typeName = "GroupSeperator";
int groupLevel;
IHierarchicalArray childs ;
SharpIndexCollection childs ;
public GroupSeperator(ColumnCollection owner, int listIndex, object[] values,int groupLevel):
base(owner,listIndex,values) {
@ -40,16 +40,89 @@ namespace SharpReportCore { @@ -40,16 +40,89 @@ namespace SharpReportCore {
}
}
public IHierarchicalArray Childs {
public SharpIndexCollection GetChildren {
get {
if (this.childs == null) {
this.childs = new SharpIndexCollection("ChildList");
}
return childs;
}
set {
childs = value;
}
#region Comparer
internal int CompareTo(BaseComparer value)
{
// we shouldn't get to this point
if (value == null)
throw new ArgumentNullException("value");
if (value.ObjectArray.Length != base.ObjectArray.Length)
throw new InvalidOperationException("Differnet size of compare data");
int compare = 0;
for (int index = 0; index < base.ObjectArray.Length; index++)
{
object leftValue = base.ObjectArray[index];
object rightValue = value.ObjectArray[index];
// Indizes sind hier deckungsgleich
GroupColumn groupColumn = (GroupColumn)base.ColumnCollection[index];
bool descending = (groupColumn.SortDirection == ListSortDirection.Descending);
// null means equl
if (leftValue == null || leftValue == System.DBNull.Value)
{
if (rightValue != null && rightValue != System.DBNull.Value)
{
return (descending) ? 1 : -1;
}
// Beide Null
continue;
}
if (rightValue == null || rightValue == System.DBNull.Value)
{
return (descending) ? -1 : 1;
}
if (leftValue.GetType() != rightValue.GetType())
throw new InvalidOperationException("Compare of different types is not supported");
if (leftValue.GetType() == typeof(string))
{
compare = String.Compare((string)leftValue, (string)rightValue,
!groupColumn.CaseSensitive, base.ColumnCollection.Culture);
}
else
{
compare = ((IComparable)leftValue).CompareTo(rightValue);
}
// Sind ungleich, tauschen je nach Richtung
if (compare != 0)
{
return (descending) ? -compare : compare;
}
}
// Gleich Werte, dann Index bercksichtigen
return this.ListIndex.CompareTo(value.ListIndex);
}
public override int CompareTo(object obj) {
base.CompareTo(obj);
return this.CompareTo((BaseComparer)obj);
}
#endregion
#region SharpReportCore.IHierarchyData interface implementation
@ -85,13 +158,13 @@ namespace SharpReportCore { @@ -85,13 +158,13 @@ namespace SharpReportCore {
}
}
public IHierarchicalEnumerable GetChildren() {
return this.childs;
}
public IHierarchyData GetParent() {
return null;
}
// public IHierarchicalEnumerable GetChildren() {
// return this.childs;
// }
//
// public IHierarchyData GetParent() {
// return null;
// }
#endregion

4
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/Comparer/SortComparer.cs

@ -28,7 +28,7 @@ namespace SharpReportCore { @@ -28,7 +28,7 @@ namespace SharpReportCore {
throw new ArgumentNullException("value");
if (value.ObjectArray.Length != base.ObjectArray.Length)
throw new InvalidOperationException("Differnet size of compare data");
throw new InvalidOperationException();
int compare = 0;
@ -61,7 +61,7 @@ namespace SharpReportCore { @@ -61,7 +61,7 @@ namespace SharpReportCore {
if (leftValue.GetType() != rightValue.GetType())
throw new InvalidOperationException("COmpare of different types is not supported");
throw new InvalidOperationException("Compare of different types is not supported");
if (leftValue.GetType() == typeof(string))
{

250
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/DataManager.cs

@ -45,12 +45,11 @@ namespace SharpReportCore { @@ -45,12 +45,11 @@ namespace SharpReportCore {
ConnectionObject connectionObject;
IDbConnection connection;
IDataViewStrategy dataViewStrategy;
// private ListChangedEventArgs resetList = new ListChangedEventArgs(ListChangedType.Reset,-1,-1);
GroupSeperator groupSeperator;
public event EventHandler <ListChangedEventArgs> ListChanged;
public event EventHandler <GroupChangedEventArgs> GroupChanged;
public event EventHandler <EventArgs> GroupChanging;
/// <summary>
/// use this Constructor for PullDataReports
@ -60,34 +59,32 @@ namespace SharpReportCore { @@ -60,34 +59,32 @@ namespace SharpReportCore {
#region Constructores
public DataManager(ConnectionObject connectionObject, ReportSettings reportSettings){
CheckAndSetReportSettings(reportSettings);
if (connectionObject == null) {
throw new ArgumentNullException("DataManager:ConnectionObject");
}
this.connectionObject = connectionObject;
try {
CheckConnection (this.connectionObject);
CheckAndSetSource(this.FillDataSet().Tables[0]);
this.dataViewStrategy = new TableStrategy((DataTable)this.dataSource,
reportSettings);
this.dataViewStrategy.ListChanged += new EventHandler <ListChangedEventArgs> (NotifyListChanged);
} catch (Exception) {
throw;
if (reportSettings == null) {
throw new ArgumentNullException("reportSettings");
}
this.connectionObject = connectionObject;
CheckConnection (this.connectionObject);
CheckReportSettings(reportSettings);
CheckDataSource(this.FillDataSet().Tables[0]);
this.dataViewStrategy = new TableStrategy((DataTable)this.dataSource,
reportSettings);
this.dataViewStrategy.ListChanged += new EventHandler <ListChangedEventArgs> (NotifyListChanged);
this.dataViewStrategy.GroupChanged += new EventHandler<GroupChangedEventArgs> (OnGroupChange);
}
public DataManager(DataTable dataSource, ReportSettings reportSettings){
try {
CheckAndSetReportSettings(reportSettings);
CheckAndSetSource(dataSource);
this.dataViewStrategy = new TableStrategy((DataTable)this.dataSource,
reportSettings);
this.dataViewStrategy.ListChanged += new EventHandler <ListChangedEventArgs> (NotifyListChanged);
} catch (Exception) {
throw ;
}
this.InitDataManager(reportSettings,dataSource);
this.dataViewStrategy = new TableStrategy((DataTable)this.dataSource,
reportSettings);
this.dataViewStrategy.ListChanged += new EventHandler <ListChangedEventArgs> (NotifyListChanged);
}
public DataManager(DataSet dataSource, ReportSettings reportSettings)
@ -97,54 +94,49 @@ namespace SharpReportCore { @@ -97,54 +94,49 @@ namespace SharpReportCore {
public DataManager(DataSet dataSource,string dataMember, ReportSettings reportSettings){
try {
this.dataMember = dataMember;
CheckAndSetReportSettings(reportSettings);
CheckAndSetSource(dataSource);
this.dataViewStrategy = new TableStrategy((DataTable)this.dataSource,
reportSettings);
this.dataViewStrategy.ListChanged += new EventHandler <ListChangedEventArgs> (NotifyListChanged);
} catch (Exception ) {
throw ;
}
this.dataMember = dataMember;
this.InitDataManager(reportSettings,dataSource);
this.dataViewStrategy = new TableStrategy((DataTable)this.dataSource,
reportSettings);
this.dataViewStrategy.ListChanged += new EventHandler <ListChangedEventArgs> (NotifyListChanged);
}
public DataManager(IList dataSource, ReportSettings reportSettings){
this.InitDataManager(reportSettings,dataSource);
this.dataViewStrategy = new CollectionStrategy ((IList)this.dataSource,
this.dataMember,
reportSettings);
this.dataViewStrategy.ListChanged += new EventHandler <ListChangedEventArgs> (NotifyListChanged);
}
#endregion
void InitDataManager (ReportSettings reportSettings,object dataSource) {
try {
CheckAndSetReportSettings(reportSettings);
CheckAndSetSource(dataSource);
this.dataViewStrategy = new CollectionStrategy ((IList)this.dataSource,
this.dataMember,
reportSettings);
this.dataViewStrategy.ListChanged += new EventHandler <ListChangedEventArgs> (NotifyListChanged);
CheckReportSettings(reportSettings);
CheckDataSource(dataSource);
} catch (Exception) {
throw;
}
}
#endregion
void CheckAndSetReportSettings(ReportSettings settings) {
if (settings == null) {
throw new ArgumentNullException("settings");
}
void CheckReportSettings(ReportSettings settings) {
try {
if (settings.DataModel != GlobalEnums.enmPushPullModel.PushData) {
SqlQueryCkecker check = new SqlQueryCkecker();
check.Check(settings.CommandText);
SqlQueryChecker checker = new SqlQueryChecker();
checker.Check(settings.CommandText);
}
} catch (Exception) {
throw;
}
this.reportSettings = settings;
}
void CheckAndSetSource(object source) {
void CheckDataSource(object source) {
if (source == null) {
throw new MissingDataSourceException();
}
@ -175,7 +167,7 @@ namespace SharpReportCore { @@ -175,7 +167,7 @@ namespace SharpReportCore {
}
}
}else {
throw new ArgumentException("DataManager:No Tables in DataSet");
throw new MissingDataSourceException();
}
return;
}
@ -186,24 +178,13 @@ namespace SharpReportCore { @@ -186,24 +178,13 @@ namespace SharpReportCore {
this.dataSource = list;
this.dataMember = source.ToString();
if (list.Count == 0) {
//System.Console.WriteLine("List mit {0} Rows",list.Count);
throw new ArgumentException("No empty IList allowed");
throw new MissingDataSourceException();
}
return;
}
// if (source is IList) {
// IList list = source as IList;
// this.dataSource = list;
// this.dataMember = source.ToString();
// if (list.Count == 0) {
// //System.Console.WriteLine("List mit {0} Rows",list.Count);
// throw new ArgumentException("No empty IList allowed");
// }
// return;
// }
} else {
throw new ArgumentException ("DataManager:Wrong DataSource");
throw new MissingDataSourceException();
}
}
@ -215,7 +196,7 @@ namespace SharpReportCore { @@ -215,7 +196,7 @@ namespace SharpReportCore {
}
connection.Open();
connection.Close();
} catch (Exception ) {
} catch (Exception) {
throw;
}
}
@ -296,14 +277,25 @@ namespace SharpReportCore { @@ -296,14 +277,25 @@ namespace SharpReportCore {
this.ListChanged (this,e);
}
}
private void NotifyGroupChanging () {
if (this.GroupChanging!= null) {
this.GroupChanging (this,EventArgs.Empty);
}
}
private void NotifyGroupChange (object sender,GroupChangedEventArgs e) {
if (this.GroupChanged != null) {
this.GroupChanged (this,e);
private void NotifyGroupChanged() {
if (this.IsGrouped) {
if (this.GroupChanged != null) {
this.GroupChanged (this,new GroupChangedEventArgs(this.groupSeperator));
}
}
}
private void OnGroupChange (object sender,GroupChangedEventArgs e) {
this.groupSeperator = e.GroupSeperator;
this.NotifyGroupChanging();
}
#endregion
public string DataMember {
@ -319,59 +311,13 @@ namespace SharpReportCore { @@ -319,59 +311,13 @@ namespace SharpReportCore {
}
public IHierarchicalArray IHierarchicalArray {
get {
return (IHierarchicalArray)this.dataViewStrategy.IHierarchicalEnumerable;
}
}
/*
public void PerformHierarchy (IHierarchicalEnumerable list) {
IEnumerator iter = list.GetEnumerator();
System.Console.WriteLine("PerformHierarchy");
if (iter != null) {
while (iter.MoveNext()){
GroupSeperator g = (GroupSeperator)iter.Current;
System.Console.WriteLine("list {0} {1}",g.Path,g.ListIndex);
CheckGroups (g);
}
} else {
throw new SystemException("PerformHierarchy: No valid IEnumerator");
}
}
private void CheckGroups(GroupSeperator sep) {
System.Console.WriteLine("CheckGroups");
IEnumerator children = ((IHierarchicalEnumerable)sep.GetChildren()).GetEnumerator();
while (children.MoveNext()) {
System.Console.WriteLine("children");
}
}
public IHierarchicalEnumerable HierarchicalList {
get {
return hierarchicalList;
}
}
*/
#region SharpReportCore.IDataContainer interface implementation
public object DataSource {
get {
return this.dataSource;
}
set {
this.dataSource = value;
Reset();
}
}
public int CurrentRow {
@ -399,9 +345,8 @@ namespace SharpReportCore { @@ -399,9 +345,8 @@ namespace SharpReportCore {
public bool DataBind() {
this.dataViewStrategy.Bind();
this.dataViewStrategy.GroupChanged += new EventHandler <GroupChangedEventArgs>(NotifyGroupChange);
CheckReportColumns();
this.dataViewStrategy.Bind();
return true;
}
@ -411,11 +356,30 @@ namespace SharpReportCore { @@ -411,11 +356,30 @@ namespace SharpReportCore {
public void FetchData(ReportItemCollection collection) {
try {
foreach (IItemRenderer item in collection) {
this.dataViewStrategy.Fill(item);
}
} catch (Exception) {
foreach (IItemRenderer item in collection) {
this.dataViewStrategy.Fill(item);
}
this.NotifyGroupChanged();
}
/// <summary>
/// Indicate's if the current <see cref="GroupSeperator"></see> has ChildRows
/// </summary>
public bool HasChilds {
get {
return this.dataViewStrategy.HasChilds;
}
}
/// <summary>
/// Returns a <see cref="SharpArrayList"></see>, be carefull, this list is only a Indexlist
/// to the actuall data
/// </summary>
public SharpIndexCollection ChildRows {
get {
return this.dataViewStrategy.ChildRows;
}
}
@ -436,7 +400,7 @@ namespace SharpReportCore { @@ -436,7 +400,7 @@ namespace SharpReportCore {
public object Current {
get {
throw new NotImplementedException("DataManager.Current");
throw new NotImplementedException();
}
}
@ -463,10 +427,40 @@ namespace SharpReportCore { @@ -463,10 +427,40 @@ namespace SharpReportCore {
}
}
public bool IsSorted {
get {
return this.dataViewStrategy.IsSorted;
}
}
public bool IsFiltered {
get {
return this.dataViewStrategy.IsFiltered;
}
}
#region System.IDisposable interface implementation
public void Dispose() {
this.connectionObject = null;
this.dataViewStrategy = null;
this.Dispose(true);
GC.SuppressFinalize(this);
}
~DataManager(){
Dispose(false);
}
protected virtual void Dispose(bool disposing){
try {
if (disposing) {
// Free other state (managed objects).
if (this.dataViewStrategy != null) {
this.dataViewStrategy.Dispose();
}
}
} finally {
// Release unmanaged resources.
// Set large fields to null.
// Call Dispose on your base class.
}
}
#endregion

56
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/ExtendedPropertyDescriptor.cs

@ -8,7 +8,7 @@ namespace SharpReportCore { @@ -8,7 +8,7 @@ namespace SharpReportCore {
/// This class supports data binding
/// </summary>
public class SharpPropertyDescriptor : PropertyDescriptor{
bool readOnly;
Type componentType;
Type propertyType;
PropertyInfo prop;
@ -18,65 +18,59 @@ namespace SharpReportCore { @@ -18,65 +18,59 @@ namespace SharpReportCore {
{
this.componentType = componentType;
this.propertyType = propertyType;
this.readOnly= false;
}
public override object GetValue (object component)
{
if (!componentType.IsAssignableFrom(component.GetType()))
{
public override object GetValue (object component){
if (!componentType.IsAssignableFrom(component.GetType())){
return null;
}
if (prop == null)
if (prop == null) {
prop = componentType.GetProperty (Name);
object o = prop.GetValue (component, null);
if (o is IList)
{
PropertyTypeHash.Instance[componentType, Name] = SharpArrayList.GetElementType((IList)o, componentType, Name);
}
return o;
object obj = prop.GetValue (component, null);
if (obj != null) {
if (obj is IList){
PropertyTypeHash.Instance[componentType, Name] = SharpDataCollection<object>.GetElementType((IList)obj, componentType, Name);
}
}
return obj;
}
public override void SetValue(object component, object value)
{
if (IsReadOnly)
public override void SetValue(object component, object value) {
if (IsReadOnly){
return;
if (prop == null)
}
if (prop == null){
prop = componentType.GetProperty (Name);
}
prop.SetValue (component, value, null);
}
public override void ResetValue(object component)
{
public override void ResetValue(object component) {
return;
}
public override bool CanResetValue(object component)
{
public override bool CanResetValue(object component) {
return false;
}
public override bool ShouldSerializeValue(object component)
{
public override bool ShouldSerializeValue(object component) {
return false;
}
public override Type ComponentType
{
public override Type ComponentType{
get { return componentType; }
}
public override bool IsReadOnly
{
get { return readOnly; }
public override bool IsReadOnly{
get { return false; }
}
public override Type PropertyType
{
public override Type PropertyType{
get { return propertyType; }
}
}

45
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/IExtendedList.cs

@ -1,45 +0,0 @@ @@ -1,45 +0,0 @@
/*
* Created by SharpDevelop.
* User: Forstmeier Helmut
* Date: 04.08.2005
* Time: 09:06
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections;
namespace SharpReportCore {
public interface IExtendedList{
///<summary>
/// Build the Hash/IndexList we need for indexing the DataSource
/// </summary>
void BuildHashList (IList list);
/// <summary>
/// This List is used as an Index to the DataSource
/// ListItems are added by derived Classes
/// </summary>
IList IndexList{
get;
}
/// <summary>
/// returns the Name of the <see cref="ExtendedListArray"></see>
/// </summary>
string Name {
get;
}
///<summary>
/// CurrentPosition in <see cref="SharpArrayList"></see>
/// </summary>
int CurrentPosition {
get;set;
}
}
}

41
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/IHierarchicalArray.cs

@ -1,41 +0,0 @@ @@ -1,41 +0,0 @@
//------------------------------------------------------------------------------
// <autogenerated>
// This code was generated by a tool.
// Runtime Version: 1.1.4322.2032
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------
namespace SharpReportCore {
using System;
using SharpReportCore;
using System.Collections;
/// <summary>
///
/// </summary>
/// <remarks>
/// created by - Forstmeier peter
/// created on - 02.12.2005 13:42:08
/// </remarks>
public class IHierarchicalArray : ArrayList,IHierarchicalEnumerable {
/// <summary>
/// Default constructor - initializes all fields to default values
/// </summary>
public IHierarchicalArray(){
}
#region SharpReportCore.IHierarchicalEnumerable interface implementation
public IHierarchyData GetHierarchyData(Object enumeratedItem) {
return enumeratedItem as IHierarchyData;
}
#endregion
}
}

8
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/PropertyTypeHash.cs

@ -12,22 +12,22 @@ namespace SharpReportCore{ @@ -12,22 +12,22 @@ namespace SharpReportCore{
Hashtable types = new Hashtable();
private string MakeIndex(Type t, string name)
private static string MakeIndex(Type t, string name)
{
return t.FullName + '.' + name;
}
public object this[Type t, string fieldName]
public object this[Type type, string fieldName]
{
get
{
return types[MakeIndex(t, fieldName)];
return types[MakeIndex(type, fieldName)];
}
set
{
if (value == null)
return;
string key = MakeIndex(t, fieldName);
string key = MakeIndex(type, fieldName);
if (!types.Contains(key))
types.Add(key, value);
}

383
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListHandling/SharpArrayList.cs

@ -1,306 +1,229 @@ @@ -1,306 +1,229 @@
using System;
using System.Data;
using System.Diagnostics;
using System.Reflection;
using System.Collections;
using System.ComponentModel;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace SharpReportCore
{
/// <summary>
/// This class act'S as a IndexList to
/// <see cref="SharpBaseList"></see>
/// </summary>
public class SharpArrayList : ArrayList, IBindingList ,ITypedList,IExtendedList
{
Type elementType;
public class SharpIndexCollection :List<BaseComparer> {
string name;
int currentPosition;
bool allowNew = true;
bool allowEdit = true;
bool allowRemove = true;
bool supportsSearching ;
bool supportsSorting ;
bool isSorted;
private ListChangedEventArgs resetEvent = new ListChangedEventArgs(ListChangedType.Reset, -1);
public event ListChangedEventHandler ListChanged;
public SharpArrayList(Type elementType,string name){
this.Clear();
this.elementType = elementType;
this.name = name;
Reset();
public SharpIndexCollection():this ("SharpIndexList"){
}
#region ITypedList Member
public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] listAccessors){
if (listAccessors != null && listAccessors.Length > 0){
Type t = this.elementType;
for(int i = 0; i < listAccessors.Length; i++){
PropertyDescriptor pd = listAccessors[i];
// System.Diagnostics.Debug.WriteLine("*** " + t.FullName + ": " + pd.Name);
t = (Type) PropertyTypeHash.Instance[t, pd.Name];
}
// System.Diagnostics.Debug.WriteLine("*** New Collection for " + t.FullName);
// if t is null an empty list will be generated
return SharpTypeDescriptor.GetProperties(t);
}
return SharpTypeDescriptor.GetProperties(elementType);
}
public static Type GetElementType(IList list,
Type parentType,
string propertyName){
SharpArrayList al = list as SharpArrayList;
if (al == null)
return null;
return al.elementType;
}
#if longVersion
public static Type GetElementType(IList list,
Type parentType,
string propertyName){
SharpArrayList al = null;
object element = null;
al = CheckForArrayList(list);
if (al == null){
if (list.Count > 0){
element = list[0];
}
}
if (al == null && element == null){
PropertyInfo pi = parentType.GetProperty(propertyName);
if (pi != null){
object parentObject = null;
try{
parentObject = Activator.CreateInstance(parentType);
}
catch(Exception ex) {}
if (parentObject != null){
list = pi.GetValue(parentObject, null) as IList;
al = CheckForArrayList(list);
}
}
}
if (al != null){
return al.elementType;
}
else if (element != null){
return element.GetType();
}
return null;
}
private static SharpArrayList CheckForArrayList(object l){
IList list = l as IList;
if (list == null)
return null;
if (list.GetType().FullName == "System.Collections.ArrayList+ReadOnlyArrayList"){
FieldInfo fi = list.GetType().GetField("_list", BindingFlags.NonPublic | BindingFlags.Instance);
if (fi != null){
list = (IList) fi.GetValue(list);
}
}
return list as SharpArrayList;
}
#endif
public string GetListName(PropertyDescriptor[] listAccessors){
return elementType.Name;
}
#endregion
protected void Reset(){
this.currentPosition = 0;
this.OnListChange (resetEvent);
}
private void OnListChange (ListChangedEventArgs handler) {
if (this.ListChanged != null) {
this.ListChanged (this,handler);
}
public SharpIndexCollection(string name){
this.name = name;
}
#region System.ComponentModel.IBindingList interface implementation
public bool AllowNew {
#region properties
public int CurrentPosition {
get {
return this.allowNew;
return currentPosition;
}
}
public bool AllowEdit {
get {
return this.allowEdit;
set {
currentPosition = value;
}
}
public bool AllowRemove {
public string Name {
get {
return this.allowRemove;
return name;
}
}
public bool SupportsChangeNotification {
get {
return true;
}
}
public bool SupportsSearching {
get {
return this.supportsSearching;
}
set {
this.supportsSearching = value;
}
}
#endregion
}
/// <summary>
/// This class act's as a store of the original Data
/// </summary>
public class SharpDataCollection<T> : IList<T>,ITypedList{
Collection<T> list = new Collection<T>();
Type elementType;
public bool SupportsSorting {
get {
return this.supportsSorting;
}
set {
this.supportsSorting = value;
}
public SharpDataCollection(Type elementType)
{
this.elementType = elementType;
}
public bool IsSorted {
public T this[int index] {
get {
return this.isSorted;
return list[index];
}
set {
this.isSorted = value;
T oldValue = list[index];
if (!object.Equals(oldValue, value)) {
list[index] = value;
}
}
}
public System.ComponentModel.PropertyDescriptor SortProperty {
public int Count {
[DebuggerStepThrough]
get {
return null;
return list.Count;
}
}
public System.ComponentModel.ListSortDirection SortDirection {
public bool IsReadOnly {
get {
return ListSortDirection.Ascending;
return false;
}
}
public void RemoveSort() {
throw new NotImplementedException("RemoveSort");
}
//TODO Test fehlt
public void RemoveIndex(System.ComponentModel.PropertyDescriptor property) {
throw new NotImplementedException("RemoveIndex");
public int IndexOf(T item)
{
return list.IndexOf(item);
}
//TODO Test fehlt
public int Find(System.ComponentModel.PropertyDescriptor property, object key) {
// return 0;
throw new NotImplementedException("Find");
public void Insert(int index, T item)
{
list.Insert(index, item);
}
//TODO Test fehlt
public void ApplySort(System.ComponentModel.PropertyDescriptor property, System.ComponentModel.ListSortDirection direction) {
throw new NotImplementedException("ApplySort");
}
//TODO Test fehlt
public void AddIndex(System.ComponentModel.PropertyDescriptor property) {
throw new NotImplementedException("AddIndex");
public void RemoveAt(int index)
{
// T item = list[index];
list.RemoveAt(index);
}
public object AddNew() {
throw new NotImplementedException("AddNew");
public void Add(T item)
{
list.Add(item);
}
#endregion
#region overrides
public override int Add(object value) {
if (this.elementType.GetType().IsAssignableFrom (value.GetType())) {
System.Console.WriteLine("type ok");
}
if ((value.GetType().IsSubclassOf(this.elementType))||( value.GetType() == this.elementType)){
if (this.allowNew) {
int i = base.Add(value);
this.OnListChange (new ListChangedEventArgs(ListChangedType.ItemAdded,i));
return i;
} else {
throw new NotSupportedException("SharpArrayList:Add(object)");
}
} else {
string str = String.Format("Add:Wrong Type {0} {1}",this.elementType,value.GetType());
throw new ArgumentException(str);
public void AddRange(IList range)
{
foreach(T t in range) {
Add(t);
}
}
public override void AddRange(System.Collections.ICollection c) {
foreach (object o in c) {
this.Add (o);
}
public void Clear(){
list = new Collection<T>();
}
public override void RemoveAt(int index) {
if (this.allowRemove) {
if (index > -1) {
base.RemoveAt(index);
this.OnListChange (new ListChangedEventArgs(ListChangedType.ItemDeleted,index));
}
} else {
throw new NotSupportedException("SharpArrayList:RemoveAt (index)");
}
public bool Contains(T item)
{
return list.Contains(item);
}
#endregion
#region SharpReport.Data.IExtendedList interface implementation
public string Name {
get {
return this.name;
}
public void CopyTo(T[] array, int arrayIndex)
{
list.CopyTo(array, arrayIndex);
}
public int CurrentPosition {
get {
return currentPosition;
public bool Remove(T item)
{
if (list.Remove(item)) {
return true;
}
set {
currentPosition = value;
return false;
}
#region ITypedList Member
public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] listAccessors){
if (listAccessors != null && listAccessors.Length > 0){
Type t = this.elementType;
for(int i = 0; i < listAccessors.Length; i++){
PropertyDescriptor pd = listAccessors[i];
t = (Type) PropertyTypeHash.Instance[t, pd.Name];
}
// if t is null an empty list will be generated
return SharpTypeDescriptor.GetProperties(t);
}
return SharpTypeDescriptor.GetProperties(elementType);
}
public string GetListName(PropertyDescriptor[] listAccessors){
return elementType.Name;
}
public IList IndexList {
get {
return(IList)this;
public static Type GetElementType(IList list, Type parentType, string propertyName)
{
SharpDataCollection<T> al = null;
object element = null;
al = CheckForArrayList(list);
if (al == null)
{
if (list.Count > 0)
{
element = list[0];
}
}
if (al == null && element == null)
{
PropertyInfo pi = parentType.GetProperty(propertyName);
if (pi != null)
{
object parentObject = null;
try
{
parentObject = Activator.CreateInstance(parentType);
}
catch(Exception) {}
if (parentObject != null)
{
list = pi.GetValue(parentObject, null) as IList;
al = CheckForArrayList(list);
}
}
}
if (al != null)
{
return al.elementType;
}
else if (element != null)
{
return element.GetType();
}
return null;
}
public void BuildHashList(IList list) {
throw new NotImplementedException("SharpArrayList:BuildHashList");
/*
this.Clear();
for (int i = 0;i < list.Count ;i++ ) {
// this.Add (new PlainIndexItem(i,"satz " + i.ToString()));
private static SharpDataCollection<T> CheckForArrayList(object l)
{
IList list = l as IList;
if (list == null)
return null;
if (list.GetType().FullName == "System.Collections.ArrayList+ReadOnlyArrayList")
{
FieldInfo fi = list.GetType().GetField("_list", BindingFlags.NonPublic | BindingFlags.Instance);
if (fi != null)
{
list = (IList) fi.GetValue(list);
}
}
this.OnListChange (new ListChangedEventArgs(ListChangedType.Reset,-1,-1));
*/
return list as SharpDataCollection<T>;
}
#endregion
[DebuggerStepThrough]
public IEnumerator<T> GetEnumerator()
{
return list.GetEnumerator();
}
[DebuggerStepThrough]
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return list.GetEnumerator();
}
}
}

263
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/BaseListStrategy.cs

@ -16,7 +16,7 @@ using System.Collections.Generic; @@ -16,7 +16,7 @@ using System.Collections.Generic;
using SharpReportCore;
/// <summary>
/// BaseClass for all datahandling Strategies
/// BaseClass for all Datahandling Strategies
/// </summary>
/// <remarks>
/// created by - Forstmeier Peter
@ -30,10 +30,9 @@ namespace SharpReportCore { @@ -30,10 +30,9 @@ namespace SharpReportCore {
private bool isGrouped;
//Index to plain Datat
private SharpArrayList indexList;
private SharpIndexCollection indexList;
private ReportSettings reportSettings;
private IHierarchicalArray hierarchicalList;
private ListChangedEventArgs resetList = new ListChangedEventArgs(ListChangedType.Reset,-1,-1);
@ -43,20 +42,16 @@ namespace SharpReportCore { @@ -43,20 +42,16 @@ namespace SharpReportCore {
#region Constructor
protected BaseListStrategy(ReportSettings reportSettings) {
if (reportSettings == null) {
throw new ArgumentNullException("reportSettings");
}
this.reportSettings = reportSettings;
this.indexList = new SharpArrayList(typeof(BaseComparer),"IndexList");
this.indexList = new SharpIndexCollection("IndexList");
}
#endregion
#region Event's
protected void NotifyGroupChange (object source,GroupSeperator groupSeperator) {
if (this.GroupChanged != null) {
this.GroupChanged (source,new GroupChangedEventArgs(groupSeperator));
}
}
protected void NotifyResetList(){
if (this.ListChanged != null) {
@ -64,10 +59,18 @@ namespace SharpReportCore { @@ -64,10 +59,18 @@ namespace SharpReportCore {
}
}
protected void NotifyGroupChanging (object source,GroupSeperator groupSeperator) {
if (this.GroupChanged != null) {
this.GroupChanged (source,new GroupChangedEventArgs(groupSeperator));
}
}
#endregion
public SharpArrayList IndexList {
public SharpIndexCollection IndexList {
get {
return indexList;
}
@ -79,21 +82,87 @@ namespace SharpReportCore { @@ -79,21 +82,87 @@ namespace SharpReportCore {
return reportSettings;
}
}
#region Building Groups
private static void WriteToIndexFile (SharpIndexCollection destination,BaseComparer comparer) {
SortComparer sc = comparer as SortComparer;
// if (sc != null) {
// System.Console.WriteLine("\t {0} - <{1}>",comparer.ListIndex, comparer.ObjectArray[0].ToString());
// } else {
// System.Console.WriteLine("Wrong comparer");
// }
destination.Add(comparer);
}
protected void CheckSortArray (ArrayList arr,string text){
// System.Console.WriteLine("");
private static GroupSeperator BuildGroupSeperator (BaseComparer newGroup,int groupLevel) {
GroupSeperator seperator = new GroupSeperator (newGroup.ColumnCollection,
newGroup.ListIndex,
newGroup.ObjectArray,
groupLevel);
// System.Console.WriteLine("Add Parent <{0}>",seperator.ObjectArray[0].ToString());
return seperator;
}
protected void MakeGroupedIndexList (SharpIndexCollection sourceList) {
if (sourceList == null) {
throw new ArgumentNullException("sourceList");
}
int level = 0;
this.indexList.Clear();
SortComparer compareComparer = null;
GroupSeperator parent = null;
// System.Console.WriteLine("MakeGroupedIndexList with {0} rows",sourceList.Count);
for (int i = 0;i < sourceList.Count ;i++ ) {
SortComparer currentComparer = (SortComparer)sourceList[i];
/*
System.Console.WriteLine("\t\t\t performing nr {0}",i);
if (i == 68) {
System.Console.WriteLine("last");
}
*/
if (compareComparer != null) {
string str1,str2;
str1 = currentComparer.ObjectArray[0].ToString();
str2 = compareComparer.ObjectArray[0].ToString();
int compareVal = str1.CompareTo(str2);
if (compareVal != 0) {
BaseListStrategy.WriteToIndexFile(parent.GetChildren,compareComparer);
parent = BaseListStrategy.BuildGroupSeperator (currentComparer,level);
this.indexList.Add(parent);
BaseListStrategy.WriteToIndexFile(parent.GetChildren,currentComparer);
} else {
BaseListStrategy.WriteToIndexFile(parent.GetChildren,compareComparer);
}
}
else {
parent = BaseListStrategy.BuildGroupSeperator (currentComparer,level);
this.indexList.Add(parent);
}
compareComparer = (SortComparer)sourceList[i];
}
BaseListStrategy.WriteToIndexFile(parent.GetChildren,compareComparer);
}
#endregion
protected static void CheckSortArray (SharpIndexCollection arr,string text){
System.Console.WriteLine("{0}",text);
// string tabs = String.Empty;
if (arr != null) {
int row = 0;
foreach (BaseComparer bc in arr) {
GroupSeperator sep = bc as GroupSeperator;
if (sep != null) {
// System.Console.WriteLine("\t Group change {0} level {1}",sep.ObjectArray[0].ToString(),
// sep.GroupLevel);
} else {
object [] oarr = bc.ObjectArray;
@ -107,12 +176,10 @@ namespace SharpReportCore { @@ -107,12 +176,10 @@ namespace SharpReportCore {
}
}
System.Console.WriteLine("----------------");
System.Console.WriteLine("");
System.Console.WriteLine("-----End of <CheckSortArray>-----------");
}
#region SharpReportCore.IDataViewStrategy interface implementation
public virtual ColumnCollection AvailableFields {
@ -133,8 +200,7 @@ namespace SharpReportCore { @@ -133,8 +200,7 @@ namespace SharpReportCore {
}
set {
if (value > this.indexList.Count){
throw new IndexOutOfRangeException ("There is no row at " +
"currentRow: " + value + ".");
throw new IndexOutOfRangeException ();
}
this.indexList.CurrentPosition = value;
}
@ -167,15 +233,10 @@ namespace SharpReportCore { @@ -167,15 +233,10 @@ namespace SharpReportCore {
get {
return this.isGrouped;
}
set {
this.isGrouped = true;
}
}
protected virtual void Group() {
if (this.indexList != null) {
this.BuildHierarchicalList (this.indexList);
this.isGrouped = true;
this.isSorted = true;
} else {
@ -185,123 +246,77 @@ namespace SharpReportCore { @@ -185,123 +246,77 @@ namespace SharpReportCore {
}
protected IHierarchicalArray HierarchicalList {
get {
return hierarchicalList;
}
}
public virtual void Sort() {
this.indexList.Clear();
}
public virtual void Reset() {
this.NotifyResetList();
}
private GroupSeperator MakeSeperator (BaseComparer newGroup,int groupLevel) {
public virtual void Bind() {
GroupSeperator seperator = new GroupSeperator (newGroup.ColumnCollection,
newGroup.ListIndex,
newGroup.ObjectArray,
groupLevel);
// System.Console.WriteLine("");
// System.Console.WriteLine("\t Group change {0} level {1}",seperator.ObjectArray[0].ToString(),
// seperator.GroupLevel);
// System.Console.WriteLine("");
return seperator;
}
public virtual void Fill(IItemRenderer item) {
private IHierarchicalEnumerable BuildHierarchicalList(ArrayList sourceList) {
IHierarchicalArray destList = new IHierarchicalArray();
IHierarchicalArray childList = new IHierarchicalArray();
int level = 0;
// System.Console.WriteLine("");
// System.Console.WriteLine("BuildHierachicalList");
// ColumnCollection grBy =this.reportSettings.GroupColumnsCollection;
// string columnName = grBy[level].ColumnName;
GroupComparer compareComparer = null;
GroupSeperator seperator = null;
destList.Clear();
childList.Clear();
for (int i = 0;i < sourceList.Count ;i++ ) {
GroupComparer currentComparer = (GroupComparer)sourceList[i];
if (compareComparer != null) {
string str1,str2;
str1 = currentComparer.ObjectArray[0].ToString();
str2 = compareComparer.ObjectArray[0].ToString();
int compareVal = str1.CompareTo(str2);
if (compareVal != 0) {
// System.Console.WriteLine("child list with {0} entries",childList.Count);
seperator.Childs = childList;
/*
//testcode
if (childList != null) {
foreach (BaseComparer bc in seperator.Childs) {
System.Console.WriteLine("\t {0} {1}",bc.ListIndex,
bc.ObjectArray[0].ToString());
}
}
// end testCode
*/
childList = new IHierarchicalArray();
seperator = MakeSeperator (currentComparer,level);
childList.Clear();
destList.Add (seperator);
}
public bool HasChilds {
get {
if (this.IsGrouped == true) {
GroupSeperator gs = (GroupSeperator)this.indexList[this.CurrentRow] as GroupSeperator;
if (gs != null) {
return (gs.GetChildren.Count > 0);
} else {
return false;
}
} else {
return false;
}
else {
// System.Console.WriteLine("\t\t Start of List {0}",currentComparer.ObjectArray[0].ToString());
//
// System.Console.WriteLine("Group change ");
seperator = MakeSeperator (currentComparer,level);
childList.Clear();
destList.Add (seperator);
seperator.Childs = childList;
}
// System.Console.WriteLine("write {0} {1}",currentComparer.ListIndex,currentComparer.ObjectArray[0].ToString());
childList.Add (currentComparer);
compareComparer = (GroupComparer)sourceList[i];
}
// Add the last list
seperator.Childs = childList;
this.hierarchicalList = destList;
return destList;
}
public IHierarchicalEnumerable IHierarchicalEnumerable {
public SharpIndexCollection ChildRows {
get {
return this.hierarchicalList;
if (this.IsGrouped == true) {
GroupSeperator gs = (GroupSeperator)this.indexList[this.CurrentRow] as GroupSeperator;
if (gs != null) {
return (gs.GetChildren);
} else {
return null;
}
} else {
return null;
}
}
}
public virtual void Sort() {
public virtual void Dispose(){
this.Dispose(true);
GC.SuppressFinalize(this);
}
public virtual void Reset() {
this.NotifyResetList();
~BaseListStrategy(){
Dispose(false);
}
public virtual void Bind() {
protected virtual void Dispose(bool disposing){
if (disposing) {
// Free other state (managed objects).
if (this.indexList != null) {
this.indexList.Clear();
this.indexList = null;
}
}
}
public virtual void Fill(IItemRenderer item) {
// Release unmanaged resources.
// Set large fields to null.
// Call Dispose on your base class.
}
#endregion
}
}

228
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/CollectionStrategy.cs

@ -23,29 +23,67 @@ namespace SharpReportCore { @@ -23,29 +23,67 @@ namespace SharpReportCore {
public class CollectionStrategy : BaseListStrategy {
// Holds the plain Data
private SharpArrayList baseList;
private Type itemType;
private object firstItem;
private object current;
private PropertyDescriptorCollection listProperties;
private SharpDataCollection<object> baseList;
public CollectionStrategy(IList list,string dataMember,ReportSettings reportSettings):base(reportSettings) {
if (list.Count > 0) {
firstItem = list[0];
itemType = firstItem.GetType();
this.baseList = new SharpArrayList(itemType,dataMember);
this.baseList = new SharpDataCollection <object>(itemType);
this.baseList.AddRange(list);
this.baseList.CurrentPosition = 0;
this.current = this.baseList[0];
}
this.listProperties = this.baseList.GetItemProperties(null);
}
private void BuildGroup(){
// throw new NotImplementedException("No grouping at the time");
return;
try {
SharpIndexCollection groupedArray = new SharpIndexCollection();
if (base.ReportSettings.GroupColumnsCollection != null) {
if (base.ReportSettings.GroupColumnsCollection.Count > 0) {
this.BuildSortIndex (groupedArray,base.ReportSettings.GroupColumnsCollection);
}
}
base.MakeGroupedIndexList (groupedArray);
foreach (BaseComparer bc in this.IndexList) {
GroupSeperator gs = bc as GroupSeperator;
if (gs != null) {
System.Console.WriteLine("Group Header <{0}> with <{1}> Childs ",gs.ObjectArray[0].ToString(),gs.GetChildren.Count);
if (gs.HasChildren) {
foreach (SortComparer sc in gs.GetChildren) {
System.Console.WriteLine("\t {0} {1}",sc.ListIndex,sc.ObjectArray[0].ToString()); }
}
} else {
SortComparer sc = bc as SortComparer;
if (sc != null) {
System.Console.WriteLine("\t Child {0}",sc.ObjectArray[0].ToString());
}
}
}
} catch (Exception e) {
System.Console.WriteLine("BuildGroup {0}",e.Message);
throw;
}
}
private PropertyDescriptor[] BuildSortProperties (ColumnCollection col){
@ -66,69 +104,54 @@ namespace SharpReportCore { @@ -66,69 +104,54 @@ namespace SharpReportCore {
}
#region Index Building
//Sorted Indexlist
private ArrayList BuildSortIndex(ColumnCollection col) {
private void BuildSortIndex(SharpIndexCollection arrayList,ColumnCollection col) {
PropertyDescriptor[] sortProperties = BuildSortProperties (col);
// Übertragen der zu sortierenden Werte in eine standartComparer Auflistung
ArrayList sortValues = new ArrayList(this.baseList.Count);
try {
for (int rowIndex = 0; rowIndex < this.baseList.Count; rowIndex++){
object rowItem = this.baseList[rowIndex];
object[] values = new object[col.Count];
for (int rowIndex = 0; rowIndex < this.baseList.Count; rowIndex++){
object rowItem = this.baseList[rowIndex];
object[] values = new object[col.Count];
// Hier bereits Wertabruf um dies nicht während des Sortierens tun zu müssen.
for (int criteriaIndex = 0; criteriaIndex < sortProperties.Length; criteriaIndex++){
object value = sortProperties[criteriaIndex].GetValue(rowItem);
// Hier auf Verträglichkeit testen um Vergleiche bei Sortierung zu vereinfachen.
// Muss IComparable und gleicher Typ sein.
// Hier bereits Wertabruf um dies nicht während des Sortierens tun zu müssen.
for (int criteriaIndex = 0; criteriaIndex < sortProperties.Length; criteriaIndex++){
object value = sortProperties[criteriaIndex].GetValue(rowItem);
// Hier auf Verträglichkeit testen um Vergleiche bei Sortierung zu vereinfachen.
// Muss IComparable und gleicher Typ sein.
if (value != null && value != DBNull.Value)
{
if (!(value is IComparable)){
throw new InvalidOperationException("ReportDataSource:BuildSortArray - > This type doesn't support IComparable." + value.ToString());
}
values[criteriaIndex] = value;
if (value != null && value != DBNull.Value)
{
if (!(value is IComparable)){
throw new InvalidOperationException("ReportDataSource:BuildSortArray - > This type doesn't support IComparable." + value.ToString());
}
values[criteriaIndex] = value;
}
sortValues.Add(new SortComparer(col, rowIndex, values));
}
} catch (Exception) {
throw ;
arrayList.Add(new SortComparer(col, rowIndex, values));
}
sortValues.Sort();
return sortValues;
arrayList.Sort();
}
// 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 ArrayList BuildPlainIndex(ColumnCollection col) {
private void BuildPlainIndex(SharpIndexCollection arrayList,ColumnCollection col) {
PropertyDescriptor[] sortProperties = new PropertyDescriptor[1];
PropertyDescriptorCollection c = this.baseList.GetItemProperties(null);
PropertyDescriptor descriptor = c[0];
sortProperties[0] = descriptor;
ArrayList sortValues = new ArrayList(this.baseList.Count);
try {
for (int rowIndex = 0; rowIndex < this.baseList.Count; rowIndex++){
object[] values = new object[1];
// We insert only the RowNr as a dummy value
values[0] = rowIndex;
sortValues.Add(new BaseComparer(col, rowIndex, values));
}
} catch (Exception) {
throw ;
for (int rowIndex = 0; rowIndex < this.baseList.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));
}
return sortValues;;
}
#endregion
#region SharpReportCore.IDataViewStrategy interface implementation
@ -156,7 +179,6 @@ namespace SharpReportCore { @@ -156,7 +179,6 @@ namespace SharpReportCore {
set {
base.CurrentRow = value;
current = this.baseList[((BaseComparer)base.IndexList[value]).ListIndex];
}
}
@ -164,28 +186,19 @@ namespace SharpReportCore { @@ -164,28 +186,19 @@ namespace SharpReportCore {
public override void Sort() {
base.Sort();
ArrayList sortedArray = new ArrayList();
try {
ColumnCollection sortColumnCollection = base.ReportSettings.SortColumnCollection;
if (sortColumnCollection != null) {
if (sortColumnCollection.Count > 0) {
sortedArray = this.BuildSortIndex (sortColumnCollection);
base.IsSorted = true;
} else {
sortedArray = BuildPlainIndex (sortColumnCollection);
base.IsSorted = false;
}
if ((base.ReportSettings.SortColumnCollection != null)) {
if (base.ReportSettings.SortColumnCollection.Count > 0) {
this.BuildSortIndex (base.IndexList,
base.ReportSettings.SortColumnCollection);
base.IsSorted = true;
// BaseListStrategy.CheckSortArray (base.IndexList,"TableStrategy - CheckSortArray");
} else {
this.BuildPlainIndex(base.IndexList,
base.ReportSettings.SortColumnCollection);
base.IsSorted = false;
}
base.IndexList.Clear();
base.IndexList.AddRange (sortedArray);
// base.CheckSortArray (sortedArray,"CollectionStrategy - CheckSortArray");
} catch (Exception) {
throw;
}
if (base.IndexList == null){
throw new NotSupportedException("Sortieren für die Liste nicht unterstützt.");
}
}
@ -200,24 +213,23 @@ namespace SharpReportCore { @@ -200,24 +213,23 @@ namespace SharpReportCore {
public override void Bind() {
base.Bind();
if (base.IndexList.Count > 0) {
base.IndexList.Clear();
}
this.listProperties = this.baseList.GetItemProperties(null);
if ((base.ReportSettings.GroupColumnsCollection != null) && (base.ReportSettings.GroupColumnsCollection.Count > 0)) {
BuildGroup ();
this.Group ();
Reset();
return;
}
this.Sort ();
this.Reset();
base.NotifyResetList();
if (base.ReportSettings.SortColumnCollection != null) {
this.Sort ();
}
Reset();
}
public override void Fill(IItemRenderer item) {
base.Fill(item);
if (current != null) {
try {
try {
base.Fill(item);
if (current != null) {
BaseDataItem baseDataItem = item as BaseDataItem;
PropertyDescriptor p = this.listProperties.Find (baseDataItem.ColumnName,true);
@ -225,12 +237,50 @@ namespace SharpReportCore { @@ -225,12 +237,50 @@ namespace SharpReportCore {
baseDataItem.DbValue = "";
baseDataItem.DbValue = p.GetValue(this.current).ToString();
}
} catch (Exception) {
}
} catch (System.NullReferenceException) {
}
}
protected override void Group() {
if (base.ReportSettings.GroupColumnsCollection.Count == 0) {
return;
}
this.BuildGroup();
base.Group();
}
#endregion
#region IDisposable
public override void Dispose(){
this.Dispose(true);
GC.SuppressFinalize(this);
}
~CollectionStrategy(){
Dispose(false);
}
protected override void Dispose(bool disposing){
try {
if (disposing) {
if (this.baseList != null) {
this.baseList.Clear();
this.baseList = null;
}
}
} finally {
base.Dispose(disposing);
// Release unmanaged resources.
// Set large fields to null.
// Call Dispose on your base class.
}
}
#endregion
}
}

296
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/TableStrategy.cs

@ -24,7 +24,7 @@ namespace SharpReportCore { @@ -24,7 +24,7 @@ namespace SharpReportCore {
/// created by - Forstmeier Peter
/// created on - 23.10.2005 15:12:06
/// </remarks>
public class TableStrategy : BaseListStrategy,IDisposable {
public class TableStrategy : BaseListStrategy {
DataTable table;
DataView view = new DataView();
@ -32,44 +32,19 @@ namespace SharpReportCore { @@ -32,44 +32,19 @@ namespace SharpReportCore {
public TableStrategy(DataTable table,ReportSettings reportSettings):base(reportSettings) {
if (table == null) {
throw new ArgumentNullException("table");
}
this.table = table;
// view.ListChanged += new ListChangedEventHandler (OnListChange);
view = this.table.DefaultView;
}
// private void OnListChange (object sender,ListChangedEventArgs e) {
// System.Console.WriteLine("called from view");
// MessageBox.Show ("On List Change");
// }
/*
private string a_BuildSort(ColumnCollection sortCollection){
System.Console.WriteLine("BuildSort");
StringBuilder sb = new StringBuilder();
for (int i = 0;i < sortCollection.Count ;i++ ) {
SortColumn sc = (SortColumn)sortCollection[i];
sb.Append(sc.ColumnName);
if (sc.SortDirection == ListSortDirection.Ascending) {
sb.Append (" ASC");
} else {
sb.Append(" DESC");
}
sb.Append (",");
}
if (sb.ToString().EndsWith (",")) {
sb.Remove(sb.Length -1,1);
}
System.Console.WriteLine("\tsort by {0}",sb.ToString());
return sb.ToString();
}
*/
#region Building the Index list
// 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 ArrayList BuildSortIndex(ColumnCollection col) {
private void BuildSortIndex(SharpIndexCollection arrayList,ColumnCollection col) {
ArrayList sortValues = new ArrayList(this.view.Count);
try {
for (int rowIndex = 0; rowIndex < this.view.Count; rowIndex++){
DataRowView rowItem = this.view[rowIndex];
@ -88,171 +63,79 @@ namespace SharpReportCore { @@ -88,171 +63,79 @@ namespace SharpReportCore {
values[criteriaIndex] = DBNull.Value;
}
}
sortValues.Add(new SortComparer(col, rowIndex, values));
arrayList.Add(new SortComparer(col, rowIndex, values));
}
} catch (Exception) {
throw;
}
sortValues.Sort();
return sortValues;
}
private ArrayList BuildPlainIndex(ColumnCollection col) {
ArrayList sortValues = new ArrayList(this.view.Count);
arrayList.Sort();
}
// 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;
sortValues.Add(new BaseComparer(col, rowIndex, values));
arrayList.Add(new BaseComparer(col, rowIndex, values));
}
} catch (Exception) {
throw ;
}
return sortValues;;
}
private ArrayList BuildGroupIndex(ColumnCollection col) {
ArrayList groupValues = new ArrayList(this.view.Count);
System.Console.WriteLine("\tBuildGroupIndex");
try {
for (int rowIndex = 0; rowIndex < this.view.Count; rowIndex++){
DataRowView rowItem = this.view[rowIndex];
object[] values = new object[col.Count];
for (int criteriaIndex = 0; criteriaIndex < col.Count; criteriaIndex++){
AbstractColumn c = (AbstractColumn)col[criteriaIndex];
object value = rowItem[c.ColumnName];
if (value != null && value != DBNull.Value){
if (!(value is IComparable)){
throw new InvalidOperationException("ReportDataSource:BuildSortArray - > This type doesn't support IComparable." + value.ToString());
}
values[criteriaIndex] = value;
} else {
values[criteriaIndex] = DBNull.Value;
}
}
groupValues.Add(new GroupComparer(col, rowIndex, values));
}
} catch (Exception) {
}
groupValues.Sort();
return groupValues;
}
#endregion
#region Grouping
private void WriteToIndexFile (ArrayList destination,int index,GroupComparer comparer) {
destination.Add(comparer);
}
private void BuildGroupSeperator (ArrayList destination,BaseComparer newGroup,int groupLevel) {
GroupSeperator seperator = new GroupSeperator (newGroup.ColumnCollection,
newGroup.ListIndex,
newGroup.ObjectArray,
groupLevel);
// System.Console.WriteLine("\t Group change {0} level {1}",seperator.ObjectArray[0].ToString(),
// seperator.GroupLevel);
// System.Console.WriteLine("write group seperator");
destination.Add(seperator);
}
private ArrayList InsertGroupRows (ArrayList sourceList) {
ArrayList destList = new ArrayList();
int level = 0;
// // only for testing
// ColumnCollection grBy = base.ReportSettings.GroupColumnsCollection;
// string columnName = grBy[level].ColumnName;
//// System.Console.WriteLine("");
// System.Console.WriteLine("InsertGroupRows Grouping for {0}",columnName);
GroupComparer compareComparer = null;
for (int i = 0;i < sourceList.Count ;i++ ) {
GroupComparer currentComparer = (GroupComparer)sourceList[i];
if (compareComparer != null) {
string str1,str2;
str1 = currentComparer.ObjectArray[0].ToString();
str2 = compareComparer.ObjectArray[0].ToString();
int compareVal = str1.CompareTo(str2);
if (compareVal != 0) {
this.BuildGroupSeperator (destList,currentComparer,level);
}
}
else {
// System.Console.WriteLine("\t\t Start of List {0}",currentComparer.ObjectArray[0].ToString());
this.BuildGroupSeperator (destList,currentComparer,level);
}
this.WriteToIndexFile (destList,i,currentComparer);
compareComparer = (GroupComparer)sourceList[i];
}
return destList;
}
private void BuildGroup(){
try {
ArrayList groupedArray = new ArrayList();
SharpIndexCollection groupedArray = new SharpIndexCollection();
if (base.ReportSettings.GroupColumnsCollection != null) {
if (base.ReportSettings.GroupColumnsCollection.Count > 0) {
groupedArray = this.BuildGroupIndex (base.ReportSettings.GroupColumnsCollection);
System.Console.WriteLine("\t1");
} else {
groupedArray = BuildPlainIndex (base.ReportSettings.GroupColumnsCollection);
this.BuildSortIndex (groupedArray,base.ReportSettings.GroupColumnsCollection);
}
}
base.IndexList.Clear();
base.IndexList.AddRange (InsertGroupRows(groupedArray));
if (base.IndexList == null){
throw new NotSupportedException("Sortieren für die Liste nicht unterstützt.");
base.MakeGroupedIndexList (groupedArray);
// System.Console.WriteLine("GroupedList with {0} elements",base.IndexList.Count);
/*
foreach (BaseComparer bc in this.IndexList) {
GroupSeperator gs = bc as GroupSeperator;
if (gs != null) {
// System.Console.WriteLine("Group Header <{0}> with <{1}> Childs ",gs.ObjectArray[0].ToString(),gs.GetChildren.Count);
if (gs.HasChildren) {
foreach (SortComparer sc in gs.GetChildren) {
System.Console.WriteLine("\t {0} {1}",sc.ListIndex,sc.ObjectArray[0].ToString()); }
}
} else {
SortComparer sc = bc as SortComparer;
if (sc != null) {
System.Console.WriteLine("\t Child {0}",sc.ObjectArray[0].ToString());
}
}
}
*/
} catch (Exception e) {
System.Console.WriteLine("BuildGroup {0}",e.Message);
throw;
}
}
protected override void Group() {
if (base.ReportSettings.GroupColumnsCollection.Count == 0) {
return;
}
try {
this.BuildGroup();
base.Group();
if (this.IsGrouped == false) {
throw new SharpReportException("TableStratregy:Group Error in grouping");
}
} catch (Exception e) {
System.Console.WriteLine("Group {0}",e.Message);
base.IsGrouped = false;
base.IsSorted = false;
throw;
}
}
#endregion
@ -260,12 +143,10 @@ namespace SharpReportCore { @@ -260,12 +143,10 @@ namespace SharpReportCore {
public override void Bind() {
base.Bind();
view = this.table.DefaultView;
if ((base.ReportSettings.GroupColumnsCollection != null) && (base.ReportSettings.GroupColumnsCollection.Count > 0)) {
this.Group ();
Reset();
base.NotifyResetList();
return;
}
@ -273,47 +154,44 @@ namespace SharpReportCore { @@ -273,47 +154,44 @@ namespace SharpReportCore {
this.Sort ();
}
Reset();
base.NotifyResetList();
}
public override void Sort () {
base.Sort();
ArrayList sortedArray = new ArrayList();
try {
if ((base.ReportSettings.SortColumnCollection != null)) {
if (base.ReportSettings.SortColumnCollection.Count > 0) {
SortColumn sc = (SortColumn)base.ReportSettings.SortColumnCollection[0];
sortedArray = this.BuildSortIndex (base.ReportSettings.SortColumnCollection);
base.IsSorted = true;
} else {
sortedArray = BuildPlainIndex (base.ReportSettings.SortColumnCollection);
base.IsSorted = false;
}
if ((base.ReportSettings.SortColumnCollection != null)) {
if (base.ReportSettings.SortColumnCollection.Count > 0) {
this.BuildSortIndex (base.IndexList,
base.ReportSettings.SortColumnCollection);
base.IsSorted = true;
} else {
this.BuildPlainIndex(base.IndexList,
base.ReportSettings.SortColumnCollection);
base.IsSorted = false;
}
base.IndexList.Clear();
base.IndexList.AddRange (sortedArray);
// base.CheckSortArray (sortedArray,"TableStrategy - CheckSortArray");
} catch (Exception) {
throw;
}
if (base.IndexList == null){
throw new NotSupportedException("Sortieren für die Liste nicht unterstützt.");
}
protected override void Group() {
if (base.ReportSettings.GroupColumnsCollection.Count == 0) {
return;
}
this.BuildGroup();
base.Group();
}
public override void Fill (IItemRenderer item) {
try {
base.Fill(item);
BaseDataItem baseDataItem = item as BaseDataItem;
if (baseDataItem != null) {
baseDataItem.DbValue = row[baseDataItem.ColumnName].ToString();
if (this.row != null) {
BaseDataItem baseDataItem = item as BaseDataItem;
if (baseDataItem != null) {
baseDataItem.DbValue = row[baseDataItem.ColumnName].ToString();
}
}
} catch (Exception ) {
} catch (System.NullReferenceException) {
}
}
@ -340,7 +218,7 @@ namespace SharpReportCore { @@ -340,7 +218,7 @@ namespace SharpReportCore {
public override int Count {
get {
return this.table.Rows.Count;
return this.IndexList.Count;
}
}
@ -356,31 +234,41 @@ namespace SharpReportCore { @@ -356,31 +234,41 @@ namespace SharpReportCore {
GroupSeperator sep = bc as GroupSeperator;
if (sep != null) {
base.NotifyGroupChange(this,sep);
base.NotifyGroupChanging(this,sep);
}
row = this.view[((BaseComparer)base.IndexList[value]).ListIndex];
}
}
}
#endregion
#region IDisposable
public override bool IsSorted {
get {
return (this.view.Sort.Length > 0);
}
public override void Dispose(){
this.Dispose(true);
GC.SuppressFinalize(this);
}
#endregion
~TableStrategy(){
Dispose(false);
}
#region IDisposable
public void Dispose(){
if (this.view != null) {
this.view.Dispose();
protected override void Dispose(bool disposing){
try {
if (disposing) {
if (this.view != null) {
this.view.Dispose();
this.view = null;
}
}
} finally {
// Release unmanaged resources.
// Set large fields to null.
// Call Dispose on your base class.
base.Dispose(disposing);
}
}
#endregion
}

4
src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/SqlQueryChecker.cs

@ -16,14 +16,14 @@ namespace SharpReportCore @@ -16,14 +16,14 @@ namespace SharpReportCore
/// <summary>
/// This Class checks for invalid SqlStatements
/// </summary>
internal class SqlQueryCkecker{
internal class SqlQueryChecker{
internal string UPDATE = "UPDATE";
internal string DELETE = "DELETE";
internal string INSERT = "INSERT";
internal string noValidMessage = "is no valid Member of SqlString";
public SqlQueryCkecker(){
public SqlQueryChecker(){
}
public void Check (string queryString) {

4
src/AddIns/Misc/SharpReport/SharpReportCore/Exceptions/MissingDataSourceException.cs

@ -17,9 +17,7 @@ using System.Runtime.Serialization; @@ -17,9 +17,7 @@ using System.Runtime.Serialization;
/// created by - Forstmeier Peter
/// created on - 05.07.2005 22:32:47
/// </remarks>
///<remarks>
/// When porting to NET 2.0 use <see cref="Microsoft.Reporting.MissingdatasourceException"></see>
/// </remarks>
namespace SharpReportCore {
[Serializable()]

15
src/AddIns/Misc/SharpReport/SharpReportCore/Globals/FontSingleton.cs

@ -31,7 +31,6 @@ namespace SharpReportCore { @@ -31,7 +31,6 @@ namespace SharpReportCore {
private FontSingleton() {
MessageBox.Show ("Should be commented out","FontSingleton");
hash = new Hashtable();
}
public Hashtable Hash {
@ -54,14 +53,6 @@ namespace SharpReportCore { @@ -54,14 +53,6 @@ namespace SharpReportCore {
public Font GetFont(string family, float size, FontStyle style){
try {
string s=family+size.ToString()+((int)style).ToString();
MessageBox.Show (s);
//Remove when tested
if(hash.Contains(s)){
MessageBox.Show ("font from hashtable","GetFont");
} else {
MessageBox.Show ("font created","getFont");
}
if(hash.Contains(s)){
return (Font)hash[s];
@ -75,10 +66,6 @@ MessageBox.Show ("font from hashtable","GetFont"); @@ -75,10 +66,6 @@ MessageBox.Show ("font from hashtable","GetFont");
}
public override string ToString() {
return base.ToString() + " FontSingleton / ";
}
/// <summary>
/// Clear the Hashtable from all Fonts
/// </summary>
@ -87,7 +74,7 @@ MessageBox.Show ("font from hashtable","GetFont"); @@ -87,7 +74,7 @@ MessageBox.Show ("font from hashtable","GetFont");
///
/// </remarks>
public void Dispose() {
MessageBox.Show ("dispose fonts " + hash.Count.ToString());
}
}
}

6
src/AddIns/Misc/SharpReport/SharpReportCore/Globals/GlobalEnums.cs

@ -97,15 +97,15 @@ namespace SharpReportCore { @@ -97,15 +97,15 @@ namespace SharpReportCore {
/// Convert any possible string-Value of a given enumeration
/// type to its internal representation.
public static object StringToEnum( Type t, string value ) {
foreach ( FieldInfo fi in t.GetFields() )
public static object StringToEnum( Type type, string value ) {
foreach ( FieldInfo fi in type.GetFields() )
if ( fi.Name == value )
return fi.GetValue( null ); // We use null because
throw new Exception( string.Format(CultureInfo.CurrentCulture,
"Can't convert {0} to {1}",
value,
t.ToString()) );
type.ToString()) );
}
}
}

7
src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IDataContainer.cs

@ -26,12 +26,7 @@ namespace SharpReportCore { @@ -26,12 +26,7 @@ namespace SharpReportCore {
/// Reads one row of data and fill the
/// <see cref="ReportItemCollection"></see>
void FetchData (ReportItemCollection collection);
// /// <summary>
// /// set,get the SharpReportCore
// /// </summary>
// object SharpReportCore{
// get;set;
// }
int Count {
get;
}

27
src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IDataViewStrategy.cs

@ -5,7 +5,7 @@ using System.Collections; @@ -5,7 +5,7 @@ using System.Collections;
using System.ComponentModel;
namespace SharpReportCore{
public interface IDataViewStrategy {
public interface IDataViewStrategy:IDisposable{
/// <summary>
/// Sort the DataSource
@ -33,15 +33,7 @@ namespace SharpReportCore{ @@ -33,15 +33,7 @@ namespace SharpReportCore{
get;
}
/// <summary>
/// Build a Hierarchical List of grouped DataRows
/// </summary>
/// <param name="sourceList"></param>
/// <returns></returns>
IHierarchicalEnumerable IHierarchicalEnumerable{
get;
}
int Count {
get;
@ -78,8 +70,21 @@ namespace SharpReportCore{ @@ -78,8 +70,21 @@ namespace SharpReportCore{
bool IsGrouped {
get;
}
// event ListChangedEventHandler ListChanged;
/// <summary>
/// Returns if the current Row has Child's
/// </summary>
bool HasChilds {
get;
}
SharpIndexCollection ChildRows {
get;
}
event EventHandler <ListChangedEventArgs> ListChanged;
/// <summary>
/// Fired each tim the grouping will change, this means theGroupLevel changes up or down
/// </summary>

15
src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IHierarchyInterfaces.cs

@ -13,19 +13,12 @@ using System.Collections; @@ -13,19 +13,12 @@ using System.Collections;
namespace SharpReportCore {
public interface IHierarchicalEnumerable :IEnumerable {
IHierarchyData GetHierarchyData (Object enumeratedItem);
}
public interface IHierarchyData{
IHierarchicalEnumerable GetChildren ();
IHierarchyData GetParent();
SharpIndexCollection GetChildren {
get;
}
bool HasChildren {
get;
}

6
src/AddIns/Misc/SharpReport/SharpReportCore/Interfaces/IOutputStrategy.cs

@ -20,18 +20,18 @@ namespace SharpReportCore @@ -20,18 +20,18 @@ namespace SharpReportCore
/// <summary>
/// Measure the Size of the currnet Item
/// </summary>
SizeF MeasureItem(System.Drawing.Graphics e);
SizeF MeasureItem(System.Drawing.Graphics graphics);
/// <summary>
/// Format the current (TextBased)
/// </summary>
/// <param name="e"></param>
/// <returns></returns>
void FormatItem(System.Drawing.Graphics e );
void FormatItem(System.Drawing.Graphics graphics );
/// <summary>
/// Print them out to ....
/// </summary>
/// <param name="e"></param>
void OutputItem (System.Drawing.Graphics e);
void OutputItem (System.Drawing.Graphics graphics);
}
}

15
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs

@ -47,12 +47,23 @@ namespace SharpReportCore { @@ -47,12 +47,23 @@ namespace SharpReportCore {
}
public RenderDataReport(ReportModel model,DataManager dataManager):base (model){
// System.Console.WriteLine("RenderDataReport".ToUpper());
this.dataManager = dataManager;
System.Console.WriteLine("ReenderDataReport");
System.Console.WriteLine("connect to groupingevents");
this.dataManager.GroupChanged += new EventHandler<GroupChangedEventArgs>(OnGroupChanged);
this.dataManager.GroupChanging += new EventHandler <EventArgs> (OnGroupChanging);
}
void OnGroupChanged (object sender,GroupChangedEventArgs e) {
System.Console.WriteLine("OnGroupChanged");
}
void OnGroupChanging (object sender, EventArgs e) {
System.Console.WriteLine("OnGroupChanging");
}
#region overrides

2
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/ReportDocument.cs

@ -80,7 +80,7 @@ namespace SharpReportCore { @@ -80,7 +80,7 @@ namespace SharpReportCore {
}
public void ReportDocumentPrintPage (object sender, PrintPageEventArgs e) {
// System.Console.WriteLine("\tReportDocument PrintPage");
System.Console.WriteLine("\tReportDocument PrintPage");
pageNr ++;
ReportPageEventArgs pea = new ReportPageEventArgs (e,pageNr,false,new PointF (0,0));

26
src/AddIns/Misc/SharpReport/SharpReportCore/ReportModel.cs

@ -117,9 +117,6 @@ namespace SharpReportCore { @@ -117,9 +117,6 @@ namespace SharpReportCore {
get {
return sectionCollection;
}
set {
sectionCollection = value;
}
}
#endregion
@ -136,16 +133,23 @@ namespace SharpReportCore { @@ -136,16 +133,23 @@ namespace SharpReportCore {
}
protected virtual void Dispose(bool disposing){
if (disposing) {
// Free other state (managed objects).
if (this.reportSettings != null) {
this.reportSettings.Dispose();
this.reportSettings = null;
try {
if (disposing) {
// Free other state (managed objects).
if (this.reportSettings != null) {
this.reportSettings.Dispose();
this.reportSettings = null;
}
if (this.sectionCollection != null) {
this.sectionCollection.Clear();
this.sectionCollection = null;
}
}
}
// Free your own state (unmanaged objects).
// Set large fields to null.
} finally {
// Free your own state (unmanaged objects).
// Set large fields to null.
}
}
#endregion
}

66
src/AddIns/Misc/SharpReport/SharpReportCore/ReportSettings.cs

@ -100,18 +100,15 @@ namespace SharpReportCore{ @@ -100,18 +100,15 @@ namespace SharpReportCore{
XmlElement ctrlElem,
AbstractColumn item) {
try {
XmlNodeList nodeList = ctrlElem.ChildNodes;
foreach (XmlNode node in nodeList) {
if (node is XmlElement) {
XmlElement elem = (XmlElement)node;
if (elem.HasAttribute("value")) {
reader.SetValue (item,elem.Name,elem.GetAttribute("value"));
}
XmlNodeList nodeList = ctrlElem.ChildNodes;
foreach (XmlNode node in nodeList) {
XmlElement elem = node as XmlElement;
if (elem != null) {
if (elem.HasAttribute("value")) {
reader.SetValue (item,elem.Name,elem.GetAttribute("value"));
}
}
} catch (Exception ) {
throw ;
}
}
@ -124,18 +121,18 @@ namespace SharpReportCore{ @@ -124,18 +121,18 @@ namespace SharpReportCore{
private void BuildReportParameter(XmlFormReader reader,
XmlElement parElement,
SharpReportCore.AbstractParameter item) {
try {
XmlNodeList nodeList = parElement.ChildNodes;
foreach (XmlNode node in nodeList) {
XmlElement elem = (XmlElement)node;
XmlNodeList nodeList = parElement.ChildNodes;
foreach (XmlNode node in nodeList) {
XmlElement elem = node as XmlElement;
if (elem != null) {
if (elem.HasAttribute("value")) {
reader.SetValue ((SqlParameter)item,elem.Name,elem.GetAttribute("value"));
}
}
} catch (Exception) {
}
}
#endregion
#region RestoreItems
@ -152,8 +149,8 @@ namespace SharpReportCore{ @@ -152,8 +149,8 @@ namespace SharpReportCore{
XmlNodeList nodeList = xmlCol.ChildNodes;
this.availableFields.Clear();
foreach (XmlNode node in nodeList) {
if (node is XmlElement) {
XmlElement elem = (XmlElement) node;
XmlElement elem = node as XmlElement;
if (elem != null) {
AbstractColumn abstr = new AbstractColumn();
BuildAbstractColumn (xmlReader,elem,abstr);
this.availableFields.Add(abstr);
@ -167,8 +164,8 @@ namespace SharpReportCore{ @@ -167,8 +164,8 @@ namespace SharpReportCore{
XmlNodeList nodeList = xmlCol.ChildNodes;
this.sortingCollection.Clear();
foreach (XmlNode node in nodeList) {
if (node is XmlElement) {
XmlElement elem = (XmlElement) node;
XmlElement elem = node as XmlElement;
if (elem != null) {
SortColumn sc = new SortColumn();
BuildAbstractColumn (xmlReader,elem,sc);
sortingCollection.Add(sc);
@ -181,8 +178,8 @@ namespace SharpReportCore{ @@ -181,8 +178,8 @@ namespace SharpReportCore{
XmlNodeList nodeList = xmlCol.ChildNodes;
this.groupingsCollection.Clear();
foreach (XmlNode node in nodeList) {
if (node is XmlElement) {
XmlElement elem = (XmlElement) node;
XmlElement elem = node as XmlElement;
if (elem != null) {
GroupColumn gc = new GroupColumn();
BuildAbstractColumn (xmlReader,elem,gc);
groupingsCollection.Add(gc);
@ -195,8 +192,8 @@ namespace SharpReportCore{ @@ -195,8 +192,8 @@ namespace SharpReportCore{
XmlNodeList nodeList = xmlCol.ChildNodes;
this.reportParametersCollection.Clear();
foreach( XmlNode node in nodeList) {
if (node is XmlElement) {
XmlElement elem = (XmlElement) node;
XmlElement elem = node as XmlElement;
if (elem != null) {
SqlParameter parameter = new SqlParameter();
BuildReportParameter (xmlReader,
elem,
@ -205,10 +202,7 @@ namespace SharpReportCore{ @@ -205,10 +202,7 @@ namespace SharpReportCore{
}
}
break;
}
default:
throw new SharpReportException ("Invalid Collection found in ReportSettings:CheckForCollection");
}
}
}
@ -218,8 +212,8 @@ namespace SharpReportCore{ @@ -218,8 +212,8 @@ namespace SharpReportCore{
XmlFormReader xmlFormReader = new XmlFormReader();
base.InitDone = false;
foreach (XmlNode node in nodeList) {
if (node is XmlElement) {
XmlElement elem = (XmlElement) node;
XmlElement elem = node as XmlElement;
if (elem != null) {
CheckForCollection (xmlFormReader,elem);
if (elem.Name == "PageSettings") {
@ -228,9 +222,7 @@ namespace SharpReportCore{ @@ -228,9 +222,7 @@ namespace SharpReportCore{
CultureInfo.InvariantCulture);
}
else if (elem.Name == "DefaultFont") {
Font f = XmlFormReader.MakeFont (elem.GetAttribute("value"));
}
else if (elem.HasAttribute("value")) {
xmlFormReader.SetValue (this,elem.Name,elem.GetAttribute("value"));
}
@ -526,9 +518,9 @@ namespace SharpReportCore{ @@ -526,9 +518,9 @@ namespace SharpReportCore{
get {
return sortingCollection;
}
set {
sortingCollection = value;
}
// set {
// sortingCollection = value;
// }
}
[Browsable(false)]
[XmlIgnoreAttribute]
@ -539,6 +531,7 @@ namespace SharpReportCore{ @@ -539,6 +531,7 @@ namespace SharpReportCore{
}
return groupingsCollection;
}
/*
set {
if (this.groupingsCollection == null) {
groupingsCollection = new ColumnCollection();
@ -548,6 +541,7 @@ namespace SharpReportCore{ @@ -548,6 +541,7 @@ namespace SharpReportCore{
this.NotifyPropertyChanged();
}
}
*/
}
[Browsable(false)]

9
src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj

@ -32,12 +32,12 @@ @@ -32,12 +32,12 @@
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<Reference Include="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<Reference Include="System.ServiceProcess, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="System" />
<Reference Include="System.Data" />
</ItemGroup>
<ItemGroup>
<Compile Include="BaseItems\BaseTextItem.cs" />
@ -50,13 +50,10 @@ @@ -50,13 +50,10 @@
<Compile Include="BaseItems\Functions\BaseToday.cs" />
<Compile Include="BaseItems\Functions\BasePageNumber.cs" />
<Compile Include="DataManager\Comparer\BaseComparer.cs" />
<Compile Include="DataManager\Comparer\GroupComparer.cs" />
<Compile Include="DataManager\Comparer\GroupSeperator.cs" />
<Compile Include="DataManager\Comparer\SortComparer.cs" />
<Compile Include="DataManager\ListHandling\ExtendedPropertyDescriptor.cs" />
<Compile Include="DataManager\ListHandling\ExtendedTypeDescriptor.cs" />
<Compile Include="DataManager\ListHandling\IExtendedList.cs" />
<Compile Include="DataManager\ListHandling\IHierarchicalArray.cs" />
<Compile Include="DataManager\ListHandling\PropertyTypeHash.cs" />
<Compile Include="DataManager\ListHandling\SharpArrayList.cs" />
<Compile Include="DataManager\ListStrategy\BaseListStrategy.cs" />
@ -85,7 +82,6 @@ @@ -85,7 +82,6 @@
<Compile Include="Interfaces\IBaseRenderer.cs" />
<Compile Include="Interfaces\IDataContainer.cs" />
<Compile Include="Interfaces\IDataViewStrategy.cs" />
<Compile Include="Interfaces\IHierarchyInterfaces.cs" />
<Compile Include="Interfaces\IItemRenderer.cs" />
<Compile Include="Interfaces\IOutputStrategy.cs" />
<Compile Include="Interfaces\IRender.cs" />
@ -129,6 +125,7 @@ @@ -129,6 +125,7 @@
<Compile Include="Collections\Collections.cs" />
<Compile Include="DataManager\SqlQueryChecker.cs" />
<Compile Include="Exceptions\MissingModelException.cs" />
<Compile Include="Interfaces\IHierarchyInterfaces.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="BaseItems" />

61
src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportEngine.cs

@ -41,6 +41,7 @@ namespace SharpReportCore { @@ -41,6 +41,7 @@ namespace SharpReportCore {
private PreviewControl previewControl;
private ConnectionObject connectionObject;
private DataManager dataManager;
public event EventHandler <SharpReportEventArgs> NoData;
public event EventHandler <SharpReportParametersEventArgs> ParametersRequest;
@ -134,22 +135,18 @@ namespace SharpReportCore { @@ -134,22 +135,18 @@ namespace SharpReportCore {
}
}
private DataManager SetupDataContainer (ReportSettings settings) {
private void InitDataContainer (ReportSettings settings) {
if (settings.ReportType == GlobalEnums.enmReportType.DataReport) {
if (settings.CommandText != null) {
try {
GrapSqlParameters (settings);
if (this.connectionObject != null) {
DataManager container = new DataManager(this.connectionObject,
this.dataManager = new DataManager(this.connectionObject,
settings);
if (container.DataBind() == true) {
return container;
} else {
return null;
}
this.dataManager.DataBind();
}else {
throw new NullReferenceException("SetupContainer:connectionObject is missing");
}
@ -163,7 +160,6 @@ namespace SharpReportCore { @@ -163,7 +160,6 @@ namespace SharpReportCore {
}
}
}
return null;
}
@ -187,6 +183,7 @@ namespace SharpReportCore { @@ -187,6 +183,7 @@ namespace SharpReportCore {
protected SharpReportCore.AbstractRenderer SetupStandartRenderer (ReportModel model) {
AbstractRenderer abstr = null;
switch (model.ReportSettings.ReportType) {
//FormSheets reports
@ -195,9 +192,10 @@ namespace SharpReportCore { @@ -195,9 +192,10 @@ namespace SharpReportCore {
break;
//Databased reports
case GlobalEnums.enmReportType.DataReport :
DataManager dataManager = SetupDataContainer (model.ReportSettings);
if (dataManager != null) {
if (dataManager.DataSource != null) {
// DataManager dataManager = SetupDataContainer (model.ReportSettings);
InitDataContainer (model.ReportSettings);
if (this.dataManager != null) {
if (this.dataManager.DataSource != null) {
abstr = new RendererFactory().Create (model,dataManager);
}
@ -239,11 +237,12 @@ namespace SharpReportCore { @@ -239,11 +237,12 @@ namespace SharpReportCore {
}
AbstractRenderer abstr = null;
DataManager dataManager = new DataManager (dataTable,model.ReportSettings);
if (dataManager != null) {
dataManager.DataBind();
if (dataManager.DataSource != null) {
this.dataManager = new DataManager (dataTable,model.ReportSettings);
if (this.dataManager != null) {
this.dataManager.DataBind();
if (this.dataManager.DataSource != null) {
abstr = new RendererFactory().Create (model,dataManager);
}
@ -475,7 +474,7 @@ namespace SharpReportCore { @@ -475,7 +474,7 @@ namespace SharpReportCore {
try {
model = ModelFromFile (fileName);
if (!CheckForPushModel(model)) {
throw new SharpReportException ("PrintPushdataReport: No valid ReportModel");
throw new MissingModelException();
}
renderer = this.SetupPushDataRenderer (model,dataTable);
@ -555,19 +554,25 @@ namespace SharpReportCore { @@ -555,19 +554,25 @@ namespace SharpReportCore {
}
protected virtual void Dispose(bool disposing){
if (disposing) {
// Free other state (managed objects).
if (this.connectionObject != null) {
this.connectionObject.Dispose();
}
if (this.previewControl != null) {
this.previewControl.Dispose();
try {
if (disposing) {
// Free other state (managed objects).
if (this.connectionObject != null) {
this.connectionObject.Dispose();
}
if (this.dataManager != null) {
this.dataManager.Dispose();
this.dataManager = null;
}
if (this.previewControl != null) {
this.previewControl.Dispose();
}
}
} finally {
// Release unmanaged resources.
// Set large fields to null.
// Call Dispose on your base class.
}
// Release unmanaged resources.
// Set large fields to null.
// Call Dispose on your base class.
}
#endregion
}

30
src/AddIns/Misc/SharpReport/SharpReportCore/Xml/XmlHelper.cs

@ -44,12 +44,8 @@ namespace SharpReportCore { @@ -44,12 +44,8 @@ namespace SharpReportCore {
///
public static bool IsSharpReport (XmlElement elem) {
bool isOk = false;
try {
if (elem.Name.Equals (SharpReportCore.GlobalValues.SharpReportString)) {
isOk = true;
}
} catch (Exception) {
throw ;
if (elem.Name.Equals (SharpReportCore.GlobalValues.SharpReportString)) {
isOk = true;
}
return isOk;
}
@ -75,13 +71,13 @@ namespace SharpReportCore { @@ -75,13 +71,13 @@ namespace SharpReportCore {
// Valid Document
return xmlDoc;
} else {
throw new SharpReportException ("XmlHelper.OpenSharpReport - > No SharpReport");
throw new IllegalFileFormatException();
}
} else {
throw new SharpReportException ("XmlHelper.OpenSharpReport - > No valid DocumentElement");
throw new IllegalFileFormatException();
}
}
catch (System.Xml.XmlException) {
catch (System.Xml.XmlException ) {
IllegalFileFormatException wf = new IllegalFileFormatException("XmlHelper.OpenSharpReport - > Wrong File Format");
throw wf;
}
@ -108,19 +104,13 @@ namespace SharpReportCore { @@ -108,19 +104,13 @@ namespace SharpReportCore {
XmlNodeList nodeList = element.ChildNodes;
foreach (XmlNode node in nodeList) {
if (node is XmlElement) {
XmlElement elem = (XmlElement) node;
XmlElement elem = node as XmlElement;
if (elem != null) {
if (elem.HasAttribute("value")) {
try {
reader.SetValue (section,elem.Name,elem.GetAttribute("value"));
} catch (Exception e) {
MessageBox.Show (elem.Name + " / " + elem.GetAttribute("value"));
MessageBox.Show (e.Message);
}
reader.SetValue (section,elem.Name,elem.GetAttribute("value"));
}
} else {
throw new System.Xml.XmlException ("Report : SetValues Wrong Node in Report");
}else {
throw new System.Xml.XmlException ();
}
}
}

Loading…
Cancel
Save