Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/reportsDataAddIn@6233 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61pull/1/head
30 changed files with 15 additions and 5891 deletions
@ -1,67 +0,0 @@ |
|||||||
/* |
|
||||||
* Erstellt mit SharpDevelop. |
|
||||||
* Benutzer: Peter Forstmeier |
|
||||||
* Datum: 29.08.2008 |
|
||||||
* Zeit: 19:44 |
|
||||||
* |
|
||||||
* Sie können diese Vorlage unter Extras > Optionen > Codeerstellung > Standardheader ändern. |
|
||||||
*/ |
|
||||||
using System; |
|
||||||
using System.ComponentModel; |
|
||||||
using ICSharpCode.Reports.Core; |
|
||||||
using SharpQuery.Collections; |
|
||||||
using SharpQuery.SchemaClass; |
|
||||||
|
|
||||||
namespace ICSharpCode.Reports.Addin.ReportWizard |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Description of SqlParameterConverter.
|
|
||||||
/// </summary>
|
|
||||||
public class SqlParameterConverter:TypeConverter |
|
||||||
{ |
|
||||||
public SqlParameterConverter() |
|
||||||
{ |
|
||||||
} |
|
||||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) |
|
||||||
{ |
|
||||||
if (sourceType == typeof(SharpQuerySchemaClassCollection)) { |
|
||||||
return true; |
|
||||||
} |
|
||||||
return base.CanConvertFrom(context, sourceType); |
|
||||||
} |
|
||||||
|
|
||||||
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) |
|
||||||
{ |
|
||||||
return base.ConvertFrom(context, culture, value); |
|
||||||
} |
|
||||||
|
|
||||||
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) |
|
||||||
{ |
|
||||||
if (destinationType == typeof(ParameterCollection)) { |
|
||||||
return true; |
|
||||||
} |
|
||||||
return base.CanConvertFrom(context, destinationType); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) |
|
||||||
{ |
|
||||||
SharpQuerySchemaClassCollection tmp= value as SharpQuerySchemaClassCollection; |
|
||||||
|
|
||||||
if (destinationType == typeof (ParameterCollection)) { |
|
||||||
ParameterCollection a = new ParameterCollection(); |
|
||||||
foreach (SharpQueryParameter par in tmp){ |
|
||||||
SqlParameter reportPar = new SqlParameter (par.Name, |
|
||||||
par.DataType, |
|
||||||
String.Empty, |
|
||||||
par.Type); |
|
||||||
reportPar.ParameterValue = par.Value.ToString(); |
|
||||||
a.Add(reportPar); |
|
||||||
} |
|
||||||
return a; |
|
||||||
} |
|
||||||
return base.ConvertTo(context, culture, value, destinationType); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,57 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Luc Morin" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using ICSharpCode.Core; |
|
||||||
using SharpQuery.Gui.TreeView; |
|
||||||
|
|
||||||
namespace SharpQuery.Commands |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Base class of all commands of SharpQuery Addin
|
|
||||||
/// </summary>
|
|
||||||
public abstract class AbstractSharpQueryCommand : AbstractMenuCommand |
|
||||||
{ |
|
||||||
protected ISharpQueryNode sharpQueryNode = null; |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// get the selected <see cref="SharpQuery.Gui.TreeView.ISharpQueryNode"> SharpQuery node </see>
|
|
||||||
/// and Enabled or disabled the command
|
|
||||||
/// <remarks> If the selected node is <code>null</code> or this is not a <see cref="SharpQuery.Gui.TreeView.ISharpQueryNode"> SharpQuery node </see>, return <code>false</code> (disable the menu)</remarks>
|
|
||||||
/// </summary>
|
|
||||||
public override bool IsEnabled |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
SharpQueryTree sharpQueryTree; |
|
||||||
sharpQueryTree = this.Owner as SharpQueryTree; |
|
||||||
|
|
||||||
if ((sharpQueryTree != null) && (sharpQueryTree.SelectedNode != null)) |
|
||||||
{ |
|
||||||
this.sharpQueryNode = sharpQueryTree.SelectedNode as ISharpQueryNode; |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
this.sharpQueryNode = null; |
|
||||||
} |
|
||||||
|
|
||||||
return (this.sharpQueryNode != null); |
|
||||||
} |
|
||||||
set { } |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Create a new SharpQueryCommand
|
|
||||||
/// </summary>
|
|
||||||
public AbstractSharpQueryCommand() |
|
||||||
: base() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,284 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Luc Morin" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Windows.Forms; |
|
||||||
using SharpQuery.Collections; |
|
||||||
using SharpQuery.Connection; |
|
||||||
|
|
||||||
namespace SharpQuery.SchemaClass |
|
||||||
{ |
|
||||||
public abstract class AbstractSharpQuerySchemaClass : ISchemaClass |
|
||||||
{ |
|
||||||
protected string pCatalogName = null; |
|
||||||
protected string pSchemaName = null; |
|
||||||
protected string pOwnerName = null; |
|
||||||
protected string pName = null; |
|
||||||
|
|
||||||
protected IConnection pDataConnection = null; |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// check if there are white spaces into the string.
|
|
||||||
/// if yes, then add "[" at the begin and "]" at the end.
|
|
||||||
///</summary>
|
|
||||||
internal static string CheckWhiteSpace(string str) |
|
||||||
{ |
|
||||||
string returnStr = str; |
|
||||||
|
|
||||||
if (returnStr.IndexOf(" ") > -1) |
|
||||||
{ |
|
||||||
if (returnStr.StartsWith("[") == false) |
|
||||||
{ |
|
||||||
returnStr = "[" + returnStr; |
|
||||||
} |
|
||||||
if (returnStr.EndsWith("]") == false) |
|
||||||
{ |
|
||||||
returnStr = returnStr + "]"; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
return returnStr; |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>remove "[" at the begin and at the end of the str</summary>
|
|
||||||
internal static string RemoveBracket(string str) |
|
||||||
{ |
|
||||||
string returnStr = str; |
|
||||||
if (returnStr.StartsWith("[") == true) |
|
||||||
{ |
|
||||||
returnStr = returnStr.Remove(0, 1); |
|
||||||
} |
|
||||||
if (returnStr.EndsWith("]") == true) |
|
||||||
{ |
|
||||||
returnStr = returnStr.Remove(returnStr.Length - 1, 1); |
|
||||||
} |
|
||||||
return returnStr; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// those, are list of the childs schema.
|
|
||||||
/// i am using a dictionnary (<see cref="SharpQuery.Collections.SharpQueryListDictionary"></see>) because is more simplest to write
|
|
||||||
/// <code>Entities["PROCEDURES"]</code> than <code>Entities[0]</code>.
|
|
||||||
///</summary>
|
|
||||||
protected SharpQueryListDictionary pEntities = null; |
|
||||||
|
|
||||||
public string CatalogName |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return CheckWhiteSpace(this.pCatalogName); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public string SchemaName |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return CheckWhiteSpace(this.pSchemaName); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public string OwnerName |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return CheckWhiteSpace(this.pOwnerName); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public string Name |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return CheckWhiteSpace(this.pName); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public string InternalName |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return RemoveBracket(this.Name); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public virtual string NormalizedName |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return CheckWhiteSpace(Name); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// those, are list of the childs schema.
|
|
||||||
/// i am using a dictionnary (<see cref="SharpQuery.Collections.SharpQueryListDictionary"></see>) because is more simplest to write
|
|
||||||
/// <code>Entities["PROCEDURES"]</code> than <code>Entities[0]</code>.
|
|
||||||
///</summary>
|
|
||||||
public SharpQueryListDictionary Entities |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return pEntities; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public IConnection Connection |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return this.pDataConnection; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
///<summary> return a <see cref="System.Windows.Forms.DataObject">DataObject</see>
|
|
||||||
///</summary>
|
|
||||||
public virtual DataObject DragObject |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
//create the entities list
|
|
||||||
protected virtual void CreateEntitiesList() |
|
||||||
{ |
|
||||||
if (this.pEntities == null) |
|
||||||
{ |
|
||||||
this.pEntities = new SharpQueryListDictionary(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// construtor
|
|
||||||
/// <list type="bullet">
|
|
||||||
/// <listheader>
|
|
||||||
/// <term>parameters</term>
|
|
||||||
/// <description></description>
|
|
||||||
/// </listheader>
|
|
||||||
/// <item>
|
|
||||||
/// <term><code>connection</code></term>
|
|
||||||
/// <description>connection object from wich this schema is extracted</description>
|
|
||||||
/// </item>
|
|
||||||
/// <item>
|
|
||||||
/// <term><code>catalogName</code></term>
|
|
||||||
/// <description> this is the catalog of this schema entity </description>
|
|
||||||
/// </item>
|
|
||||||
/// <item>
|
|
||||||
/// <term><code>schemaName</code></term>
|
|
||||||
/// <description> this is the schema of this schema entity </description>
|
|
||||||
/// </item>
|
|
||||||
/// <item>
|
|
||||||
/// <term><code>ownerName</code></term>
|
|
||||||
/// <description> this is the owner name of this schema entity </description>
|
|
||||||
/// </item>
|
|
||||||
/// <item>
|
|
||||||
/// <term><code>name</code></term>
|
|
||||||
/// <description> this is the name of this schema entity </description>
|
|
||||||
/// </item>
|
|
||||||
/// </list>
|
|
||||||
///</summary>
|
|
||||||
public AbstractSharpQuerySchemaClass(IConnection connection, string catalogName, string schemaName, string ownerName, string name) |
|
||||||
: base() |
|
||||||
{ |
|
||||||
this.pCatalogName = catalogName; |
|
||||||
this.pSchemaName = schemaName; |
|
||||||
this.pOwnerName = ownerName; |
|
||||||
this.pName = name; |
|
||||||
this.pDataConnection = connection; |
|
||||||
|
|
||||||
this.CreateEntitiesList(); |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// called by <see cref=".Refresh()">Refresh</see> just after the <see cref=".Clear()">Clear</see> and before <see cref=".Refresh()">childs'refresh</see>.
|
|
||||||
/// In this, you could change the <see cref=".Entities">Entities dicntionnary.</see>
|
|
||||||
///</summary>
|
|
||||||
protected abstract void OnRefresh(); |
|
||||||
|
|
||||||
public void Refresh() |
|
||||||
{ |
|
||||||
this.Clear(); |
|
||||||
this.CreateEntitiesList(); |
|
||||||
|
|
||||||
if (this.Connection.IsOpen == true) |
|
||||||
{ |
|
||||||
this.OnRefresh(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void Clear() |
|
||||||
{ |
|
||||||
if (this.pEntities != null) |
|
||||||
{ |
|
||||||
this.pEntities.Clear(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// For a Table or a View extract data.
|
|
||||||
/// For a stocked procedure, execute it :o).
|
|
||||||
/// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
|
|
||||||
/// <returns><see cref="System.Data.DataTable">DataTable</see>
|
|
||||||
/// or a <see cref="System.Data.DataSet">DataSet</see> </returns>
|
|
||||||
/// </summary>
|
|
||||||
public abstract object Execute(int rows, SharpQuerySchemaClassCollection parameters); |
|
||||||
|
|
||||||
///<summary> if <see cref=".Dataconnection.CatalogName">CatalogName</see> is <code>null</code> or <code>empty</code>
|
|
||||||
/// enumerate all catalogs from the database.
|
|
||||||
/// Else enumerate the current catalog's properties.
|
|
||||||
/// </summary>
|
|
||||||
public virtual SharpQuerySchemaClassCollection GetSchemaCatalogs() |
|
||||||
{ |
|
||||||
return this.pDataConnection.GetSchemaCatalogs(this); |
|
||||||
} |
|
||||||
|
|
||||||
///<summary> if <see cref=".Dataconnection.CatalogName">CatalogName</see> is <code>null</code> or <code>empty</code>
|
|
||||||
/// enumerate all shcema from the database.
|
|
||||||
/// Else enumerate schemas from the current catalog.
|
|
||||||
/// </summary>
|
|
||||||
public virtual SharpQuerySchemaClassCollection GetSchemaSchemas() |
|
||||||
{ |
|
||||||
return this.pDataConnection.GetSchemaSchemas(this); |
|
||||||
} |
|
||||||
|
|
||||||
///<summary> Enumerate the <see cref=".CatalogName">CatalogName<see cref=".SchemaName">.SchemaName</see></see>'s tables
|
|
||||||
/// </summary>
|
|
||||||
public virtual SharpQuerySchemaClassCollection GetSchemaTables() |
|
||||||
{ |
|
||||||
return this.pDataConnection.GetSchemaTables(this); |
|
||||||
} |
|
||||||
|
|
||||||
///<summary> Enumerate the <see cref=".CatalogName">CatalogName<see cref=".SchemaName">.SchemaName</see></see>'s views
|
|
||||||
/// </summary>
|
|
||||||
public virtual SharpQuerySchemaClassCollection GetSchemaViews() |
|
||||||
{ |
|
||||||
return this.pDataConnection.GetSchemaViews(this); |
|
||||||
} |
|
||||||
|
|
||||||
///<summary> Enumerate the <see cref=".CatalogName">CatalogName<see cref=".SchemaName">.SchemaName</see></see>'s procedures
|
|
||||||
/// </summary>
|
|
||||||
public virtual SharpQuerySchemaClassCollection GetSchemaProcedures() |
|
||||||
{ |
|
||||||
return this.pDataConnection.GetSchemaProcedures(this); |
|
||||||
} |
|
||||||
|
|
||||||
public virtual SharpQuerySchemaClassCollection GetSchemaColumns() |
|
||||||
{ |
|
||||||
SharpQuerySchemaClassCollection list = new SharpQuerySchemaClassCollection(); |
|
||||||
return list; |
|
||||||
} |
|
||||||
|
|
||||||
public virtual SharpQuerySchemaClassCollection GetSchemaParameters() |
|
||||||
{ |
|
||||||
SharpQuerySchemaClassCollection list = new SharpQuerySchemaClassCollection(); |
|
||||||
return list; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,67 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Luc Morin" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using SharpQuery.SchemaClass; |
|
||||||
|
|
||||||
namespace SharpQuery.Collections |
|
||||||
{ |
|
||||||
[Serializable()] |
|
||||||
public class SharpQuerySchemaClassCollection : List<ISchemaClass> |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
[Serializable()] |
|
||||||
public class SharpQueryListDictionary : Dictionary<string, SharpQuerySchemaClassCollection> |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
[Serializable()] |
|
||||||
public class SharpQueryParameterCollection : List<SharpQueryParameter>{ |
|
||||||
|
|
||||||
public SharpQueryParameterCollection () { |
|
||||||
} |
|
||||||
/// <summary>
|
|
||||||
/// <para>
|
|
||||||
/// Initializes a new instance of <see cref='.SharpQueryParameterCollection'/> based on another <see cref='.SharpQueryParameterCollection'/>.
|
|
||||||
/// </para>
|
|
||||||
/// </summary>
|
|
||||||
/// <param name='value'>
|
|
||||||
/// A <see cref='.SharpQueryParameterCollection'/> from which the contents are copied
|
|
||||||
/// </param>
|
|
||||||
public SharpQueryParameterCollection(SharpQueryParameterCollection value) { |
|
||||||
this.AddRange(value); |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// <para>
|
|
||||||
/// Initializes a new instance of <see cref='.SharpQueryParameterCollection'/> containing any array of <see cref='.SharpQueryParameter'/> objects.
|
|
||||||
/// </para>
|
|
||||||
/// </summary>
|
|
||||||
/// <param name='value'>
|
|
||||||
/// A array of <see cref='.SharpQueryParameter'/> objects with which to intialize the collection
|
|
||||||
/// </param>
|
|
||||||
public SharpQueryParameterCollection(SharpQueryParameter[] value) { |
|
||||||
this.AddRange(value); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
public SharpQuerySchemaClassCollection ToBaseSchemaCollection(){ |
|
||||||
SharpQuerySchemaClassCollection returnValues = new SharpQuerySchemaClassCollection(); |
|
||||||
foreach( SharpQueryParameter par in this ){ |
|
||||||
returnValues.Add( par ); |
|
||||||
} |
|
||||||
return returnValues; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
[Serializable()] |
|
||||||
public class SharpQueryStringDictionary : Dictionary<string, string> |
|
||||||
{ |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,554 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Luc Morin" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Data; |
|
||||||
using System.Data.OleDb; |
|
||||||
|
|
||||||
using SharpQuery.Collections; |
|
||||||
using SharpQuery.Exceptions; |
|
||||||
using SharpQuery.SchemaClass; |
|
||||||
|
|
||||||
namespace SharpQuery.Connection |
|
||||||
{ |
|
||||||
|
|
||||||
//
|
|
||||||
// ADO .NET Wrapper (better than OleDB)
|
|
||||||
//
|
|
||||||
///<summary>
|
|
||||||
/// This class is associated with a class <see cref="ICSharpCode.SharpDevelop.Gui.SharpQuery.TreeView.SharpQueryNodeConnection"/>
|
|
||||||
///</summary>
|
|
||||||
public class ADOConnectionWrapper : AbstractSharpQueryConnectionWrapper |
|
||||||
{ |
|
||||||
protected ADODB.ConnectionClass pADOConnection; |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// OLEDB connection String.
|
|
||||||
/// i use this for speed up the code writing ...
|
|
||||||
///</summary>
|
|
||||||
public override string ConnectionString |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return base.ConnectionString; |
|
||||||
} |
|
||||||
|
|
||||||
set |
|
||||||
{ |
|
||||||
if (IsOpen == true) |
|
||||||
{ |
|
||||||
this.Close(); |
|
||||||
} |
|
||||||
try |
|
||||||
{ |
|
||||||
this.pADOConnection.ConnectionString = value; |
|
||||||
wrongConnectionString = false; |
|
||||||
} |
|
||||||
catch (System.Exception) |
|
||||||
{ |
|
||||||
string mes = this.ConnectionString + "\n\r"; |
|
||||||
wrongConnectionString = true; |
|
||||||
|
|
||||||
foreach (ADODB.Error err in this.pADOConnection.Errors) |
|
||||||
{ |
|
||||||
mes += "-----------------\n\r"; |
|
||||||
mes += err.Description + "\n\r"; |
|
||||||
mes += err.NativeError + "\n\r"; |
|
||||||
} |
|
||||||
throw new ConnectionStringException(mes); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override bool IsOpen |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return (pADOConnection.State == (int)ADODB.ObjectStateEnum.adStateOpen); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override object GetProperty(AbstractSharpQueryConnectionWrapper.SharpQueryPropertyEnum property) |
|
||||||
{ |
|
||||||
object returnValue = null; |
|
||||||
string Key = null; |
|
||||||
|
|
||||||
switch (property) |
|
||||||
{ |
|
||||||
case SharpQueryPropertyEnum.Catalog: |
|
||||||
Key = "Current Catalog"; |
|
||||||
break; |
|
||||||
case SharpQueryPropertyEnum.ConnectionString: |
|
||||||
returnValue = this.pADOConnection.ConnectionString.ToString(); |
|
||||||
break; |
|
||||||
case SharpQueryPropertyEnum.DataSource: |
|
||||||
Key = "Data Source"; |
|
||||||
break; |
|
||||||
case SharpQueryPropertyEnum.DataSourceName: |
|
||||||
Key = "Data Source Name"; |
|
||||||
break; |
|
||||||
case SharpQueryPropertyEnum.DBMSName: |
|
||||||
Key = "DBMS Name"; |
|
||||||
break; |
|
||||||
case SharpQueryPropertyEnum.ProviderName: |
|
||||||
returnValue = this.pADOConnection.Provider.ToString(); |
|
||||||
break; |
|
||||||
default: |
|
||||||
Key = null; |
|
||||||
break; |
|
||||||
} |
|
||||||
|
|
||||||
try |
|
||||||
{ |
|
||||||
if (Key != null) |
|
||||||
{ |
|
||||||
if (this.pADOConnection.Properties[Key].Value != null) |
|
||||||
{ |
|
||||||
returnValue = this.pADOConnection.Properties[Key].Value; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
catch (System.Exception) |
|
||||||
{ |
|
||||||
returnValue = null; |
|
||||||
} |
|
||||||
|
|
||||||
return returnValue; |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a new DataConnection object
|
|
||||||
/// </summary>
|
|
||||||
public ADOConnectionWrapper() |
|
||||||
: base() |
|
||||||
{ |
|
||||||
this.pADOConnection = new ADODB.ConnectionClass(); |
|
||||||
} |
|
||||||
|
|
||||||
public ADOConnectionWrapper(string connectionString) |
|
||||||
: this() |
|
||||||
{ |
|
||||||
this.ConnectionString = connectionString; |
|
||||||
} |
|
||||||
|
|
||||||
protected override void OnRefresh() |
|
||||||
{ |
|
||||||
this.pADOConnection.Properties.Refresh(); |
|
||||||
|
|
||||||
base.OnRefresh(); |
|
||||||
} |
|
||||||
|
|
||||||
public override bool Open() |
|
||||||
{ |
|
||||||
try |
|
||||||
{ |
|
||||||
if (this.IsOpen == false && wrongConnectionString == false) |
|
||||||
{ |
|
||||||
this.pADOConnection.GetType().InvokeMember( |
|
||||||
"Open", |
|
||||||
System.Reflection.BindingFlags.InvokeMethod, |
|
||||||
null, |
|
||||||
this.pADOConnection, |
|
||||||
null); |
|
||||||
} |
|
||||||
} |
|
||||||
catch (System.Exception) |
|
||||||
{ |
|
||||||
string mes = this.ConnectionString + "\n\r"; |
|
||||||
wrongConnectionString = true; |
|
||||||
|
|
||||||
foreach (ADODB.Error err in this.pADOConnection.Errors) |
|
||||||
{ |
|
||||||
mes += "-----------------\n\r"; |
|
||||||
mes += err.Description + "\n\r"; |
|
||||||
mes += err.NativeError + "\n\r"; |
|
||||||
} |
|
||||||
throw new OpenConnectionException(mes); |
|
||||||
} |
|
||||||
|
|
||||||
return this.IsOpen; |
|
||||||
} |
|
||||||
|
|
||||||
public override void Close() |
|
||||||
{ |
|
||||||
if (this.IsOpen == true) |
|
||||||
{ |
|
||||||
this.pADOConnection.Close(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Execute a SQL command
|
|
||||||
/// <param name="SQLText">
|
|
||||||
/// SQL command to execute
|
|
||||||
/// </param>
|
|
||||||
/// <param name="rows">
|
|
||||||
/// Maximum number of row to extract. If is "0" then all rows are extracted.
|
|
||||||
/// </param>
|
|
||||||
/// <returns> return a <see cref="System.Data.DataTable">DataTable</see>
|
|
||||||
///or a <see cref="System.Data.DataSet">DataSet</see> object.
|
|
||||||
/// </returns>
|
|
||||||
/// </summary>
|
|
||||||
public override object ExecuteSQL(string SQLText, int rows) |
|
||||||
{ |
|
||||||
ADODB.Recordset record = new ADODB.Recordset(); |
|
||||||
DataTable table = null; |
|
||||||
|
|
||||||
this.pADOConnection.BeginTrans(); |
|
||||||
|
|
||||||
try |
|
||||||
{ |
|
||||||
record.MaxRecords = rows; |
|
||||||
record.Open((object)SQLText, |
|
||||||
(object)this.pADOConnection, |
|
||||||
ADODB.CursorTypeEnum.adOpenDynamic, |
|
||||||
ADODB.LockTypeEnum.adLockPessimistic, |
|
||||||
(int)ADODB.CommandTypeEnum.adCmdText |
|
||||||
); |
|
||||||
|
|
||||||
table = RecordSetToDataTable(record); |
|
||||||
} |
|
||||||
catch (System.Exception) |
|
||||||
{ |
|
||||||
this.pADOConnection.RollbackTrans(); |
|
||||||
|
|
||||||
string mes = SQLText + "\n\r"; |
|
||||||
|
|
||||||
foreach (ADODB.Error err in this.pADOConnection.Errors) |
|
||||||
{ |
|
||||||
mes += "-----------------\n\r"; |
|
||||||
mes += err.Description + "\n\r"; |
|
||||||
mes += err.NativeError + "\n\r"; |
|
||||||
} |
|
||||||
throw new ExecuteSQLException(mes); |
|
||||||
} |
|
||||||
finally |
|
||||||
{ |
|
||||||
this.pADOConnection.CommitTrans(); |
|
||||||
} |
|
||||||
|
|
||||||
return table; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
protected ADODB.ParameterDirectionEnum ParamDirectionToADODirection(ParameterDirection dir) |
|
||||||
{ |
|
||||||
ADODB.ParameterDirectionEnum ret = ADODB.ParameterDirectionEnum.adParamInput; |
|
||||||
|
|
||||||
switch (dir) |
|
||||||
{ |
|
||||||
case ParameterDirection.Input: ret = ADODB.ParameterDirectionEnum.adParamInput; break; |
|
||||||
case ParameterDirection.InputOutput: ret = ADODB.ParameterDirectionEnum.adParamInputOutput; break; |
|
||||||
case ParameterDirection.Output: ret = ADODB.ParameterDirectionEnum.adParamOutput; break; |
|
||||||
case ParameterDirection.ReturnValue: ret = ADODB.ParameterDirectionEnum.adParamReturnValue; break; |
|
||||||
default: throw new ArgumentOutOfRangeException("dir"); |
|
||||||
} |
|
||||||
|
|
||||||
return ret; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
protected ADODB.DataTypeEnum DbTypeToDataType(DbType t) |
|
||||||
{ |
|
||||||
ADODB.DataTypeEnum ret = ADODB.DataTypeEnum.adChar; |
|
||||||
|
|
||||||
switch (t) |
|
||||||
{ |
|
||||||
case DbType.AnsiString: ret = ADODB.DataTypeEnum.adChar; break; |
|
||||||
case DbType.Binary: ret = ADODB.DataTypeEnum.adBinary; break; |
|
||||||
case DbType.Boolean: ret = ADODB.DataTypeEnum.adBoolean; break; |
|
||||||
case DbType.Byte: ret = ADODB.DataTypeEnum.adUnsignedTinyInt; break; |
|
||||||
case DbType.Currency: ret = ADODB.DataTypeEnum.adCurrency; break; |
|
||||||
case DbType.Date: ret = ADODB.DataTypeEnum.adDate; break; |
|
||||||
case DbType.DateTime: ret = ADODB.DataTypeEnum.adDBTimeStamp; break; |
|
||||||
case DbType.Decimal: ret = ADODB.DataTypeEnum.adDecimal; break; |
|
||||||
case DbType.Double: ret = ADODB.DataTypeEnum.adDouble; break; |
|
||||||
case DbType.Guid: ret = ADODB.DataTypeEnum.adGUID; break; |
|
||||||
case DbType.Int16: ret = ADODB.DataTypeEnum.adSmallInt; break; |
|
||||||
case DbType.Int32: ret = ADODB.DataTypeEnum.adInteger; break; |
|
||||||
case DbType.Int64: ret = ADODB.DataTypeEnum.adBigInt; break; |
|
||||||
case DbType.Object: ret = ADODB.DataTypeEnum.adUserDefined; break; |
|
||||||
case DbType.SByte: ret = ADODB.DataTypeEnum.adTinyInt; break; |
|
||||||
case DbType.Single: ret = ADODB.DataTypeEnum.adSingle; break; |
|
||||||
case DbType.String: ret = ADODB.DataTypeEnum.adVarWChar; break; |
|
||||||
case DbType.StringFixedLength: ret = ADODB.DataTypeEnum.adWChar; break; |
|
||||||
case DbType.Time: ret = ADODB.DataTypeEnum.adDBTime; break; |
|
||||||
case DbType.UInt16: ret = ADODB.DataTypeEnum.adUnsignedSmallInt; break; |
|
||||||
case DbType.UInt32: ret = ADODB.DataTypeEnum.adUnsignedInt; break; |
|
||||||
case DbType.UInt64: ret = ADODB.DataTypeEnum.adUnsignedBigInt; break; |
|
||||||
case DbType.VarNumeric: ret = ADODB.DataTypeEnum.adVarNumeric; break; |
|
||||||
default: throw new ArgumentOutOfRangeException("t"); |
|
||||||
} |
|
||||||
|
|
||||||
return ret; |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Execute a stocked procedure.
|
|
||||||
/// <param name="schema">
|
|
||||||
/// <see cref="SharpQuery.SchemaClass">SchemaClass</see> object.
|
|
||||||
/// </param>
|
|
||||||
/// <param name="rows">
|
|
||||||
/// Maximum number of row to extract. If is "0" then all rows are extracted.
|
|
||||||
/// </param>
|
|
||||||
/// <returns> return a <see cref="System.Data.DataTable">DataTable</see>
|
|
||||||
///or a <see cref="System.Data.DataSet">DataSet</see> object.
|
|
||||||
/// </returns>
|
|
||||||
/// </summary>
|
|
||||||
public override object ExecuteProcedure(ISchemaClass schema, int rows, SharpQuerySchemaClassCollection parameters) |
|
||||||
{ |
|
||||||
DataTable table = null; |
|
||||||
|
|
||||||
if (schema == null) |
|
||||||
{ |
|
||||||
throw new System.ArgumentNullException("schema"); |
|
||||||
} |
|
||||||
|
|
||||||
ADODB.Recordset record = null; |
|
||||||
ADODB.Command command = new ADODB.Command(); |
|
||||||
command.ActiveConnection = this.pADOConnection; |
|
||||||
ADODB.Parameter para = null; |
|
||||||
|
|
||||||
command.CommandText = schema.Name; |
|
||||||
command.CommandType = ADODB.CommandTypeEnum.adCmdStoredProc; |
|
||||||
|
|
||||||
if (parameters != null) |
|
||||||
{ |
|
||||||
foreach (SharpQueryParameter classParam in parameters) |
|
||||||
{ |
|
||||||
para = new ADODB.Parameter(); |
|
||||||
para.Type = DbTypeToDataType(classParam.DataType); |
|
||||||
para.Direction = ParamDirectionToADODirection(classParam.Type); |
|
||||||
para.Name = classParam.Name; |
|
||||||
if (para.Name.StartsWith("[")) |
|
||||||
{ |
|
||||||
para.Name = para.Name.Remove(0, 1); |
|
||||||
} |
|
||||||
if (para.Name.EndsWith("]")) |
|
||||||
{ |
|
||||||
para.Name = para.Name.Remove(para.Name.Length - 1, 1); |
|
||||||
} |
|
||||||
para.Value = classParam.Value; |
|
||||||
command.Parameters.Append(para); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
this.pADOConnection.BeginTrans(); |
|
||||||
|
|
||||||
try |
|
||||||
{ |
|
||||||
record = (ADODB.Recordset)command.GetType().InvokeMember( |
|
||||||
"Execute", |
|
||||||
System.Reflection.BindingFlags.InvokeMethod, |
|
||||||
null, |
|
||||||
command, |
|
||||||
null); |
|
||||||
|
|
||||||
//record.MaxRecords = rows;
|
|
||||||
table = RecordSetToDataTable(record); |
|
||||||
|
|
||||||
//Procedure is ReadOnly
|
|
||||||
table.DefaultView.AllowDelete = false; |
|
||||||
table.DefaultView.AllowEdit = false; |
|
||||||
table.DefaultView.AllowNew = false; |
|
||||||
} |
|
||||||
catch (System.Exception e) |
|
||||||
{ |
|
||||||
if (schema != null) |
|
||||||
{ |
|
||||||
this.pADOConnection.RollbackTrans(); |
|
||||||
|
|
||||||
string mes = schema.Name + "\n\r"; |
|
||||||
|
|
||||||
foreach (ADODB.Error err in this.pADOConnection.Errors) |
|
||||||
{ |
|
||||||
mes += "-----------------\n\r"; |
|
||||||
mes += err.Description + "\n\r"; |
|
||||||
mes += err.NativeError + "\n\r"; |
|
||||||
} |
|
||||||
throw new ExecuteProcedureException(mes); |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
throw new ExecuteProcedureException(e.Message); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
this.pADOConnection.CommitTrans(); |
|
||||||
|
|
||||||
return table; |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// check the internal connection object is valid
|
|
||||||
/// Throw an exception if pADOConnection == null
|
|
||||||
///</summary>
|
|
||||||
protected override void CheckConnectionObject() |
|
||||||
{ |
|
||||||
if (this.pADOConnection == null) |
|
||||||
throw new ArgumentNullException("pADONETConnection"); |
|
||||||
} |
|
||||||
|
|
||||||
protected DataTable RecordSetToDataTable(ADODB.Recordset record) |
|
||||||
{ |
|
||||||
OleDbDataAdapter custDA = new OleDbDataAdapter(); |
|
||||||
DataTable custTable = new DataTable(); |
|
||||||
custDA.Fill(custTable, record); |
|
||||||
return custTable; |
|
||||||
} |
|
||||||
|
|
||||||
protected override DataTable GetSchema(SharpQuerySchemaEnum schema, object[] restrictions) |
|
||||||
{ |
|
||||||
ADODB.SchemaEnum internalSchema = 0; |
|
||||||
ADODB.Recordset ADOrecord = null; |
|
||||||
|
|
||||||
switch (schema) |
|
||||||
{ |
|
||||||
case SharpQuerySchemaEnum.Asserts: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaAsserts; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Catalogs: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaCatalogs; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.CharacterSets: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaCharacterSets; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.CheckConstraints: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaCheckConstraints; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Collations: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaCollations; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.ColumnPrivileges: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaColumnPrivileges; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Columns: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaColumns; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.ColumnsDomainUsage: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaColumnsDomainUsage; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.ConstraintColumnUsage: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaConstraintColumnUsage; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.ConstaintTableUsage: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaConstraintTableUsage; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Cubes: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaCubes; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.DBInfoKeyWords: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaDBInfoKeywords; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.DBInfoLiterals: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaDBInfoLiterals; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Dimensions: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaDimensions; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.ForeignKeys: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaForeignKeys; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Hierarchies: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaHierarchies; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Indexes: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaIndexes; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.KeyColumnUsage: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaKeyColumnUsage; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Levels: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaLevels; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Measures: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaMeasures; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Members: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaMembers; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Null: |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.PrimaryKeys: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaPrimaryKeys; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.ProcedureColumns: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaProcedureColumns; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.ProcedureParameters: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaProcedureParameters; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Procedures: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaProcedures; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Properties: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaProperties; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.ProviderTypes: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaProviderTypes; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.ReferentialConstraints: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaReferentialConstraints; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Schemata: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaSchemata; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.SQLLanguages: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaSQLLanguages; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Statistics: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaStatistics; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.TableConstraints: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaTableConstraints; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.TablePrivileges: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaTablePrivileges; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Tables: |
|
||||||
case SharpQuerySchemaEnum.Views: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaTables; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Tanslations: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaTranslations; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Trustees: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaTrustees; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.UsagePrivileges: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaUsagePrivileges; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.ViewColumnUsage: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaViewColumnUsage; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.ViewColumns: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaColumns; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.ViewTableUsage: |
|
||||||
internalSchema = ADODB.SchemaEnum.adSchemaViewTableUsage; |
|
||||||
break; |
|
||||||
default: |
|
||||||
throw new System.ArgumentException("", "schema"); |
|
||||||
} |
|
||||||
|
|
||||||
if (schema != SharpQuerySchemaEnum.Null) |
|
||||||
{ |
|
||||||
ADOrecord = (ADODB.Recordset)this.pADOConnection.GetType().InvokeMember( |
|
||||||
"OpenSchema", |
|
||||||
System.Reflection.BindingFlags.InvokeMethod, |
|
||||||
null, |
|
||||||
this.pADOConnection, |
|
||||||
new Object[] { internalSchema, this.NormalizeRestrictions(restrictions) }); |
|
||||||
} |
|
||||||
|
|
||||||
return RecordSetToDataTable(ADOrecord); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1,228 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Luc Morin" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System.Data; |
|
||||||
using SharpQuery.Collections; |
|
||||||
using SharpQuery.SchemaClass; |
|
||||||
|
|
||||||
namespace SharpQuery.Connection |
|
||||||
{ |
|
||||||
///<summary>
|
|
||||||
/// This interface is used by any connection wrapper class.
|
|
||||||
///</summary>
|
|
||||||
public interface IConnection |
|
||||||
{ |
|
||||||
///<summary>
|
|
||||||
/// return <c>true</c> if the connection string is invalid.
|
|
||||||
///</summary>
|
|
||||||
bool IsConnectionStringWrong |
|
||||||
{ |
|
||||||
get; |
|
||||||
} |
|
||||||
///<summary>Return the connection string.</summary>
|
|
||||||
string ConnectionString { get; set;} |
|
||||||
|
|
||||||
///<summary>Provider'sname.
|
|
||||||
/// </summary>
|
|
||||||
string Provider { get; } |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// get the <code>connection</code>'s <code>catalog</code> name.
|
|
||||||
///</summary>
|
|
||||||
string CatalogName { get; } |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// get the <code>connection</code>'s <code>schema</code> name.
|
|
||||||
///</summary>
|
|
||||||
string SchemaName { get; } |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// get the <code>entity</code>'s name
|
|
||||||
///</summary>
|
|
||||||
string Name { get; } |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// <code>entity</code>'s normalized name.
|
|
||||||
/// <example>
|
|
||||||
/// there are a database <code>test</code>. In this database there are a <code>schema</code>
|
|
||||||
/// named <code>fool</code>. In this <code>schema</code> there are a <code>table</code> named <code>fooltable</code>
|
|
||||||
/// and a in this <code>table</code> there are a <code>column</code> named <code>foolcolumn</code>.
|
|
||||||
/// So, the normalized name of the <code>schema</code> is <code>test.[fool]</code>.
|
|
||||||
/// The normalized name of the <code>table</code> is <code>test.[fool].fooltable</code>.
|
|
||||||
/// The normalized name of the <code>column</code> is <code>test.[fool].fooltable.foolcolumn</code>.
|
|
||||||
///</example>
|
|
||||||
///</summary>
|
|
||||||
string NormalizedName { get; } |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// <returns>
|
|
||||||
/// <code>true</code> if the connection is opened.
|
|
||||||
/// <code>false</code> if the connection is not opened.
|
|
||||||
/// </returns>
|
|
||||||
/// </summary>
|
|
||||||
bool IsOpen { get; } |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Those, are list of the childs schema.( columns, etc etc )
|
|
||||||
/// i am using a dictionnary because is more simplest to write
|
|
||||||
/// <code>Entities["PROCEDURES"]</code> than <code>Entities[0]</code>.
|
|
||||||
///</summary>
|
|
||||||
SharpQueryListDictionary Entities { get; } |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// <returns>
|
|
||||||
/// an array of string with the string properties's provider
|
|
||||||
/// </returns>
|
|
||||||
/// <remarks> properties are indexed ans sorted with <see cref=" SharpQuery.SchemaClass.AbstractSharpQueryConnectionWrapper.SharpQueryPropertyEnum">SharpQueryPropertyEnum</see></remarks>
|
|
||||||
/// </summary>
|
|
||||||
object GetProperty(AbstractSharpQueryConnectionWrapper.SharpQueryPropertyEnum property); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Open a connection with the <seealso cref='.IConnection.ConnectionString'/>
|
|
||||||
/// <returns>
|
|
||||||
/// <code>true</code> if the connection is opened.
|
|
||||||
/// <code>false</code> if the connection is not opened.
|
|
||||||
/// </returns>
|
|
||||||
/// </summary>
|
|
||||||
bool Open(); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Close the connection with the server.
|
|
||||||
/// </summary>
|
|
||||||
void Close(); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Refresh child schemas from the database.
|
|
||||||
///</summary>
|
|
||||||
void Refresh(); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Erase all child schemas
|
|
||||||
///</summary>
|
|
||||||
void Clear(); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Execute a SQL command
|
|
||||||
/// <param name="SQLText">
|
|
||||||
/// SQL command to execute
|
|
||||||
/// </param>
|
|
||||||
/// <param name="rows">
|
|
||||||
/// Maximum number of row to extract. If is "0" then all rows are extracted.
|
|
||||||
/// </param>
|
|
||||||
/// <returns> return a <see cref="System.Data.DataTable">DataTable</see>
|
|
||||||
///or a <see cref="System.Data.DataSet">DataSet</see> object.
|
|
||||||
/// </returns>
|
|
||||||
/// </summary>
|
|
||||||
object ExecuteSQL(string SQLText, int rows); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Execute a stocked procedure.
|
|
||||||
/// <param name="schema">
|
|
||||||
/// <see cref="SharpQuery.SchemaClass">SchemaClass</see> object.
|
|
||||||
/// </param>
|
|
||||||
/// <param name="rows">
|
|
||||||
/// Maximum number of row to extract. If is "0" then all rows are extracted.
|
|
||||||
/// </param>
|
|
||||||
/// <returns> return a <see cref="System.Data.DataTable">DataTable</see>
|
|
||||||
///or a <see cref="System.Data.DataSet">DataSet</see> object.
|
|
||||||
/// </returns>
|
|
||||||
/// </summary>
|
|
||||||
object ExecuteProcedure(ISchemaClass schema, int rows, SharpQuerySchemaClassCollection parameters); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Extract Data from a Table or a View
|
|
||||||
/// <param name="schema">
|
|
||||||
/// <see cref="SharpQuery.SchemaClass">SchemaClass</see> object.
|
|
||||||
/// </param>
|
|
||||||
/// <param name="rows">
|
|
||||||
/// Maximum number of row to extract. If is "0" then all rows are extracted.
|
|
||||||
/// </param>
|
|
||||||
/// <returns> return a <see cref="System.Data.DataTable">DataTable</see>
|
|
||||||
///or a <see cref="System.Data.DataSet">DataSet</see> object.
|
|
||||||
/// </returns>
|
|
||||||
/// </summary>
|
|
||||||
object ExtractData(ISchemaClass schema, int rows); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Update <see cref="System.Data.DataRow">row</see>'s fields into the current opened database.
|
|
||||||
/// <param name="row">a <see cref="System.Data.DataRow">row</see> </param>
|
|
||||||
/// <param name="schema"> a <see cref="SharpQuery.SchemaClass.ISchema">schema</see> </param>
|
|
||||||
///</summary>
|
|
||||||
void UpDateRow(ISchemaClass schema, DataRow row); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Delete <see cref="System.Data.DataRow">row</see> into the current opened database.
|
|
||||||
/// <param name="row">a <see cref="System.Data.DataRow">row</see> </param>
|
|
||||||
/// <param name="schema"> a <see cref="SharpQuery.SchemaClass.ISchema">schema</see> </param>
|
|
||||||
///</summary>
|
|
||||||
void DeleteRow(ISchemaClass schema, DataRow row); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Insert <see cref="System.Data.DataRow">row</see> into the current opened database.
|
|
||||||
/// <param name="row">a <see cref="System.Data.DataRow">row</see> </param>
|
|
||||||
/// <param name="schema"> a <see cref="SharpQuery.SchemaClass.ISchema">schema</see> </param>
|
|
||||||
///</summary>
|
|
||||||
void InsertRow(ISchemaClass schema, DataRow row); |
|
||||||
|
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Get <seealso cref='.ISchemaClass.Connection'/>'s catalogs.
|
|
||||||
///</summary>
|
|
||||||
SharpQuerySchemaClassCollection GetSchemaCatalogs(ISchemaClass schema); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Get <seealso cref='.ISchemaClass.Connection'/>'s Schemas.
|
|
||||||
///</summary>
|
|
||||||
SharpQuerySchemaClassCollection GetSchemaSchemas(ISchemaClass schema); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// From a catalog object, get tables from all schemas.
|
|
||||||
/// From a schema object get tables from all this schema.
|
|
||||||
/// From other object, return an empty list.
|
|
||||||
///</summary>
|
|
||||||
SharpQuerySchemaClassCollection GetSchemaTables(ISchemaClass schema); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// From a catalog object, get views from all schemas.
|
|
||||||
/// From a schema object get views from all this schema.
|
|
||||||
/// From other object, return an empty list.
|
|
||||||
///</summary>
|
|
||||||
SharpQuerySchemaClassCollection GetSchemaViews(ISchemaClass schema); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// From a catalog object, get procedures from all schemas.
|
|
||||||
/// From a schema object get procedures from all this schema.
|
|
||||||
/// From other object, return an empty list.
|
|
||||||
///</summary>
|
|
||||||
SharpQuerySchemaClassCollection GetSchemaProcedures(ISchemaClass schema); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// From a table object, get columns from the table.
|
|
||||||
/// From other object, return an empty list.
|
|
||||||
///</summary>
|
|
||||||
SharpQuerySchemaClassCollection GetSchemaTableColumns(ISchemaClass schema); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// From a view object, get columns from the view.
|
|
||||||
/// From other object, return an empty list.
|
|
||||||
///</summary>
|
|
||||||
SharpQuerySchemaClassCollection GetSchemaViewColumns(ISchemaClass schema); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// From a procedure object , get columns from the procedure.
|
|
||||||
/// From other object, return an empty list.
|
|
||||||
///</summary>
|
|
||||||
SharpQuerySchemaClassCollection GetSchemaProcedureColumns(ISchemaClass schema); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// From a procedure object , get parameters from the procedure.
|
|
||||||
/// From other object, return an empty list.
|
|
||||||
///</summary>
|
|
||||||
SharpQuerySchemaClassCollection GetSchemaProcedureParameters(ISchemaClass schema); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,446 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Luc Morin" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Data; |
|
||||||
using System.Data.OleDb; |
|
||||||
|
|
||||||
using SharpQuery.Collections; |
|
||||||
using SharpQuery.Exceptions; |
|
||||||
using SharpQuery.SchemaClass; |
|
||||||
|
|
||||||
namespace SharpQuery.Connection |
|
||||||
{ |
|
||||||
//
|
|
||||||
// ADO .NET Wrapper (better than OleDB)
|
|
||||||
//
|
|
||||||
///<summary>
|
|
||||||
/// This class is associated with a class <see cref="ICSharpCode.SharpDevelop.Gui.SharpQuery.TreeView.SharpQueryNodeConnection"/>
|
|
||||||
///</summary>
|
|
||||||
public class OLEDBConnectionWrapper : AbstractSharpQueryConnectionWrapper |
|
||||||
{ |
|
||||||
private System.Data.OleDb.OleDbConnection pOLEConnection = null; |
|
||||||
private System.Data.OleDb.OleDbDataAdapter pOLEAdapter = new OleDbDataAdapter(); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// OLEDB connection String.
|
|
||||||
/// i use this for speed up the code writing ...
|
|
||||||
///</summary>
|
|
||||||
public override string ConnectionString |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return base.ConnectionString; |
|
||||||
} |
|
||||||
|
|
||||||
set |
|
||||||
{ |
|
||||||
if (IsOpen == true) |
|
||||||
{ |
|
||||||
this.Close(); |
|
||||||
} |
|
||||||
try |
|
||||||
{ |
|
||||||
this.pOLEConnection.ConnectionString = value; |
|
||||||
wrongConnectionString = false; |
|
||||||
} |
|
||||||
catch (OleDbException e) |
|
||||||
{ |
|
||||||
string mes = this.ConnectionString + "\n\r"; |
|
||||||
wrongConnectionString = true; |
|
||||||
|
|
||||||
foreach (OleDbError err in e.Errors) |
|
||||||
{ |
|
||||||
mes += "-----------------\n\r"; |
|
||||||
mes += err.Message + "\n\r"; |
|
||||||
mes += err.NativeError + "\n\r"; |
|
||||||
} |
|
||||||
throw new ConnectionStringException(mes); |
|
||||||
} |
|
||||||
catch (System.Exception e) |
|
||||||
{ |
|
||||||
wrongConnectionString = true; |
|
||||||
throw new ConnectionStringException(value |
|
||||||
+ "\n\r" |
|
||||||
+ "-------------------\n\r" |
|
||||||
+ e.Message |
|
||||||
); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override bool IsOpen |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return (this.pOLEConnection.State == ConnectionState.Open); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override object GetProperty(AbstractSharpQueryConnectionWrapper.SharpQueryPropertyEnum property) |
|
||||||
{ |
|
||||||
object returnValue = null; |
|
||||||
|
|
||||||
switch (property) |
|
||||||
{ |
|
||||||
case SharpQueryPropertyEnum.Catalog: |
|
||||||
case SharpQueryPropertyEnum.DataSourceName: |
|
||||||
returnValue = this.pOLEConnection.Database; |
|
||||||
break; |
|
||||||
case SharpQueryPropertyEnum.ConnectionString: |
|
||||||
returnValue = this.pOLEConnection.ConnectionString.ToString(); |
|
||||||
break; |
|
||||||
case SharpQueryPropertyEnum.DataSource: |
|
||||||
returnValue = this.pOLEConnection.DataSource; |
|
||||||
break; |
|
||||||
case SharpQueryPropertyEnum.DBMSName: |
|
||||||
returnValue = ""; |
|
||||||
break; |
|
||||||
case SharpQueryPropertyEnum.ProviderName: |
|
||||||
//Key = "Provider Name";
|
|
||||||
returnValue = this.pOLEConnection.Provider.ToString(); |
|
||||||
break; |
|
||||||
default: |
|
||||||
returnValue = null; |
|
||||||
break; |
|
||||||
} |
|
||||||
|
|
||||||
return returnValue; |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a new DataConnection object
|
|
||||||
/// </summary>
|
|
||||||
public OLEDBConnectionWrapper() |
|
||||||
: base() |
|
||||||
{ |
|
||||||
this.pOLEConnection = new System.Data.OleDb.OleDbConnection(); |
|
||||||
this.pOLEAdapter = new System.Data.OleDb.OleDbDataAdapter(); |
|
||||||
this.pOLEAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey; |
|
||||||
} |
|
||||||
|
|
||||||
public OLEDBConnectionWrapper(string connectionString) |
|
||||||
: this() |
|
||||||
{ |
|
||||||
this.ConnectionString = connectionString; |
|
||||||
} |
|
||||||
|
|
||||||
public override bool Open() |
|
||||||
{ |
|
||||||
try |
|
||||||
{ |
|
||||||
if (this.IsOpen == false && wrongConnectionString == false) |
|
||||||
{ |
|
||||||
this.pOLEConnection.Open(); |
|
||||||
} |
|
||||||
} |
|
||||||
catch (OleDbException e) |
|
||||||
{ |
|
||||||
string mes = this.ConnectionString + "\n\r"; |
|
||||||
wrongConnectionString = true; |
|
||||||
|
|
||||||
foreach (OleDbError err in e.Errors) |
|
||||||
{ |
|
||||||
mes += "-----------------\n\r"; |
|
||||||
mes += err.Message + "\n\r"; |
|
||||||
mes += err.NativeError + "\n\r"; |
|
||||||
} |
|
||||||
throw new OpenConnectionException(mes); |
|
||||||
} |
|
||||||
catch (System.Exception) |
|
||||||
{ |
|
||||||
wrongConnectionString = true; |
|
||||||
throw new OpenConnectionException(this.ConnectionString); |
|
||||||
} |
|
||||||
|
|
||||||
return this.IsOpen; |
|
||||||
} |
|
||||||
|
|
||||||
public override void Close() |
|
||||||
{ |
|
||||||
if (this.IsOpen == true) |
|
||||||
{ |
|
||||||
this.pOLEConnection.Close(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Execute a SQL command
|
|
||||||
/// <param name="SQLText">
|
|
||||||
/// SQL command to execute
|
|
||||||
/// </param>
|
|
||||||
/// <param name="rows">
|
|
||||||
/// Maximum number of row to extract. If is "0" then all rows are extracted.
|
|
||||||
/// </param>
|
|
||||||
/// <returns> return a <see cref="System.Data.DataTable">DataTable</see>
|
|
||||||
///or a <see cref="System.Data.DataSet">DataSet</see> object.
|
|
||||||
/// </returns> /// </summary>
|
|
||||||
public override object ExecuteSQL(string SQLText, int rows) |
|
||||||
{ |
|
||||||
OleDbCommand command = new OleDbCommand(); |
|
||||||
DataSet returnValues = new DataSet(); |
|
||||||
|
|
||||||
command.Connection = this.pOLEConnection; |
|
||||||
command.CommandText = SQLText; |
|
||||||
command.CommandType = System.Data.CommandType.Text; |
|
||||||
|
|
||||||
// some stranges things occurs with the OleDbDataAdapter and transaction
|
|
||||||
command.Transaction = this.pOLEConnection.BeginTransaction(System.Data.IsolationLevel.ReadCommitted); |
|
||||||
|
|
||||||
try |
|
||||||
{ |
|
||||||
this.pOLEAdapter.SelectCommand = command; |
|
||||||
this.pOLEAdapter.Fill(returnValues); |
|
||||||
|
|
||||||
} |
|
||||||
catch (OleDbException e) |
|
||||||
{ |
|
||||||
command.Transaction.Rollback(); |
|
||||||
|
|
||||||
string mes = SQLText + "\n\r"; |
|
||||||
|
|
||||||
foreach (OleDbError err in e.Errors) |
|
||||||
{ |
|
||||||
mes += "-----------------\n\r"; |
|
||||||
mes += err.Message + "\n\r"; |
|
||||||
mes += err.NativeError + "\n\r"; |
|
||||||
} |
|
||||||
throw new ExecuteSQLException(mes); |
|
||||||
} |
|
||||||
catch (System.Exception) |
|
||||||
{ |
|
||||||
command.Transaction.Rollback(); |
|
||||||
throw new ExecuteSQLException(SQLText); |
|
||||||
} |
|
||||||
finally |
|
||||||
{ |
|
||||||
command.Transaction.Commit(); |
|
||||||
} |
|
||||||
|
|
||||||
return returnValues; |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Execute a stocked procedure.
|
|
||||||
/// <param name="schema">
|
|
||||||
/// <see cref="SharpQuery.SchemaClass">SchemaClass</see> object.
|
|
||||||
/// </param>
|
|
||||||
/// <param name="rows">
|
|
||||||
/// Maximum number of row to extract. If is "0" then all rows are extracted.
|
|
||||||
/// </param>
|
|
||||||
/// <returns> return a <see cref="System.Data.DataTable">DataTable</see>
|
|
||||||
///or a <see cref="System.Data.DataSet">DataSet</see> object.
|
|
||||||
/// </returns> /// </summary>
|
|
||||||
public override object ExecuteProcedure(ISchemaClass schema, int rows, SharpQuerySchemaClassCollection parameters) |
|
||||||
{ |
|
||||||
|
|
||||||
DataSet returnValues = null; |
|
||||||
|
|
||||||
if (schema == null) |
|
||||||
{ |
|
||||||
throw new System.ArgumentNullException("schema"); |
|
||||||
} |
|
||||||
|
|
||||||
OleDbCommand command = new OleDbCommand(); |
|
||||||
OleDbParameter para = null; |
|
||||||
returnValues = new DataSet(); |
|
||||||
|
|
||||||
command.Connection = this.pOLEConnection; |
|
||||||
command.CommandText = schema.Name; |
|
||||||
command.CommandType = System.Data.CommandType.StoredProcedure; |
|
||||||
|
|
||||||
if (parameters != null) |
|
||||||
{ |
|
||||||
foreach (SharpQueryParameter classParam in parameters) |
|
||||||
{ |
|
||||||
para = new OleDbParameter(); |
|
||||||
para.DbType = classParam.DataType; |
|
||||||
para.Direction = (ParameterDirection)classParam.Type; |
|
||||||
para.ParameterName = classParam.Name; |
|
||||||
if (para.ParameterName.StartsWith("[")) |
|
||||||
{ |
|
||||||
para.ParameterName = para.ParameterName.Remove(0, 1); |
|
||||||
} |
|
||||||
if (para.ParameterName.EndsWith("]")) |
|
||||||
{ |
|
||||||
para.ParameterName = para.ParameterName.Remove(para.ParameterName.Length - 1, 1); |
|
||||||
} |
|
||||||
para.Value = classParam.Value; |
|
||||||
command.Parameters.Add(para); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
// command.Prepare();
|
|
||||||
command.Transaction = this.pOLEConnection.BeginTransaction(System.Data.IsolationLevel.ReadCommitted); |
|
||||||
|
|
||||||
try |
|
||||||
{ |
|
||||||
this.pOLEAdapter.SelectCommand = command; |
|
||||||
this.pOLEAdapter.Fill(returnValues); |
|
||||||
} |
|
||||||
catch (OleDbException e) |
|
||||||
{ |
|
||||||
command.Transaction.Rollback(); |
|
||||||
|
|
||||||
string mes = schema.Name + "\n\r"; |
|
||||||
|
|
||||||
foreach (OleDbError err in e.Errors) |
|
||||||
{ |
|
||||||
mes += "-----------------\n\r"; |
|
||||||
mes += err.Message + "\n\r"; |
|
||||||
mes += err.NativeError + "\n\r"; |
|
||||||
} |
|
||||||
throw new ExecuteProcedureException(mes); |
|
||||||
} |
|
||||||
catch (System.Exception e) |
|
||||||
{ |
|
||||||
command.Transaction.Rollback(); |
|
||||||
throw new ExecuteProcedureException(e.Message); |
|
||||||
} |
|
||||||
|
|
||||||
command.Transaction.Commit(); |
|
||||||
|
|
||||||
foreach (DataTable table in returnValues.Tables) |
|
||||||
{ |
|
||||||
//readonly
|
|
||||||
table.DefaultView.AllowDelete = false; |
|
||||||
table.DefaultView.AllowEdit = false; |
|
||||||
table.DefaultView.AllowNew = false; |
|
||||||
} |
|
||||||
|
|
||||||
return returnValues; |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// check the internal connection object is valid
|
|
||||||
/// Throw an exception if pADOConnection == null
|
|
||||||
///</summary>
|
|
||||||
protected override void CheckConnectionObject() |
|
||||||
{ |
|
||||||
if (this.pOLEConnection == null) |
|
||||||
throw new ArgumentNullException("pOLEConnection"); |
|
||||||
} |
|
||||||
|
|
||||||
protected override DataTable GetSchema(SharpQuerySchemaEnum schema, object[] restrictions) |
|
||||||
{ |
|
||||||
System.Guid internalSchema = OleDbSchemaGuid.Assertions; |
|
||||||
DataTable OLErecord = null; |
|
||||||
|
|
||||||
switch (schema) |
|
||||||
{ |
|
||||||
case SharpQuerySchemaEnum.Asserts: |
|
||||||
internalSchema = OleDbSchemaGuid.Assertions; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Catalogs: |
|
||||||
internalSchema = OleDbSchemaGuid.Catalogs; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.CharacterSets: |
|
||||||
internalSchema = OleDbSchemaGuid.Character_Sets; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.CheckConstraints: |
|
||||||
internalSchema = OleDbSchemaGuid.Check_Constraints; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Collations: |
|
||||||
internalSchema = OleDbSchemaGuid.Collations; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.ColumnPrivileges: |
|
||||||
internalSchema = OleDbSchemaGuid.Column_Privileges; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Columns: |
|
||||||
internalSchema = OleDbSchemaGuid.Columns; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.ConstraintColumnUsage: |
|
||||||
internalSchema = OleDbSchemaGuid.Constraint_Column_Usage; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.ConstaintTableUsage: |
|
||||||
internalSchema = OleDbSchemaGuid.Constraint_Table_Usage; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.DBInfoLiterals: |
|
||||||
internalSchema = OleDbSchemaGuid.DbInfoLiterals; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.ForeignKeys: |
|
||||||
internalSchema = OleDbSchemaGuid.Foreign_Keys; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Indexes: |
|
||||||
internalSchema = OleDbSchemaGuid.Indexes; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.KeyColumnUsage: |
|
||||||
internalSchema = OleDbSchemaGuid.Key_Column_Usage; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Null: |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.PrimaryKeys: |
|
||||||
internalSchema = OleDbSchemaGuid.Primary_Keys; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.ProcedureColumns: |
|
||||||
internalSchema = OleDbSchemaGuid.Procedure_Columns; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.ProcedureParameters: |
|
||||||
internalSchema = OleDbSchemaGuid.Procedure_Parameters; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Procedures: |
|
||||||
internalSchema = OleDbSchemaGuid.Procedures; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.ProviderTypes: |
|
||||||
internalSchema = OleDbSchemaGuid.Provider_Types; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.ReferentialConstraints: |
|
||||||
internalSchema = OleDbSchemaGuid.Referential_Constraints; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Schemata: |
|
||||||
internalSchema = OleDbSchemaGuid.Schemata; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.SQLLanguages: |
|
||||||
internalSchema = OleDbSchemaGuid.Sql_Languages; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Statistics: |
|
||||||
internalSchema = OleDbSchemaGuid.Statistics; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.TableConstraints: |
|
||||||
internalSchema = OleDbSchemaGuid.Table_Constraints; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.TablePrivileges: |
|
||||||
internalSchema = OleDbSchemaGuid.Table_Privileges; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Tables: |
|
||||||
case SharpQuerySchemaEnum.Views: |
|
||||||
internalSchema = OleDbSchemaGuid.Tables; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Tanslations: |
|
||||||
internalSchema = OleDbSchemaGuid.Translations; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.Trustees: |
|
||||||
internalSchema = OleDbSchemaGuid.Trustee; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.UsagePrivileges: |
|
||||||
internalSchema = OleDbSchemaGuid.Usage_Privileges; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.ViewColumnUsage: |
|
||||||
internalSchema = OleDbSchemaGuid.View_Column_Usage; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.ViewColumns: |
|
||||||
internalSchema = OleDbSchemaGuid.Columns; |
|
||||||
break; |
|
||||||
case SharpQuerySchemaEnum.ViewTableUsage: |
|
||||||
internalSchema = OleDbSchemaGuid.View_Table_Usage; |
|
||||||
break; |
|
||||||
default: |
|
||||||
throw new System.ArgumentException("", "schema"); |
|
||||||
} |
|
||||||
|
|
||||||
if (schema != SharpQuerySchemaEnum.Null) |
|
||||||
{ |
|
||||||
OLErecord = this.pOLEConnection.GetOleDbSchemaTable(internalSchema, this.NormalizeRestrictions(restrictions)); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return OLErecord; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,52 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Luc Morin" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Runtime.Serialization; |
|
||||||
using ICSharpCode.Core; |
|
||||||
using SharpQuery.SchemaClass; |
|
||||||
|
|
||||||
namespace SharpQuery.Exceptions |
|
||||||
{ |
|
||||||
[Serializable()] |
|
||||||
public class ConnectionStringException : Exception |
|
||||||
{ |
|
||||||
public ConnectionStringException() |
|
||||||
: base(StringParser.Parse("${res:SharpQuery.Error.WrongConnectionString}")) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public ConnectionStringException(ISchemaClass schema) |
|
||||||
: base(StringParser.Parse("${res:SharpQuery.Error.WrongConnectionString}") |
|
||||||
+ "\n\r" |
|
||||||
+ "-----------------" |
|
||||||
+ "\n\r" |
|
||||||
+ "(" + schema.Connection.ConnectionString + ")" |
|
||||||
+ "\n\r" |
|
||||||
+ "(" + schema.Connection.Name + ")" |
|
||||||
) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public ConnectionStringException(string message) |
|
||||||
: base(StringParser.Parse("${res:SharpQuery.Error.WrongConnectionString}") |
|
||||||
+ "\n\r" |
|
||||||
+ "-----------------" |
|
||||||
+ "\n\r" |
|
||||||
+ message) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public ConnectionStringException(string message, Exception innerException) : base(message, innerException) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
protected ConnectionStringException(SerializationInfo info, StreamingContext context) : base(info, context) |
|
||||||
{ |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,53 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Luc Morin" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Runtime.Serialization; |
|
||||||
using ICSharpCode.Core; |
|
||||||
using SharpQuery.SchemaClass; |
|
||||||
|
|
||||||
namespace SharpQuery.Exceptions |
|
||||||
{ |
|
||||||
[Serializable()] |
|
||||||
public class ExecuteProcedureException : Exception |
|
||||||
{ |
|
||||||
public ExecuteProcedureException() |
|
||||||
: base(StringParser.Parse("${res:SharpQuery.Error.ProcedureExecution}")) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public ExecuteProcedureException(ISchemaClass schema) |
|
||||||
: base(StringParser.Parse("${res:SharpQuery.Error.ProcedureExecution}") |
|
||||||
+ "\n\r" |
|
||||||
+ "-----------------" |
|
||||||
+ "\n\r" |
|
||||||
+ "(" + schema.Connection.ConnectionString + ")" |
|
||||||
+ "\n\r" |
|
||||||
+ "(" + schema.Connection.Name + ")" |
|
||||||
) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public ExecuteProcedureException(string message) |
|
||||||
: base(StringParser.Parse("${res:SharpQuery.Error.ProcedureExecution}") |
|
||||||
+ "\n\r" |
|
||||||
+ "-----------------" |
|
||||||
+ "\n\r" |
|
||||||
+ message) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public ExecuteProcedureException(string message, Exception innerException) : base(message, innerException) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
protected ExecuteProcedureException(SerializationInfo info, StreamingContext context) : base(info, context) |
|
||||||
{ |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,53 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Luc Morin" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Runtime.Serialization; |
|
||||||
using ICSharpCode.Core; |
|
||||||
using SharpQuery.SchemaClass; |
|
||||||
|
|
||||||
namespace SharpQuery.Exceptions |
|
||||||
{ |
|
||||||
[Serializable()] |
|
||||||
public class ExecuteSQLException : Exception |
|
||||||
{ |
|
||||||
public ExecuteSQLException() |
|
||||||
: base(StringParser.Parse("${res:SharpQuery.Error.SQLExecution}")) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public ExecuteSQLException(ISchemaClass schema) |
|
||||||
: base(StringParser.Parse("${res:SharpQuery.Error.SQLExecution}") |
|
||||||
+ "\n\r" |
|
||||||
+ "-----------------" |
|
||||||
+ "\n\r" |
|
||||||
+ "(" + schema.Connection.ConnectionString + ")" |
|
||||||
+ "\n\r" |
|
||||||
+ "(" + schema.Connection.Name + ")" |
|
||||||
) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public ExecuteSQLException(string message) |
|
||||||
: base(StringParser.Parse("${res:SharpQuery.Error.SQLExecution}") |
|
||||||
+ "\n\r" |
|
||||||
+ "-----------------" |
|
||||||
+ "\n\r" |
|
||||||
+ message) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public ExecuteSQLException(string message, Exception innerException) : base(message, innerException) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
protected ExecuteSQLException(SerializationInfo info, StreamingContext context) : base(info, context) |
|
||||||
{ |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,53 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Luc Morin" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Runtime.Serialization; |
|
||||||
using ICSharpCode.Core; |
|
||||||
using SharpQuery.SchemaClass; |
|
||||||
|
|
||||||
namespace SharpQuery.Exceptions |
|
||||||
{ |
|
||||||
[Serializable()] |
|
||||||
public class OpenConnectionException : Exception |
|
||||||
{ |
|
||||||
public OpenConnectionException() |
|
||||||
: base(StringParser.Parse("${res:SharpQuery.Error.OpenError}")) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public OpenConnectionException(ISchemaClass schema) |
|
||||||
: base(StringParser.Parse("${res:SharpQuery.Error.OpenError}") |
|
||||||
+ "\n\r" |
|
||||||
+ "-----------------" |
|
||||||
+ "\n\r" |
|
||||||
+ "(" + schema.Connection.ConnectionString + ")" |
|
||||||
+ "\n\r" |
|
||||||
+ "(" + schema.Connection.Name + ")" |
|
||||||
) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public OpenConnectionException(string message) |
|
||||||
: base(StringParser.Parse("${res:SharpQuery.Error.OpenError}") |
|
||||||
+ "\n\r" |
|
||||||
+ "-----------------" |
|
||||||
+ "\n\r" |
|
||||||
+ message) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public OpenConnectionException(string message, Exception innerException) : base(message, innerException) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
protected OpenConnectionException(SerializationInfo info, StreamingContext context) : base(info, context) |
|
||||||
{ |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,32 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Luc Morin" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Runtime.Serialization; |
|
||||||
|
|
||||||
namespace SharpQuery.Exceptions |
|
||||||
{ |
|
||||||
[Serializable()] |
|
||||||
public abstract class SharpQueryAbstractException : Exception |
|
||||||
{ |
|
||||||
public SharpQueryAbstractException() : base() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryAbstractException(string message) : base(message) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryAbstractException(string message, Exception innerException) : base(message, innerException) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
protected SharpQueryAbstractException(SerializationInfo info, StreamingContext context) : base(info, context) |
|
||||||
{ |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,300 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Luc Morin" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.ComponentModel; |
|
||||||
using System.Reflection; |
|
||||||
using System.Windows.Forms; |
|
||||||
|
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.SharpDevelop.Gui; |
|
||||||
using SharpQuery.Collections; |
|
||||||
using SharpQuery.Connection; |
|
||||||
using SharpQuery.Gui.DataView; |
|
||||||
using SharpQuery.SchemaClass; |
|
||||||
|
|
||||||
namespace SharpQuery.Gui.TreeView |
|
||||||
{ |
|
||||||
public abstract class AbstractSharpQueryNode : System.Windows.Forms.TreeNode, ISharpQueryNode |
|
||||||
{ |
|
||||||
internal static SQLParameterInput inputform = null; |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// this variable force to have a "plus" near the node.
|
|
||||||
/// </summary>
|
|
||||||
protected Assembly ass = null; |
|
||||||
|
|
||||||
protected ISchemaClass pSchemaClass = null; |
|
||||||
|
|
||||||
///<summary> force to displayed a "+" for the node</summary>
|
|
||||||
protected virtual bool NullChildAllowed |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return true; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public virtual string AddinContextMenu |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return ""; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public virtual string entityNormalizedName |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
if (this.SchemaClass != null) |
|
||||||
{ |
|
||||||
return AbstractSharpQuerySchemaClass.RemoveBracket(this.SchemaClass.NormalizedName); |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
return ""; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public virtual string entityName |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
if (this.SchemaClass != null) |
|
||||||
{ |
|
||||||
return this.SchemaClass.InternalName; |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
return ""; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public ISchemaClass SchemaClass |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
if (this.pSchemaClass != null) |
|
||||||
{ |
|
||||||
return this.pSchemaClass; |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public virtual IConnection Connection |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
if (this.SchemaClass != null) |
|
||||||
{ |
|
||||||
return this.SchemaClass.Connection; |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public virtual SharpQueryListDictionary Entities |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
if (this.SchemaClass != null) |
|
||||||
{ |
|
||||||
return this.SchemaClass.Entities; |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public AbstractSharpQueryNode() |
|
||||||
: base() |
|
||||||
{ |
|
||||||
ass = System.Reflection.Assembly.GetExecutingAssembly(); |
|
||||||
} |
|
||||||
|
|
||||||
public AbstractSharpQueryNode(ISchemaClass schemaclass) |
|
||||||
: this() |
|
||||||
{ |
|
||||||
this.pSchemaClass = schemaclass; |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// called by <see cref=".Refresh()">Refresh</see> just after the <see cref=".Clear()">Clear</see> and before <see cref=".Refresh()">childs'refresh</see>.
|
|
||||||
/// In this, you could change the <see cref=".Entities">Entities dicntionnary.</see>
|
|
||||||
///</summary>
|
|
||||||
protected virtual void OnRefresh() |
|
||||||
{ |
|
||||||
// Nothing !
|
|
||||||
} |
|
||||||
|
|
||||||
public virtual void Refresh() |
|
||||||
{ |
|
||||||
try |
|
||||||
{ |
|
||||||
if (this.TreeView != null) |
|
||||||
{ |
|
||||||
this.TreeView.BeginUpdate(); |
|
||||||
} |
|
||||||
|
|
||||||
this.Clear(); |
|
||||||
|
|
||||||
this.OnRefresh(); |
|
||||||
|
|
||||||
if (this.Connection.IsOpen) |
|
||||||
{ |
|
||||||
this.Text = this.entityName; |
|
||||||
|
|
||||||
if (this.IsExpanded == true) |
|
||||||
{ |
|
||||||
if (this.SchemaClass != null) |
|
||||||
{ |
|
||||||
this.SchemaClass.Refresh(); |
|
||||||
} |
|
||||||
|
|
||||||
this.BuildsChilds(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
finally |
|
||||||
{ |
|
||||||
if (this.TreeView != null) |
|
||||||
{ |
|
||||||
this.TreeView.EndUpdate(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public virtual void Clear() |
|
||||||
{ |
|
||||||
if (this.SchemaClass != null) |
|
||||||
{ |
|
||||||
this.SchemaClass.Clear(); |
|
||||||
} |
|
||||||
|
|
||||||
this.Nodes.Clear(); |
|
||||||
|
|
||||||
if ((this.IsExpanded == false) && (this.NullChildAllowed == true)) |
|
||||||
{ |
|
||||||
this.Nodes.Add(new TreeNode()); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// allow the user to add some parameters while executing an SQL command
|
|
||||||
/// </summary>
|
|
||||||
protected virtual SharpQuerySchemaClassCollection OnExecute(CancelEventArgs e) |
|
||||||
{ |
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// For a Table or a View extract data.
|
|
||||||
/// For a stocked procedure, execute it :o).
|
|
||||||
/// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
|
|
||||||
/// </summary>
|
|
||||||
public void Execute(int rows) |
|
||||||
{ |
|
||||||
try |
|
||||||
{ |
|
||||||
if (this.SchemaClass != null) |
|
||||||
{ |
|
||||||
CancelEventArgs e = new CancelEventArgs(); |
|
||||||
SharpQuerySchemaClassCollection ret = this.OnExecute(e); |
|
||||||
if (e.Cancel == false) |
|
||||||
{ |
|
||||||
WorkbenchSingleton.Workbench.ShowView(new SharpQueryDataView(this.SchemaClass, rows, ret)); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
catch (Exception e) |
|
||||||
{ |
|
||||||
MessageService.ShowError(e.Message); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public virtual void BuildsChilds() |
|
||||||
{ |
|
||||||
string childclass = ""; |
|
||||||
ISharpQueryNode ChildNode = null; |
|
||||||
|
|
||||||
if (this.Entities != null) |
|
||||||
{ |
|
||||||
foreach ( KeyValuePair<string, SharpQuerySchemaClassCollection> DicEntry in this.Entities) |
|
||||||
{ |
|
||||||
if (DicEntry.Value != null) |
|
||||||
{ |
|
||||||
SharpQuerySchemaClassCollection entitieslist = DicEntry.Value as SharpQuerySchemaClassCollection; |
|
||||||
|
|
||||||
foreach (ISchemaClass entity in entitieslist) |
|
||||||
{ |
|
||||||
childclass = SharpQueryTree.SchemaClassDict[entity.GetType().FullName]; |
|
||||||
if ((childclass != null) && (childclass != "")) |
|
||||||
{ |
|
||||||
ChildNode = (ISharpQueryNode)ass.CreateInstance(childclass, false, BindingFlags.CreateInstance, null, new object[] { entity }, null, null); |
|
||||||
if (ChildNode != null) |
|
||||||
{ |
|
||||||
bool addNode = true; |
|
||||||
|
|
||||||
if (ChildNode is SharpQueryNodeNotSupported) |
|
||||||
{ |
|
||||||
addNode = this.ShowUnsupported(); |
|
||||||
} |
|
||||||
|
|
||||||
if (addNode == true) |
|
||||||
{ |
|
||||||
this.Nodes.Add(ChildNode as TreeNode); |
|
||||||
ChildNode.Refresh(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
protected bool ShowUnsupported() |
|
||||||
{ |
|
||||||
// AddInTreeNode AddinNode;
|
|
||||||
bool ret = true; |
|
||||||
|
|
||||||
// AddinNode = AddInTree.GetTreeNode("/SharpQuery/Connection");
|
|
||||||
// foreach ( DictionaryEntry entryChild in AddinNode.ChildNodes)
|
|
||||||
// {
|
|
||||||
// AddInTreeNode ChildNode = entryChild.Value as AddInTreeNode;
|
|
||||||
// if ( ChildNode != null )
|
|
||||||
// {
|
|
||||||
// SharpQueryConnectionCodon codon = ChildNode.Codon as SharpQueryConnectionCodon;
|
|
||||||
// if ( codon != null )
|
|
||||||
// {
|
|
||||||
// if ( codon.Node == this.GetType().FullName )
|
|
||||||
// {
|
|
||||||
// ret = bool.Parse( codon.ShowUnsuported );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
return ret; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,66 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Luc Morin" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using SharpQuery.Collections; |
|
||||||
using SharpQuery.Connection; |
|
||||||
using SharpQuery.SchemaClass; |
|
||||||
|
|
||||||
namespace SharpQuery.Gui.TreeView |
|
||||||
{ |
|
||||||
public interface ISharpQueryNode |
|
||||||
{ |
|
||||||
///<summary>
|
|
||||||
/// <returns> Path to a string #develop menu command object.</returns>
|
|
||||||
/// <remarks>You should add this extension path in the addin file.</remarks>
|
|
||||||
/// </summary>
|
|
||||||
string AddinContextMenu { get; } |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// His schema class from wich to displayed data informations.
|
|
||||||
///</summary>
|
|
||||||
ISchemaClass SchemaClass { get; } |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// the <see cref=".ISharpQueryNode.SchemaClass">SchemaClass</see>'s connection.
|
|
||||||
///</summary>
|
|
||||||
IConnection Connection { get; } |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Those, are list of the childs schema.( columns, etc etc )
|
|
||||||
/// i am using a dictionnary because is more simplest to write
|
|
||||||
/// <code>Entities["PROCEDURES"]</code> than <code>Entities[0]</code>.
|
|
||||||
///</summary>
|
|
||||||
SharpQueryListDictionary Entities { get; } |
|
||||||
|
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Calls the <see cref=".ISharpQueryNode.Clear()">Clear()</see> method.
|
|
||||||
/// Calls the <see cref=".ISchemaClass.Refresh()">Refresh()</see> method of his <see cref=".ISharpQueryNode.SchemaClass">SchemaClass</see> member.
|
|
||||||
/// Calls the <see cref=".ISchemaClass.BuildsChilds()">BuildsChild()</see> method.
|
|
||||||
/// </summary>
|
|
||||||
void Refresh(); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Calls the <code>Clear()</code> method of each child nodes.
|
|
||||||
/// Calls the <see cref=".ISchemaClass.Clear()">Clear()</see> methode of his <see cref=".ISharpQueryNode.SchemaClass">SchemaClass</see> member.
|
|
||||||
/// Remove each child nodes.
|
|
||||||
/// </summary>
|
|
||||||
void Clear(); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// For a Table or a View extract data.
|
|
||||||
/// For a stocked procedure, execute it :o).
|
|
||||||
/// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
|
|
||||||
/// </summary>
|
|
||||||
void Execute(int rows); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Builds childs <see cref=".ISharpQueryNode">ISharpQueryNode</see>
|
|
||||||
/// </summary>
|
|
||||||
void BuildsChilds(); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,75 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Luc Morin" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Data; |
|
||||||
using System.Windows.Forms; |
|
||||||
|
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.SharpDevelop.Gui.XmlForms; |
|
||||||
using SharpQuery.Collections; |
|
||||||
using SharpQuery.SchemaClass; |
|
||||||
|
|
||||||
namespace SharpQuery.Gui.DataView |
|
||||||
{ |
|
||||||
public class SQLParameterInput : XmlForm |
|
||||||
{ |
|
||||||
private DataGrid _dataGrid = null; |
|
||||||
|
|
||||||
public DataGrid dataGrid |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
if (this._dataGrid == null) |
|
||||||
{ |
|
||||||
this._dataGrid = this.ControlDictionary["dataGrid"] as DataGrid; |
|
||||||
} |
|
||||||
return this._dataGrid; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private void ResetClick(object sender, EventArgs e) |
|
||||||
{ |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
protected void FillParameters(SharpQueryParameterCollection parameters) |
|
||||||
{ |
|
||||||
SharpQueryParameter par = null; |
|
||||||
for (int i = 0; i < parameters.Count; i++) |
|
||||||
{ |
|
||||||
par = parameters[i]; |
|
||||||
if (par.Type == ParameterDirection.ReturnValue) |
|
||||||
{ |
|
||||||
i--; |
|
||||||
parameters.Remove(par); |
|
||||||
} |
|
||||||
} |
|
||||||
this.dataGrid.CaptionVisible = true; |
|
||||||
this.dataGrid.DataSource = parameters; |
|
||||||
this.dataGrid.DataMember = null; |
|
||||||
this.dataGrid.AllowNavigation = false; |
|
||||||
} |
|
||||||
|
|
||||||
public SQLParameterInput() |
|
||||||
{ |
|
||||||
SetupFromXmlResource(PropertyService.DataDirectory + @"\resources\dialogs\SharpQuery\SqlParametersInput.xfrm"); |
|
||||||
} |
|
||||||
|
|
||||||
public SQLParameterInput(SharpQueryParameterCollection parameters) |
|
||||||
: this() |
|
||||||
{ |
|
||||||
this.FillParameters(parameters); |
|
||||||
} |
|
||||||
|
|
||||||
protected override void SetupXmlLoader() |
|
||||||
{ |
|
||||||
xmlLoader.StringValueFilter = new SharpDevelopStringValueFilter(); |
|
||||||
xmlLoader.PropertyValueCreator = new SharpDevelopPropertyValueCreator(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,233 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Luc Morin" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Data; |
|
||||||
using System.Windows.Forms; |
|
||||||
|
|
||||||
using ICSharpCode.SharpDevelop.Gui; |
|
||||||
using SharpQuery.Collections; |
|
||||||
using SharpQuery.SchemaClass; |
|
||||||
|
|
||||||
namespace SharpQuery.Gui.DataView |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// Description of the view content
|
|
||||||
/// </summary>
|
|
||||||
public class SharpQueryDataView : AbstractViewContent |
|
||||||
{ |
|
||||||
DataGrid pDataGrid; |
|
||||||
ISchemaClass pSchema; |
|
||||||
|
|
||||||
#region AbstractViewContent requirements
|
|
||||||
/// <summary>
|
|
||||||
/// The <see cref="System.Windows.Forms.Control"/> representing the view
|
|
||||||
/// </summary>
|
|
||||||
///
|
|
||||||
public override object Control |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return pDataGrid; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a new MyView object
|
|
||||||
/// </summary>
|
|
||||||
public SharpQueryDataView(ISchemaClass entity, int lines, SharpQuerySchemaClassCollection parameters) |
|
||||||
{ |
|
||||||
if (entity == null) |
|
||||||
{ |
|
||||||
throw new ArgumentNullException("entity"); |
|
||||||
} |
|
||||||
|
|
||||||
TitleName = SharpQuery.SchemaClass.AbstractSharpQuerySchemaClass.RemoveBracket(entity.NormalizedName); |
|
||||||
|
|
||||||
this.pDataGrid = new DataGrid(); |
|
||||||
this.pDataGrid.CaptionVisible = true; |
|
||||||
this.pDataGrid.DataMember = ""; |
|
||||||
this.pDataGrid.Dock = System.Windows.Forms.DockStyle.Fill; |
|
||||||
this.pDataGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText; |
|
||||||
this.pDataGrid.Location = new System.Drawing.Point(0, 0); |
|
||||||
this.pDataGrid.Name = "dataGrid"; |
|
||||||
this.pDataGrid.Size = new System.Drawing.Size(292, 266); |
|
||||||
this.pDataGrid.TabIndex = 0; |
|
||||||
this.Schema = entity; |
|
||||||
this.Datatable = this.Schema.Execute(lines, parameters); |
|
||||||
// if ( this.Datatable == null )
|
|
||||||
// {
|
|
||||||
// WorkbenchSingleton.Workbench.ViewContentCollection.Remove( this );
|
|
||||||
// }
|
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Loads a new file into MyView
|
|
||||||
/// </summary>
|
|
||||||
public override void Load(ICSharpCode.SharpDevelop.OpenedFile file, System.IO.Stream stream) |
|
||||||
{ |
|
||||||
throw new System.NotImplementedException(); |
|
||||||
//base.Load(file, stream);
|
|
||||||
} |
|
||||||
// public override void Load(string fileName)
|
|
||||||
// {
|
|
||||||
// // TODO
|
|
||||||
// throw new System.NotImplementedException();
|
|
||||||
// }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Cleans up all used resources
|
|
||||||
/// </summary>
|
|
||||||
public override void Dispose() |
|
||||||
{ |
|
||||||
// TODO: Clean up resources in this method
|
|
||||||
pDataGrid.Dispose(); |
|
||||||
} |
|
||||||
#endregion
|
|
||||||
|
|
||||||
public ISchemaClass Schema |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return this.pSchema; |
|
||||||
} |
|
||||||
set |
|
||||||
{ |
|
||||||
this.pSchema = value; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// <see cref="System.Data.DataTable">DataTable</see> to display in the
|
|
||||||
/// <see cref="System.Windows.Forms.DataGrid">DataGrid</see>
|
|
||||||
/// </summary>
|
|
||||||
public object Datatable |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return this.pDataGrid.DataSource; |
|
||||||
} |
|
||||||
|
|
||||||
set |
|
||||||
{ |
|
||||||
removeChangedHandler(); |
|
||||||
|
|
||||||
this.pDataGrid.DataSource = value; |
|
||||||
this.pDataGrid.DataMember = null; |
|
||||||
this.pDataGrid.AllowNavigation = true; |
|
||||||
|
|
||||||
DataSet dataset = this.pDataGrid.DataSource as DataSet; |
|
||||||
|
|
||||||
if (dataset != null) |
|
||||||
{ |
|
||||||
if (dataset.Tables.Count == 1) |
|
||||||
{ |
|
||||||
this.pDataGrid.DataMember = dataset.Tables[0].TableName; |
|
||||||
this.pDataGrid.AllowNavigation = false; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
addChangedHandler(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private void removeChangedHandler() |
|
||||||
{ |
|
||||||
if (this.pDataGrid.DataSource != null) |
|
||||||
{ |
|
||||||
DataSet dataset = this.pDataGrid.DataSource as DataSet; |
|
||||||
|
|
||||||
if (dataset != null) |
|
||||||
{ |
|
||||||
foreach (DataTable table in dataset.Tables) |
|
||||||
{ |
|
||||||
table.RowChanged -= new DataRowChangeEventHandler(this.UpdateTable); |
|
||||||
table.RowDeleted -= new DataRowChangeEventHandler(this.DeleteRow); |
|
||||||
} |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
(this.pDataGrid.DataSource as DataTable).RowChanged -= new DataRowChangeEventHandler(this.UpdateTable); |
|
||||||
(this.pDataGrid.DataSource as DataTable).RowDeleted -= new DataRowChangeEventHandler(this.DeleteRow); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
private void addChangedHandler() |
|
||||||
{ |
|
||||||
if (this.pDataGrid.DataSource != null) |
|
||||||
{ |
|
||||||
DataSet dataset = this.pDataGrid.DataSource as DataSet; |
|
||||||
|
|
||||||
if (dataset != null) |
|
||||||
{ |
|
||||||
foreach (DataTable table in dataset.Tables) |
|
||||||
{ |
|
||||||
table.RowChanged += new DataRowChangeEventHandler(this.UpdateTable); |
|
||||||
table.RowDeleted += new DataRowChangeEventHandler(this.DeleteRow); |
|
||||||
} |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
(this.pDataGrid.DataSource as DataTable).RowChanged += new DataRowChangeEventHandler(this.UpdateTable); |
|
||||||
(this.pDataGrid.DataSource as DataTable).RowDeleted += new DataRowChangeEventHandler(this.DeleteRow); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void UpdateTable(object sender, DataRowChangeEventArgs e) |
|
||||||
{ |
|
||||||
if (Datatable != null) |
|
||||||
{ |
|
||||||
switch (e.Action) |
|
||||||
{ |
|
||||||
case DataRowAction.Add: |
|
||||||
this.Schema.Connection.InsertRow(this.Schema, e.Row); |
|
||||||
break; |
|
||||||
case DataRowAction.Change: |
|
||||||
this.Schema.Connection.UpDateRow(this.Schema, e.Row); |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void DeleteRow(object sender, DataRowChangeEventArgs e) |
|
||||||
{ |
|
||||||
switch (e.Action) |
|
||||||
{ |
|
||||||
case DataRowAction.Delete: |
|
||||||
this.Schema.Connection.DeleteRow(this.Schema, e.Row); |
|
||||||
break; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
public override void Save(ICSharpCode.SharpDevelop.OpenedFile file, System.IO.Stream stream) |
|
||||||
{ |
|
||||||
throw new System.NotImplementedException(); |
|
||||||
//base.Save(file, stream);
|
|
||||||
} |
|
||||||
/* |
|
||||||
public override void Save(string fileName) |
|
||||||
{ |
|
||||||
DataSet dataset = this.pDataGrid.DataSource as DataSet; |
|
||||||
if (dataset == null) |
|
||||||
{ |
|
||||||
DataTable dataTable = this.pDataGrid.DataSource as DataTable; |
|
||||||
if (dataTable != null) |
|
||||||
{ |
|
||||||
dataset = new DataSet(); |
|
||||||
dataset.Tables.Add(dataTable); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
dataset.WriteXml(fileName); |
|
||||||
} |
|
||||||
*/ |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,66 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Luc Morin" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Windows.Forms; |
|
||||||
using ICSharpCode.SharpDevelop.Gui; |
|
||||||
using SharpQuery.Gui.TreeView; |
|
||||||
|
|
||||||
//TODO : dans les SharpQueryList faire correspondre les restrictions vec les objets ajoutés
|
|
||||||
//TODO : dans les SharpQueryList faire correspondre les dataconnection avec les objets ajoutés
|
|
||||||
//TODO : ajout statistiques.
|
|
||||||
|
|
||||||
namespace SharpQuery.Pads |
|
||||||
{ |
|
||||||
/// <summary>
|
|
||||||
/// This Pad Show a tree where you can add/remove databases connections.
|
|
||||||
/// You can administrate databases from this tree.
|
|
||||||
/// </summary>
|
|
||||||
public class SharpQueryPad : AbstractPadContent |
|
||||||
{ |
|
||||||
private static SharpQueryTree sharpQueryTree = null; |
|
||||||
#region AbstractPadContent requirements
|
|
||||||
/// <summary>
|
|
||||||
/// The <see cref="System.Windows.Forms.Control"/> representing the pad
|
|
||||||
/// </summary>
|
|
||||||
public override object Control |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return sharpQueryTree; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Creates a new SharpQueryPad object
|
|
||||||
/// </summary>
|
|
||||||
public SharpQueryPad() |
|
||||||
{ |
|
||||||
CreateDefaultSharpQuery(); |
|
||||||
sharpQueryTree.Dock = DockStyle.Fill; |
|
||||||
} |
|
||||||
|
|
||||||
void CreateDefaultSharpQuery() |
|
||||||
{ |
|
||||||
sharpQueryTree = new SharpQueryTree(); |
|
||||||
} |
|
||||||
|
|
||||||
public void SaveSharpQueryView() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Cleans up all used resources
|
|
||||||
/// </summary>
|
|
||||||
public override void Dispose() |
|
||||||
{ |
|
||||||
this.SaveSharpQueryView(); |
|
||||||
sharpQueryTree.Dispose(); |
|
||||||
} |
|
||||||
#endregion
|
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,255 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Luc Morin" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.ComponentModel; |
|
||||||
using System.Windows.Forms; |
|
||||||
|
|
||||||
using ICSharpCode.SharpDevelop.Gui; |
|
||||||
using SharpQuery.Collections; |
|
||||||
using SharpQuery.Gui.DataView; |
|
||||||
using SharpQuery.SchemaClass; |
|
||||||
|
|
||||||
namespace SharpQuery.Gui.TreeView |
|
||||||
{ |
|
||||||
///<summary>
|
|
||||||
/// Column Node
|
|
||||||
///</summary>
|
|
||||||
public class SharpQueryNodeColumn : AbstractSharpQueryNode |
|
||||||
{ |
|
||||||
///<summary> force to displayed a "+" for the node</summary>
|
|
||||||
protected override bool NullChildAllowed |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override string AddinContextMenu |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return "/SharpQuery/ContextMenu/Column"; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryNodeColumn(SharpQueryColumn sharpQueryColumn) |
|
||||||
: base(sharpQueryColumn) |
|
||||||
{ |
|
||||||
this.ImageIndex = 9; |
|
||||||
this.SelectedImageIndex = 9; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Parameter Node
|
|
||||||
///</summary>
|
|
||||||
public class SharpQueryNodeParameter : AbstractSharpQueryNode |
|
||||||
{ |
|
||||||
|
|
||||||
///<summary> force to displayed a "+" for the node</summary>
|
|
||||||
protected override bool NullChildAllowed |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override string AddinContextMenu |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return "/SharpQuery/ContextMenu/Parameter"; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryNodeParameter(SharpQueryParameter sharpQueryParameter) |
|
||||||
: base(sharpQueryParameter) |
|
||||||
{ |
|
||||||
this.ImageIndex = 9; |
|
||||||
this.SelectedImageIndex = 9; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Table Node
|
|
||||||
///</summary>
|
|
||||||
public class SharpQueryNodeTable : AbstractSharpQueryNode |
|
||||||
{ |
|
||||||
public override string AddinContextMenu |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return "/SharpQuery/ContextMenu/Table"; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryNodeTable(SharpQueryTable sharpQueryTable) |
|
||||||
: base(sharpQueryTable) |
|
||||||
{ |
|
||||||
this.ImageIndex = 6; |
|
||||||
this.SelectedImageIndex = 6; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// View Node
|
|
||||||
///</summary>
|
|
||||||
public class SharpQueryNodeView : AbstractSharpQueryNode |
|
||||||
{ |
|
||||||
public override string AddinContextMenu |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return "/SharpQuery/ContextMenu/View"; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryNodeView(SharpQueryView sharpQueryView) |
|
||||||
: base(sharpQueryView) |
|
||||||
{ |
|
||||||
this.ImageIndex = 7; |
|
||||||
this.SelectedImageIndex = 7; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Procedure Node
|
|
||||||
///</summary>
|
|
||||||
public class SharpQueryNodeProcedure : AbstractSharpQueryNode |
|
||||||
{ |
|
||||||
|
|
||||||
public override string AddinContextMenu |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return "/SharpQuery/ContextMenu/Procedure"; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryNodeProcedure(SharpQueryProcedure sharpQueryProcedure) |
|
||||||
: base(sharpQueryProcedure) |
|
||||||
{ |
|
||||||
this.ImageIndex = 8; |
|
||||||
this.SelectedImageIndex = 8; |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// allow the user to add some parameters while executing an SQL command
|
|
||||||
/// </summary>
|
|
||||||
protected override SharpQuerySchemaClassCollection OnExecute(CancelEventArgs e) |
|
||||||
{ |
|
||||||
SharpQuerySchemaClassCollection tmp = this.SchemaClass.GetSchemaParameters(); |
|
||||||
SharpQueryParameterCollection parameters = null; |
|
||||||
SharpQuerySchemaClassCollection returnValue = null; |
|
||||||
|
|
||||||
if (tmp.Count == 1 && tmp[0] is SharpQueryNotSupported) |
|
||||||
{ |
|
||||||
parameters = new SharpQueryParameterCollection(); |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
parameters = new SharpQueryParameterCollection(); |
|
||||||
foreach (SharpQueryParameter par in tmp) |
|
||||||
parameters.Add(par); |
|
||||||
} |
|
||||||
|
|
||||||
if (parameters != null && parameters.Count > 0) |
|
||||||
{ |
|
||||||
inputform = new SQLParameterInput(parameters); |
|
||||||
inputform.Owner = (Form)WorkbenchSingleton.Workbench; |
|
||||||
|
|
||||||
if (inputform.ShowDialog() != DialogResult.OK) |
|
||||||
{ |
|
||||||
returnValue = null; |
|
||||||
e.Cancel = true; |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
returnValue = new SharpQuerySchemaClassCollection(); |
|
||||||
foreach (SharpQueryParameter par in parameters) |
|
||||||
{ |
|
||||||
returnValue.Add(par); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
return returnValue; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Node displayed when a function is not supported by the provider!
|
|
||||||
///</summary>
|
|
||||||
public class SharpQueryNodeNotSupported : AbstractSharpQueryNode |
|
||||||
{ |
|
||||||
|
|
||||||
///<summary> force to displayed a "+" for the node</summary>
|
|
||||||
protected override bool NullChildAllowed |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return false; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryNodeNotSupported(SharpQueryNotSupported sharpQueryNotSupported) |
|
||||||
: base(sharpQueryNotSupported) |
|
||||||
{ |
|
||||||
this.ImageIndex = 10; |
|
||||||
this.SelectedImageIndex = 10; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Schema Node
|
|
||||||
///</summary>
|
|
||||||
public class SharpQueryNodeSchema : AbstractSharpQueryNode |
|
||||||
{ |
|
||||||
public override string AddinContextMenu |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return "/SharpQuery/ContextMenu/Schema"; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryNodeSchema(SharpQuerySchema schema) |
|
||||||
: base(schema) |
|
||||||
{ |
|
||||||
this.ImageIndex = 1; |
|
||||||
this.SelectedImageIndex = 1; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Catalog Node
|
|
||||||
///</summary>
|
|
||||||
public class SharpQueryNodeCatalog : AbstractSharpQueryNode |
|
||||||
{ |
|
||||||
public override string AddinContextMenu |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return "/SharpQuery/ContextMenu/Catalog"; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryNodeCatalog(SharpQueryCatalog catalog) |
|
||||||
: base(catalog) |
|
||||||
{ |
|
||||||
this.ImageIndex = 1; |
|
||||||
this.SelectedImageIndex = 1; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
} |
|
||||||
@ -1,385 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Luc Morin" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
// created on 04/11/2003 at 17:29
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Reflection; |
|
||||||
using System.Windows.Forms; |
|
||||||
|
|
||||||
using ICSharpCode.Core; |
|
||||||
using SharpQuery.Collections; |
|
||||||
using SharpQuery.Connection; |
|
||||||
using SharpQuery.Exceptions; |
|
||||||
using SharpQuery.SchemaClass; |
|
||||||
|
|
||||||
namespace SharpQuery.Gui.TreeView |
|
||||||
{ |
|
||||||
///<summary>
|
|
||||||
/// this is the root of all others nodes!
|
|
||||||
///</summary>
|
|
||||||
public class SharpQueryNodeDatabaseRoot : AbstractSharpQueryNode |
|
||||||
{ |
|
||||||
public override string AddinContextMenu |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return "/SharpQuery/ContextMenu/DatabaseRoot"; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override string entityName |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return StringParser.Parse("${res:SharpQuery.Label.DataBasesRoot}"); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryNodeDatabaseRoot() |
|
||||||
: base(null) |
|
||||||
{ |
|
||||||
this.Text = this.entityName; |
|
||||||
|
|
||||||
this.ImageIndex = 0; |
|
||||||
this.SelectedImageIndex = 0; |
|
||||||
} |
|
||||||
|
|
||||||
public override void Refresh() |
|
||||||
{ |
|
||||||
this.Text = this.entityName; |
|
||||||
|
|
||||||
foreach (ISharpQueryNode node in this.Nodes) |
|
||||||
{ |
|
||||||
node.Refresh(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override void Clear() |
|
||||||
{ |
|
||||||
foreach (ISharpQueryNode node in this.Nodes) |
|
||||||
{ |
|
||||||
node.Clear(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override void BuildsChilds() |
|
||||||
{ |
|
||||||
IConnection connection = null; |
|
||||||
ISharpQueryNode node = null; |
|
||||||
|
|
||||||
try |
|
||||||
{ |
|
||||||
connection = AbstractSharpQueryConnectionWrapper.CreateFromDataConnectionLink(); |
|
||||||
|
|
||||||
if (connection != null) |
|
||||||
{ |
|
||||||
string ChildClass = ""; |
|
||||||
|
|
||||||
if (SharpQueryTree.SchemaClassDict.ContainsKey(connection.GetType().FullName) == true) |
|
||||||
{ |
|
||||||
ChildClass = SharpQueryTree.SchemaClassDict[connection.GetType().FullName]; |
|
||||||
} |
|
||||||
|
|
||||||
if ((ChildClass != null) && (ChildClass != "")) |
|
||||||
{ |
|
||||||
node = (ISharpQueryNode)ass.CreateInstance(ChildClass, false, BindingFlags.CreateInstance, null, new object[] { connection }, null, null); |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
node = new SharpQueryNodeNotSupported(new SharpQueryNotSupported(connection, "", "", "", connection.GetType().FullName)); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
//TODO : do an interface for the node connection!
|
|
||||||
(node as SharpQueryNodeConnection).Connect(); |
|
||||||
this.Nodes.Add(node as TreeNode); |
|
||||||
node.Refresh(); |
|
||||||
|
|
||||||
if (node.Connection.IsConnectionStringWrong == true) |
|
||||||
{ |
|
||||||
this.Nodes.Remove(node as TreeNode); |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
this.Expand(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
catch (ConnectionStringException e) |
|
||||||
{ |
|
||||||
if (this.Nodes.Contains(node as TreeNode) == true) |
|
||||||
{ |
|
||||||
this.Nodes.Remove(node as TreeNode); |
|
||||||
} |
|
||||||
MessageService.ShowError(e.Message); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Root nodes for a connection to a database
|
|
||||||
///</summary>
|
|
||||||
public class SharpQueryNodeConnection : AbstractSharpQueryNode |
|
||||||
{ |
|
||||||
IConnection pConnection = null; |
|
||||||
|
|
||||||
public override string entityNormalizedName |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
if (this.pConnection != null) |
|
||||||
{ |
|
||||||
return this.pConnection.NormalizedName; |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
return ""; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override string entityName |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
if (this.pConnection != null) |
|
||||||
{ |
|
||||||
return this.pConnection.Name; |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
return ""; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override IConnection Connection |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
if (this.pConnection != null) |
|
||||||
{ |
|
||||||
return this.pConnection; |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override SharpQueryListDictionary Entities |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
if (this.Connection != null) |
|
||||||
{ |
|
||||||
return this.Connection.Entities; |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override string AddinContextMenu |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return "/SharpQuery/ContextMenu/DatabaseConnection"; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryNodeConnection(IConnection dataConnection) |
|
||||||
: base(null) |
|
||||||
{ |
|
||||||
this.pConnection = dataConnection; |
|
||||||
this.ImageIndex = 1; |
|
||||||
this.SelectedImageIndex = 1; |
|
||||||
} |
|
||||||
|
|
||||||
public bool IsConnected |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return this.Connection.IsOpen; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void Disconnect() |
|
||||||
{ |
|
||||||
if (this.IsConnected == true) |
|
||||||
{ |
|
||||||
this.Collapse(); |
|
||||||
this.Clear(); |
|
||||||
this.Connection.Close(); |
|
||||||
this.ImageIndex = 1; |
|
||||||
this.SelectedImageIndex = 1; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public void Connect() |
|
||||||
{ |
|
||||||
try |
|
||||||
{ |
|
||||||
if (this.IsConnected == false) |
|
||||||
{ |
|
||||||
if (this.Connection.Open()) |
|
||||||
{ |
|
||||||
this.Refresh(); |
|
||||||
this.ImageIndex = 2; |
|
||||||
this.SelectedImageIndex = 2; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
catch (OpenConnectionException e) |
|
||||||
{ |
|
||||||
MessageService.ShowError(e.Message); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
protected override void OnRefresh() |
|
||||||
{ |
|
||||||
if (this.IsConnected == true) |
|
||||||
{ |
|
||||||
this.Clear(); |
|
||||||
this.Connection.Refresh(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override void Clear() |
|
||||||
{ |
|
||||||
if (this.Connection != null) |
|
||||||
{ |
|
||||||
this.Connection.Clear(); |
|
||||||
} |
|
||||||
|
|
||||||
base.Clear(); |
|
||||||
} |
|
||||||
|
|
||||||
public void RemoveConnection() |
|
||||||
{ |
|
||||||
this.Disconnect(); |
|
||||||
this.pConnection = null; |
|
||||||
|
|
||||||
this.Parent.Nodes.Remove(this); |
|
||||||
} |
|
||||||
|
|
||||||
public void ModifyConnection() |
|
||||||
{ |
|
||||||
IConnection Oldconnection = this.pConnection; |
|
||||||
bool error = false; |
|
||||||
try |
|
||||||
{ |
|
||||||
IConnection connection = null; |
|
||||||
|
|
||||||
connection = AbstractSharpQueryConnectionWrapper.UpDateFromDataConnectionLink(this.Connection); |
|
||||||
|
|
||||||
if (connection != null) |
|
||||||
{ |
|
||||||
this.Disconnect(); |
|
||||||
this.pConnection = connection; |
|
||||||
this.Refresh(); |
|
||||||
error = this.pConnection.IsConnectionStringWrong; |
|
||||||
} |
|
||||||
} |
|
||||||
catch (ConnectionStringException e) |
|
||||||
{ |
|
||||||
error = true; |
|
||||||
MessageService.ShowError(e.Message); |
|
||||||
} |
|
||||||
finally |
|
||||||
{ |
|
||||||
if (error == true) |
|
||||||
{ |
|
||||||
this.pConnection = Oldconnection; |
|
||||||
this.Connect(); |
|
||||||
this.Refresh(); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Tables Root Node
|
|
||||||
///</summary>
|
|
||||||
public class SharpQueryNodeTableRoot : AbstractSharpQueryNode |
|
||||||
{ |
|
||||||
///<summary>
|
|
||||||
/// Addin Path of the node's context menu
|
|
||||||
///</summary>
|
|
||||||
public override string AddinContextMenu |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return "/SharpQuery/ContextMenu/TablesRoot"; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryNodeTableRoot(AbstractSharpQuerySchemaClass databaseclass) |
|
||||||
: base(databaseclass) |
|
||||||
{ |
|
||||||
this.ImageIndex = 3; |
|
||||||
this.SelectedImageIndex = 3; |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Views Root Node
|
|
||||||
///</summary>
|
|
||||||
public class SharpQueryNodeViewRoot : AbstractSharpQueryNode |
|
||||||
{ |
|
||||||
///<summary>
|
|
||||||
/// Addin Path of the node's context menu
|
|
||||||
///</summary>
|
|
||||||
public override string AddinContextMenu |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return "/SharpQuery/ContextMenu/ViewsRoot"; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryNodeViewRoot(AbstractSharpQuerySchemaClass databaseclass) |
|
||||||
: base(databaseclass) |
|
||||||
{ |
|
||||||
this.ImageIndex = 4; |
|
||||||
this.SelectedImageIndex = 4; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Procedure Root Node
|
|
||||||
///</summary>
|
|
||||||
public class SharpQueryNodeProcedureRoot : AbstractSharpQueryNode |
|
||||||
{ |
|
||||||
///<summary>
|
|
||||||
/// Addin Path of the node's context menu
|
|
||||||
///</summary>
|
|
||||||
public override string AddinContextMenu |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return "/SharpQuery/ContextMenu/ProceduresRoot"; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryNodeProcedureRoot(AbstractSharpQuerySchemaClass databaseclass) |
|
||||||
: base(databaseclass) |
|
||||||
{ |
|
||||||
this.ImageIndex = 5; |
|
||||||
this.SelectedImageIndex = 5; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
} |
|
||||||
@ -1,172 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Luc Morin" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
// created on 04/11/2003 at 16:05
|
|
||||||
using ICSharpCode.Core.WinForms; |
|
||||||
using System; |
|
||||||
using System.Windows.Forms; |
|
||||||
using ICSharpCode.Core; |
|
||||||
using ICSharpCode.SharpDevelop; |
|
||||||
using SharpQuery.Collections; |
|
||||||
|
|
||||||
namespace SharpQuery.Gui.TreeView |
|
||||||
{ |
|
||||||
///<summary>
|
|
||||||
/// This class shows all databases connections in a treeview.
|
|
||||||
///</summary>
|
|
||||||
public class SharpQueryTree : System.Windows.Forms.TreeView |
|
||||||
{ |
|
||||||
private System.Windows.Forms.ImageList pNodeImages; |
|
||||||
|
|
||||||
public static SharpQueryStringDictionary SchemaClassDict; |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Create a SharpQueryTree objec
|
|
||||||
///</summary>
|
|
||||||
public SharpQueryTree() |
|
||||||
: base() |
|
||||||
{ |
|
||||||
this.pNodeImages = new ImageList(); |
|
||||||
this.pNodeImages.ColorDepth = System.Windows.Forms.ColorDepth.Depth24Bit; |
|
||||||
this.pNodeImages.ImageSize = new System.Drawing.Size(16, 16); |
|
||||||
this.pNodeImages.TransparentColor = System.Drawing.Color.DarkCyan; |
|
||||||
|
|
||||||
this.pNodeImages.Images.Add(IconService.GetBitmap("Icons.16x16.SharpQuery.DataBaseRoot")); |
|
||||||
this.pNodeImages.Images.Add(IconService.GetBitmap("Icons.16x16.SharpQuery.DatabaseConnectionClose")); |
|
||||||
this.pNodeImages.Images.Add(IconService.GetBitmap("Icons.16x16.SharpQuery.DatabaseConnection")); |
|
||||||
this.pNodeImages.Images.Add(IconService.GetBitmap("Icons.16x16.SharpQuery.TablesRoot")); |
|
||||||
this.pNodeImages.Images.Add(IconService.GetBitmap("Icons.16x16.SharpQuery.ViewsRoot")); |
|
||||||
this.pNodeImages.Images.Add(IconService.GetBitmap("Icons.16x16.SharpQuery.ProceduresRoot")); |
|
||||||
this.pNodeImages.Images.Add(IconService.GetBitmap("Icons.16x16.SharpQuery.Table")); |
|
||||||
this.pNodeImages.Images.Add(IconService.GetBitmap("Icons.16x16.SharpQuery.View")); |
|
||||||
this.pNodeImages.Images.Add(IconService.GetBitmap("Icons.16x16.SharpQuery.Procedure")); |
|
||||||
this.pNodeImages.Images.Add(IconService.GetBitmap("Icons.16x16.SharpQuery.Column")); |
|
||||||
this.pNodeImages.Images.Add(IconService.GetBitmap("Icons.16x16.SharpQuery.NodeError")); |
|
||||||
|
|
||||||
this.ImageList = this.pNodeImages; |
|
||||||
|
|
||||||
SchemaClassDict = new SharpQueryStringDictionary(); |
|
||||||
|
|
||||||
LoadSharpQueryConnectionCodon(); |
|
||||||
|
|
||||||
//Add the Root Node.
|
|
||||||
this.Nodes.Add(new SharpQueryNodeDatabaseRoot()); |
|
||||||
} |
|
||||||
|
|
||||||
protected void LoadSharpQueryConnectionCodon() |
|
||||||
{ |
|
||||||
AddInTreeNode AddinNode = AddInTree.GetTreeNode("/SharpQuery/Connection"); |
|
||||||
LoggingService.Info("Building SharpQuery Codons..."); |
|
||||||
foreach (Codon c in AddinNode.Codons) |
|
||||||
{ |
|
||||||
if (c.Properties["schema"] != null && c.Properties["schema"] != string.Empty) |
|
||||||
{ |
|
||||||
if (SchemaClassDict.ContainsKey(c.Properties["schema"])) |
|
||||||
{ |
|
||||||
SchemaClassDict[c.Properties["schema"]] = c.Properties["node"]; |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
SchemaClassDict.Add(c.Properties["schema"], c.Properties["node"]); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Select the node under the mouse cursor
|
|
||||||
///</summary>
|
|
||||||
protected override void OnMouseDown(MouseEventArgs e) |
|
||||||
{ |
|
||||||
if (e.Button == MouseButtons.Right || e.Button == MouseButtons.Left) |
|
||||||
{ |
|
||||||
this.SelectedNode = this.GetNodeAt(e.X, e.Y); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
base.OnMouseDown(e); |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Display the context menu associated with a node type
|
|
||||||
///</summary>
|
|
||||||
protected override void OnMouseUp(MouseEventArgs e) |
|
||||||
{ |
|
||||||
if (e.Button == MouseButtons.Right && this.SelectedNode != null && SelectedNode is ISharpQueryNode) |
|
||||||
{ |
|
||||||
ISharpQueryNode selectedBrowserNode = SelectedNode as ISharpQueryNode; |
|
||||||
if (selectedBrowserNode.AddinContextMenu != "") |
|
||||||
{ |
|
||||||
MenuService.ShowContextMenu(this, selectedBrowserNode.AddinContextMenu, this, e.X, e.Y); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
base.OnMouseUp(e); |
|
||||||
} |
|
||||||
|
|
||||||
protected override void OnItemDrag(ItemDragEventArgs e) |
|
||||||
{ |
|
||||||
base.OnItemDrag(e); |
|
||||||
AbstractSharpQueryNode node = e.Item as AbstractSharpQueryNode; |
|
||||||
if (node != null) |
|
||||||
{ |
|
||||||
DataObject dataObject = null; |
|
||||||
|
|
||||||
if (node.SchemaClass != null) |
|
||||||
{ |
|
||||||
dataObject = node.SchemaClass.DragObject; |
|
||||||
|
|
||||||
if (dataObject != null) |
|
||||||
{ |
|
||||||
dataObject.SetData(node.GetType(), node); |
|
||||||
DoDragDrop(dataObject, DragDropEffects.All); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
protected override void OnBeforeExpand(TreeViewCancelEventArgs e) |
|
||||||
{ |
|
||||||
SharpQueryNodeConnection node = e.Node as SharpQueryNodeConnection; |
|
||||||
|
|
||||||
if (node != null) |
|
||||||
{ |
|
||||||
if (node.IsConnected == false) |
|
||||||
{ |
|
||||||
node.Connect(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
base.OnBeforeExpand(e); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
protected override void OnAfterExpand(TreeViewEventArgs e) |
|
||||||
{ |
|
||||||
ISharpQueryNode node = e.Node as ISharpQueryNode; |
|
||||||
|
|
||||||
if (node != null) |
|
||||||
{ |
|
||||||
node.Refresh(); |
|
||||||
} |
|
||||||
|
|
||||||
base.OnAfterExpand(e); |
|
||||||
} |
|
||||||
|
|
||||||
protected override void OnAfterCollapse(TreeViewEventArgs e) |
|
||||||
{ |
|
||||||
ISharpQueryNode node = e.Node as ISharpQueryNode; |
|
||||||
|
|
||||||
if (node != null) |
|
||||||
{ |
|
||||||
node.Clear(); |
|
||||||
} |
|
||||||
|
|
||||||
base.OnAfterCollapse(e); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,145 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Luc Morin" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System.Windows.Forms; |
|
||||||
using SharpQuery.Collections; |
|
||||||
using SharpQuery.Connection; |
|
||||||
|
|
||||||
namespace SharpQuery.SchemaClass |
|
||||||
{ |
|
||||||
///<summary>
|
|
||||||
/// This interface is used by any schema class in sharp query.
|
|
||||||
/// A schema class is a class that is the database definition of a <code>table</code>,
|
|
||||||
/// a <code>view</code>, a <code>column</code>, etc etc ...
|
|
||||||
/// <remarks>
|
|
||||||
/// <code>entity</code> is <code>table</code>, a <code>view</code> or other database struct.
|
|
||||||
/// <code>schema</code>'s names are displayed between <code>[</code> and <code>]</code>
|
|
||||||
/// </remarks>
|
|
||||||
///</summary>
|
|
||||||
public interface ISchemaClass |
|
||||||
{ |
|
||||||
///<summary>
|
|
||||||
/// get the connection object
|
|
||||||
///</summary>
|
|
||||||
IConnection Connection { get; } |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// get the <code>entity</code>'s <code>catalog</code> name.
|
|
||||||
///</summary>
|
|
||||||
string CatalogName { get; } |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// get the <code>entity</code>'s <code>schema</code> name.
|
|
||||||
///</summary>
|
|
||||||
string SchemaName { get; } |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Get the <code>entity</code>'s owner name
|
|
||||||
/// <example>
|
|
||||||
/// for exemple, the owner of a <code>column</code> is a <code>table</code>,
|
|
||||||
/// and this property return the name of the <code>table</code>
|
|
||||||
///</example>
|
|
||||||
///</summary>
|
|
||||||
string OwnerName { get; } |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// get the <code>entity</code>'s name
|
|
||||||
///</summary>
|
|
||||||
string Name { get; } |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Internal name, used internally
|
|
||||||
/// </summary>
|
|
||||||
string InternalName { get; } |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// <code>entity</code>'s normalized name.
|
|
||||||
/// <example>
|
|
||||||
/// there are a database <code>test</code>. In this database there are a <code>schema</code>
|
|
||||||
/// named <code>fool</code>. In this <code>schema</code> there are a <code>table</code> named <code>fooltable</code>
|
|
||||||
/// and a in this <code>table</code> there are a <code>column</code> named <code>foolcolumn</code>.
|
|
||||||
/// So, the normalized name of the <code>schema</code> is <code>test.[fool]</code>.
|
|
||||||
/// The normalized name of the <code>table</code> is <code>test.[fool].fooltable</code>.
|
|
||||||
/// The normalized name of the <code>column</code> is <code>test.[fool].fooltable.foolcolumn</code>.
|
|
||||||
///</example>
|
|
||||||
///</summary>
|
|
||||||
string NormalizedName { get; } |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Those, are list of the childs schema.( columns, etc etc )
|
|
||||||
/// i am using a dictionnary because is more simplest to write
|
|
||||||
/// <code>Entities["PROCEDURES"]</code> than <code>Entities[0]</code>.
|
|
||||||
///</summary>
|
|
||||||
SharpQueryListDictionary Entities { get; } |
|
||||||
|
|
||||||
///<summary> return a <see cref="System.Windows.Forms.DataObject">DataObject</see> </summary>
|
|
||||||
DataObject DragObject { get; } |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Refresh child schemas from the database.
|
|
||||||
///</summary>
|
|
||||||
void Refresh(); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Erase all child schemas
|
|
||||||
///</summary>
|
|
||||||
void Clear(); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// For a Table or a View extract data.
|
|
||||||
/// For a stocked procedure, execute it :o).
|
|
||||||
/// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
|
|
||||||
/// <returns><see cref="System.Data.DataTable">DataTable</see>
|
|
||||||
/// or a <see cref="System.Data.DataSet">DataSet</see> </returns>
|
|
||||||
/// </summary>
|
|
||||||
object Execute(int rows, SharpQuerySchemaClassCollection parameters); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Get <seealso cref='.ISchemaClass.Connection'/>'s catalogs.
|
|
||||||
///</summary>
|
|
||||||
SharpQuerySchemaClassCollection GetSchemaCatalogs(); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Get <seealso cref='.ISchemaClass.Connection'/>'s Schemas.
|
|
||||||
///</summary>
|
|
||||||
SharpQuerySchemaClassCollection GetSchemaSchemas(); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// From a catalog object, get tables from all schemas.
|
|
||||||
/// From a schema object get tables from all this schema.
|
|
||||||
/// From other object, return an empty list.
|
|
||||||
///</summary>
|
|
||||||
SharpQuerySchemaClassCollection GetSchemaTables(); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// From a catalog object, get views from all schemas.
|
|
||||||
/// From a schema object get views from all this schema.
|
|
||||||
/// From other object, return an empty list.
|
|
||||||
///</summary>
|
|
||||||
SharpQuerySchemaClassCollection GetSchemaViews(); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// From a catalog object, get procedures from all schemas.
|
|
||||||
/// From a schema object get procedures from all this schema.
|
|
||||||
/// From other object, return an empty list.
|
|
||||||
///</summary>
|
|
||||||
SharpQuerySchemaClassCollection GetSchemaProcedures(); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// From a table or a view or procedure object, get columns from the table.
|
|
||||||
/// From other object, return an empty list.
|
|
||||||
///</summary>
|
|
||||||
SharpQuerySchemaClassCollection GetSchemaColumns(); |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Get parameters from the procedure.
|
|
||||||
/// If parameters are not supported by the schema, return an empty list.
|
|
||||||
///</summary>
|
|
||||||
SharpQuerySchemaClassCollection GetSchemaParameters(); |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
@ -1,197 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Luc Morin" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using SharpQuery.Gui.TreeView; |
|
||||||
|
|
||||||
namespace SharpQuery.Commands |
|
||||||
{ |
|
||||||
public class SharpQueryRefreshCommand : AbstractSharpQueryCommand |
|
||||||
{ |
|
||||||
public override bool IsEnabled |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return base.IsEnabled && (this.sharpQueryNode is AbstractSharpQueryNode) |
|
||||||
&& (this.sharpQueryNode as AbstractSharpQueryNode).Connection != null |
|
||||||
&& (this.sharpQueryNode as AbstractSharpQueryNode).Connection.IsOpen == true; |
|
||||||
} |
|
||||||
set { } |
|
||||||
} |
|
||||||
/// <summary>
|
|
||||||
/// Refresh the selected <see cref="SharpQuery.Gui.TreeView.ISharpQueryNode">node</see> of the <see cref="SharpQuery.Gui.TreeView.SharpQueryTree"> SharpQuery Tree.</see>
|
|
||||||
/// </summary>
|
|
||||||
public override void Run() |
|
||||||
{ |
|
||||||
(this.sharpQueryNode as ISharpQueryNode).Refresh(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Add a connection to a database server into the <see cref="SharpQuery.Gui.TreeView.SharpQueryTree"></see>
|
|
||||||
/// </summary>
|
|
||||||
public class SharpQueryAddconnectionCommand : AbstractSharpQueryCommand |
|
||||||
{ |
|
||||||
|
|
||||||
public override bool IsEnabled |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return base.IsEnabled && (this.sharpQueryNode is SharpQueryNodeDatabaseRoot); |
|
||||||
} |
|
||||||
set { } |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Add a connection to a database server into the <see cref="SharpQuery.Gui.TreeView.SharpQueryTree"></see>
|
|
||||||
/// </summary>
|
|
||||||
public override void Run() |
|
||||||
{ |
|
||||||
try { |
|
||||||
(this.sharpQueryNode as SharpQueryNodeDatabaseRoot).BuildsChilds(); |
|
||||||
} catch (System.IO.FileNotFoundException ex) { |
|
||||||
if (ex.ToString().Contains("ADODB")) { |
|
||||||
ICSharpCode.Core.MessageService.ShowError("ADODB is not installed on your computer.\n" + |
|
||||||
"Please install the .NET Framework SDK; or install " + |
|
||||||
"the ADODB assembly into the GAC."); |
|
||||||
} else { |
|
||||||
throw; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Remove a connection from a database server into the <see cref="SharpQuery.Gui.TreeView.SharpQueryTree"></see>
|
|
||||||
/// </summary>
|
|
||||||
public class SharpQueryRemoveConnectionCommand : AbstractSharpQueryCommand |
|
||||||
{ |
|
||||||
public override bool IsEnabled |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return base.IsEnabled && (this.sharpQueryNode is SharpQueryNodeConnection); |
|
||||||
} |
|
||||||
set { } |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Remove a connection from a database server into the <see cref="SharpQuery.Gui.TreeView.SharpQueryTree"></see>
|
|
||||||
/// </summary>
|
|
||||||
public override void Run() |
|
||||||
{ |
|
||||||
(this.sharpQueryNode as SharpQueryNodeConnection).RemoveConnection(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Remove a connection from a database server into the <see cref="SharpQuery.Gui.TreeView.SharpQueryTree"></see>
|
|
||||||
/// </summary>
|
|
||||||
public class SharpQueryModifyConnectionCommand : AbstractSharpQueryCommand |
|
||||||
{ |
|
||||||
|
|
||||||
public override bool IsEnabled |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return base.IsEnabled && (this.sharpQueryNode is SharpQueryNodeConnection); |
|
||||||
} |
|
||||||
set { } |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Remove a connection from a database server into the <see cref="SharpQuery.Gui.TreeView.SharpQueryTree"></see>
|
|
||||||
/// </summary>
|
|
||||||
public override void Run() |
|
||||||
{ |
|
||||||
(this.sharpQueryNode as SharpQueryNodeConnection).ModifyConnection(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Disconnect From a database server
|
|
||||||
/// </summary>
|
|
||||||
public class SharpQueryDisconnectCommand : AbstractSharpQueryCommand |
|
||||||
{ |
|
||||||
|
|
||||||
public override bool IsEnabled |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return base.IsEnabled && (this.sharpQueryNode is SharpQueryNodeConnection) |
|
||||||
&& (this.sharpQueryNode as SharpQueryNodeConnection).IsConnected == true; |
|
||||||
} |
|
||||||
set { } |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryDisconnectCommand() |
|
||||||
: base() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Disconnect From a database server
|
|
||||||
/// </summary>
|
|
||||||
public override void Run() |
|
||||||
{ |
|
||||||
(this.sharpQueryNode as SharpQueryNodeConnection).Disconnect(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Disconnect From a database server
|
|
||||||
/// </summary>
|
|
||||||
public class SharpQueryConnectCommand : AbstractSharpQueryCommand |
|
||||||
{ |
|
||||||
|
|
||||||
public override bool IsEnabled |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return base.IsEnabled && (this.sharpQueryNode is SharpQueryNodeConnection) |
|
||||||
&& (this.sharpQueryNode as SharpQueryNodeConnection).IsConnected == false; |
|
||||||
} |
|
||||||
set { } |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryConnectCommand() |
|
||||||
: base() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Disconnect From a database server
|
|
||||||
/// </summary>
|
|
||||||
public override void Run() |
|
||||||
{ |
|
||||||
(this.sharpQueryNode as SharpQueryNodeConnection).Connect(); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Disconnect From a database server
|
|
||||||
/// </summary>
|
|
||||||
public class SharpQueryExecuteCommand : AbstractSharpQueryCommand |
|
||||||
{ |
|
||||||
public SharpQueryExecuteCommand() |
|
||||||
: base() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Disconnect From a database server
|
|
||||||
/// </summary>
|
|
||||||
public override void Run() |
|
||||||
{ |
|
||||||
this.sharpQueryNode.Execute(0); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
} |
|
||||||
@ -1,796 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Luc Morin" email=""/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using System.Data; |
|
||||||
using System.Windows.Forms; |
|
||||||
|
|
||||||
using ICSharpCode.Core; |
|
||||||
using SharpQuery.Collections; |
|
||||||
using SharpQuery.Connection; |
|
||||||
|
|
||||||
namespace SharpQuery.SchemaClass |
|
||||||
{ |
|
||||||
//
|
|
||||||
// Children
|
|
||||||
//
|
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Column class
|
|
||||||
///</summary>
|
|
||||||
public class SharpQueryColumn : AbstractSharpQuerySchemaClass |
|
||||||
{ |
|
||||||
public override string NormalizedName |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
string normalizedName = ""; |
|
||||||
|
|
||||||
if ((this.OwnerName != "") && (this.OwnerName != null)) |
|
||||||
{ |
|
||||||
normalizedName += this.OwnerName + "."; |
|
||||||
} |
|
||||||
|
|
||||||
normalizedName += this.Name; |
|
||||||
|
|
||||||
return normalizedName; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
protected override void CreateEntitiesList() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryColumn(IConnection connection, string catalogName, string schemaName, string ownerName, string name) |
|
||||||
: base(connection, catalogName, schemaName, ownerName, name) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
protected override void OnRefresh() |
|
||||||
{ |
|
||||||
//nothing !
|
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// For a Table or a View extract data.
|
|
||||||
/// For a stocked procedure, execute it :o).
|
|
||||||
/// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
|
|
||||||
/// <returns><see cref="System.Data.DataTable">DataTable</see>
|
|
||||||
/// or a <see cref="System.Data.DataSet">DataSet</see> </returns>
|
|
||||||
/// </summary>
|
|
||||||
public override object Execute(int rows, SharpQuerySchemaClassCollection parameters) |
|
||||||
{ |
|
||||||
//nothing
|
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
///<summary> return a <see cref="System.Windows.Forms.DataObject">DataObject</see>
|
|
||||||
///</summary>
|
|
||||||
public override DataObject DragObject |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
DataObject returnValue = new DataObject(); |
|
||||||
string extract = this.NormalizedName; |
|
||||||
returnValue.SetData(typeof(string), extract); |
|
||||||
return returnValue; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Procedurre's parameters class
|
|
||||||
///</summary>
|
|
||||||
public class SharpQueryParameter : AbstractSharpQuerySchemaClass |
|
||||||
{ |
|
||||||
private DbType _dataType; |
|
||||||
private object _value = null; |
|
||||||
private ParameterDirection _type; |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Data Type of the parameter
|
|
||||||
/// ( used only while extracting data or executing procedure )
|
|
||||||
///</summary>
|
|
||||||
public DbType DataType |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return this._dataType; |
|
||||||
} |
|
||||||
set |
|
||||||
{ |
|
||||||
this._dataType = value; |
|
||||||
switch (value) |
|
||||||
{ |
|
||||||
//string type
|
|
||||||
case DbType.AnsiString: |
|
||||||
case DbType.AnsiStringFixedLength: |
|
||||||
case DbType.String: |
|
||||||
case DbType.StringFixedLength: this._value = new string((char[])null); break; |
|
||||||
//array type
|
|
||||||
case DbType.Binary: this._value = new byte[8000]; break; |
|
||||||
//bool type
|
|
||||||
case DbType.Boolean: this._value = new bool(); break; |
|
||||||
//interger type
|
|
||||||
case DbType.SByte: this._value = new sbyte(); break; |
|
||||||
case DbType.Byte: this._value = new byte(); break; |
|
||||||
case DbType.Int16: this._value = new short(); break; |
|
||||||
case DbType.Int32: this._value = new int(); break; |
|
||||||
case DbType.Int64: this._value = new long(); break; |
|
||||||
case DbType.UInt16: this._value = new ushort(); break; |
|
||||||
case DbType.UInt32: this._value = new uint(); break; |
|
||||||
case DbType.UInt64: this._value = new long(); break; |
|
||||||
//Date type
|
|
||||||
case DbType.Date: |
|
||||||
case DbType.DateTime: |
|
||||||
case DbType.Time: this._value = new DateTime(); break; |
|
||||||
//float type
|
|
||||||
case DbType.Decimal: this._value = new decimal(); break; |
|
||||||
case DbType.Currency: |
|
||||||
case DbType.VarNumeric: |
|
||||||
case DbType.Double: this._value = new double(); break; |
|
||||||
case DbType.Single: this._value = new float(); break; |
|
||||||
//user defined
|
|
||||||
case DbType.Object: this._value = new object(); break; |
|
||||||
//Guid
|
|
||||||
case DbType.Guid: this._value = new Guid(); break; |
|
||||||
default: throw new ArgumentOutOfRangeException("value"); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
protected void SetValue(string value) |
|
||||||
{ |
|
||||||
switch (this.DataType) |
|
||||||
{ |
|
||||||
//string type
|
|
||||||
case DbType.Object: |
|
||||||
case DbType.Binary: |
|
||||||
case DbType.AnsiString: |
|
||||||
case DbType.AnsiStringFixedLength: |
|
||||||
case DbType.String: |
|
||||||
case DbType.StringFixedLength: this._value = value; break; |
|
||||||
|
|
||||||
case DbType.Boolean: this._value = bool.Parse(value); break; |
|
||||||
|
|
||||||
case DbType.SByte: this._value = sbyte.Parse(value); break; |
|
||||||
case DbType.Byte: this._value = byte.Parse(value); break; |
|
||||||
case DbType.Int16: this._value = short.Parse(value); break; |
|
||||||
case DbType.Int32: this._value = int.Parse(value); break; |
|
||||||
case DbType.Int64: this._value = long.Parse(value); break; |
|
||||||
case DbType.UInt16: this._value = ushort.Parse(value); break; |
|
||||||
case DbType.UInt32: this._value = uint.Parse(value); break; |
|
||||||
case DbType.UInt64: this._value = long.Parse(value); break; |
|
||||||
|
|
||||||
case DbType.Date: |
|
||||||
case DbType.DateTime: |
|
||||||
case DbType.Time: this._value = DateTime.Parse(value); break; |
|
||||||
|
|
||||||
case DbType.Decimal: this._value = decimal.Parse(value); break; |
|
||||||
case DbType.Currency: |
|
||||||
case DbType.VarNumeric: |
|
||||||
case DbType.Double: this._value = double.Parse(value); break; |
|
||||||
case DbType.Single: this._value = float.Parse(value); break; |
|
||||||
|
|
||||||
case DbType.Guid: this._value = new Guid(value); break; |
|
||||||
default: throw new ArgumentOutOfRangeException("value"); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Value of the parameter
|
|
||||||
/// ( used only while extracting data or executing procedure )
|
|
||||||
///</summary>
|
|
||||||
public object Value |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return this._value; |
|
||||||
} |
|
||||||
set |
|
||||||
{ |
|
||||||
this.SetValue(value.ToString()); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Value of the parameter
|
|
||||||
/// ( used only while extracting data or executing procedure )
|
|
||||||
///</summary>
|
|
||||||
public ParameterDirection Type |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
return this._type; |
|
||||||
} |
|
||||||
set |
|
||||||
{ |
|
||||||
this._type = value; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public override string NormalizedName |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
string normalizedName = ""; |
|
||||||
|
|
||||||
if ((this.OwnerName != "") && (this.OwnerName != null)) |
|
||||||
{ |
|
||||||
normalizedName += this.OwnerName + "."; |
|
||||||
} |
|
||||||
|
|
||||||
normalizedName += this.Name; |
|
||||||
|
|
||||||
return normalizedName; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
protected override void CreateEntitiesList() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryParameter(IConnection connection, string catalogName, string schemaName, string ownerName, string name) |
|
||||||
: base(connection, catalogName, schemaName, ownerName, name) |
|
||||||
{ |
|
||||||
this.pEntities = null; |
|
||||||
} |
|
||||||
|
|
||||||
protected override void OnRefresh() |
|
||||||
{ |
|
||||||
//nothing !
|
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// For a Table or a View extract data.
|
|
||||||
/// For a stocked procedure, execute it :o).
|
|
||||||
/// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
|
|
||||||
/// <returns><see cref="System.Data.DataTable">DataTable</see></returns>
|
|
||||||
/// </summary>
|
|
||||||
public override object Execute(int rows, SharpQuerySchemaClassCollection parameters) |
|
||||||
{ |
|
||||||
//nothing
|
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
///<summary> return a <see cref="System.Windows.Forms.DataObject">DataObject</see>
|
|
||||||
///</summary>
|
|
||||||
public override DataObject DragObject |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
DataObject returnValue = new DataObject(); |
|
||||||
string extract = NormalizedName; |
|
||||||
returnValue.SetData(typeof(string), extract); |
|
||||||
return returnValue; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Table class
|
|
||||||
///</summary>
|
|
||||||
public class SharpQueryProcedure : AbstractSharpQuerySchemaClass |
|
||||||
{ |
|
||||||
public override string NormalizedName |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
if ((this.CatalogName != "") && (this.CatalogName != null)) |
|
||||||
{ |
|
||||||
return this.CatalogName + "." + this.Name; |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
return CheckWhiteSpace(this.Connection.GetProperty(AbstractSharpQueryConnectionWrapper.SharpQueryPropertyEnum.DataSource).ToString()) + "." + this.Name; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
protected override void CreateEntitiesList() |
|
||||||
{ |
|
||||||
base.CreateEntitiesList(); |
|
||||||
this.pEntities.Add("PROCEDURE_COLUMNS", new SharpQuerySchemaClassCollection()); |
|
||||||
this.pEntities.Add("PROCEDURE_PARAMETERS", new SharpQuerySchemaClassCollection()); |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryProcedure(IConnection connection, string catalogName, string schemaName, string ownerName, string name) |
|
||||||
: base(connection, catalogName, schemaName, ownerName, name) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public override SharpQuerySchemaClassCollection GetSchemaParameters() |
|
||||||
{ |
|
||||||
return this.pDataConnection.GetSchemaProcedureParameters(this); |
|
||||||
} |
|
||||||
|
|
||||||
public override SharpQuerySchemaClassCollection GetSchemaColumns() |
|
||||||
{ |
|
||||||
return this.pDataConnection.GetSchemaProcedureColumns(this); |
|
||||||
} |
|
||||||
|
|
||||||
protected override void OnRefresh() |
|
||||||
{ |
|
||||||
this.Entities["PROCEDURE_COLUMNS"].AddRange(this.GetSchemaColumns()); |
|
||||||
this.Entities["PROCEDURE_PARAMETERS"].AddRange(this.GetSchemaParameters()); |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// For a Table or a View extract data.
|
|
||||||
/// For a stocked procedure, execute it :o).
|
|
||||||
/// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
|
|
||||||
/// <returns><see cref="System.Data.DataTable">DataTable</see>
|
|
||||||
/// or a <see cref="System.Data.DataSet">DataSet</see> </returns>
|
|
||||||
/// </summary>
|
|
||||||
public override object Execute(int rows, SharpQuerySchemaClassCollection parameters) |
|
||||||
{ |
|
||||||
return this.Connection.ExecuteProcedure(this, rows, parameters); |
|
||||||
} |
|
||||||
|
|
||||||
///<summary> return a <see cref="System.Windows.Forms.DataObject">DataObject</see>
|
|
||||||
///</summary>
|
|
||||||
public override DataObject DragObject |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
DataObject returnValue = new DataObject(); |
|
||||||
string extract = "EXECUTE " + NormalizedName; |
|
||||||
returnValue.SetData(typeof(string), extract); |
|
||||||
return returnValue; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Table class
|
|
||||||
///</summary>
|
|
||||||
public class SharpQueryTable : AbstractSharpQuerySchemaClass |
|
||||||
{ |
|
||||||
public override string NormalizedName |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
if ((this.CatalogName != "") && (this.CatalogName != null)) |
|
||||||
{ |
|
||||||
return this.CatalogName + "." + this.Name; |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
return CheckWhiteSpace(this.Connection.GetProperty(AbstractSharpQueryConnectionWrapper.SharpQueryPropertyEnum.DataSource).ToString()) + "." + this.Name; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
protected override void CreateEntitiesList() |
|
||||||
{ |
|
||||||
base.CreateEntitiesList(); |
|
||||||
this.pEntities.Add("TABLE_COLUMNS", new SharpQuerySchemaClassCollection()); |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryTable(IConnection connection, string catalogName, string schemaName, string ownerName, string name) |
|
||||||
: base(connection, catalogName, schemaName, ownerName, name) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public override SharpQuerySchemaClassCollection GetSchemaColumns() |
|
||||||
{ |
|
||||||
return this.pDataConnection.GetSchemaTableColumns(this); |
|
||||||
} |
|
||||||
|
|
||||||
protected override void OnRefresh() |
|
||||||
{ |
|
||||||
this.Entities["TABLE_COLUMNS"].AddRange(this.GetSchemaColumns()); |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// For a Table or a View extract data.
|
|
||||||
/// For a stocked procedure, execute it :o).
|
|
||||||
/// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
|
|
||||||
/// <returns><see cref="System.Data.DataTable">DataTable</see>
|
|
||||||
/// or a <see cref="System.Data.DataSet">DataSet</see> </returns>
|
|
||||||
/// </summary>
|
|
||||||
public override object Execute(int rows, SharpQuerySchemaClassCollection parameters) |
|
||||||
{ |
|
||||||
return this.Connection.ExtractData(this, rows); |
|
||||||
} |
|
||||||
|
|
||||||
///<summary> return a <see cref="System.Windows.Forms.DataObject">DataObject</see>
|
|
||||||
///</summary>
|
|
||||||
public override DataObject DragObject |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
string SQLSelect = "SELECT "; |
|
||||||
string SQLFrom = "FROM "; |
|
||||||
|
|
||||||
SharpQuerySchemaClassCollection entitieslist = null; |
|
||||||
|
|
||||||
SQLFrom += this.Name; |
|
||||||
|
|
||||||
this.Refresh(); |
|
||||||
|
|
||||||
//we have only a table or view :o)
|
|
||||||
foreach (KeyValuePair<string, SharpQuerySchemaClassCollection> DicEntry in Entities) |
|
||||||
{ |
|
||||||
entitieslist = DicEntry.Value as SharpQuerySchemaClassCollection; |
|
||||||
break; |
|
||||||
} |
|
||||||
|
|
||||||
if (entitieslist == null) |
|
||||||
{ |
|
||||||
throw new System.ArgumentNullException("entitieslist"); |
|
||||||
} |
|
||||||
|
|
||||||
foreach (ISchemaClass column in entitieslist) |
|
||||||
{ |
|
||||||
SQLSelect += column.NormalizedName; |
|
||||||
SQLSelect += ","; |
|
||||||
} |
|
||||||
|
|
||||||
SQLSelect = SQLSelect.TrimEnd(new Char[] { ',' }); |
|
||||||
SQLSelect += " "; |
|
||||||
|
|
||||||
DataObject returnValue = new DataObject(); |
|
||||||
|
|
||||||
returnValue.SetData(typeof(string), SQLSelect + SQLFrom); |
|
||||||
return returnValue; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// View class
|
|
||||||
///</summary>
|
|
||||||
public class SharpQueryView : AbstractSharpQuerySchemaClass |
|
||||||
{ |
|
||||||
public override string NormalizedName |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
if ((this.CatalogName != "") && (this.CatalogName != null)) |
|
||||||
{ |
|
||||||
return this.CatalogName + "." + this.Name; |
|
||||||
} |
|
||||||
else |
|
||||||
{ |
|
||||||
return CheckWhiteSpace(this.Connection.GetProperty(AbstractSharpQueryConnectionWrapper.SharpQueryPropertyEnum.DataSource).ToString()) + "." + this.Name; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
protected override void CreateEntitiesList() |
|
||||||
{ |
|
||||||
base.CreateEntitiesList(); |
|
||||||
this.pEntities.Add("VIEWS_COLUMNS", new SharpQuerySchemaClassCollection()); |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryView(IConnection connection, string catalogName, string schemaName, string ownerName, string name) |
|
||||||
: base(connection, catalogName, schemaName, ownerName, name) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public override SharpQuerySchemaClassCollection GetSchemaColumns() |
|
||||||
{ |
|
||||||
return this.pDataConnection.GetSchemaViewColumns(this); |
|
||||||
} |
|
||||||
|
|
||||||
protected override void OnRefresh() |
|
||||||
{ |
|
||||||
this.Entities["VIEWS_COLUMNS"].AddRange(this.GetSchemaColumns()); |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// For a Table or a View extract data.
|
|
||||||
/// For a stocked procedure, execute it :o).
|
|
||||||
/// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
|
|
||||||
/// <returns><see cref="System.Data.DataTable">DataTable</see>
|
|
||||||
/// or a <see cref="System.Data.DataSet">DataSet</see> </returns>
|
|
||||||
/// </summary>
|
|
||||||
public override object Execute(int rows, SharpQuerySchemaClassCollection parameters) |
|
||||||
{ |
|
||||||
return this.Connection.ExtractData(this, rows); |
|
||||||
} |
|
||||||
|
|
||||||
///<summary> return a <see cref="System.Windows.Forms.DataObject">DataObject</see>
|
|
||||||
///</summary>
|
|
||||||
public override DataObject DragObject |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
string SQLSelect = "SELECT "; |
|
||||||
string SQLFrom = "FROM "; |
|
||||||
|
|
||||||
SharpQuerySchemaClassCollection entitieslist = null; |
|
||||||
|
|
||||||
SQLFrom += this.Name; |
|
||||||
|
|
||||||
this.Refresh(); |
|
||||||
|
|
||||||
//we have only a table or view :o)
|
|
||||||
foreach (KeyValuePair<string, SharpQuerySchemaClassCollection> DicEntry in Entities) |
|
||||||
{ |
|
||||||
entitieslist = DicEntry.Value as SharpQuerySchemaClassCollection; |
|
||||||
break; |
|
||||||
} |
|
||||||
|
|
||||||
if (entitieslist == null) |
|
||||||
{ |
|
||||||
throw new System.ArgumentNullException("entitieslist"); |
|
||||||
} |
|
||||||
|
|
||||||
foreach (ISchemaClass column in entitieslist) |
|
||||||
{ |
|
||||||
SQLSelect += column.NormalizedName; |
|
||||||
SQLSelect += ","; |
|
||||||
} |
|
||||||
|
|
||||||
SQLSelect = SQLSelect.TrimEnd(new Char[] { ',' }); |
|
||||||
SQLSelect += " "; |
|
||||||
|
|
||||||
DataObject returnValue = new DataObject(); |
|
||||||
|
|
||||||
returnValue.SetData(typeof(string), SQLSelect + SQLFrom); |
|
||||||
return returnValue; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Class for unsupported functions
|
|
||||||
///</summary>
|
|
||||||
public class SharpQueryNotSupported : AbstractSharpQuerySchemaClass |
|
||||||
{ |
|
||||||
protected override void CreateEntitiesList() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryNotSupported(IConnection connection, string catalogName, string schemaName, string ownerName, string name) |
|
||||||
: base(connection, catalogName, schemaName, ownerName, name) |
|
||||||
{ |
|
||||||
this.pName += " " + StringParser.Parse("${res:SharpQuery.Error.NotSuported}") + " " + connection.Provider; |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
protected override void OnRefresh() |
|
||||||
{ |
|
||||||
//nothing !
|
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// For a Table or a View extract data.
|
|
||||||
/// For a stocked procedure, execute it :o).
|
|
||||||
/// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
|
|
||||||
/// <returns><see cref="System.Data.DataTable">DataTable</see>
|
|
||||||
/// or a <see cref="System.Data.DataSet">DataSet</see> </returns>
|
|
||||||
/// </summary>
|
|
||||||
public override object Execute(int rows, SharpQuerySchemaClassCollection parameters) |
|
||||||
{ |
|
||||||
//nothing
|
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Class lis of Tables
|
|
||||||
///</summary>
|
|
||||||
public class SharpQueryTables : AbstractSharpQuerySchemaClass |
|
||||||
{ |
|
||||||
protected override void CreateEntitiesList() |
|
||||||
{ |
|
||||||
base.CreateEntitiesList(); |
|
||||||
this.pEntities.Add("TABLES", new SharpQuerySchemaClassCollection()); |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryTables(IConnection connection, string catalogName, string schemaName, string ownerName, string name) |
|
||||||
: base(connection, catalogName, schemaName, ownerName, name) |
|
||||||
{ |
|
||||||
this.pName = StringParser.Parse("${res:SharpQuery.Label.TablesRoot}"); |
|
||||||
} |
|
||||||
|
|
||||||
protected override void OnRefresh() |
|
||||||
{ |
|
||||||
this.Entities["TABLES"].AddRange(this.GetSchemaTables()); |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// For a Table or a View extract data.
|
|
||||||
/// For a stocked procedure, execute it :o).
|
|
||||||
/// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
|
|
||||||
/// <returns><see cref="System.Data.DataTable">DataTable</see>
|
|
||||||
/// or a <see cref="System.Data.DataSet">DataSet</see> </returns>
|
|
||||||
/// </summary>
|
|
||||||
public override object Execute(int rows, SharpQuerySchemaClassCollection parameters) |
|
||||||
{ |
|
||||||
//nothing
|
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Class lis of Views
|
|
||||||
///</summary>
|
|
||||||
public class SharpQueryViews : AbstractSharpQuerySchemaClass |
|
||||||
{ |
|
||||||
|
|
||||||
protected override void CreateEntitiesList() |
|
||||||
{ |
|
||||||
base.CreateEntitiesList(); |
|
||||||
this.pEntities.Add("VIEWS", new SharpQuerySchemaClassCollection()); |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryViews(IConnection connection, string catalogName, string schemaName, string ownerName, string name) |
|
||||||
: base(connection, catalogName, schemaName, ownerName, name) |
|
||||||
{ |
|
||||||
this.pName = StringParser.Parse("${res:SharpQuery.Label.ViewsRoot}"); |
|
||||||
} |
|
||||||
|
|
||||||
protected override void OnRefresh() |
|
||||||
{ |
|
||||||
this.Entities["VIEWS"].AddRange(this.GetSchemaViews()); |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// For a Table or a View extract data.
|
|
||||||
/// For a stocked procedure, execute it :o).
|
|
||||||
/// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
|
|
||||||
/// <returns><see cref="System.Data.DataTable">DataTable</see>
|
|
||||||
/// or a <see cref="System.Data.DataSet">DataSet</see> </returns>
|
|
||||||
/// </summary>
|
|
||||||
public override object Execute(int rows, SharpQuerySchemaClassCollection parameters) |
|
||||||
{ |
|
||||||
//nothing
|
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Class lis of Procedures
|
|
||||||
///</summary>
|
|
||||||
public class SharpQueryProcedures : AbstractSharpQuerySchemaClass |
|
||||||
{ |
|
||||||
protected override void CreateEntitiesList() |
|
||||||
{ |
|
||||||
base.CreateEntitiesList(); |
|
||||||
this.pEntities.Add("PROCEDURES", new SharpQuerySchemaClassCollection()); |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryProcedures(IConnection connection, string catalogName, string schemaName, string ownerName, string name) |
|
||||||
: base(connection, catalogName, schemaName, ownerName, name) |
|
||||||
{ |
|
||||||
this.pName = StringParser.Parse("${res:SharpQuery.Label.ProceduresRoot}"); |
|
||||||
} |
|
||||||
|
|
||||||
protected override void OnRefresh() |
|
||||||
{ |
|
||||||
this.Entities["PROCEDURES"].AddRange(this.GetSchemaProcedures()); |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// For a Table or a View extract data.
|
|
||||||
/// For a stocked procedure, execute it :o).
|
|
||||||
/// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
|
|
||||||
/// <returns><see cref="System.Data.DataTable">DataTable</see>
|
|
||||||
/// or a <see cref="System.Data.DataSet">DataSet</see> </returns>
|
|
||||||
/// </summary>
|
|
||||||
public override object Execute(int rows, SharpQuerySchemaClassCollection parameters) |
|
||||||
{ |
|
||||||
//nothing
|
|
||||||
return null; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Class lis of Schemas
|
|
||||||
///</summary>
|
|
||||||
public class SharpQuerySchema : AbstractSharpQuerySchemaClass |
|
||||||
{ |
|
||||||
protected override void CreateEntitiesList() |
|
||||||
{ |
|
||||||
base.CreateEntitiesList(); |
|
||||||
|
|
||||||
SharpQuerySchemaClassCollection cl; |
|
||||||
cl = new SharpQuerySchemaClassCollection(); |
|
||||||
cl.Add(new SharpQueryTables(this.pDataConnection, this.CatalogName, this.Name, "", "")); |
|
||||||
this.pEntities.Add("TABLES", cl); |
|
||||||
|
|
||||||
cl = new SharpQuerySchemaClassCollection(); |
|
||||||
cl.Add(new SharpQueryViews(this.pDataConnection, this.CatalogName, this.Name, "", "")); |
|
||||||
this.pEntities.Add("VIEWS", cl); |
|
||||||
|
|
||||||
cl = new SharpQuerySchemaClassCollection(); |
|
||||||
cl.Add(new SharpQueryProcedures(this.pDataConnection, this.CatalogName, this.Name, "", "")); |
|
||||||
this.pEntities.Add("PROCEDURES", cl); |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQuerySchema(IConnection connection, string catalogName, string schemaName, string ownerName, string name) |
|
||||||
: base(connection, catalogName, schemaName, ownerName, name) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
protected override void OnRefresh() |
|
||||||
{ |
|
||||||
// Nothing !
|
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// For a Table or a View extract data.
|
|
||||||
/// For a stocked procedure, execute it :o).
|
|
||||||
/// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
|
|
||||||
/// <returns><see cref="System.Data.DataTable">DataTable</see>
|
|
||||||
/// or a <see cref="System.Data.DataSet">DataSet</see> </returns>
|
|
||||||
/// </summary>
|
|
||||||
public override object Execute(int rows, SharpQuerySchemaClassCollection parameters) |
|
||||||
{ |
|
||||||
//nothing
|
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
///<summary> return a <see cref="System.Windows.Forms.DataObject">DataObject</see>
|
|
||||||
///</summary>
|
|
||||||
public override DataObject DragObject |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
DataObject returnValue = new DataObject(); |
|
||||||
string extract = NormalizedName; |
|
||||||
returnValue.SetData(typeof(string), extract); |
|
||||||
return returnValue; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// Class for a catalog
|
|
||||||
///</summary>
|
|
||||||
public class SharpQueryCatalog : AbstractSharpQuerySchemaClass |
|
||||||
{ |
|
||||||
protected override void CreateEntitiesList() |
|
||||||
{ |
|
||||||
base.CreateEntitiesList(); |
|
||||||
this.pEntities.Add("SCHEMAS", new SharpQuerySchemaClassCollection()); |
|
||||||
} |
|
||||||
|
|
||||||
public SharpQueryCatalog(IConnection connection, string catalogName, string schemaName, string ownerName, string name) |
|
||||||
: base(connection, catalogName, schemaName, ownerName, name) |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
protected override void OnRefresh() |
|
||||||
{ |
|
||||||
this.Entities["SCHEMAS"].AddRange(this.GetSchemaSchemas()); |
|
||||||
} |
|
||||||
|
|
||||||
///<summary>
|
|
||||||
/// For a Table or a View extract data.
|
|
||||||
/// For a stocked procedure, execute it :o).
|
|
||||||
/// <param name="rows">Number of row to extract. if "0", extract all rows.</param>
|
|
||||||
/// <returns><see cref="System.Data.DataTable">DataTable</see>
|
|
||||||
/// or a <see cref="System.Data.DataSet">DataSet</see> </returns>
|
|
||||||
/// </summary>
|
|
||||||
public override object Execute(int rows, SharpQuerySchemaClassCollection parameters) |
|
||||||
{ |
|
||||||
//nothing
|
|
||||||
return null; |
|
||||||
} |
|
||||||
|
|
||||||
///<summary> return a <see cref="System.Windows.Forms.DataObject">DataObject</see>
|
|
||||||
///</summary>
|
|
||||||
public override DataObject DragObject |
|
||||||
{ |
|
||||||
get |
|
||||||
{ |
|
||||||
DataObject returnValue = new DataObject(); |
|
||||||
string extract = NormalizedName; |
|
||||||
returnValue.SetData(typeof(string), extract); |
|
||||||
return returnValue; |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
||||||
Loading…
Reference in new issue