Browse Source

Fixed endless loop for nonsorted Reports, implement a basic checking of CommandText, (check for 'Update' and 'Delete')

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1012 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Peter Forstmeier 20 years ago
parent
commit
62fb0abb39
  1. 2
      src/AddIns/Misc/SharpReport/SharpReport.sln
  2. 1
      src/AddIns/Misc/SharpReport/SharpReport/SharpReportManager.cs
  3. 25
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/DataManager.cs
  4. 5
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/ListStrategy/TableStrategy.cs
  5. 49
      src/AddIns/Misc/SharpReport/SharpReportCore/DataManager/SqlQueryChecker.cs
  6. 1
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/RenderDataReport.cs
  7. 1
      src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportCore.csproj
  8. 11
      src/AddIns/Misc/SharpReport/SharpReportCore/SharpReportEngine.cs
  9. 7
      src/AddIns/Misc/SharpReport/SharpReportWizard/WizardPanels/ResultPanel.cs

2
src/AddIns/Misc/SharpReport/SharpReport.sln

@ -1,5 +1,5 @@ @@ -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}"

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

@ -116,6 +116,7 @@ namespace SharpReport{ @@ -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);
}

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

@ -130,12 +130,21 @@ namespace SharpReportCore { @@ -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 { @@ -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 { @@ -188,6 +197,7 @@ namespace SharpReportCore {
}
void CheckConnection (ConnectionObject connectionObject) {
System.Console.WriteLine("CheckOnnection");
try {
connection = connectionObject.Connection;
@ -202,6 +212,7 @@ namespace SharpReportCore { @@ -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 { @@ -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,16 +402,14 @@ namespace SharpReportCore { @@ -391,16 +402,14 @@ namespace SharpReportCore {
this.dataViewStrategy.CurrentRow ++;
}
/*
public void Reset() {
this.dataViewStrategy.Reset();
}
*/
public void FetchData(ReportItemCollection collection) {
try {
foreach (IItemRenderer item in collection) {
this.dataViewStrategy.Fill(item);
}
} catch (Exception) {
}
}
public string Filter {

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

@ -75,7 +75,7 @@ namespace SharpReportCore { @@ -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 { @@ -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];
@ -308,7 +308,6 @@ namespace SharpReportCore { @@ -308,7 +308,6 @@ namespace SharpReportCore {
baseDataItem.DbValue = row[baseDataItem.ColumnName].ToString();
}
} catch (Exception ) {
throw;
}
}

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

@ -0,0 +1,49 @@ @@ -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
{
/// <summary>
/// This Class checks for invalid SqlStatements
/// </summary>
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);
}
}
}

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

@ -64,7 +64,6 @@ namespace SharpReportCore { @@ -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();
}
}

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

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

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

@ -90,6 +90,7 @@ namespace SharpReportCore { @@ -90,6 +90,7 @@ namespace SharpReportCore {
ParametersRequest (this,e);
}
}
}
@ -133,7 +134,10 @@ namespace SharpReportCore { @@ -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 { @@ -503,10 +507,17 @@ namespace SharpReportCore {
if (fileName.Length == 0) {
throw new ArgumentException("ModelfromFile:FileName");
}
try {
ReportModel model = new ReportModel();
SharpReportCore.LoadModelVisitor modelVisitor = new SharpReportCore.LoadModelVisitor(model,fileName);
model.Accept (modelVisitor);
return model;
} catch (Exception) {
}
return null;
}

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

@ -59,7 +59,7 @@ namespace ReportGenerator{ @@ -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());
@ -72,6 +72,7 @@ namespace ReportGenerator{ @@ -72,6 +72,7 @@ namespace ReportGenerator{
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{ @@ -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{ @@ -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{ @@ -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;

Loading…
Cancel
Save