diff --git a/src/AddIns/Misc/SharpReport/SharpReport.sln b/src/AddIns/Misc/SharpReport/SharpReport.sln index 5918c97f8d..a86d9b4589 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport.sln +++ b/src/AddIns/Misc/SharpReport/SharpReport.sln @@ -1,5 +1,5 @@ Microsoft Visual Studio Solution File, Format Version 9.00 -# SharpDevelop 2.0.0.1004 +# SharpDevelop 2.0.0.1009 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpReportCore", "SharpReportCore\SharpReportCore.csproj", "{4B2239FF-8FD6-431D-9D22-1B8049BA6917}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpReport", "SharpReport\SharpReport.csproj", "{F5563727-8309-4AC3-BACA-EB28EFD8A1D0}" diff --git a/src/AddIns/Misc/SharpReport/SharpReport/SharpReportManager.cs b/src/AddIns/Misc/SharpReport/SharpReport/SharpReportManager.cs index 2008a6cee9..edd22e6f62 100644 --- a/src/AddIns/Misc/SharpReport/SharpReport/SharpReportManager.cs +++ b/src/AddIns/Misc/SharpReport/SharpReport/SharpReportManager.cs @@ -116,6 +116,7 @@ namespace SharpReport{ if (base.ConnectionObject == null) { base.ConnectionObject = this.BuildConnectionObject(model.ReportSettings); } + System.Console.WriteLine("BuildRenderer ok"); return base.AbstractRenderer(model); } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/DataManager.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/DataManager.cs index 3389c768a9..55dbd81438 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/DataManager.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/DataManager.cs @@ -130,12 +130,21 @@ namespace SharpReportCore { if (settings == null) { throw new ArgumentNullException("DataManager:ReportSettings"); } + + try { + SqlQueryCkecker check = new SqlQueryCkecker(); + check.Check(settings.CommandText); + } catch (Exception e) { + MessageBox.Show (e.Message); + throw e; + } + this.reportSettings = settings; } void CheckAndSetSource(object source) { - + System.Console.WriteLine("CheckAndSetSource"); if (source == null) { throw new MissingDataSourceException(); @@ -146,7 +155,7 @@ namespace SharpReportCore { if (source is DataTable) { DataTable tbl = source as DataTable; this.dataMember = tbl.TableName; - + System.Console.WriteLine("\t Source = table with {0}",tbl.Rows.Count); return; } @@ -188,6 +197,7 @@ namespace SharpReportCore { } void CheckConnection (ConnectionObject connectionObject) { + System.Console.WriteLine("CheckOnnection"); try { connection = connectionObject.Connection; @@ -202,6 +212,7 @@ namespace SharpReportCore { } private DataSet FillDataSet() { + System.Console.WriteLine("FillDataSet"); try { if (this.connection.State == ConnectionState.Closed) { this.connection.Open(); @@ -218,7 +229,7 @@ namespace SharpReportCore { DataSet ds = new DataSet(); adapter.Fill (ds); - + System.Console.WriteLine("\t {0} in Table",ds.Tables[0].Rows.Count); return ds; } catch (Exception) { throw; @@ -391,15 +402,13 @@ namespace SharpReportCore { this.dataViewStrategy.CurrentRow ++; } - /* - public void Reset() { - this.dataViewStrategy.Reset(); - } - */ public void FetchData(ReportItemCollection collection) { - foreach (IItemRenderer item in collection) { - this.dataViewStrategy.Fill(item); + try { + foreach (IItemRenderer item in collection) { + this.dataViewStrategy.Fill(item); + } + } catch (Exception) { } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/TableStrategy.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/TableStrategy.cs index 40a95532a1..c0bc67272f 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/TableStrategy.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/TableStrategy.cs @@ -75,7 +75,7 @@ namespace SharpReportCore { for (int criteriaIndex = 0; criteriaIndex < col.Count; criteriaIndex++){ AbstractColumn c = (AbstractColumn)col[criteriaIndex]; object value = rowItem[c.ColumnName]; -// System.Console.WriteLine("\t\t{0}",value.ToString()); + if (value != null && value != DBNull.Value){ if (!(value is IComparable)){ throw new InvalidOperationException("ReportDataSource:BuildSortArray - > This type doesn't support IComparable." + value.ToString()); @@ -275,7 +275,7 @@ namespace SharpReportCore { base.Sort(); ArrayList sortedArray = new ArrayList(); try { - if (base.ReportSettings.SortColumnCollection != null) { + if ((base.ReportSettings.SortColumnCollection != null)) { if (base.ReportSettings.SortColumnCollection.Count > 0) { SortColumn sc = (SortColumn)base.ReportSettings.SortColumnCollection[0]; @@ -306,9 +306,8 @@ namespace SharpReportCore { BaseDataItem baseDataItem = item as BaseDataItem; if (baseDataItem != null) { baseDataItem.DbValue = row[baseDataItem.ColumnName].ToString(); - } + } } catch (Exception ) { - throw; } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/SqlQueryChecker.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/SqlQueryChecker.cs new file mode 100644 index 0000000000..cb0343d498 --- /dev/null +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/SqlQueryChecker.cs @@ -0,0 +1,49 @@ +/* + * Created by SharpDevelop. + * User: Forstmeier Helmut + * Date: 20.01.2006 + * Time: 13:44 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ + +using System; +using System.Globalization; +using System.Windows.Forms; + +namespace SharpReportCore +{ + /// + /// This Class checks for invalid SqlStatements + /// + internal class SqlQueryCkecker{ + internal string UPDATE = "UPDATE"; + internal string DELETE = "DELETE"; + internal string noValidMessage = "is no valid Member of SqlString"; + private string queryString; + + + public SqlQueryCkecker(){ + } + + public void Check (string queryString) { + this.queryString = queryString.ToUpper(CultureInfo.CurrentCulture); + + if (this.queryString.IndexOf (this.UPDATE) > -1) { + string str = String.Format("{0} is no valid Member of SqlString",this.UPDATE); + this.Invalid (this.UPDATE); + } + + if (this.queryString.IndexOf(this.DELETE) > -1) { + this.Invalid (this.DELETE); + string str = String.Format("{0} is no valid Member of SqlString",this.DELETE); + + } + } + + private void Invalid (string invalidArgument) { + string str = String.Format("{0} {1}",invalidArgument,this.noValidMessage); + throw new SharpReportCore.SharpReportException(str); + } + } +} diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs index 1a2e542229..a36d846b8c 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs @@ -64,7 +64,6 @@ namespace SharpReportCore { base.ReportBegin (sender,e); //allways reset the dataManager before printing if (this.dataManager != null) { - System.Console.WriteLine("\tReset DataManager"); this.dataManager.Reset(); } } diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj b/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj index 14c3445a68..809b75de9d 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj @@ -129,6 +129,7 @@ + diff --git a/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportEngine.cs b/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportEngine.cs index b95d28bd0f..9983ab0c6c 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportEngine.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportEngine.cs @@ -81,7 +81,7 @@ namespace SharpReportCore { } - void GrapSqlParameters (ReportSettings settings) { + void GrapSqlParameters (ReportSettings settings) { if (settings.SqlParametersCollection != null && settings.SqlParametersCollection.Count > 0) { if (this.ParametersRequest != null) { SharpReportParametersEventArgs e = new SharpReportParametersEventArgs(); @@ -90,6 +90,7 @@ namespace SharpReportCore { ParametersRequest (this,e); } } + } @@ -133,7 +134,10 @@ namespace SharpReportCore { } private DataManager SetupDataContainer (ReportSettings settings) { + System.Console.WriteLine("SetupContainer"); + + System.Console.WriteLine("after check"); if (settings.ReportType == GlobalEnums.enmReportType.DataReport) { if (settings.CommandText != null) { try { @@ -503,10 +507,17 @@ namespace SharpReportCore { if (fileName.Length == 0) { throw new ArgumentException("ModelfromFile:FileName"); } - ReportModel model = new ReportModel(); - SharpReportCore.LoadModelVisitor modelVisitor = new SharpReportCore.LoadModelVisitor(model,fileName); - model.Accept (modelVisitor); - return model; + + try { + ReportModel model = new ReportModel(); + SharpReportCore.LoadModelVisitor modelVisitor = new SharpReportCore.LoadModelVisitor(model,fileName); + model.Accept (modelVisitor); + return model; + } catch (Exception) { + + } + return null; + } diff --git a/src/AddIns/Misc/SharpReport/SharpReportWizard/WizardPanels/ResultPanel.cs b/src/AddIns/Misc/SharpReport/SharpReportWizard/WizardPanels/ResultPanel.cs index c2e4260e67..1a7f9c1eda 100644 --- a/src/AddIns/Misc/SharpReport/SharpReportWizard/WizardPanels/ResultPanel.cs +++ b/src/AddIns/Misc/SharpReport/SharpReportWizard/WizardPanels/ResultPanel.cs @@ -59,7 +59,7 @@ namespace ReportGenerator{ #region Fill data private void FillGrid() { - + System.Console.WriteLine("FillGrid"); this.grdQuery.DataSource = null; this.txtSqlString.Text = null; ReportModel model = generator.FillReportModel(new ReportModel()); @@ -68,10 +68,11 @@ namespace ReportGenerator{ this.txtSqlString.Text = model.ReportSettings.CommandText; if (model.ReportSettings.CommandType == CommandType.StoredProcedure){ - + if (generator.SharpQueryProcedure == null) { throw new NullReferenceException("ResultPanel:FillGrid"); } + System.Console.WriteLine("\tStoredProcedure {0}",generator.SharpQueryProcedure.Name); SharpQueryProcedure proc = generator.SharpQueryProcedure; // we have some Parameters, to get them we use the Dialogfrom SharpQuery @@ -88,7 +89,9 @@ namespace ReportGenerator{ } } // SharpQueryParameterCollection parameters = new SharpQueryParameterCollection(tmp); + System.Console.WriteLine("\t\t # of params {0}",parameters.Count); if (parameters != null && parameters.Count > 0){ + using (SQLParameterInput inputform = new SQLParameterInput(parameters)){ if ( inputform.ShowDialog() != DialogResult.OK ){ parametersClass = null; @@ -103,6 +106,7 @@ namespace ReportGenerator{ } } else { + System.Console.WriteLine("\t\t No params"); try { // Stored Proc without Parameters resultDataSet = (DataSet) proc.Execute(0,proc.GetSchemaParameters()); @@ -115,6 +119,7 @@ namespace ReportGenerator{ // from here we create from an SqlString like "Select...." if (model.ReportSettings.CommandType == CommandType.Text){ + System.Console.WriteLine("\tCommandText"); try { generator.Parameters = null; this.txtSqlString.Text = model.ReportSettings.CommandText;