Browse Source

Further refactoring of ReportGenerator, new Exception MissingModelException.cs added

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1071 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Peter Forstmeier 20 years ago
parent
commit
43ae176456
  1. 42
      src/AddIns/Misc/SharpReport/SharpReport/AutoReport.cs
  2. 1
      src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/PageNumber.cs
  3. 9
      src/AddIns/Misc/SharpReport/SharpReport/SharpReportManager.cs
  4. 2
      src/AddIns/Misc/SharpReport/SharpReportAddin/FieldsExplorer/FieldsExplorer.cs
  5. 16
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseImageItem.cs
  6. 37
      src/AddIns/Misc/SharpReport/SharpReportCore/Exceptions/MissingModelException.cs
  7. 1
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs
  8. 1
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs
  9. 3
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/ReportDocument.cs
  10. 1
      src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj
  11. 20
      src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportEngine.cs
  12. 82
      src/AddIns/Misc/SharpReport/SharpReportWizard/GeneratorCommands.cs
  13. 147
      src/AddIns/Misc/SharpReport/SharpReportWizard/Generators/AbstractReportGenerator.cs
  14. 38
      src/AddIns/Misc/SharpReport/SharpReportWizard/Generators/GeneratePullDataReport.cs
  15. 16
      src/AddIns/Misc/SharpReport/SharpReportWizard/Generators/GeneratePushDataReport.cs
  16. 16
      src/AddIns/Misc/SharpReport/SharpReportWizard/ReportGenerator.cs
  17. 20
      src/AddIns/Misc/SharpReport/SharpReportWizard/WizardPanels/BaseSettingsPanel.cs
  18. 3
      src/AddIns/Misc/SharpReport/SharpReportWizard/WizardPanels/PullModelPanel.cs
  19. 48
      src/AddIns/Misc/SharpReport/SharpReportWizard/WizardPanels/PushModelPanel.cs
  20. 68
      src/AddIns/Misc/SharpReport/SharpReportWizard/WizardPanels/ResultPanel.cs

42
src/AddIns/Misc/SharpReport/SharpReport/AutoReport.cs

@ -77,6 +77,31 @@ namespace SharpReport { @@ -77,6 +77,31 @@ namespace SharpReport {
return itemCol;
}
///<summary>
/// Build a <see cref="ColumnCollection"></see> this collection holds all the fields
/// comming from the DataSource
///</summary>
public ColumnCollection AbstractColumnsFromDataSet(DataSet dataSet) {
if (dataSet.Tables.Count > 1) {
MessageService.ShowError ("AutoBuildFromDataSet : at this time no more than one table is allowed " + dataSet.Tables.Count.ToString());
throw new ArgumentException ("Too much Tables in DataSet");
}
ColumnCollection collection = new ColumnCollection();
foreach (DataTable tbl in dataSet.Tables) {
DataColumn col;
for (int i = 0;i < tbl.Columns.Count ;i++ ) {
col = tbl.Columns[i];
AbstractColumn abstrColumn = new AbstractColumn();
abstrColumn.ColumnName = col.ColumnName;
abstrColumn.DataType = col.DataType;
collection.Add (abstrColumn);
}
}
return collection;
}
/// <summary>
/// Build BaseDataItems from a *.xsd File
/// </summary>
@ -160,14 +185,20 @@ namespace SharpReport { @@ -160,14 +185,20 @@ namespace SharpReport {
}
public ReportItemCollection AutoHeaderFromReportItems(ReportItemCollection col,BaseSection section,bool setOnTop) {
if (col != null) {
public ReportItemCollection AutoHeaderFromReportItems(ReportItemCollection reportItemCollection,BaseSection section,bool setOnTop) {
if (reportItemCollection == null) {
throw new ArgumentNullException ("reportItemCollection");
}
if (section == null) {
throw new ArgumentNullException ("section");
}
ReportItemCollection itemCol = new ReportItemCollection();
ReportDataItem sourceItem = null;
for (int i = 0;i < col.Count ;i++ ){
for (int i = 0;i < reportItemCollection.Count ;i++ ){
BaseTextItem rItem = (BaseTextItem)iDesignableFactory.Create("ReportTextItem");
if (rItem != null) {
sourceItem = (ReportDataItem)col[i];
sourceItem = (ReportDataItem)reportItemCollection[i];
rItem.Text = sourceItem.ColumnName;
rItem.Text = sourceItem.ColumnName;
@ -181,9 +212,6 @@ namespace SharpReport { @@ -181,9 +212,6 @@ namespace SharpReport {
}
}
return itemCol;
}else {
throw new ArgumentNullException ("AutoReport:ReportItemCollection");
}
}
#endregion

1
src/AddIns/Misc/SharpReport/SharpReport/ReportItems/Functions/MiscFunctions/PageNumber.cs

@ -47,6 +47,7 @@ namespace SharpReport.ReportItems.Functions { @@ -47,6 +47,7 @@ namespace SharpReport.ReportItems.Functions {
ItemsHelper.UpdateTextControl (this.visualControl,this);
this.Text = functionName;
this.visualControl.FunctionValue = String.Empty;
GrapFromBase();
this.initDone = true;
}

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

@ -187,6 +187,7 @@ namespace SharpReport{ @@ -187,6 +187,7 @@ namespace SharpReport{
#endregion
#region HeaderColumns
/*
/// <summary>
/// Builds ColumHeaders for Reports, we take the ColumnNames as Text Property
/// </summary>
@ -207,7 +208,7 @@ namespace SharpReport{ @@ -207,7 +208,7 @@ namespace SharpReport{
}
}
}
*/
///<summary>
/// Create ColumHeaders for Reports
/// </summary>
@ -232,7 +233,7 @@ namespace SharpReport{ @@ -232,7 +233,7 @@ namespace SharpReport{
#region Create report from Query
/*
/// <summary>
/// Create Columns from SchemaTable
/// </summary>
@ -258,6 +259,7 @@ namespace SharpReport{ @@ -258,6 +259,7 @@ namespace SharpReport{
}
}
}
*/
#endregion
#region Create Reports from .Xsd Files
@ -291,9 +293,8 @@ namespace SharpReport{ @@ -291,9 +293,8 @@ namespace SharpReport{
public AbstractRenderer GetRendererForStandartReports (ReportModel model) {
System.Console.WriteLine("Manager.GetRenderer");
if (model == null) {
throw new ArgumentException("SharpReportManager:GetRendererForStandartReports 'ReportModel'");
throw new ArgumentNullException("model");
}
return this.BuildStandartRenderer (model);
}

2
src/AddIns/Misc/SharpReport/SharpReportAddin/FieldsExplorer/FieldsExplorer.cs

@ -253,7 +253,7 @@ namespace SharpReportAddin { @@ -253,7 +253,7 @@ namespace SharpReportAddin {
}
} catch (Exception er) {
System.Console.WriteLine("\t{0}",er.Message);
System.Console.WriteLine("\tFieldsExplorer {0}",er.Message);
}
}

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

@ -35,19 +35,21 @@ namespace SharpReportCore { @@ -35,19 +35,21 @@ namespace SharpReportCore {
public BaseImageItem():base() {
}
private void LoadImage (string fName) {
if (fName == "") {
throw new ArgumentException("BaseImageItem:FileName");
private void LoadImage (string fileName) {
if (String.IsNullOrEmpty(fileName)) {
throw new ArgumentNullException("fileName");
}
try {
this.image = null;
this.image = Image.FromFile (fName);
this.image = Image.FromFile (fileName);
if (image == null) {
string str = String.Format(CultureInfo.InvariantCulture,
"Unable to Load {0}",fName);
throw new ApplicationException(str);
"Unable to Load {0}",fileName);
throw new SharpReportException(str);
}
} catch (Exception) {
} catch (System.OutOfMemoryException) {
throw;
} catch (System.IO.FileNotFoundException) {
throw;
}

37
src/AddIns/Misc/SharpReport/SharpReportCore/Exceptions/MissingModelException.cs

@ -0,0 +1,37 @@ @@ -0,0 +1,37 @@
/*
* Created by SharpDevelop.
* User: Forstmeier Peter
* Date: 03.02.2006
* Time: 13:57
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Runtime.Serialization;
/// <summary>
/// Description of MissingModelException.
/// </summary>
namespace SharpReportCore{
[Serializable()]
public class MissingModelException: System.Exception
{
public MissingModelException():base(){
}
public MissingModelException(string errorMessage) :base (errorMessage){
}
public MissingModelException(string errorMessage,
Exception exception):base (errorMessage,exception){
}
protected MissingModelException(SerializationInfo info,
StreamingContext context) : base(info, context){
// Implement type-specific serialization constructor logic.
}
}
}

1
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/AbstractRenderer.cs

@ -331,7 +331,6 @@ namespace SharpReportCore { @@ -331,7 +331,6 @@ namespace SharpReportCore {
#region property's
public ReportDocument ReportDocument {
get {
System.Console.WriteLine("Get the AbstractRenderer:ReportDocument");
return reportDocument;
}
}

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

@ -61,7 +61,6 @@ namespace SharpReportCore { @@ -61,7 +61,6 @@ namespace SharpReportCore {
}
protected override void ReportBegin(object sender, ReportPageEventArgs e) {
System.Console.WriteLine("\tRenderDataReport:ReportBegin");
base.ReportBegin (sender,e);
//allways reset the dataManager before printing
if (this.dataManager != null) {

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

@ -33,7 +33,6 @@ namespace SharpReportCore { @@ -33,7 +33,6 @@ namespace SharpReportCore {
public ReportDocument():base() {
System.Console.WriteLine("ReportDocument Constructor");
base.BeginPrint += new PrintEventHandler (ReportDocumentBeginPrint);
base.PrintPage += new PrintPageEventHandler (ReportDocumentPrintPage);
@ -43,7 +42,6 @@ namespace SharpReportCore { @@ -43,7 +42,6 @@ namespace SharpReportCore {
}
void GeneratePage (SharpReportCore.ReportPageEventArgs page) {
System.Console.WriteLine("\tGeneratePage");
if (PrintPageBegin != null) {
PrintPageBegin (this,page);
}
@ -71,7 +69,6 @@ namespace SharpReportCore { @@ -71,7 +69,6 @@ namespace SharpReportCore {
#region events
//this events are also used by PrintPreviewControl
public void ReportDocumentBeginPrint (object sender,PrintEventArgs e) {
System.Console.WriteLine("\tReportDocument BeginPrint");
pageNr = 0;
}

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

@ -129,6 +129,7 @@ @@ -129,6 +129,7 @@
<Compile Include="BaseClasses\SqlParameter.cs" />
<Compile Include="Collections\Collections.cs" />
<Compile Include="DataManager\SqlQueryChecker.cs" />
<Compile Include="Exceptions\MissingModelException.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="BaseItems" />

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

@ -336,11 +336,11 @@ namespace SharpReportCore { @@ -336,11 +336,11 @@ namespace SharpReportCore {
/// <param name="fileName">Filename to the location of the ReportFile</param>
/// <param name="dataTable">a Datatable, containing the data</param>
public void PreviewPushDataReport (string fileName,DataTable dataTable) {
if (fileName.Length == 0) {
throw new ArgumentException("PreviewPushDataReport fileName");
if (String.IsNullOrEmpty(fileName)) {
throw new ArgumentNullException("fileName");
}
if (dataTable == null) {
throw new ArgumentNullException("PreviewPushDataReport dataTable");
throw new ArgumentNullException("dataTable");
}
ReportModel model = null;
AbstractRenderer renderer = null;
@ -394,16 +394,16 @@ namespace SharpReportCore { @@ -394,16 +394,16 @@ namespace SharpReportCore {
/// <param name="renderTo">Type of renderer currently only "ToText" is implemented</param>
public void PrintStandartReport (string fileName) {
if (fileName.Length == 0) {
throw new ArgumentException("PreviewPushDataReport fileName");
if (String.IsNullOrEmpty(fileName)) {
throw new ArgumentNullException("fileName");
}
PrintStandartReport (fileName,null);
}
public void PrintStandartReport (string fileName,ReportParameters reportParameters) {
if (fileName.Length == 0) {
throw new ArgumentException("PreviewPushDataReport fileName");
if (String.IsNullOrEmpty(fileName)) {
throw new ArgumentNullException("fileName");
}
ReportModel model = null;
@ -430,11 +430,11 @@ namespace SharpReportCore { @@ -430,11 +430,11 @@ namespace SharpReportCore {
DataTable dataTable,
bool showPrintDialog) {
if (fileName.Length == 0) {
throw new ArgumentException("PreviewPushDataReport fileName");
if (String.IsNullOrEmpty(fileName)) {
throw new ArgumentNullException("fileName");
}
if (dataTable == null) {
throw new ArgumentNullException("PreviewPushDataReport dataTable");
throw new ArgumentNullException("dataTable");
}
ReportModel model = null;
AbstractRenderer renderer = null;

82
src/AddIns/Misc/SharpReport/SharpReportWizard/GeneratorCommands.cs

@ -13,24 +13,13 @@ @@ -13,24 +13,13 @@
/// </summary>
using System;
using System.Windows.Forms;
using System.Drawing.Printing;
using System.Data;
using System.Data.OleDb;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using SharpReport;
using SharpReportCore;
using SharpReport.Designer;
using SharpQuery.SchemaClass;
using SharpQuery.Collections;
using System.Diagnostics;
namespace ReportGenerator{
/// <summary>
@ -48,6 +37,9 @@ namespace ReportGenerator{ @@ -48,6 +37,9 @@ namespace ReportGenerator{
}
public CreateReport(ReportModel reportModel){
if (reportModel == null) {
throw new ArgumentNullException("reportModel");
}
this.reportModel = reportModel;
}
@ -58,13 +50,11 @@ namespace ReportGenerator{ @@ -58,13 +50,11 @@ namespace ReportGenerator{
customizer.Set("Language", ".XSD");
using (WizardDialog wizard = new WizardDialog("Report Wizard", customizer, WizardPath)) {
if (wizard.ShowDialog() == DialogResult.OK) {
Debug.Assert (reportModel != null,"No report model");
try {
gen.FillReportModel (reportModel);
DoCreate(reportModel);
} catch (Exception) {
// MessageService.ShowError (e,e.Message);
// return;
throw;
}
} else {
@ -81,71 +71,20 @@ namespace ReportGenerator{ @@ -81,71 +71,20 @@ namespace ReportGenerator{
dataModel = model.DataModel;
switch (dataModel) {
case GlobalEnums.enmPushPullModel.PullData:
GeneratePullReport (model);
GeneratePullDataReport generatePullDataReport = new GeneratePullDataReport(customizer,model);
generatePullDataReport.GenerateReport();
break;
case GlobalEnums.enmPushPullModel.PushData:
GeneratePushReport (model);
GeneratePushDataReport generatePushDataReport = new GeneratePushDataReport(customizer,model);
generatePushDataReport.GenerateReport();
break;
case GlobalEnums.enmPushPullModel.FormSheet:
GenerateFormSheet (model);
model.ReportSettings.ReportType = GlobalEnums.enmReportType.FormSheet;
break;
}
}
/// <summary>
/// Generate a report
/// Pull - Report fill's data be themselve
/// </summary>
/// <param name="model">ReportModel</param>
void GeneratePullReport (ReportModel model) {
try {
GeneratePullDataReport generator = new GeneratePullDataReport(customizer,model);
if (generator != null) {
generator.GenerateReport();
} else {
throw new NullReferenceException ("GeneratePullDataReport");
}
} catch (Exception) {
throw;
}
}
/// <summary>
/// Push Model Report
/// Report is created by an .Xsd File
/// </summary>
/// <param name="model">ReportModel</param>
void GeneratePushReport (ReportModel model) {
try {
GeneratePushDataReport generator = new GeneratePushDataReport(customizer,model);
if (generator != null) {
generator.GenerateReport();
} else {
throw new NullReferenceException ("GeneratePullDataReport");
}
} catch (Exception) {
throw;
}
}
private static void GenerateFormSheet (ReportModel model) {
if (model.ReportSettings.DataModel != GlobalEnums.enmPushPullModel.FormSheet) {
throw new ArgumentNullException ("model");
}
try {
model.ReportSettings.ReportType = GlobalEnums.enmReportType.FormSheet;
} catch (Exception) {
throw;
}
}
}
public class WriteXsdComplete : AbstractMenuCommand {
public override void Run() {
ResultPanel resultPanel = base.Owner as ResultPanel;
@ -164,7 +103,6 @@ namespace ReportGenerator{ @@ -164,7 +103,6 @@ namespace ReportGenerator{
}
}
}
}
}

147
src/AddIns/Misc/SharpReport/SharpReportWizard/Generators/AbstractReportGenerator.cs

@ -19,20 +19,19 @@ using ICSharpCode.Core; @@ -19,20 +19,19 @@ using ICSharpCode.Core;
using SharpReport;
using SharpReportCore;
using SharpQuery;
using SharpQuery.Collections;
using SharpQuery.Connection;
using SharpQuery.SchemaClass;
/// <summary>
/// Abstract Class for all ReportGenerators
/// </summary>
/// <remarks>
/// created by - Forstmeier Peter
/// created on - 07.09.2005 14:21:07
/// </remarks>
/// <summary>
/// Abstract Class for all ReportGenerators
/// </summary>
/// <remarks>
/// created by - Forstmeier Peter
/// created on - 07.09.2005 14:21:07
/// </remarks>
///
using System.Windows.Forms;
namespace ReportGenerator {
public class AbstractReportGenerator : IReportGenerator {
public class AbstractReportGenerator : IReportGenerator,IDisposable {
private ReportModel reportModel;
private ReportGenerator reportGenerator;
private Properties customizer;
@ -42,11 +41,15 @@ namespace ReportGenerator { @@ -42,11 +41,15 @@ namespace ReportGenerator {
}
public AbstractReportGenerator(Properties customizer,ReportModel reportModel){
this.customizer = customizer;
this.reportModel = reportModel;
if (reportModel == null) {
throw new ArgumentNullException("reportModel");
}
if (customizer == null) {
throw new ArgumentNullException("customizer");
}
this.customizer = customizer;
this.reportModel = reportModel;
reportGenerator = (ReportGenerator)customizer.Get("Generator");
manager = new SharpReportManager();
}
@ -54,102 +57,14 @@ namespace ReportGenerator { @@ -54,102 +57,14 @@ namespace ReportGenerator {
#region ReportGenerator.IReportGenerator interface implementation
public virtual void GenerateReport() {
if (this.reportModel == null) {
throw new NullReferenceException("ReportModel");
throw new MissingModelException();
}
BuildStandartSections();
manager.CreatePageHeader (reportModel);
manager.CreatePageNumber(reportModel);
manager.CreatePageHeader (this.reportModel);
manager.CreatePageNumber(this.reportModel);
}
#endregion
/*
protected ColumnCollection AvailableColumnsFromTable (DataTable table) {
if (table == null) {
throw new ArgumentNullException("table");
}
ColumnCollection collection = new ColumnCollection();
AbstractColumn abstr;
foreach (DataRow row in table.Rows) {
abstr = new AbstractColumn();
abstr.ColumnName = Convert.ToString(row["ColumnName"],CultureInfo.InvariantCulture);
collection.Add (abstr);
}
return collection;
}
*/
protected DataTable GenerateFieldsTable(ReportModel reportModel) {
if (reportModel == null) {
throw new ArgumentNullException("reportModel");
}
if (reportModel.ReportSettings.ConnectionString.Length == 0) {
throw new ArgumentException("CreateOLEDB Connection : No ConnectionString");
}
OleDbConnection connection = null;
OleDbCommand command = null;
try {
connection = new OleDbConnection(reportModel.ReportSettings.ConnectionString);
connection.Open();
if (connection == null) {
throw new ArgumentNullException("AbstractReportGenerator:GenerateFieldsTable <connection");
}
command = connection.CreateCommand();
command.CommandText = reportModel.ReportSettings.CommandText;
command.CommandType = reportModel.ReportSettings.CommandType;
// If needed Add some parameters
if (reportModel.ReportSettings.SqlParametersCollection != null &&
reportModel.ReportSettings.SqlParametersCollection.Count > 0) {
int rpc = reportModel.ReportSettings.SqlParametersCollection.Count;
OleDbParameter oleDBPar = null;
SqlParameter rpPar;
for (int i = 0;i < rpc ;i++) {
rpPar = (SqlParameter)reportModel.ReportSettings.SqlParametersCollection[i];
// System.Console.WriteLine("{0} {1} {2}",rpPar.ParameterName,rpPar.DataType,rpPar.DefaultValue);
if (rpPar.DataType != System.Data.DbType.Binary) {
oleDBPar = new OleDbParameter(rpPar.ParameterName,
rpPar.DataType);
oleDBPar.Value = rpPar.DefaultValue;
} else {
// System.Console.WriteLine("binary");
oleDBPar = new OleDbParameter(rpPar.ParameterName,
System.Data.DbType.Binary);
}
oleDBPar.Direction = rpPar.ParameterDirection;
command.Parameters.Add(oleDBPar);
}
}
} catch (Exception) {
throw;
}
OleDbDataReader reader = null;
DataTable schemaTable = null;
try {
if (connection.State != ConnectionState.Open) {
connection.Open();
}
reader = command.ExecuteReader(CommandBehavior.KeyInfo);
schemaTable = reader.GetSchemaTable();
return schemaTable;
} catch (Exception e) {
throw e;
} finally {
if (reader != null) {
reader.Close();
}
connection.Close();
}
}
protected void BuildStandartSections () {
@ -197,5 +112,27 @@ namespace ReportGenerator { @@ -197,5 +112,27 @@ namespace ReportGenerator {
#endregion
public void Dispose(){
this.Dispose(true);
GC.SuppressFinalize(this);
}
~AbstractReportGenerator(){
Dispose(false);
}
protected void Dispose(bool disposing){
if (disposing) {
// Free other state (managed objects).
if (this.manager != null) {
this.manager.Dispose();
}
}
// Release unmanaged resources.
// Set large fields to null.
// Call Dispose on your base class.
}
}
}

38
src/AddIns/Misc/SharpReport/SharpReportWizard/Generators/GeneratePullDataReport.cs

@ -8,9 +8,9 @@ @@ -8,9 +8,9 @@
// </autogenerated>
//------------------------------------------------------------------------------
using System;
using System.Data;
using ICSharpCode.Core;
using SharpReportCore;
/// <summary>
/// This class is used to AutoGenerate a (PullData) Report
@ -33,45 +33,31 @@ namespace ReportGenerator { @@ -33,45 +33,31 @@ namespace ReportGenerator {
}
}
#region ReportGenerator.IReportGenerator interface implementation
public override void GenerateReport() {
try {
base.ReportModel.ReportSettings.ReportType = GlobalEnums.enmReportType.DataReport;
DataTable tableFields = null;
if (base.ReportGenerator.CommandType == CommandType.StoredProcedure) {
// we have Storedprocedure
if (base.ReportGenerator.SharpQueryProcedure.GetSchemaParameters() != null &&
base.ReportGenerator.SharpQueryProcedure.GetSchemaParameters().Count > 0) {
// with parameters so we have prepare build the ParametersCollection here
base.ReportModel.ReportSettings.SqlParametersCollection = base.ReportGenerator.BuildSqlParameterList();
tableFields = base.GenerateFieldsTable (base.ReportModel);
} else {
// no params, just run
tableFields = base.GenerateFieldsTable (base.ReportModel);
}
} else {
// just run
tableFields = base.GenerateFieldsTable (base.ReportModel);
}
base.GenerateReport();
base.Manager.HeaderColumnsFromTable(base.ReportModel.PageHeader,
tableFields);
base.ReportModel.ReportSettings.DataModel = GlobalEnums.enmPushPullModel.PullData;
base.Manager.DataColumnsFromTable (base.ReportModel,
tableFields);
ReportItemCollection col = (ReportItemCollection)base.Customizer.Get ("ReportItemCollection");
ColumnCollection columnCollection = (ColumnCollection)base.Customizer.Get ("ColumnCollection");
this.ReportModel.ReportSettings.AvailableFieldsCollection = columnCollection;
base.GenerateReport();
base.Manager.HeaderColumnsFromReportItems (base.ReportModel.PageHeader,col);
base.Manager.DataColumnsFromReportItems (base.ReportModel.DetailSection,col);
using (TableLayout layout = new TableLayout(base.ReportModel)){
layout.BuildLayout();
}
base.AdjustAll();
} catch (Exception e) {
throw e;
} catch (Exception) {
throw;
}
}
#endregion
}
}

16
src/AddIns/Misc/SharpReport/SharpReportWizard/Generators/GeneratePushDataReport.cs

@ -9,12 +9,11 @@ @@ -9,12 +9,11 @@
//------------------------------------------------------------------------------
using System;
using System.Data;
using ICSharpCode.Core;
using SharpReportCore;
using System.Windows.Forms;
/// <summary>
/// This class is used to generate PushDataReports
/// (Reports, that are feed with an DataSet etc)
@ -39,23 +38,22 @@ namespace ReportGenerator { @@ -39,23 +38,22 @@ namespace ReportGenerator {
}
public override void GenerateReport() {
base.ReportModel.ReportSettings.ReportType = GlobalEnums.enmReportType.DataReport;
base.ReportModel.ReportSettings.ReportType = GlobalEnums.enmReportType.DataReport;
base.ReportModel.ReportSettings.DataModel = GlobalEnums.enmPushPullModel.PushData;
ReportItemCollection col = (ReportItemCollection)base.Customizer.Get ("ReportItemCollection");
// MessageBox.Show (col.Count.ToString());
//we can't use the customizer here
ReportItemCollection col = base.ReportGenerator.ReportItemCollection;
base.ReportModel.ReportSettings.AvailableFieldsCollection = base.ReportGenerator.ColumnCollection;
base.GenerateReport();
base.Manager.HeaderColumnsFromReportItems (base.ReportModel.PageHeader,col);
base.Manager.DataColumnsFromReportItems (base.ReportModel.DetailSection,col);
using (TableLayout layout = new TableLayout(base.ReportModel)){
layout.BuildLayout();
}
base.AdjustAll();
}
}
}

16
src/AddIns/Misc/SharpReport/SharpReportWizard/ReportGenerator.cs

@ -53,6 +53,7 @@ namespace ReportGenerator { @@ -53,6 +53,7 @@ namespace ReportGenerator {
private CommandType commandType;
private SharpQueryProcedure sharpQueryProcedure;
private ReportItemCollection reportItemCollection;
private ColumnCollection columnCollection;
private SharpQuerySchemaClassCollection queryParameters;
public ReportGenerator() {
@ -224,7 +225,19 @@ namespace ReportGenerator { @@ -224,7 +225,19 @@ namespace ReportGenerator {
#endregion
#region PushModelpanel
#region PushModelPanel
public ColumnCollection ColumnCollection {
get {
return columnCollection;
}
set {
columnCollection = value;
}
}
public ReportItemCollection ReportItemCollection {
get {
return reportItemCollection;
@ -235,5 +248,6 @@ namespace ReportGenerator { @@ -235,5 +248,6 @@ namespace ReportGenerator {
}
#endregion
}
}

20
src/AddIns/Misc/SharpReport/SharpReportWizard/WizardPanels/BaseSettingsPanel.cs

@ -15,7 +15,7 @@ using System.Globalization; @@ -15,7 +15,7 @@ using System.Globalization;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
//using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using SharpReportCore;
@ -80,9 +80,8 @@ namespace ReportGenerator{ @@ -80,9 +80,8 @@ namespace ReportGenerator{
public override bool ReceiveDialogMessage(DialogMessage message){
if (message == DialogMessage.Finish) {
// System.Console.WriteLine(" resiveMessage Finish");
} else if ( message == DialogMessage.Next) {
// System.Console.WriteLine(" resiveMessage Next");
base.EnableFinish = true;
}
return true;
@ -93,7 +92,9 @@ namespace ReportGenerator{ @@ -93,7 +92,9 @@ namespace ReportGenerator{
return customizer;
}
set {
if (value == null) {
throw new ArgumentNullException("value");
}
this.customizer = (Properties)value;
generator = (ReportGenerator)customizer.Get("Generator");
}
@ -159,16 +160,13 @@ namespace ReportGenerator{ @@ -159,16 +160,13 @@ namespace ReportGenerator{
void Button1Click(object sender, System.EventArgs e) {
try {
ICSharpCode.SharpDevelop.Gui.FolderDialog ff = new ICSharpCode.SharpDevelop.Gui.FolderDialog();
ff.DisplayDialog("");
ff.DisplayDialog(String.Empty);
if (!String.IsNullOrEmpty(ff.Path)) {
if (!ff.Path.EndsWith(@"\")){
this.txtPath.Text = ff.Path + @"\";
System.Console.WriteLine("added slash");
} else {
this.txtPath.Text = ff.Path;
System.Console.WriteLine("no slash added");
}
generator.Path = this.txtPath.Text;
}
@ -257,7 +255,7 @@ namespace ReportGenerator{ @@ -257,7 +255,7 @@ namespace ReportGenerator{
this.txtPath.Name = "txtPath";
this.txtPath.Size = new System.Drawing.Size(224, 20);
this.txtPath.TabIndex = 13;
this.txtPath.Text = "";
this.txtPath.Text = String.Empty;
this.txtPath.TextChanged += new System.EventHandler(this.ChangedEvent);
//
// txtFileName
@ -266,7 +264,7 @@ namespace ReportGenerator{ @@ -266,7 +264,7 @@ namespace ReportGenerator{
this.txtFileName.Name = "txtFileName";
this.txtFileName.Size = new System.Drawing.Size(248, 20);
this.txtFileName.TabIndex = 11;
this.txtFileName.Text = "";
this.txtFileName.Text = String.Empty;
//
// cboGraphicsUnit
//
@ -290,7 +288,7 @@ namespace ReportGenerator{ @@ -290,7 +288,7 @@ namespace ReportGenerator{
this.txtReportName.Name = "txtReportName";
this.txtReportName.Size = new System.Drawing.Size(248, 20);
this.txtReportName.TabIndex = 0;
this.txtReportName.Text = "";
this.txtReportName.Text = String.Empty;
this.txtReportName.TextChanged += new System.EventHandler(this.ChangedEvent);
//
// groupBox1

3
src/AddIns/Misc/SharpReport/SharpReportWizard/WizardPanels/PullModelPanel.cs

@ -110,6 +110,9 @@ namespace ReportGenerator @@ -110,6 +110,9 @@ namespace ReportGenerator
public override object CustomizationObject {
get { return customizer; }
set {
if (value == null) {
throw new ArgumentNullException("value");
}
this.customizer = (Properties)value;
generator = (ReportGenerator)customizer.Get("Generator");
}

48
src/AddIns/Misc/SharpReport/SharpReportWizard/WizardPanels/PushModelPanel.cs

@ -16,7 +16,6 @@ using System.Collections; @@ -16,7 +16,6 @@ using System.Collections;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using SharpReport;
@ -39,7 +38,8 @@ namespace ReportGenerator @@ -39,7 +38,8 @@ namespace ReportGenerator
private ReportGenerator generator;
private Properties customizer;
private ReportItemCollection colDetail;
private ReportItemCollection reportItems;
private ColumnCollection columnCollection;
public PushModelPanel(){
InitializeComponent();
@ -74,47 +74,63 @@ namespace ReportGenerator @@ -74,47 +74,63 @@ namespace ReportGenerator
DataSet ds = new DataSet();
ds.Locale = CultureInfo.CurrentCulture;
ds.ReadXml (fileName);
base.EnableNext = true;
base.EnableFinish = true;
base.IsLastPanel = true;
using (AutoReport auto = new AutoReport()){
ReportModel model = generator.FillReportModel (new ReportModel());
colDetail = auto.ReportItemsFromSchema(model,ds);
columnCollection = auto.AbstractColumnsFromDataSet (ds);
reportItems = auto.ReportItemsFromSchema(model,ds);
if (colDetail != null) {
foreach (ReportDataItem item in colDetail) {
if (reportItems != null) {
foreach (ReportDataItem item in reportItems) {
this.checkedListBox.Items.Add (item.MappingName,CheckState.Checked);
}
}
}
base.EnableNext = true;
base.EnableFinish = true;
base.IsLastPanel = true;
}
#endregion
#region overrides
public override object CustomizationObject {
get {
return customizer;
}
set {
if (value == null) {
throw new ArgumentNullException("value");
}
this.customizer = (Properties)value;
generator = (ReportGenerator)customizer.Get("Generator");
}
}
public override bool ReceiveDialogMessage(DialogMessage message){
// base.EnableNext = true;
// base.EnableFinish = true;
if (message == DialogMessage.Activated) {
// base.EnableNext = true;
// base.EnableFinish = true;
// base.IsLastPanel = true;
}
else if (message == DialogMessage.Finish) {
if (message == DialogMessage.Finish) {
ReportItemCollection itemCol = new ReportItemCollection ();
if (this.colDetail != null) {
ReportItemCollection itemCollection = new ReportItemCollection ();
if (this.reportItems != null) {
foreach (int ind in this.checkedListBox.CheckedIndices) {
IItemRenderer item = this.colDetail[ind];
itemCol.Add(item);
IItemRenderer item = this.reportItems[ind];
itemCollection.Add(item);
}
}
customizer.Set ("ReportItemCollection",itemCol);
base.EnableNext = true;
base.EnableFinish = true;
base.IsLastPanel = true;
//We can't use the customizer here, because Resultpanel is called later on
// and null's the proerties
generator.ReportItemCollection = itemCollection;
generator.ColumnCollection = columnCollection;
}
return true;
}

68
src/AddIns/Misc/SharpReport/SharpReportWizard/WizardPanels/ResultPanel.cs

@ -16,7 +16,6 @@ using System.Drawing; @@ -16,7 +16,6 @@ using System.Drawing;
using System.Windows.Forms;
using System.Xml;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
@ -45,10 +44,12 @@ namespace ReportGenerator{ @@ -45,10 +44,12 @@ namespace ReportGenerator{
private ReportGenerator generator;
private Properties customizer;
private ReportModel model;
private SharpQuerySchemaClassCollection parametersClass;
private DataSet resultDataSet;
private ReportItemCollection colDetail;
private ColumnCollection abstractColumns;
public ResultPanel(){
InitializeComponent();
@ -57,16 +58,16 @@ namespace ReportGenerator{ @@ -57,16 +58,16 @@ namespace ReportGenerator{
base.EnableNext = true;
base.Refresh();
this.label1.Text = ResourceService.GetString("SharpReport.Wizard.PullModel.CommandText");
}
#region Fill data
private void FillGrid() {
private DataSet FillGrid() {
this.grdQuery.DataSource = null;
this.txtSqlString.Text = null;
ReportModel model = generator.FillReportModel(new ReportModel());
resultDataSet = new DataSet();
resultDataSet.Locale = CultureInfo.CurrentCulture;
DataSet dataSet = new DataSet();
dataSet.Locale = CultureInfo.CurrentCulture;
this.txtSqlString.Text = model.ReportSettings.CommandText;
if (model.ReportSettings.CommandType == CommandType.StoredProcedure){
@ -100,7 +101,7 @@ namespace ReportGenerator{ @@ -100,7 +101,7 @@ namespace ReportGenerator{
}else{
parametersClass = parameters.ToBaseSchemaCollection();
if (parametersClass != null) {
resultDataSet = (DataSet) proc.Execute(0,parametersClass);
dataSet = (DataSet) proc.Execute(0,parametersClass);
generator.Parameters = parametersClass;
}
}
@ -111,7 +112,7 @@ namespace ReportGenerator{ @@ -111,7 +112,7 @@ namespace ReportGenerator{
System.Console.WriteLine("\t\t No params");
try {
// Stored Proc without Parameters
resultDataSet = (DataSet) proc.Execute(0,proc.GetSchemaParameters());
dataSet = (DataSet) proc.Execute(0,proc.GetSchemaParameters());
} catch (Exception) {
throw;
}
@ -125,24 +126,26 @@ namespace ReportGenerator{ @@ -125,24 +126,26 @@ namespace ReportGenerator{
try {
generator.Parameters = null;
this.txtSqlString.Text = model.ReportSettings.CommandText;
resultDataSet = BuildFromSqlString(model.ReportSettings);
dataSet = BuildFromSqlString(model.ReportSettings);
} catch (OleDbException oleDbex) {
throw oleDbex;
}
catch (Exception e) {
throw e;
} catch (OleDbException) {
throw;
}
catch (Exception) {
throw;
}
//For now we show only the first table, but we should find a better solution?
if (resultDataSet != null) {
this.grdQuery.DataSource = resultDataSet.Tables[0];
} else {
NullReferenceException e = new NullReferenceException("ResultPanel:FillGrid");
throw e;
}
CreateCollections (dataSet);
return dataSet;
}
private void CreateCollections (DataSet dataSet) {
using (AutoReport auto = new AutoReport()){
abstractColumns = auto.AbstractColumnsFromDataSet (dataSet);
colDetail = auto.ReportItemsFromSchema(this.model,dataSet);
}
}
private static DataSet BuildFromSqlString(ReportSettings settings) {
OLEDBConnectionWrapper con = null;
@ -167,8 +170,8 @@ namespace ReportGenerator{ @@ -167,8 +170,8 @@ namespace ReportGenerator{
}
#endregion
#region Create *.Xsd File
public void GrdQueryMouseUp(object sender, System.Windows.Forms.MouseEventArgs e){
#region Create a *.Xsd File
private void GrdQueryMouseUp(object sender, System.Windows.Forms.MouseEventArgs e){
if (e.Button == MouseButtons.Right) {
ContextMenuStrip ctMen = MenuService.CreateContextMenu (this,contextMenuPath);
ctMen.Show (this.grdQuery,new Point (e.X,e.Y));
@ -196,9 +199,9 @@ namespace ReportGenerator{ @@ -196,9 +199,9 @@ namespace ReportGenerator{
xmlWriter.WriteStartDocument(true);
if (schemaOnly) {
resultDataSet.WriteXmlSchema(xmlWriter);
this.resultDataSet.WriteXmlSchema(xmlWriter);
} else {
resultDataSet.WriteXml(xmlWriter,XmlWriteMode.WriteSchema);
this.resultDataSet.WriteXml(xmlWriter,XmlWriteMode.WriteSchema);
}
xmlWriter.Close();
}
@ -212,11 +215,17 @@ namespace ReportGenerator{ @@ -212,11 +215,17 @@ namespace ReportGenerator{
#endregion
#region overrides
public override bool ReceiveDialogMessage(DialogMessage message)
{
public override bool ReceiveDialogMessage(DialogMessage message){
if (message == DialogMessage.Activated) {
try {
FillGrid();
this.resultDataSet = new DataSet();
this.resultDataSet.Locale = CultureInfo.InvariantCulture;
this.model = generator.FillReportModel(new ReportModel());
this.resultDataSet = FillGrid();
if (this.resultDataSet != null) {
this.grdQuery.DataSource = this.resultDataSet.Tables[0];
}
base.EnableNext = true;
base.EnableFinish = true;
} catch (Exception e) {
@ -224,6 +233,11 @@ namespace ReportGenerator{ @@ -224,6 +233,11 @@ namespace ReportGenerator{
base.EnableNext = false;
base.EnableFinish = false;
}
} else if (message == DialogMessage.Finish) {
customizer.Set ("ColumnCollection",abstractColumns);
customizer.Set ("ReportItemCollection",colDetail);
base.EnableNext = true;
base.EnableFinish = true;
}
return true;
}

Loading…
Cancel
Save