Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5229 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
48 changed files with 0 additions and 4605 deletions
@ -1,15 +0,0 @@
@@ -1,15 +0,0 @@
|
||||
using System.Reflection; |
||||
using System.Runtime.CompilerServices; |
||||
using System.Runtime.InteropServices; |
||||
|
||||
// Information about this assembly is defined by the following
|
||||
// attributes.
|
||||
//
|
||||
// change them to the information which is associated with the assembly
|
||||
// you compile.
|
||||
|
||||
[assembly: AssemblyTitle("DataTools.Model")] |
||||
[assembly: AssemblyDescription("")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyTrademark("")] |
||||
[assembly: AssemblyCulture("")] |
@ -1,63 +0,0 @@
@@ -1,63 +0,0 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup> |
||||
<ProjectGuid>{51783FC4-D8D2-4BFB-A1F1-AC8857CF3ED0}</ProjectGuid> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>ICSharpCode.DataTools.Model</RootNamespace> |
||||
<AssemblyName>ICSharpCode.DataTools.Model</AssemblyName> |
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||
<NoStdLib>False</NoStdLib> |
||||
<WarningLevel>4</WarningLevel> |
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||
<OutputPath>..\..\..\..\..\AddIns\AddIns\Misc\SharpServerTools\</OutputPath> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
<Optimize>False</Optimize> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<OutputPath>..\..\..\..\..\AddIns\AddIns\Misc\SharpServerTools\</OutputPath> |
||||
<DebugSymbols>False</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' "> |
||||
<RegisterForComInterop>False</RegisterForComInterop> |
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
||||
<BaseAddress>4194304</BaseAddress> |
||||
<PlatformTarget>AnyCPU</PlatformTarget> |
||||
<FileAlignment>4096</FileAlignment> |
||||
</PropertyGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
<ItemGroup> |
||||
<Reference Include="log4net"> |
||||
<HintPath>..\..\..\..\Libraries\log4net\log4net.dll</HintPath> |
||||
<SpecificVersion>False</SpecificVersion> |
||||
</Reference> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Data" /> |
||||
<Reference Include="System.Xml" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="..\..\..\..\Main\GlobalAssemblyInfo.cs"> |
||||
<Link>Configuration\GlobalAssemblyInfo.cs</Link> |
||||
</Compile> |
||||
<Compile Include="Configuration\AssemblyInfo.cs" /> |
||||
<Compile Include="Src\ColumnNames.cs" /> |
||||
<Compile Include="Src\DbModelInfo.cs" /> |
||||
<Compile Include="Src\DbModelInfoService.cs" /> |
||||
<Compile Include="Src\DbProvidersException.cs" /> |
||||
<Compile Include="Src\DbProvidersService.cs" /> |
||||
<Compile Include="Src\MetadataNames.cs" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Folder Include="Configuration" /> |
||||
<Folder Include="Resources" /> |
||||
<Folder Include="Src" /> |
||||
</ItemGroup> |
||||
</Project> |
@ -1,22 +0,0 @@
@@ -1,22 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Dickon Field" email=""/>
|
||||
// <version>$Revision: 1784 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
namespace SharpDbTools.Data |
||||
{ |
||||
/// <summary>
|
||||
/// Description of Columns.
|
||||
/// </summary>
|
||||
public sealed class ColumnNames |
||||
{ |
||||
public const string InvariantName = "invariantName"; |
||||
public const string Name = "name"; |
||||
public const string ConnectionString = "connectionString"; |
||||
public const string TableName = "TABLE_NAME"; |
||||
} |
||||
} |
@ -1,170 +0,0 @@
@@ -1,170 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Dickon Field" email=""/>
|
||||
// <version>$Revision: 1784 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Data; |
||||
|
||||
namespace SharpDbTools.Data |
||||
{ |
||||
/// <summary>
|
||||
/// DbModel is a DataSet containing the metadata tables returned from a DbConnection.
|
||||
/// It adds methods designed specifically to facilitate access to the data in the
|
||||
/// DataTables contained by the DbModel.
|
||||
///
|
||||
/// The DbModel class is intended to be usable in a fully disconnected mode - that is,
|
||||
/// it requires a DbConnection to populate it, but it may then be locally persisted and subsequently
|
||||
/// retrieved from its persisted data. This is intended to allow work to progress against the
|
||||
/// DbModel without requiring a connection to its RDB server.
|
||||
/// </summary>
|
||||
///
|
||||
public class DbModelInfo: DataSet |
||||
{ |
||||
public const string METADATACOLLECTIONS = "MetaDataCollections"; |
||||
|
||||
public DbModelInfo() : base() |
||||
{ |
||||
} |
||||
|
||||
public DbModelInfo(string name) : base() |
||||
{ |
||||
DataTable table = CreateConnectionInfoTable(); |
||||
// add the first and only column of this table;
|
||||
table.Rows.Add(new object[] {name, null, null}); |
||||
} |
||||
|
||||
public DbModelInfo(string name, string invariantName, string connectionString): base() |
||||
{ |
||||
DataTable table = CreateConnectionInfoTable(); |
||||
// add the first and only column of this table;
|
||||
table.Rows.Add(new object[] {name, invariantName, connectionString}); |
||||
} |
||||
|
||||
public string Name { |
||||
get { |
||||
DataTable table = this.Tables[MetadataNames.ConnectionInfo]; |
||||
string name = table.Rows[0][ColumnNames.Name] as string; |
||||
return name; |
||||
} |
||||
} |
||||
|
||||
public string InvariantName { |
||||
get { |
||||
DataTable table = this.Tables[MetadataNames.ConnectionInfo]; |
||||
string invariantName = null; |
||||
try { |
||||
invariantName = table.Rows[0][ColumnNames.InvariantName] as string; |
||||
} |
||||
catch(ArgumentException) { |
||||
// see comment below - it is correct to bury this exception
|
||||
//LoggingService.Info("InvariantName property was accessed while undefined" + e);
|
||||
} |
||||
return invariantName; |
||||
} |
||||
set { |
||||
DataTable table = this.Tables[MetadataNames.ConnectionInfo]; |
||||
string invariantName = table.Rows[0][ColumnNames.InvariantName] as string; |
||||
string name = this.Name; |
||||
string connectionString = this.ConnectionString; |
||||
|
||||
if (invariantName == null) { |
||||
table.Rows[0][ColumnNames.InvariantName] = value; |
||||
} |
||||
|
||||
// if invariant has changed must clear any existing metadata
|
||||
else if (!(invariantName.Equals(value))) { |
||||
// clear tables
|
||||
this.Clear(); |
||||
DataTable newTable = CreateConnectionInfoTable(); |
||||
// add the first and only column of this table;
|
||||
newTable.Rows.Add(new object[] {name, invariantName, connectionString}); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public string ConnectionString { |
||||
get { |
||||
DataTable table = this.Tables[MetadataNames.ConnectionInfo]; |
||||
string connectionString = null; |
||||
try { |
||||
connectionString = table.Rows[0][ColumnNames.ConnectionString] as string; |
||||
} |
||||
catch(ArgumentException) { |
||||
// this simply indicates that this attribute was not defined when the
|
||||
// DbModelInfo was saved, returning null makes sense here - so it is
|
||||
// correct to bury this exception
|
||||
//LoggingService.Info("InvariantName property was accessed while undefined" + e);
|
||||
} |
||||
return connectionString; |
||||
} |
||||
set { |
||||
DataTable table = this.Tables[MetadataNames.ConnectionInfo]; |
||||
string connectionString = this.ConnectionString; |
||||
if (connectionString == null) { |
||||
table.Rows[0][ColumnNames.ConnectionString] = value; |
||||
} |
||||
else if (!(connectionString.Equals(value))) { |
||||
string invariantName = this.InvariantName; |
||||
string name = this.Name; |
||||
this.Clear(); |
||||
// add the first and only column of this table;
|
||||
table.Rows.Add(new object[] {name, invariantName, value}); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public void SetConnectionInfo(string invariantName, string connectionString) |
||||
{ |
||||
string name = this.Name; |
||||
SetConnectionInfo(name, invariantName, connectionString); |
||||
} |
||||
|
||||
public void SetConnectionInfo(string name, string invariantName, |
||||
string connectionString) |
||||
{ |
||||
this.Clear(); |
||||
DataTable table = CreateConnectionInfoTable(); |
||||
// add the first and only column of this table;
|
||||
table.Rows.Add(new object[] {name, invariantName, connectionString}); |
||||
|
||||
} |
||||
|
||||
private DataTable CreateConnectionInfoTable() |
||||
{ |
||||
// create a table in the DbModelInfo to hold this initial info.
|
||||
// this creates a consistent representation of the data and makes
|
||||
// it easier to serialise it
|
||||
DataTable table = this.Tables.Add(MetadataNames.ConnectionInfo); |
||||
table.Columns.Add(ColumnNames.Name, typeof(string)); |
||||
table.Columns.Add(ColumnNames.InvariantName, typeof(string)); |
||||
table.Columns.Add(ColumnNames.ConnectionString, typeof(string)); |
||||
return table; |
||||
} |
||||
|
||||
public void ClearMetaData() |
||||
{ |
||||
DataTable metadataCollectionsTable = this.MetaDataCollections; |
||||
if (metadataCollectionsTable != null) { |
||||
foreach (DataRow collectionRow in metadataCollectionsTable.Rows) { |
||||
String collectionName = (string)collectionRow[0]; |
||||
this.Tables.Remove(collectionName); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public DataTable MetaDataCollections { |
||||
get { |
||||
return this.Tables[METADATACOLLECTIONS]; |
||||
} |
||||
} |
||||
|
||||
public DataTable this[string collectionName] { |
||||
get { |
||||
return this.Tables[collectionName]; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,301 +0,0 @@
@@ -1,301 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Dickon Field" email=""/>
|
||||
// <version>$Revision: 1784 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Data; |
||||
using System.Data.Common; |
||||
using System.IO; |
||||
|
||||
using log4net; |
||||
|
||||
namespace SharpDbTools.Data |
||||
{ |
||||
/// <summary>
|
||||
/// Manages a collection of DbModelInfo:
|
||||
/// - retrieval from files
|
||||
/// - opening (essentially refreshing) from a database connection
|
||||
/// - adding for new connection data (name, invariant name, connection string)
|
||||
/// - saving to files
|
||||
/// Note: it is not threadsafe
|
||||
/// </summary>
|
||||
public static class DbModelInfoService |
||||
{ |
||||
const string dbFilesDir = "DbTools"; |
||||
static SortedList<string, DbModelInfo> cache = null; |
||||
static ILog log = LogManager.GetLogger(typeof(DbModelInfoService)); |
||||
static string savePath; |
||||
|
||||
|
||||
public static string SavePath { |
||||
set { |
||||
savePath = value; |
||||
} |
||||
get { |
||||
return savePath; |
||||
} |
||||
} |
||||
public static IList<string> Names { |
||||
get { |
||||
if (cache == null) { |
||||
cache = new SortedList<string, DbModelInfo>(); |
||||
LoadNamesFromFiles(); |
||||
} |
||||
return cache.Keys; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="name">The user readable name of the provider</param>
|
||||
/// <param name="invariantName">the identifying name of the provider</param>
|
||||
/// <param name="connectionString">the connection string for this connection</param>
|
||||
/// <returns></returns>
|
||||
public static DbModelInfo Add(string name, string invariantName, string connectionString) |
||||
{ |
||||
// TODO: add validation on name; invariant name
|
||||
// assume that connection string is valid - if it fails an exception will be thrown later
|
||||
// this allows partially defined connection strings at least to be saved and worked on later
|
||||
DbModelInfo dbModel = new DbModelInfo(name, invariantName, connectionString); |
||||
|
||||
// add to cache
|
||||
cache.Add(name, dbModel); |
||||
return dbModel; |
||||
} |
||||
|
||||
public static void Remove(string name) |
||||
{ |
||||
cache.Remove(name); |
||||
} |
||||
|
||||
public static DbModelInfo GetDbModelInfo(string name) { |
||||
DbModelInfo modelInfo = null; |
||||
bool exists = cache.TryGetValue(name, out modelInfo); |
||||
return modelInfo; |
||||
} |
||||
|
||||
public static DataTable GetTableInfo(string modelName, string tableName) |
||||
{ |
||||
log.Debug("-->GetTableInfo"); |
||||
DbModelInfo modelInfo = GetDbModelInfo(modelName); |
||||
DataTable columnTable = modelInfo.Tables[MetadataNames.Columns]; |
||||
DataRow[] columnsMetadata = columnTable.Select(ColumnNames.TableName + "='" + tableName + "'"); |
||||
log.Debug("found: " + columnsMetadata.Length + " columns belonging to table: " + tableName); |
||||
DataTable tableInfo = new DataTable(); |
||||
DataColumnCollection cols = columnTable.Columns; |
||||
foreach (DataColumn c in cols) { |
||||
DataColumn nc = new DataColumn(c.ColumnName, c.DataType); |
||||
tableInfo.Columns.Add(nc); |
||||
} |
||||
foreach (DataRow r in columnsMetadata) { |
||||
DataRow newRow = tableInfo.NewRow(); |
||||
newRow.ItemArray = r.ItemArray; |
||||
tableInfo.Rows.Add(newRow); |
||||
tableInfo.AcceptChanges(); |
||||
} |
||||
return tableInfo; |
||||
|
||||
} |
||||
|
||||
public static DbModelInfo LoadMetadataFromConnection(string name) |
||||
{ |
||||
// get the DbModelInfo
|
||||
|
||||
DbModelInfo modelInfo = null; |
||||
bool exists = cache.TryGetValue(name, out modelInfo); |
||||
if (!exists) |
||||
{ |
||||
// TODO: more detail...
|
||||
throw new KeyNotFoundException(); |
||||
} |
||||
|
||||
// get the invariant name and connection string
|
||||
|
||||
string invariantName = modelInfo.InvariantName; |
||||
string connectionString = modelInfo.ConnectionString; |
||||
|
||||
// get a connection - wait until a connection has been successfully made
|
||||
// before clearing the DbModelInfo
|
||||
|
||||
DbProvidersService factoryService = DbProvidersService.GetDbProvidersService(); |
||||
DbConnection connection = null; |
||||
try { |
||||
|
||||
DbProviderFactory factory = factoryService.GetFactoryByInvariantName(invariantName); |
||||
connection = factory.CreateConnection(); |
||||
|
||||
|
||||
modelInfo.ClearMetaData(); |
||||
|
||||
// reload the metadata from the connection
|
||||
// get the Schema table
|
||||
connection.ConnectionString = connectionString; |
||||
|
||||
connection.Open(); |
||||
DataTable schemaInfo = connection.GetSchema(); |
||||
if (schemaInfo != null) { |
||||
log.Debug("retrieved schema info with " + schemaInfo.Rows.Count + " rows"); |
||||
} |
||||
|
||||
// clear the DbModelInfo prior to refreshing from the connection
|
||||
modelInfo.ClearMetaData(); |
||||
|
||||
// iterate through the rows in it - the first column of each is a
|
||||
// schema info collection name that can be retrieved as a DbTable
|
||||
// Add each one to the DbModel DataSet
|
||||
|
||||
foreach (DataRow collectionRow in schemaInfo.Rows) { |
||||
String collectionName = (string)collectionRow[0]; |
||||
log.Debug("loading metadata for collection: " + collectionName); |
||||
DataTable nextMetaData = connection.GetSchema(collectionName); |
||||
modelInfo.Merge(nextMetaData); |
||||
} |
||||
log.Debug("completed load of metadata, committing changes"); |
||||
modelInfo.AcceptChanges(); |
||||
return modelInfo; |
||||
} |
||||
catch(Exception e) { |
||||
log.Fatal("Exception caught while trying to retrieve database metadata: " + e); |
||||
throw e; |
||||
} |
||||
finally { |
||||
connection.Close(); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="name">the logical name of the DbModelInfo to save to a file</param>
|
||||
/// <param name="overwriteExistingFile">if true, any existing file will be overwritten</param>
|
||||
/// <returns>true if the DbModelInfo was saved, false if not. It will not be saved if
|
||||
/// either overwriteExistingFile is set to true, and there is an existing file</returns>
|
||||
public static bool SaveToFile(string name, bool overwriteExistingFile) |
||||
{ |
||||
string path = GetSaveLocation(); |
||||
DbModelInfo modelInfo = null; |
||||
cache.TryGetValue(name, out modelInfo); |
||||
if (modelInfo != null) { |
||||
string modelName = modelInfo.Name; |
||||
// write to a file in 'path' called <name>.metadata
|
||||
// TODO: may want to consider ways of making this more resilient
|
||||
|
||||
string connectionProps = modelInfo.ConnectionString; |
||||
string invariantName = modelInfo.InvariantName; |
||||
|
||||
|
||||
|
||||
string filePath = path + @"\" + name + ".metadata"; |
||||
log.Debug("writing metadata to: " + filePath); |
||||
if (File.Exists(filePath)) { |
||||
if (overwriteExistingFile) { |
||||
File.Delete(filePath); |
||||
} else { |
||||
return false; |
||||
} |
||||
} |
||||
using (StreamWriter sw = File.CreateText(filePath)) { |
||||
string xml = modelInfo.GetXml(); |
||||
sw.Write(xml); |
||||
sw.Flush(); |
||||
sw.Close(); |
||||
return true; |
||||
} |
||||
} else { |
||||
throw new DbModelInfoDoesNotExistException(name); |
||||
} |
||||
} |
||||
|
||||
public static void SaveAll() |
||||
{ |
||||
foreach (string name in cache.Keys) { |
||||
SaveToFile(name, true); |
||||
} |
||||
} |
||||
|
||||
public static void LoadNamesFromFiles() |
||||
{ |
||||
// load DbModelInfo's from file system
|
||||
string saveLocation = GetSaveLocation(); |
||||
log.Debug("looking for metadata files at: " + saveLocation); |
||||
string[] files = Directory.GetFileSystemEntries(saveLocation); |
||||
|
||||
cache.Clear(); |
||||
for (int i = 0; i < files.Length; i++) { |
||||
log.Debug("found to load metadata from: " + files[i]); |
||||
int start = files[i].LastIndexOf('\\'); |
||||
int end = files[i].LastIndexOf('.'); |
||||
start++; |
||||
string name = files[i].Substring(start, end - start); |
||||
DbModelInfo nextModel = new DbModelInfo(name); |
||||
cache.Add(nextModel.Name, nextModel); |
||||
} |
||||
} |
||||
|
||||
public static void LoadFromFiles() |
||||
{ |
||||
// load DbModelInfo's from file system
|
||||
string saveLocation = GetSaveLocation(); |
||||
string[] files = Directory.GetFiles(saveLocation); |
||||
cache.Clear(); |
||||
for (int i = 0; i < files.Length; i++) { |
||||
DbModelInfo nextModel = LoadFromFileAtPath(@files[i]); |
||||
cache.Add(nextModel.Name, nextModel); |
||||
} |
||||
} |
||||
|
||||
private static DbModelInfo LoadFromFileAtPath(string filePath) |
||||
{ |
||||
log.Debug("loading DbModelInfo from filePath: " + filePath); |
||||
DbModelInfo nextModel = new DbModelInfo(); |
||||
nextModel.ReadXml(filePath); |
||||
return nextModel; |
||||
} |
||||
|
||||
public static void LoadFromFile(string logicalConnectionName) |
||||
{ |
||||
log.Debug("loading DbModelInfo for name: " + logicalConnectionName); |
||||
string saveLocation = GetSaveLocation(); |
||||
string path = saveLocation + "\\" + logicalConnectionName + ".metadata"; |
||||
DbModelInfo info = LoadFromFileAtPath(path); |
||||
cache.Remove(logicalConnectionName); |
||||
cache.Add(logicalConnectionName, info); |
||||
} |
||||
|
||||
private static string GetSaveLocation() |
||||
{ |
||||
// append the path of the directory for saving Db files
|
||||
|
||||
if (SavePath == null) { |
||||
string configDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); |
||||
SavePath = configDir + @"\" + dbFilesDir; |
||||
SavePath = SavePath.Replace("/", @"\"); |
||||
} |
||||
if (!Directory.Exists(SavePath)) { |
||||
Directory.CreateDirectory(@SavePath); |
||||
} |
||||
return SavePath; |
||||
} |
||||
} |
||||
|
||||
public class DbModelInfoDoesNotExistException: ApplicationException |
||||
{ |
||||
string name; |
||||
|
||||
public DbModelInfoDoesNotExistException(string dbModelInfoName): base() |
||||
{ |
||||
this.name = dbModelInfoName; |
||||
} |
||||
|
||||
public string Name { |
||||
get { |
||||
return name; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,40 +0,0 @@
@@ -1,40 +0,0 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: dickon |
||||
* Date: 31/03/2007 |
||||
* Time: 15:57 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
|
||||
using System; |
||||
using System.Runtime.Serialization; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace SharpDbTools.Data |
||||
{ |
||||
/// <summary>
|
||||
/// Thrown when the DbProvidersService cannot find the class for
|
||||
/// a DbProviderFactory that is found in a *.config file.
|
||||
/// </summary>
|
||||
|
||||
[Serializable()] |
||||
public class DbProvidersException : Exception |
||||
{ |
||||
public DbProvidersException() : base() |
||||
{ |
||||
} |
||||
|
||||
public DbProvidersException(string message) : base(message) |
||||
{ |
||||
} |
||||
|
||||
public DbProvidersException(string message, Exception innerException) : base(message, innerException) |
||||
{ |
||||
} |
||||
|
||||
protected DbProvidersException(SerializationInfo info, StreamingContext context) : base(info, context) |
||||
{ |
||||
} |
||||
} |
||||
} |
@ -1,132 +0,0 @@
@@ -1,132 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Dickon Field" email=""/>
|
||||
// <version>$Revision: 1697 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Data; |
||||
using System.Data.Common; |
||||
|
||||
using log4net; |
||||
|
||||
namespace SharpDbTools.Data |
||||
{ |
||||
/// <summary>
|
||||
/// A utility class that caches the DbProviderFactory and DbConnectionString
|
||||
/// objects whose state is stored in the current processes config space.
|
||||
/// </summary>
|
||||
public class DbProvidersService |
||||
{ |
||||
private static DbProvidersService me = new DbProvidersService(); |
||||
private static Boolean initialized = false; |
||||
private Dictionary<string, DbProviderFactory> factories = new Dictionary<string, DbProviderFactory>(); |
||||
private Dictionary<string, DbProviderFactory> factoriesByInvariantName = new Dictionary<string, DbProviderFactory>(); |
||||
|
||||
// This is only valid witin one session - do not persist
|
||||
private Dictionary<string, string> invariantByNameLookup = new Dictionary<string, string>(); |
||||
private List<string> names = new List<string>(); |
||||
static ILog log = LogManager.GetLogger(typeof(DbProvidersService)); |
||||
List<string> errMsgs = new List<string>(); |
||||
|
||||
private DbProvidersService() |
||||
{ |
||||
} |
||||
|
||||
private void Initialize() |
||||
{ |
||||
// get a complete list of config data for DbProviderFactories, indexed by name
|
||||
DataTable providerFactoriesTable = DbProviderFactories.GetFactoryClasses(); |
||||
DataRow[] rows = providerFactoriesTable.Select(); |
||||
|
||||
List<string> errorMsgs = new List<string>(); |
||||
|
||||
foreach(DataRow row in rows) |
||||
{ |
||||
// TODO: factor out string literals for column names
|
||||
string name = (string)row["Name"]; |
||||
string invariantName = (string)row["InvariantName"]; |
||||
try { |
||||
log.Debug("adding lookup for: " + name + " to: + " + invariantName); |
||||
invariantByNameLookup.Add(name, invariantName); |
||||
//factoryData.Add(name, row);
|
||||
|
||||
log.Debug("retrieving DbProviderFactory for Name: " |
||||
+ name + " InvariantName: " + invariantName); |
||||
DbProviderFactory factory = DbProviderFactories.GetFactory(row); |
||||
names.Add(name); |
||||
factories.Add(name, factory); |
||||
factoriesByInvariantName.Add(invariantName, factory); |
||||
} catch (ArgumentException) { |
||||
errorMsgs.Add("Found duplicate config for data provider: " + name + ", invariant name: " + |
||||
invariantName + ", will use config found first"); |
||||
|
||||
} catch (Exception) { |
||||
errorMsgs.Add("Unable to load DbProviderFactory for: " + name + ", this will be unavailable." + |
||||
" Check *.config files for invalid ado.net config elements, or config"); |
||||
} |
||||
} |
||||
initialized = true; |
||||
} |
||||
|
||||
public List<string> ErrorMessages { |
||||
get { |
||||
return this.errMsgs; |
||||
} |
||||
} |
||||
|
||||
public List<string> Names { |
||||
get |
||||
{ |
||||
return names; |
||||
} |
||||
} |
||||
|
||||
public string this[int i] |
||||
{ |
||||
get |
||||
{ |
||||
return names[i]; |
||||
} |
||||
} |
||||
|
||||
public string GetInvariantName(string name) { |
||||
string invariantName = null; |
||||
invariantByNameLookup.TryGetValue(name, out invariantName); |
||||
return invariantName; |
||||
} |
||||
|
||||
public DbProviderFactory this[string name] |
||||
{ |
||||
get |
||||
{ |
||||
return factories[name]; |
||||
} |
||||
set |
||||
{ |
||||
factories[name] = value; |
||||
} |
||||
} |
||||
|
||||
public DbProviderFactory GetFactoryByInvariantName(string invariantName) |
||||
{ |
||||
DbProviderFactory factory = null; |
||||
this.factoriesByInvariantName.TryGetValue(invariantName, out factory); |
||||
return factory; |
||||
} |
||||
|
||||
public static DbProvidersService GetDbProvidersService() |
||||
{ |
||||
lock(me) |
||||
{ |
||||
if (!initialized) |
||||
{ |
||||
me.Initialize(); |
||||
} |
||||
} |
||||
return me; |
||||
} |
||||
} |
||||
} |
@ -1,22 +0,0 @@
@@ -1,22 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Dickon Field" email=""/>
|
||||
// <version>$Revision: 1784 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
namespace SharpDbTools.Data |
||||
{ |
||||
/// <summary>
|
||||
/// Description of Tables.
|
||||
/// </summary>
|
||||
public sealed class MetadataNames |
||||
{ |
||||
public const string MetaDataCollections = "MetaDataCollections"; |
||||
public const string ConnectionInfo = "ConnectionInfo"; |
||||
public static string[] PrimaryObjects = new string[] { "Tables", "Procedures", "Functions", "Views", "Users" }; |
||||
public const string Columns = "Columns"; |
||||
} |
||||
} |
@ -1,15 +0,0 @@
@@ -1,15 +0,0 @@
|
||||
using System.Reflection; |
||||
using System.Runtime.CompilerServices; |
||||
using System.Runtime.InteropServices; |
||||
|
||||
// Information about this assembly is defined by the following
|
||||
// attributes.
|
||||
//
|
||||
// change them to the information which is associated with the assembly
|
||||
// you compile.
|
||||
|
||||
[assembly: AssemblyTitle("DataTools.UI")] |
||||
[assembly: AssemblyDescription("")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyTrademark("")] |
||||
[assembly: AssemblyCulture("")] |
@ -1,65 +0,0 @@
@@ -1,65 +0,0 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup> |
||||
<ProjectGuid>{87C0E3D9-0DFD-4F6D-8E38-408AAF73F4EE}</ProjectGuid> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>ICSharpCode.DataTools.UI</RootNamespace> |
||||
<AssemblyName>ICSharpCode.DataTools.UI</AssemblyName> |
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||
<NoStdLib>False</NoStdLib> |
||||
<WarningLevel>4</WarningLevel> |
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||
<OutputPath>..\..\..\..\..\AddIns\AddIns\Misc\SharpServerTools\</OutputPath> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
<Optimize>False</Optimize> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<OutputPath>..\..\..\..\..\AddIns\AddIns\Misc\SharpServerTools\</OutputPath> |
||||
<DebugSymbols>False</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' "> |
||||
<RegisterForComInterop>False</RegisterForComInterop> |
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
||||
<BaseAddress>4194304</BaseAddress> |
||||
<PlatformTarget>AnyCPU</PlatformTarget> |
||||
<FileAlignment>4096</FileAlignment> |
||||
</PropertyGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
<ItemGroup> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Data" /> |
||||
<Reference Include="System.Drawing" /> |
||||
<Reference Include="System.Windows.Forms" /> |
||||
<Reference Include="System.Xml" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="..\..\..\..\Main\GlobalAssemblyInfo.cs"> |
||||
<Link>Configuration\GlobalAssemblyInfo.cs</Link> |
||||
</Compile> |
||||
<Compile Include="Configuration\AssemblyInfo.cs" /> |
||||
<Compile Include="Src\ConnectionStringDefinitionDialog.cs" /> |
||||
<Compile Include="Src\ConnectionStringDefinitionDialog.Designer.cs" /> |
||||
<EmbeddedResource Include="Resources\Strings.resx" /> |
||||
<EmbeddedResource Include="Src\ConnectionStringDefinitionDialog.resx"> |
||||
<DependentUpon>ConnectionStringDefinitionDialog.cs</DependentUpon> |
||||
</EmbeddedResource> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Folder Include="Configuration" /> |
||||
<Folder Include="Resources" /> |
||||
<Folder Include="Src" /> |
||||
<ProjectReference Include="..\DataTools.Model\DataTools.Model.csproj"> |
||||
<Project>{51783FC4-D8D2-4BFB-A1F1-AC8857CF3ED0}</Project> |
||||
<Name>DataTools.Model</Name> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
</Project> |
@ -1,205 +0,0 @@
@@ -1,205 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<root> |
||||
<!-- |
||||
Microsoft ResX Schema |
||||
|
||||
Version 2.0 |
||||
|
||||
The primary goals of this format is to allow a simple XML format |
||||
that is mostly human readable. The generation and parsing of the |
||||
various data types are done through the TypeConverter classes |
||||
associated with the data types. |
||||
|
||||
Example: |
||||
|
||||
... ado.net/XML headers & schema ... |
||||
<resheader name="resmimetype">text/microsoft-resx</resheader> |
||||
<resheader name="version">2.0</resheader> |
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
||||
<value>[base64 mime encoded serialized .NET Framework object]</value> |
||||
</data> |
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
||||
<comment>This is a comment</comment> |
||||
</data> |
||||
|
||||
There are any number of "resheader" rows that contain simple |
||||
name/value pairs. |
||||
|
||||
Each data row contains a name, and value. The row also contains a |
||||
type or mimetype. Type corresponds to a .NET class that support |
||||
text/value conversion through the TypeConverter architecture. |
||||
Classes that don't support this are serialized and stored with the |
||||
mimetype set. |
||||
|
||||
The mimetype is used for serialized objects, and tells the |
||||
ResXResourceReader how to depersist the object. This is currently not |
||||
extensible. For a given mimetype the value must be set accordingly: |
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format |
||||
that the ResXResourceWriter will generate, however the reader can |
||||
read any of the formats listed below. |
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64 |
||||
value : The object must be serialized with |
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter |
||||
: and then encoded with base64 encoding. |
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64 |
||||
value : The object must be serialized with |
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
||||
: and then encoded with base64 encoding. |
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64 |
||||
value : The object must be serialized into a byte array |
||||
: using a System.ComponentModel.TypeConverter |
||||
: and then encoded with base64 encoding. |
||||
--> |
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> |
||||
<xsd:element name="root" msdata:IsDataSet="true"> |
||||
<xsd:complexType> |
||||
<xsd:choice maxOccurs="unbounded"> |
||||
<xsd:element name="metadata"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" use="required" type="xsd:string" /> |
||||
<xsd:attribute name="type" type="xsd:string" /> |
||||
<xsd:attribute name="mimetype" type="xsd:string" /> |
||||
<xsd:attribute ref="xml:space" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="assembly"> |
||||
<xsd:complexType> |
||||
<xsd:attribute name="alias" type="xsd:string" /> |
||||
<xsd:attribute name="name" type="xsd:string" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="data"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> |
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
||||
<xsd:attribute ref="xml:space" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="resheader"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" type="xsd:string" use="required" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
</xsd:choice> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
</xsd:schema> |
||||
<resheader name="resmimetype"> |
||||
<value>text/microsoft-resx</value> |
||||
</resheader> |
||||
<resheader name="version"> |
||||
<value>2.0</value> |
||||
</resheader> |
||||
<resheader name="reader"> |
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
</resheader> |
||||
<resheader name="writer"> |
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
</resheader> |
||||
<data name="SharpDbTools.Data.PrimaryObjects.Tables" xml:space="preserve"> |
||||
<value>Tables</value> |
||||
</data> |
||||
<data name="SharpDbTools.Data.PrimaryObjects.Procedures" xml:space="preserve"> |
||||
<value>Procedures</value> |
||||
</data> |
||||
<data name="SharpDbTools.Data.PrimaryObjects.Functions" xml:space="preserve"> |
||||
<value>Functions |
||||
</value> |
||||
</data> |
||||
<data name="SharpDbTools.Data.PrimaryObjects.Views" xml:space="preserve"> |
||||
<value>Views</value> |
||||
</data> |
||||
<data name="SharpDbTools.Data.PrimaryObjects.Users" xml:space="preserve"> |
||||
<value>Users</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.DbObjectNodeName" xml:space="preserve"> |
||||
<value>Db Objects</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.DbExplorerNodeName" xml:space="preserve"> |
||||
<value>Database Explorer</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.AddConnectionMenu" xml:space="preserve"> |
||||
<value>Add Connection</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.DeleteConnectionMenu" xml:space="preserve"> |
||||
<value>Delete Connection</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.SaveAllMenu" xml:space="preserve"> |
||||
<value>Save All</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.ConnectionPropertiesNodeName" xml:space="preserve"> |
||||
<value>Connection Properties</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.NoMetadataNodeName" xml:space="preserve"> |
||||
<value>No Metadata</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.SetConnectionStringMenu" xml:space="preserve"> |
||||
<value>Set Connection String</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.LoadMetadataFromConnectionMenu" xml:space="preserve"> |
||||
<value>Load Metadata From Connection</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.LoadMetadataFromFileMenu" xml:space="preserve"> |
||||
<value>Load Metadata From File</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.OpenSQLToolMenu" xml:space="preserve"> |
||||
<value>Open SQL Tool</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.ConnectionStringNodeName" xml:space="preserve"> |
||||
<value>Connection String:</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.InvariantNameNodeName" xml:space="preserve"> |
||||
<value>Invariant Name:</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.ConnectionSucceededMsg" xml:space="preserve"> |
||||
<value>Connection Succeeded</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.ConnectionFailedMsg" xml:space="preserve"> |
||||
<value>Connection Failed</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.TestButton" xml:space="preserve"> |
||||
<value>Test</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.SubmitButton" xml:space="preserve"> |
||||
<value>Submit</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.CancelButton" xml:space="preserve"> |
||||
<value>Cancel</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.DataSourceTypeLabel" xml:space="preserve"> |
||||
<value>Data Source Type:</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.ConnectionStringLabel" xml:space="preserve"> |
||||
<value>Connection String:</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.ConnectionStringTab" xml:space="preserve"> |
||||
<value>Connection String</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.TestResultTab" xml:space="preserve"> |
||||
<value>Test Result Message</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.ConnectionStringDefinitionDialog" xml:space="preserve"> |
||||
<value>Set Up Connection String</value> |
||||
</data> |
||||
</root> |
@ -1,236 +0,0 @@
@@ -1,236 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Dickon Field" email=""/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
namespace SharpDbTools.Forms |
||||
{ |
||||
partial class ConnectionStringDefinitionDialog : System.Windows.Forms.Form |
||||
{ |
||||
/// <summary>
|
||||
/// Designer variable used to keep track of non-visual components.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null; |
||||
|
||||
/// <summary>
|
||||
/// Disposes resources used by the form.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing) |
||||
{ |
||||
if (disposing) { |
||||
if (components != null) { |
||||
components.Dispose(); |
||||
} |
||||
} |
||||
base.Dispose(disposing); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// This method is required for Windows Forms designer support.
|
||||
/// Do not change the method contents inside the source code editor. The Forms designer might
|
||||
/// not be able to load this method if it was changed manually.
|
||||
/// </summary>
|
||||
private void InitializeComponent() |
||||
{ |
||||
this.components = new System.ComponentModel.Container(); |
||||
this.connStringPropertyGrid = new System.Windows.Forms.PropertyGrid(); |
||||
this.buttonsFlowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel(); |
||||
this.testButton = new System.Windows.Forms.Button(); |
||||
this.submitButton = new System.Windows.Forms.Button(); |
||||
this.cancelButton = new System.Windows.Forms.Button(); |
||||
this.providerTypeComboBox = new System.Windows.Forms.ComboBox(); |
||||
this.dataSourceTypeLabel = new System.Windows.Forms.Label(); |
||||
this.connStringResult = new System.Windows.Forms.TextBox(); |
||||
this.connectionStringLabel = new System.Windows.Forms.Label(); |
||||
this.progressTimer = new System.Windows.Forms.Timer(this.components); |
||||
this.statusStrip = new System.Windows.Forms.StatusStrip(); |
||||
this.outputMessageTabControl = new System.Windows.Forms.TabControl(); |
||||
this.connectionStringTab = new System.Windows.Forms.TabPage(); |
||||
this.testResultTab = new System.Windows.Forms.TabPage(); |
||||
this.testResultTextBox = new System.Windows.Forms.TextBox(); |
||||
this.buttonsFlowLayoutPanel.SuspendLayout(); |
||||
this.outputMessageTabControl.SuspendLayout(); |
||||
this.connectionStringTab.SuspendLayout(); |
||||
this.testResultTab.SuspendLayout(); |
||||
this.SuspendLayout(); |
||||
//
|
||||
// connStringPropertyGrid
|
||||
//
|
||||
this.connStringPropertyGrid.Location = new System.Drawing.Point(0, 39); |
||||
this.connStringPropertyGrid.Name = "connStringPropertyGrid"; |
||||
this.connStringPropertyGrid.Size = new System.Drawing.Size(547, 300); |
||||
this.connStringPropertyGrid.TabIndex = 0; |
||||
//
|
||||
// buttonsFlowLayoutPanel
|
||||
//
|
||||
this.buttonsFlowLayoutPanel.Controls.Add(this.testButton); |
||||
this.buttonsFlowLayoutPanel.Controls.Add(this.submitButton); |
||||
this.buttonsFlowLayoutPanel.Controls.Add(this.cancelButton); |
||||
this.buttonsFlowLayoutPanel.Location = new System.Drawing.Point(3, 447); |
||||
this.buttonsFlowLayoutPanel.Name = "buttonsFlowLayoutPanel"; |
||||
this.buttonsFlowLayoutPanel.Size = new System.Drawing.Size(312, 34); |
||||
this.buttonsFlowLayoutPanel.TabIndex = 1; |
||||
//
|
||||
// testButton
|
||||
//
|
||||
this.testButton.Location = new System.Drawing.Point(3, 3); |
||||
this.testButton.Name = "testButton"; |
||||
this.testButton.Size = new System.Drawing.Size(75, 23); |
||||
this.testButton.TabIndex = 0; |
||||
this.testButton.Text = "Test"; |
||||
this.testButton.UseVisualStyleBackColor = true; |
||||
this.testButton.Click += new System.EventHandler(this.TestButtonClick); |
||||
//
|
||||
// submitButton
|
||||
//
|
||||
this.submitButton.Location = new System.Drawing.Point(84, 3); |
||||
this.submitButton.Name = "submitButton"; |
||||
this.submitButton.Size = new System.Drawing.Size(75, 23); |
||||
this.submitButton.TabIndex = 1; |
||||
this.submitButton.Text = "Submit"; |
||||
this.submitButton.UseVisualStyleBackColor = true; |
||||
this.submitButton.Click += new System.EventHandler(this.SubmitButtonClick); |
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.Location = new System.Drawing.Point(165, 3); |
||||
this.cancelButton.Name = "cancelButton"; |
||||
this.cancelButton.Size = new System.Drawing.Size(75, 23); |
||||
this.cancelButton.TabIndex = 2; |
||||
this.cancelButton.Text = "Cancel"; |
||||
this.cancelButton.UseVisualStyleBackColor = true; |
||||
this.cancelButton.Click += new System.EventHandler(this.CancelButtonClick); |
||||
//
|
||||
// providerTypeComboBox
|
||||
//
|
||||
this.providerTypeComboBox.FormattingEnabled = true; |
||||
this.providerTypeComboBox.Location = new System.Drawing.Point(117, 12); |
||||
this.providerTypeComboBox.Name = "providerTypeComboBox"; |
||||
this.providerTypeComboBox.Size = new System.Drawing.Size(195, 21); |
||||
this.providerTypeComboBox.TabIndex = 2; |
||||
this.providerTypeComboBox.SelectedIndexChanged += new System.EventHandler(this.ProviderTypeSelectedIndexChanged); |
||||
//
|
||||
// dataSourceTypeLabel
|
||||
//
|
||||
this.dataSourceTypeLabel.Location = new System.Drawing.Point(3, 9); |
||||
this.dataSourceTypeLabel.Name = "dataSourceTypeLabel"; |
||||
this.dataSourceTypeLabel.Size = new System.Drawing.Size(108, 23); |
||||
this.dataSourceTypeLabel.TabIndex = 3; |
||||
this.dataSourceTypeLabel.Text = "Data Source Type:"; |
||||
this.dataSourceTypeLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; |
||||
//
|
||||
// connStringResult
|
||||
//
|
||||
this.connStringResult.Enabled = false; |
||||
this.connStringResult.Location = new System.Drawing.Point(0, 0); |
||||
this.connStringResult.Multiline = true; |
||||
this.connStringResult.Name = "connStringResult"; |
||||
this.connStringResult.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; |
||||
this.connStringResult.Size = new System.Drawing.Size(413, 74); |
||||
this.connStringResult.TabIndex = 4; |
||||
//
|
||||
// connectionStringLabel
|
||||
//
|
||||
this.connectionStringLabel.Location = new System.Drawing.Point(12, 348); |
||||
this.connectionStringLabel.Name = "connectionStringLabel"; |
||||
this.connectionStringLabel.Size = new System.Drawing.Size(100, 23); |
||||
this.connectionStringLabel.TabIndex = 5; |
||||
this.connectionStringLabel.Text = "Connection String:"; |
||||
//
|
||||
// progressTimer
|
||||
//
|
||||
this.progressTimer.Interval = 1000; |
||||
this.progressTimer.Tick += new System.EventHandler(this.ProgressTimerTick); |
||||
//
|
||||
// statusStrip
|
||||
//
|
||||
this.statusStrip.Location = new System.Drawing.Point(0, 478); |
||||
this.statusStrip.Name = "statusStrip"; |
||||
this.statusStrip.Size = new System.Drawing.Size(547, 22); |
||||
this.statusStrip.TabIndex = 6; |
||||
this.statusStrip.Text = "statusStrip1"; |
||||
//
|
||||
// testResultTab
|
||||
//
|
||||
this.outputMessageTabControl.Controls.Add(this.connectionStringTab); |
||||
this.outputMessageTabControl.Controls.Add(this.testResultTab); |
||||
this.outputMessageTabControl.Location = new System.Drawing.Point(118, 345); |
||||
this.outputMessageTabControl.Name = "testResultTab"; |
||||
this.outputMessageTabControl.SelectedIndex = 0; |
||||
this.outputMessageTabControl.Size = new System.Drawing.Size(417, 100); |
||||
this.outputMessageTabControl.TabIndex = 7; |
||||
//
|
||||
// tabPage1
|
||||
//
|
||||
this.connectionStringTab.Controls.Add(this.connStringResult); |
||||
this.connectionStringTab.Location = new System.Drawing.Point(4, 22); |
||||
this.connectionStringTab.Name = "tabPage1"; |
||||
this.connectionStringTab.Padding = new System.Windows.Forms.Padding(3); |
||||
this.connectionStringTab.Size = new System.Drawing.Size(409, 74); |
||||
this.connectionStringTab.TabIndex = 0; |
||||
this.connectionStringTab.Text = "Connection String"; |
||||
this.connectionStringTab.UseVisualStyleBackColor = true; |
||||
//
|
||||
// tabPage2
|
||||
//
|
||||
this.testResultTab.Controls.Add(this.testResultTextBox); |
||||
this.testResultTab.Location = new System.Drawing.Point(4, 22); |
||||
this.testResultTab.Name = "tabPage2"; |
||||
this.testResultTab.Padding = new System.Windows.Forms.Padding(3); |
||||
this.testResultTab.Size = new System.Drawing.Size(409, 74); |
||||
this.testResultTab.TabIndex = 1; |
||||
this.testResultTab.Text = "Test Result Message"; |
||||
this.testResultTab.UseVisualStyleBackColor = true; |
||||
//
|
||||
// testResultTextBox
|
||||
//
|
||||
this.testResultTextBox.Location = new System.Drawing.Point(-5, 0); |
||||
this.testResultTextBox.Multiline = true; |
||||
this.testResultTextBox.Name = "testResultTextBox"; |
||||
this.testResultTextBox.Size = new System.Drawing.Size(418, 77); |
||||
this.testResultTextBox.TabIndex = 0; |
||||
//
|
||||
// ConnectionStringDefinitionDialog
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); |
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; |
||||
this.ClientSize = new System.Drawing.Size(547, 500); |
||||
this.Controls.Add(this.outputMessageTabControl); |
||||
this.Controls.Add(this.statusStrip); |
||||
this.Controls.Add(this.connectionStringLabel); |
||||
this.Controls.Add(this.dataSourceTypeLabel); |
||||
this.Controls.Add(this.providerTypeComboBox); |
||||
this.Controls.Add(this.buttonsFlowLayoutPanel); |
||||
this.Controls.Add(this.connStringPropertyGrid); |
||||
this.Name = "ConnectionStringDefinitionDialog"; |
||||
this.Text = "Set up Connection String"; |
||||
this.buttonsFlowLayoutPanel.ResumeLayout(false); |
||||
this.outputMessageTabControl.ResumeLayout(false); |
||||
this.connectionStringTab.ResumeLayout(false); |
||||
this.connectionStringTab.PerformLayout(); |
||||
this.testResultTab.ResumeLayout(false); |
||||
this.testResultTab.PerformLayout(); |
||||
this.ResumeLayout(false); |
||||
this.PerformLayout(); |
||||
} |
||||
private System.Windows.Forms.TabControl outputMessageTabControl; |
||||
private System.Windows.Forms.TextBox testResultTextBox; |
||||
private System.Windows.Forms.TabPage testResultTab; |
||||
private System.Windows.Forms.TabPage connectionStringTab; |
||||
|
||||
private System.Windows.Forms.Timer progressTimer; |
||||
private System.Windows.Forms.StatusStrip statusStrip; |
||||
private System.Windows.Forms.TextBox connStringResult; |
||||
private System.Windows.Forms.Label connectionStringLabel; |
||||
private System.Windows.Forms.Label dataSourceTypeLabel; |
||||
private System.Windows.Forms.ComboBox providerTypeComboBox; |
||||
private System.Windows.Forms.Button cancelButton; |
||||
private System.Windows.Forms.Button submitButton; |
||||
private System.Windows.Forms.Button testButton; |
||||
private System.Windows.Forms.FlowLayoutPanel buttonsFlowLayoutPanel; |
||||
private System.Windows.Forms.PropertyGrid connStringPropertyGrid; |
||||
} |
||||
} |
@ -1,286 +0,0 @@
@@ -1,286 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Dickon Field" email=""/>
|
||||
// <version>$Revision: 1684 $</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.ComponentModel; |
||||
using System.Data.Common; |
||||
using System.Windows.Forms; |
||||
using System.Resources; |
||||
using System.Reflection; |
||||
using System.Text; |
||||
|
||||
using SharpDbTools.Data; |
||||
|
||||
namespace SharpDbTools.Forms |
||||
{ |
||||
/// <summary>
|
||||
/// This class creates a dialog that can be used to create and test connection strings
|
||||
/// that can be used with .net 2.0 DbProviders.
|
||||
/// It utilises .net 2.0 configuration to discover any DbProviderFactories that are
|
||||
/// installed and configured in machine.config, app.config or user.config using
|
||||
/// standard .net 2.0 apis.
|
||||
/// It then enables a user to browse the properties of each type of db connection,
|
||||
/// set values for them and test the resulting connection string.
|
||||
/// When the submit button is clicked the dialog is dismissed and the connection
|
||||
/// string constructed is accessible through the ConnectionString property of the dialog.
|
||||
/// </summary>
|
||||
public partial class ConnectionStringDefinitionDialog |
||||
{ |
||||
ToolStripProgressBar connectionTestProgressBar = new ToolStripProgressBar(); |
||||
ConnectionTestBackgroundWorker testConnectionBackgroundWorker; |
||||
string resultMessage; |
||||
string succeededMessage; |
||||
string failedMessage; |
||||
string invariantName; |
||||
ConnectionTestState connectionTestState = ConnectionTestState.UnTested; |
||||
|
||||
public ConnectionStringDefinitionDialog() |
||||
{ |
||||
//
|
||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||
//
|
||||
InitializeComponent(); |
||||
|
||||
// overwrite Text properties using resMgr
|
||||
|
||||
ResourceManager resMgr = new ResourceManager("ICSharpCode.DataTools.UI" + ".Resources.Strings", |
||||
Assembly.GetAssembly(typeof(ConnectionStringDefinitionDialog))); |
||||
this.testButton.Text = resMgr.GetString("SharpDbTools.Forms.TestButton"); |
||||
this.submitButton.Text = resMgr.GetString("SharpDbTools.Forms.SubmitButton"); |
||||
this.cancelButton.Text = resMgr.GetString("SharpDbTools.Forms.CancelButton"); |
||||
this.dataSourceTypeLabel.Text = resMgr.GetString("SharpDbTools.Forms.DataSourceTypeLabel"); |
||||
this.connectionStringLabel.Text = resMgr.GetString("SharpDbTools.Forms.ConnectionStringLabel"); |
||||
this.connectionStringTab.Text = resMgr.GetString("SharpDbTools.Forms.ConnectionStringTab"); |
||||
this.testResultTab.Text = resMgr.GetString("SharpDbTools.Forms.TestResultTab"); |
||||
this.Text = resMgr.GetString("SharpDbTools.Forms.ConnectionStringDefinitionDialog"); |
||||
this.succeededMessage = resMgr.GetString("SharpDbTools.Forms.ConnectionSucceededMsg"); |
||||
this.failedMessage = resMgr.GetString("SharpDbTools.Forms.ConnectionFailedMsg"); |
||||
|
||||
|
||||
this.connStringPropertyGrid.PropertyValueChanged += |
||||
new PropertyValueChangedEventHandler(this.ConnStringAttributesViewPropertyValueChanged); |
||||
// add a ProgressBar to the statusString
|
||||
this.statusStrip.Items.Add(connectionTestProgressBar); |
||||
this.connectionTestProgressBar.Step = 10; |
||||
this.connectionTestProgressBar.Minimum = 0; |
||||
this.connectionTestProgressBar.Maximum = 150; |
||||
} |
||||
|
||||
public string InvariantName { |
||||
get { |
||||
return this.invariantName; |
||||
} |
||||
set { |
||||
this.invariantName = value; |
||||
} |
||||
} |
||||
|
||||
public ConnectionTestState ConnectionTestState { |
||||
get { |
||||
return this.connectionTestState; |
||||
} |
||||
} |
||||
|
||||
public string ResultMessage |
||||
{ |
||||
get |
||||
{ |
||||
return resultMessage; |
||||
} |
||||
set |
||||
{ |
||||
resultMessage = value; |
||||
} |
||||
} |
||||
|
||||
public DbConnectionStringBuilder ConnectionStringBuilder |
||||
{ |
||||
get |
||||
{ |
||||
return (DbConnectionStringBuilder)this.connStringPropertyGrid.SelectedObject; |
||||
} |
||||
} |
||||
|
||||
public string ConnectionString |
||||
{ |
||||
get |
||||
{ |
||||
return ((DbConnectionStringBuilder)this.connStringPropertyGrid.SelectedObject).ConnectionString; |
||||
} |
||||
} |
||||
|
||||
protected override void OnLoad(EventArgs e) |
||||
{ |
||||
//
|
||||
// set the PropertyGrid to browse the available DbProviders
|
||||
//
|
||||
|
||||
base.OnLoad(e); |
||||
DbProvidersService service = DbProvidersService.GetDbProvidersService(); |
||||
if (service.ErrorMessages.Count > 0) { |
||||
StringBuilder b = new StringBuilder(); |
||||
foreach(string s in service.ErrorMessages) { |
||||
b.Append(s).Append("\n"); |
||||
} |
||||
MessageBox.Show(b.ToString(), "Non-fatal Exception caught", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); |
||||
} |
||||
|
||||
List<string> names = service.Names; |
||||
this.providerTypeComboBox.DataSource = names; |
||||
this.connStringResult.Text = this.ConnectionString; |
||||
} |
||||
|
||||
void CancelButtonClick(object sender, System.EventArgs e) |
||||
{ |
||||
this.DialogResult = DialogResult.Cancel; |
||||
this.Close(); |
||||
} |
||||
|
||||
void ProviderTypeSelectedIndexChanged(object sender, System.EventArgs e) |
||||
{ |
||||
string selection = (string)this.providerTypeComboBox.SelectedItem; |
||||
DbProvidersService service = DbProvidersService.GetDbProvidersService(); |
||||
DbProviderFactory factory = service[selection]; |
||||
DbConnectionStringBuilder builder = factory.CreateConnectionStringBuilder(); |
||||
connStringPropertyGrid.SelectedObject = builder; |
||||
} |
||||
|
||||
void ConnStringAttributesViewPropertyValueChanged(Object s, PropertyValueChangedEventArgs args) |
||||
{ |
||||
// looking for changes to the ConnectionString property in the PropertyGrid
|
||||
this.connStringResult.Text = this.ConnectionString; |
||||
this.outputMessageTabControl.SelectTab(this.connectionStringTab); |
||||
ResetTestResultTextBox(); |
||||
} |
||||
|
||||
void TestButtonClick(object sender, System.EventArgs e) |
||||
{ |
||||
string dbTypeName = (string)this.providerTypeComboBox.SelectedItem; |
||||
testConnectionBackgroundWorker = new ConnectionTestBackgroundWorker(dbTypeName); |
||||
testConnectionBackgroundWorker.WorkerSupportsCancellation = false; |
||||
progressTimer.Enabled = true; |
||||
testConnectionBackgroundWorker.DoWork += // TODO: This may result in duplicate bindings
|
||||
new DoWorkEventHandler(this.TestConnectionBackgroundWorkerDoWork); |
||||
testConnectionBackgroundWorker.RunWorkerCompleted += |
||||
new RunWorkerCompletedEventHandler(TestConnectionRunWorkerComplete); |
||||
testConnectionBackgroundWorker.RunWorkerAsync(); |
||||
} |
||||
|
||||
void ProgressTimerTick(object sender, System.EventArgs e) |
||||
{ |
||||
this.BeginInvoke(new EventHandler(UpdateProgressBar)); |
||||
} |
||||
|
||||
void UpdateProgressBar(object sender, EventArgs e) |
||||
{ |
||||
ToolStripProgressBar p = connectionTestProgressBar; |
||||
if (p.Value == p.Maximum) p.Value = 0; |
||||
p.PerformStep(); |
||||
} |
||||
|
||||
void SetTestResultTextBox() |
||||
{ |
||||
this.testResultTextBox.Text = ResultMessage; |
||||
this.outputMessageTabControl.SelectTab(this.testResultTab); |
||||
} |
||||
|
||||
void ResetTestResultTextBox() |
||||
{ |
||||
this.testResultTextBox.Text = ""; |
||||
this.connectionTestState = ConnectionTestState.UnTested; |
||||
} |
||||
|
||||
void TestConnectionBackgroundWorkerDoWork(object sender, DoWorkEventArgs e) |
||||
{ |
||||
DbConnection connection = null; |
||||
try |
||||
{ |
||||
// get the current name
|
||||
|
||||
ConnectionTestBackgroundWorker bw = sender as ConnectionTestBackgroundWorker; |
||||
string currentDbTypeName = bw.DatabaseType; |
||||
|
||||
// get the DbProviderFactory for this name
|
||||
|
||||
DbProvidersService service = DbProvidersService.GetDbProvidersService(); |
||||
DbProviderFactory factory = service[currentDbTypeName]; |
||||
|
||||
// get a connection object or this factory
|
||||
|
||||
connection = factory.CreateConnection(); |
||||
connection.ConnectionString = this.ConnectionString; |
||||
|
||||
connection.Open(); |
||||
e.Result = this.succeededMessage; //"Connection Succeeded";
|
||||
connectionTestState = ConnectionTestState.TestSucceeded; |
||||
} |
||||
catch(Exception ex) |
||||
{ |
||||
e.Result = |
||||
this.failedMessage + ex.Message; /*"Connection Failed: "*/ |
||||
connectionTestState = ConnectionTestState.TestFailed; |
||||
} |
||||
finally |
||||
{ |
||||
if (connection != null) |
||||
{ |
||||
connection.Close(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void TestConnectionRunWorkerComplete(object sender, RunWorkerCompletedEventArgs args) |
||||
{ |
||||
ResultMessage = args.Result as string; |
||||
this.Invoke(new EventHandler(TestConnectionCompleted)); |
||||
} |
||||
|
||||
void TestConnectionCompleted(object sender, EventArgs args) |
||||
{ |
||||
progressTimer.Enabled = false; |
||||
connectionTestProgressBar.Value = 0; |
||||
SetTestResultTextBox(); |
||||
testConnectionBackgroundWorker.Dispose(); |
||||
} |
||||
|
||||
void SubmitButtonClick(object sender, System.EventArgs e) |
||||
{ |
||||
string name = (string)this.providerTypeComboBox.SelectedItem; |
||||
DbProvidersService service = DbProvidersService.GetDbProvidersService(); |
||||
this.InvariantName = service.GetInvariantName(name); |
||||
|
||||
this.DialogResult = DialogResult.OK; |
||||
this.Close(); |
||||
} |
||||
} |
||||
|
||||
public enum ConnectionTestState |
||||
{ |
||||
UnTested, |
||||
TestFailed, |
||||
TestSucceeded |
||||
} |
||||
|
||||
class ConnectionTestBackgroundWorker: BackgroundWorker |
||||
{ |
||||
private string dbTypeName; |
||||
|
||||
public ConnectionTestBackgroundWorker(string dbTypeName): base() |
||||
{ |
||||
this.dbTypeName = dbTypeName; |
||||
} |
||||
|
||||
public string DatabaseType |
||||
{ |
||||
get |
||||
{ |
||||
return dbTypeName; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,126 +0,0 @@
@@ -1,126 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<root> |
||||
<!-- |
||||
Microsoft ResX Schema |
||||
|
||||
Version 2.0 |
||||
|
||||
The primary goals of this format is to allow a simple XML format |
||||
that is mostly human readable. The generation and parsing of the |
||||
various data types are done through the TypeConverter classes |
||||
associated with the data types. |
||||
|
||||
Example: |
||||
|
||||
... ado.net/XML headers & schema ... |
||||
<resheader name="resmimetype">text/microsoft-resx</resheader> |
||||
<resheader name="version">2.0</resheader> |
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
||||
<value>[base64 mime encoded serialized .NET Framework object]</value> |
||||
</data> |
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
||||
<comment>This is a comment</comment> |
||||
</data> |
||||
|
||||
There are any number of "resheader" rows that contain simple |
||||
name/value pairs. |
||||
|
||||
Each data row contains a name, and value. The row also contains a |
||||
type or mimetype. Type corresponds to a .NET class that support |
||||
text/value conversion through the TypeConverter architecture. |
||||
Classes that don't support this are serialized and stored with the |
||||
mimetype set. |
||||
|
||||
The mimetype is used for serialized objects, and tells the |
||||
ResXResourceReader how to depersist the object. This is currently not |
||||
extensible. For a given mimetype the value must be set accordingly: |
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format |
||||
that the ResXResourceWriter will generate, however the reader can |
||||
read any of the formats listed below. |
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64 |
||||
value : The object must be serialized with |
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter |
||||
: and then encoded with base64 encoding. |
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64 |
||||
value : The object must be serialized with |
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
||||
: and then encoded with base64 encoding. |
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64 |
||||
value : The object must be serialized into a byte array |
||||
: using a System.ComponentModel.TypeConverter |
||||
: and then encoded with base64 encoding. |
||||
--> |
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> |
||||
<xsd:element name="root" msdata:IsDataSet="true"> |
||||
<xsd:complexType> |
||||
<xsd:choice maxOccurs="unbounded"> |
||||
<xsd:element name="metadata"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" use="required" type="xsd:string" /> |
||||
<xsd:attribute name="type" type="xsd:string" /> |
||||
<xsd:attribute name="mimetype" type="xsd:string" /> |
||||
<xsd:attribute ref="xml:space" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="assembly"> |
||||
<xsd:complexType> |
||||
<xsd:attribute name="alias" type="xsd:string" /> |
||||
<xsd:attribute name="name" type="xsd:string" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="data"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> |
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
||||
<xsd:attribute ref="xml:space" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="resheader"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" type="xsd:string" use="required" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
</xsd:choice> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
</xsd:schema> |
||||
<resheader name="resmimetype"> |
||||
<value>text/microsoft-resx</value> |
||||
</resheader> |
||||
<resheader name="version"> |
||||
<value>2.0</value> |
||||
</resheader> |
||||
<resheader name="reader"> |
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
</resheader> |
||||
<resheader name="writer"> |
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
</resheader> |
||||
<metadata name="progressTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> |
||||
<value>247, 17</value> |
||||
</metadata> |
||||
<metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> |
||||
<value>371, 17</value> |
||||
</metadata> |
||||
</root> |
@ -1,120 +0,0 @@
@@ -1,120 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<root> |
||||
<!-- |
||||
Microsoft ResX Schema |
||||
|
||||
Version 2.0 |
||||
|
||||
The primary goals of this format is to allow a simple XML format |
||||
that is mostly human readable. The generation and parsing of the |
||||
various data types are done through the TypeConverter classes |
||||
associated with the data types. |
||||
|
||||
Example: |
||||
|
||||
... ado.net/XML headers & schema ... |
||||
<resheader name="resmimetype">text/microsoft-resx</resheader> |
||||
<resheader name="version">2.0</resheader> |
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
||||
<value>[base64 mime encoded serialized .NET Framework object]</value> |
||||
</data> |
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
||||
<comment>This is a comment</comment> |
||||
</data> |
||||
|
||||
There are any number of "resheader" rows that contain simple |
||||
name/value pairs. |
||||
|
||||
Each data row contains a name, and value. The row also contains a |
||||
type or mimetype. Type corresponds to a .NET class that support |
||||
text/value conversion through the TypeConverter architecture. |
||||
Classes that don't support this are serialized and stored with the |
||||
mimetype set. |
||||
|
||||
The mimetype is used for serialized objects, and tells the |
||||
ResXResourceReader how to depersist the object. This is currently not |
||||
extensible. For a given mimetype the value must be set accordingly: |
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format |
||||
that the ResXResourceWriter will generate, however the reader can |
||||
read any of the formats listed below. |
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64 |
||||
value : The object must be serialized with |
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter |
||||
: and then encoded with base64 encoding. |
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64 |
||||
value : The object must be serialized with |
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
||||
: and then encoded with base64 encoding. |
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64 |
||||
value : The object must be serialized into a byte array |
||||
: using a System.ComponentModel.TypeConverter |
||||
: and then encoded with base64 encoding. |
||||
--> |
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> |
||||
<xsd:element name="root" msdata:IsDataSet="true"> |
||||
<xsd:complexType> |
||||
<xsd:choice maxOccurs="unbounded"> |
||||
<xsd:element name="metadata"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" use="required" type="xsd:string" /> |
||||
<xsd:attribute name="type" type="xsd:string" /> |
||||
<xsd:attribute name="mimetype" type="xsd:string" /> |
||||
<xsd:attribute ref="xml:space" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="assembly"> |
||||
<xsd:complexType> |
||||
<xsd:attribute name="alias" type="xsd:string" /> |
||||
<xsd:attribute name="name" type="xsd:string" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="data"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> |
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
||||
<xsd:attribute ref="xml:space" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="resheader"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" type="xsd:string" use="required" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
</xsd:choice> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
</xsd:schema> |
||||
<resheader name="resmimetype"> |
||||
<value>text/microsoft-resx</value> |
||||
</resheader> |
||||
<resheader name="version"> |
||||
<value>2.0</value> |
||||
</resheader> |
||||
<resheader name="reader"> |
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
</resheader> |
||||
<resheader name="writer"> |
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
</resheader> |
||||
</root> |
@ -1,75 +0,0 @@
@@ -1,75 +0,0 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>ICSharpCode.ServerBrowserTool</RootNamespace> |
||||
<AssemblyName>ICSharpCode.ServerBrowserTool</AssemblyName> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<ProjectGuid>{D721EAA4-8A40-4EF0-A011-5862159BE621}</ProjectGuid> |
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||
<NoStdLib>False</NoStdLib> |
||||
<RegisterForComInterop>False</RegisterForComInterop> |
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
||||
<BaseAddress>4194304</BaseAddress> |
||||
<PlatformTarget>AnyCPU</PlatformTarget> |
||||
<FileAlignment>4096</FileAlignment> |
||||
<WarningLevel>4</WarningLevel> |
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||
<OutputPath>..\..\..\..\..\AddIns\AddIns\Misc\SharpServerTools\</OutputPath> |
||||
<Optimize>False</Optimize> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<OutputPath>..\..\..\..\..\AddIns\AddIns\Misc\SharpServerTools\</OutputPath> |
||||
<Optimize>True</Optimize> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
<DebugSymbols>False</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Xml" /> |
||||
<Reference Include="System.Windows.Forms" /> |
||||
<Reference Include="System.Drawing" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="..\..\..\..\Main\GlobalAssemblyInfo.cs"> |
||||
<Link>Src\Configuration\GlobalAssemblyInfo.cs</Link> |
||||
</Compile> |
||||
<Compile Include="Src\Forms\ISupportsDragDrop.cs" /> |
||||
<Compile Include="Src\Forms\ServerToolTreeView.cs" /> |
||||
<Compile Include="Src\Forms\IInitializable.cs" /> |
||||
<Compile Include="Src\Forms\NodeAwareContextMenuStrip.cs" /> |
||||
<Compile Include="Src\Forms\RebuildRequiredEvents.cs" /> |
||||
<Compile Include="Src\Forms\ServerBrowserTool.cs" /> |
||||
<Compile Include="Src\Configuration\AssemblyInfo.cs" /> |
||||
<Compile Include="Src\Forms\ProgressEllipsis.cs" /> |
||||
<EmbeddedResource Include="Resources\Strings.resx" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Folder Include="Resources" /> |
||||
<Folder Include="Src" /> |
||||
<Folder Include="Src\Configuration" /> |
||||
<Folder Include="Src\Forms" /> |
||||
<Content Include="SharpServerTools.addin"> |
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
</Content> |
||||
<ProjectReference Include="..\..\..\..\Main\Core\Project\ICSharpCode.Core.csproj"> |
||||
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project> |
||||
<Name>ICSharpCode.Core</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> |
||||
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> |
||||
<Name>ICSharpCode.SharpDevelop</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
</Project> |
@ -1,6 +0,0 @@
@@ -1,6 +0,0 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00 |
||||
# SharpDevelop 2.1.0.1900 |
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerBrowserTool", "ServerBrowserTool.csproj", "{D721EAA4-8A40-4EF0-A011-5862159BE621}" |
||||
EndProject |
||||
Global |
||||
EndGlobal |
@ -1,48 +0,0 @@
@@ -1,48 +0,0 @@
|
||||
<AddIn name = "SharpDbTools" |
||||
author = "Dickon Field" |
||||
url = "" |
||||
description = "A collection of components and tools to help develop db-aware apps... and more"> |
||||
|
||||
<Manifest> |
||||
<Identity name = "ICSharpCode.SharpServerTools"/> |
||||
</Manifest> |
||||
|
||||
<Runtime> |
||||
<Import assembly = "ICSharpCode.ServerBrowserTool.dll"/> |
||||
<Import assembly="ICSharpCode.DataTools.AddIn.dll"/> |
||||
<Import assembly="ICSharpCode.DataTools.UI.dll"/> |
||||
<Import assembly="ICSharpCode.DataTools.Model.dll"/> |
||||
</Runtime> |
||||
|
||||
<Path name = "/SharpDevelop/Workbench/Pads"> |
||||
<Pad id = "SharpServerToolsPad" |
||||
category = "Main" |
||||
title = "Server Explorer" |
||||
icon = "ServerTool.Server" |
||||
shortcut = "Control|Alt|D" |
||||
class = "SharpServerTools.Forms.ServerBrowserTool"/> |
||||
</Path> |
||||
|
||||
<Path name = "/SharpServerTools/SharpDbTools/FormsArtefactFactory"> |
||||
<Class id = "System.Data.SQLite" |
||||
class = "SharpDbTools.SQLite.Forms.SQLiteFormsArtefactFactory"/> |
||||
</Path> |
||||
|
||||
|
||||
<Path name = "/SharpServerTools/SharpDbTools/FormsArtefactFactory"> |
||||
<Class id = "System.Data.OracleClient" |
||||
class = "SharpDbTools.Oracle.Forms.OracleFormsArtefactFactory"/> |
||||
</Path> |
||||
|
||||
<Path name = "/SharpServerTools/SharpDbTools/FormsArtefactFactory"> |
||||
<Class id = "System.Data.SqlClient" |
||||
class = "SharpDbTools.SQLServer.Forms.SQLServerFormsArtefactFactory"/> |
||||
</Path> |
||||
|
||||
<Path name = "/SharpServerTools/ServerTool"> |
||||
<Class id = "DatabaseExplorer" |
||||
class = "SharpDbTools.Forms.DatabaseExplorerTreeNode"/> |
||||
</Path> |
||||
|
||||
|
||||
</AddIn> |
@ -1,21 +0,0 @@
@@ -1,21 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Dickon Field" email=""/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System.Reflection; |
||||
using System.Runtime.InteropServices; |
||||
|
||||
// Information about this assembly is defined by the following
|
||||
// attributes.
|
||||
//
|
||||
// change them to the information which is associated with the assembly
|
||||
// you compile.
|
||||
|
||||
[assembly: AssemblyTitle("ServerBrowserTool")] |
||||
[assembly: AssemblyDescription("")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyTrademark("")] |
||||
[assembly: AssemblyCulture("")] |
@ -1,19 +0,0 @@
@@ -1,19 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Dickon Field" email=""/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
namespace SharpServerTools.Forms |
||||
{ |
||||
/// <summary>
|
||||
/// Implemented by anything that is initializable
|
||||
/// </summary>
|
||||
public interface IInitializable |
||||
{ |
||||
void Initialize(); |
||||
} |
||||
} |
@ -1,23 +0,0 @@
@@ -1,23 +0,0 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: dickon |
||||
* Date: 04/03/2007 |
||||
* Time: 09:14 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
|
||||
using System; |
||||
using System.Windows.Forms; |
||||
|
||||
namespace SharpServerTools.Forms |
||||
{ |
||||
/// <summary>
|
||||
/// This interface is implemented by any plugin to ServerExplorer that supports drag and drop
|
||||
/// of some of its data
|
||||
/// </summary>
|
||||
public interface ISupportsDragDrop |
||||
{ |
||||
void HandleMouseDownEvent(object sender, MouseEventArgs e); |
||||
} |
||||
} |
@ -1,28 +0,0 @@
@@ -1,28 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Dickon Field" email=""/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Windows.Forms; |
||||
|
||||
namespace SharpServerTools.Forms |
||||
{ |
||||
public class NodeAwareContextMenuStrip : ContextMenuStrip |
||||
{ |
||||
TreeNode treeNodeAttached; |
||||
|
||||
public NodeAwareContextMenuStrip(TreeNode treeNodeAttached) : base() |
||||
{ |
||||
this.treeNodeAttached = treeNodeAttached; |
||||
} |
||||
|
||||
public TreeNode TreeNode { |
||||
get { |
||||
return treeNodeAttached; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,56 +0,0 @@
@@ -1,56 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Dickon Field" email=""/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Text; |
||||
|
||||
namespace SharpServerTools.Forms |
||||
{ |
||||
/// <summary>
|
||||
/// Shows progress as a series of ellipses. Not threadsafe.
|
||||
/// </summary>
|
||||
public class ProgressEllipsis |
||||
{ |
||||
int noOfDots; |
||||
StringBuilder currentString; |
||||
int currentValue; |
||||
|
||||
public ProgressEllipsis() |
||||
{ |
||||
} |
||||
|
||||
public ProgressEllipsis(int noOfDots) |
||||
{ |
||||
this.noOfDots = noOfDots; |
||||
currentString = new StringBuilder(); |
||||
currentValue = 0; |
||||
} |
||||
|
||||
public void performStep() |
||||
{ |
||||
currentValue++; |
||||
if ((currentValue % noOfDots) == 0) { |
||||
currentValue = 0; |
||||
currentString.Remove(0, currentString.Length-1); |
||||
} else { |
||||
currentString.Append("."); |
||||
} |
||||
} |
||||
|
||||
public string Text { |
||||
get { |
||||
return currentString.ToString(); |
||||
} |
||||
} |
||||
|
||||
public int Value { |
||||
set { |
||||
this.currentValue = value; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,54 +0,0 @@
@@ -1,54 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Dickon Field" email=""/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace SharpServerTools.Forms |
||||
{ |
||||
/// <summary>
|
||||
/// An IRebuildable can be asked to rebuild its Node tree
|
||||
/// </summary>
|
||||
public interface IRebuildable |
||||
{ |
||||
void Rebuild(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// An IRequiresRebuildSource can request the ServerToolTreeView to rebuild
|
||||
/// it by emitting the RebuildRequiredEvent
|
||||
/// </summary>
|
||||
public interface IRequiresRebuildSource |
||||
{ |
||||
event RebuildRequiredEventHandler RebuildRequiredEvent; |
||||
} |
||||
|
||||
public delegate void RebuildRequiredEventHandler(object sender, RebuildRequiredEventArgs e); |
||||
|
||||
/// <summary>
|
||||
/// An IRequiresRebuildSource should add a reference to itself to
|
||||
/// this event if it wants to be rebuilt.
|
||||
/// The parent of an IRequiresRebuildSource may or may not add itself
|
||||
/// and resend the event to the ServerToolTreeView depending on the
|
||||
/// relationship between parent and child.
|
||||
/// </summary>
|
||||
public class RebuildRequiredEventArgs: EventArgs |
||||
{ |
||||
List<IRebuildable> rebuildNodes = new List<IRebuildable>(); |
||||
|
||||
public IEnumerable<IRebuildable> Nodes { |
||||
get { |
||||
return rebuildNodes; |
||||
} |
||||
} |
||||
|
||||
public void AddNode(IRebuildable node) |
||||
{ |
||||
rebuildNodes.Add(node); |
||||
} |
||||
} |
||||
} |
@ -1,64 +0,0 @@
@@ -1,64 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Dickon Field" email=""/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace SharpServerTools.Forms |
||||
{ |
||||
/// <summary>
|
||||
/// Enables a user to browse metadata associated with a db server and to open resources
|
||||
/// referenced therein. The intention is to extend this to other server processes over
|
||||
/// time.
|
||||
/// </summary>
|
||||
public class ServerBrowserTool : AbstractPadContent |
||||
{ |
||||
Panel ctl; |
||||
ServerToolTreeView dbTree; |
||||
|
||||
/// <summary>
|
||||
/// ServerBrowserTool hosts one or more TreeViews providing views of types
|
||||
/// of server. Currently it shows only relational database servers.
|
||||
/// </summary>
|
||||
public ServerBrowserTool() |
||||
{ |
||||
LoggingService.Debug("Loading ServerBrowserTool"); |
||||
dbTree = new ServerToolTreeView(); |
||||
dbTree.Dock = DockStyle.Fill; |
||||
ctl = new Panel(); |
||||
ctl.Controls.Add(dbTree); |
||||
dbTree.Rebuild(); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// The <see cref="System.Windows.Forms.Control"/> representing the pad
|
||||
/// </summary>
|
||||
public override Control Control { |
||||
get { |
||||
return ctl; |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Rebuildes the pad
|
||||
/// </summary>
|
||||
public override void RedrawContent() |
||||
{ |
||||
|
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Cleans up all used resources
|
||||
/// </summary>
|
||||
public override void Dispose() |
||||
{ |
||||
ctl.Dispose(); |
||||
} |
||||
} |
||||
} |
@ -1,108 +0,0 @@
@@ -1,108 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Dickon Field" email=""/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.Core; |
||||
|
||||
namespace SharpServerTools.Forms |
||||
{ |
||||
/// <summary>
|
||||
/// Provides a tree-structured visual rendering of server instances.
|
||||
/// This class should not hold references to server data, but should render its
|
||||
/// content using data retrieved from business services responsible for
|
||||
/// maintaining this model/s of underlying services.
|
||||
/// </summary>
|
||||
public class ServerToolTreeView : TreeView, IRebuildable |
||||
{ |
||||
public const string SERVERTOOL_PATH = "/SharpServerTools/ServerTool"; |
||||
|
||||
public ServerToolTreeView(): base() |
||||
{ |
||||
|
||||
AddInTreeNode node = |
||||
AddInTree.GetTreeNode(SERVERTOOL_PATH); |
||||
List<Codon> codons = node.Codons; |
||||
foreach (Codon codon in codons) { |
||||
// create an instance of the relevant ServerTool TreeNode
|
||||
string id = codon.Id; |
||||
TreeNode treeNode = (TreeNode)node.BuildChildItem(id, null, null); |
||||
|
||||
// a ServerTool plugin can register to be refreshed by the ServerToolTreeView
|
||||
// control by implementing the IRequiresRebuildSource interface
|
||||
|
||||
IRequiresRebuildSource s = treeNode as IRequiresRebuildSource; |
||||
|
||||
if (s != null) { |
||||
s.RebuildRequiredEvent += new RebuildRequiredEventHandler(RebuildRequiredNotify); |
||||
} |
||||
|
||||
// a ServerTool plugin can also register to handle drag-n-drop if it implements
|
||||
// the required interface
|
||||
|
||||
ISupportsDragDrop d = treeNode as ISupportsDragDrop; |
||||
|
||||
if (d != null) { |
||||
this.MouseDown += new MouseEventHandler(d.HandleMouseDownEvent); |
||||
} |
||||
|
||||
this.Nodes.Add(treeNode); |
||||
} |
||||
|
||||
// Type dbExplorerType = Type.GetType("SharpDbTools.Forms.DatabaseExplorerTreeNode, SharpDbTools");
|
||||
// TreeNode dbExplorerNode = (TreeNode)Activator.CreateInstance(dbExplorerType);
|
||||
// IRequiresRebuildSource s = dbExplorerNode as IRequiresRebuildSource;
|
||||
// s.RebuildRequiredEvent += new RebuildRequiredEventHandler(RebuildRequiredNotify);
|
||||
// this.Nodes.Add(dbExplorerNode);
|
||||
} |
||||
|
||||
public void RebuildChildren(IEnumerable children) |
||||
{ |
||||
// Rebuild each of the root nodes in the ServerToolTreeView
|
||||
// Currently this comprises the Database Explorer
|
||||
IEnumerable n = children; |
||||
if (n == null) { |
||||
n = this.Nodes; |
||||
} |
||||
|
||||
this.BeginUpdate(); |
||||
foreach (object o in n) { |
||||
IRebuildable se = (IRebuildable)o; |
||||
se.Rebuild(); |
||||
} |
||||
this.EndUpdate(); |
||||
} |
||||
|
||||
private void RebuildRequiredNotify(object sender, RebuildRequiredEventArgs e) |
||||
{ |
||||
IEnumerable children = e.Nodes; |
||||
if (this.InvokeRequired) { |
||||
this.Invoke(new RebuildChildrenDelegate(RebuildChildren), new object[] {children}); |
||||
} |
||||
else { |
||||
RebuildChildren(children); |
||||
} |
||||
|
||||
} |
||||
|
||||
public void Rebuild() |
||||
{ |
||||
if (this.InvokeRequired) { |
||||
this.Invoke(new RebuildChildrenDelegate(RebuildChildren), new object[] {null}); |
||||
} |
||||
else { |
||||
this.RebuildChildren(null); |
||||
} |
||||
} |
||||
|
||||
} |
||||
public delegate void RebuildChildrenDelegate(IEnumerable children); |
||||
|
||||
} |
@ -1,109 +0,0 @@
@@ -1,109 +0,0 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<PropertyGroup> |
||||
<OutputType>Library</OutputType> |
||||
<RootNamespace>ICSharpCode.DataTools.AddIn</RootNamespace> |
||||
<AssemblyName>ICSharpCode.DataTools.AddIn</AssemblyName> |
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
||||
<ProjectGuid>{93B2D6DF-7588-40C0-8A35-CA0DD7328FC3}</ProjectGuid> |
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks> |
||||
<NoStdLib>False</NoStdLib> |
||||
<WarningLevel>4</WarningLevel> |
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> |
||||
<OutputPath>..\..\..\..\..\AddIns\AddIns\Misc\SharpServerTools\</OutputPath> |
||||
<Optimize>False</Optimize> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<OutputPath>..\..\..\..\..\AddIns\AddIns\Misc\SharpServerTools\</OutputPath> |
||||
<Optimize>True</Optimize> |
||||
<DefineConstants>TRACE</DefineConstants> |
||||
<DebugSymbols>False</DebugSymbols> |
||||
<DebugType>None</DebugType> |
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' "> |
||||
<RegisterForComInterop>False</RegisterForComInterop> |
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies> |
||||
<BaseAddress>4194304</BaseAddress> |
||||
<PlatformTarget>AnyCPU</PlatformTarget> |
||||
<FileAlignment>4096</FileAlignment> |
||||
</PropertyGroup> |
||||
<ItemGroup> |
||||
<Reference Include="System" /> |
||||
<Reference Include="System.Data" /> |
||||
<Reference Include="System.Drawing" /> |
||||
<Reference Include="System.Windows.Forms" /> |
||||
<Reference Include="System.Xml" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Compile Include="..\..\..\..\Main\GlobalAssemblyInfo.cs"> |
||||
<Link>Src\Configuration\GlobalAssemblyInfo.cs</Link> |
||||
</Compile> |
||||
<Compile Include="Src\Configuration\AssemblyInfo.cs" /> |
||||
<Compile Include="Src\Forms.TextEditor\SQLTextEditorControl.cs" /> |
||||
<Compile Include="Src\Forms\SQLTool.cs" /> |
||||
<Compile Include="Src\Forms\SQLTool.Designer.cs"> |
||||
<DependentUpon>SQLTool.cs</DependentUpon> |
||||
</Compile> |
||||
<Compile Include="Src\Forms\SQLToolResourceSyntaxModeProvider.cs" /> |
||||
<Compile Include="Src\Forms\SQLToolViewContent.cs" /> |
||||
<Compile Include="Src\Forms\TableDescribeViewContent.cs" /> |
||||
<Compile Include="Src\Forms\DatabaseExplorerTreeNode.cs" /> |
||||
<Compile Include="Src\Forms\DbModelInfoTreeNode.cs" /> |
||||
<Compile Include="Src\Forms\FormsArtefactFactories.cs" /> |
||||
<Compile Include="Src\Forms\FormsArtefactFactory.cs" /> |
||||
<EmbeddedResource Include="Resources\Strings.resx" /> |
||||
<EmbeddedResource Include="Src\Forms\SQLTool.resx"> |
||||
<DependentUpon>SQLTool.cs</DependentUpon> |
||||
</EmbeddedResource> |
||||
<Compile Include="Src\Forms\TableTreeNode.cs" /> |
||||
<Compile Include="Src\Provider\OracleFormsArtefactFactory.cs" /> |
||||
<Compile Include="Src\Provider\SQLiteArtefactFactory.cs" /> |
||||
<Compile Include="Src\Provider\SQLServerFormsArtefactFactory.cs" /> |
||||
<EmbeddedResource Include="Resources\SQL.xshd" /> |
||||
<EmbeddedResource Include="Resources\SyntaxModes.xml" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<Folder Include="Resources" /> |
||||
<Folder Include="Src" /> |
||||
<Folder Include="Src\Configuration" /> |
||||
<Folder Include="Src\Data" /> |
||||
<Folder Include="Src\Forms" /> |
||||
<Folder Include="Src\Forms.TextEditor" /> |
||||
<Folder Include="Src\Provider" /> |
||||
<ProjectReference Include="..\..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj"> |
||||
<Project>{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}</Project> |
||||
<Name>ICSharpCode.TextEditor</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> |
||||
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> |
||||
<Name>ICSharpCode.SharpDevelop</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\..\Main\Core\Project\ICSharpCode.Core.csproj"> |
||||
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project> |
||||
<Name>ICSharpCode.Core</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\DataTools.Model\DataTools.Model.csproj"> |
||||
<Project>{51783FC4-D8D2-4BFB-A1F1-AC8857CF3ED0}</Project> |
||||
<Name>DataTools.Model</Name> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\DataTools.UI\DataTools.UI.csproj"> |
||||
<Project>{87C0E3D9-0DFD-4F6D-8E38-408AAF73F4EE}</Project> |
||||
<Name>DataTools.UI</Name> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\ServerBrowserTool\ServerBrowserTool.csproj"> |
||||
<Project>{D721EAA4-8A40-4EF0-A011-5862159BE621}</Project> |
||||
<Name>ServerBrowserTool</Name> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
</Project> |
@ -1,159 +0,0 @@
@@ -1,159 +0,0 @@
|
||||
<?xml version = "1.0"?> |
||||
<!-- Thanks to Troy@ebswift.com --> |
||||
|
||||
<SyntaxDefinition name = "SQL" extensions = ".sql"> |
||||
|
||||
<Environment> |
||||
<Default color = "SystemColors.WindowText" bgcolor="SystemColors.Window"/> |
||||
<VRuler color = "Blue"/> |
||||
<Selection bgcolor = "LightBlue"/> |
||||
<LineNumbers color = "Teal" bgcolor = "SystemColors.Window"/> |
||||
<InvalidLines color = "Red"/> |
||||
<EOLMarkers color = "White"/> |
||||
<SpaceMarkers color = "#E0E0E5"/> |
||||
<TabMarkers color = "#E0E0E5"/> |
||||
<CaretMarker color = "Yellow"/> |
||||
<FoldLine color = "#808080" bgcolor="Black"/> |
||||
<FoldMarker color = "#808080" bgcolor="White"/> |
||||
</Environment> |
||||
|
||||
<Properties> |
||||
<Property name="LineComment" value="--"/> |
||||
</Properties> |
||||
|
||||
<Digits name = "Digits" bold = "false" italic = "false" color = "DarkBlue"/> |
||||
|
||||
<RuleSets> |
||||
<RuleSet ignorecase = "true"> |
||||
|
||||
<Delimiters>=!><+-/*%&|^~.}{,;][?:()</Delimiters> |
||||
|
||||
<Span name ="LineComment" bold ="false" italic ="true" color ="DarkGreen" stopateol ="true"> |
||||
<Begin>--</Begin> |
||||
</Span> |
||||
|
||||
<Span name ="BlockComment" bold ="false" italic ="false" color ="DarkGreen" stopateol ="false"> |
||||
<Begin>/*</Begin> |
||||
<End>*/</End> |
||||
</Span> |
||||
|
||||
<Span name ="String" bold ="false" italic ="false" color ="Sienna" stopateol ="false"> |
||||
<Begin>"</Begin> |
||||
<End>"</End> |
||||
</Span> |
||||
|
||||
<Span name = "Character" bold = "false" italic = "false" color = "Sienna" stopateol = "true"> |
||||
<Begin>'</Begin> |
||||
<End>'</End> |
||||
</Span> |
||||
|
||||
<KeyWords name ="SqlKeywords" bold="false" italic = "false" color = "Blue"> |
||||
<Key word = "from" /> |
||||
<Key word = "where" /> |
||||
<Key word = "in" /> |
||||
<Key word = "on" /> |
||||
<Key word = "exists" /> |
||||
<Key word = "or" /> |
||||
<Key word = "and" /> |
||||
<Key word = "not" /> |
||||
<Key word = "null" /> |
||||
<Key word = "having" /> |
||||
<Key word = "group" /> |
||||
<Key word = "by" /> |
||||
<Key word = "order" /> |
||||
|
||||
|
||||
<Key word = "into" /> |
||||
<Key word = "values" /> |
||||
<Key word = "set" /> |
||||
<Key word = "inner" /> |
||||
<Key word = "outer" /> |
||||
<Key word = "join" /> |
||||
<Key word = "union" /> |
||||
<Key word = "desc" /> |
||||
<Key word = "asc" /> |
||||
</KeyWords> |
||||
|
||||
<KeyWords name ="SqlActionWords" bold="false" italic = "false" color = "Blue"> |
||||
<Key word = "select" /> |
||||
<Key word = "update" /> |
||||
<Key word = "use" /> |
||||
<Key word = "insert" /> |
||||
<Key word = "create" /> |
||||
<Key word = "drop" /> |
||||
<Key word = "delete" /> |
||||
<Key word = "truncate" /> |
||||
<Key word = "alter" /> |
||||
<Key word = "add" /> |
||||
</KeyWords> |
||||
|
||||
<KeyWords name ="SqlTypes" bold="false" italic = "false" color = "DarkRed"> |
||||
<Key word = "varchar" /> |
||||
<Key word = "nvarchar" /> |
||||
<Key word = "char" /> |
||||
<Key word = "nchar" /> |
||||
<Key word = "int" /> |
||||
<Key word = "text" /> |
||||
<Key word = "ntext" /> |
||||
<Key word = "double" /> |
||||
<Key word = "money" /> |
||||
<Key word = "bit" /> |
||||
</KeyWords> |
||||
|
||||
<KeyWords name ="SqlObjects" bold="false" italic = "false" color = "DarkRed"> |
||||
<Key word = "table" /> |
||||
<Key word = "proc" /> |
||||
<Key word = "procedure" /> |
||||
<Key word = "function" /> |
||||
<Key word = "view" /> |
||||
<Key word = "trigger" /> |
||||
<Key word = "index" /> |
||||
<Key word = "database" /> |
||||
</KeyWords> |
||||
|
||||
<KeyWords name ="TSql" bold="false" italic = "false" color = "DarkBlue"> |
||||
<Key word = "IF" /> |
||||
<Key word = "ELSE" /> |
||||
<Key word = "CASE" /> |
||||
<Key word = "RETURN" /> |
||||
<Key word = "END" /> |
||||
<Key word = "DECLARE" /> |
||||
|
||||
<Key word = "SWITCH" /> |
||||
<Key word = "END" /> |
||||
|
||||
<Key word = "BEGIN" /> |
||||
<Key word = "CASE" /> |
||||
<Key word = "WHEN" /> |
||||
<Key word = "END" /> |
||||
</KeyWords> |
||||
|
||||
<KeyWords name ="Punctuation" bold="false" italic = "false" color = "DarkSlateGray"> |
||||
<Key word = "(" /> |
||||
<Key word = ")" /> |
||||
</KeyWords> |
||||
|
||||
<KeyWords name ="Operators" bold="false" italic = "false" color = "DarkSlateGray"> |
||||
<Key word = "<" /> |
||||
<Key word = ">" /> |
||||
<Key word = "=" /> |
||||
</KeyWords> |
||||
|
||||
<KeyWords name ="Functions" bold="false" italic = "false" color = "DarkRed"> |
||||
<Key word = "substring" /> |
||||
<Key word = "upper" /> |
||||
<Key word = "lower" /> |
||||
<Key word = "reverse" /> |
||||
<Key word = "avg" /> |
||||
<Key word = "min" /> |
||||
<Key word = "max" /> |
||||
<Key word = "replace" /> |
||||
<Key word = "ltrim" /> |
||||
<Key word = "rtrim" /> |
||||
<Key word = "cast" /> |
||||
|
||||
</KeyWords> |
||||
</RuleSet> |
||||
</RuleSets> |
||||
</SyntaxDefinition> |
||||
|
@ -1,205 +0,0 @@
@@ -1,205 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<root> |
||||
<!-- |
||||
Microsoft ResX Schema |
||||
|
||||
Version 2.0 |
||||
|
||||
The primary goals of this format is to allow a simple XML format |
||||
that is mostly human readable. The generation and parsing of the |
||||
various data types are done through the TypeConverter classes |
||||
associated with the data types. |
||||
|
||||
Example: |
||||
|
||||
... ado.net/XML headers & schema ... |
||||
<resheader name="resmimetype">text/microsoft-resx</resheader> |
||||
<resheader name="version">2.0</resheader> |
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
||||
<value>[base64 mime encoded serialized .NET Framework object]</value> |
||||
</data> |
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
||||
<comment>This is a comment</comment> |
||||
</data> |
||||
|
||||
There are any number of "resheader" rows that contain simple |
||||
name/value pairs. |
||||
|
||||
Each data row contains a name, and value. The row also contains a |
||||
type or mimetype. Type corresponds to a .NET class that support |
||||
text/value conversion through the TypeConverter architecture. |
||||
Classes that don't support this are serialized and stored with the |
||||
mimetype set. |
||||
|
||||
The mimetype is used for serialized objects, and tells the |
||||
ResXResourceReader how to depersist the object. This is currently not |
||||
extensible. For a given mimetype the value must be set accordingly: |
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format |
||||
that the ResXResourceWriter will generate, however the reader can |
||||
read any of the formats listed below. |
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64 |
||||
value : The object must be serialized with |
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter |
||||
: and then encoded with base64 encoding. |
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64 |
||||
value : The object must be serialized with |
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
||||
: and then encoded with base64 encoding. |
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64 |
||||
value : The object must be serialized into a byte array |
||||
: using a System.ComponentModel.TypeConverter |
||||
: and then encoded with base64 encoding. |
||||
--> |
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> |
||||
<xsd:element name="root" msdata:IsDataSet="true"> |
||||
<xsd:complexType> |
||||
<xsd:choice maxOccurs="unbounded"> |
||||
<xsd:element name="metadata"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" use="required" type="xsd:string" /> |
||||
<xsd:attribute name="type" type="xsd:string" /> |
||||
<xsd:attribute name="mimetype" type="xsd:string" /> |
||||
<xsd:attribute ref="xml:space" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="assembly"> |
||||
<xsd:complexType> |
||||
<xsd:attribute name="alias" type="xsd:string" /> |
||||
<xsd:attribute name="name" type="xsd:string" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="data"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> |
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
||||
<xsd:attribute ref="xml:space" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="resheader"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" type="xsd:string" use="required" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
</xsd:choice> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
</xsd:schema> |
||||
<resheader name="resmimetype"> |
||||
<value>text/microsoft-resx</value> |
||||
</resheader> |
||||
<resheader name="version"> |
||||
<value>2.0</value> |
||||
</resheader> |
||||
<resheader name="reader"> |
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
</resheader> |
||||
<resheader name="writer"> |
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
</resheader> |
||||
<data name="SharpDbTools.Data.PrimaryObjects.Tables" xml:space="preserve"> |
||||
<value>Tables</value> |
||||
</data> |
||||
<data name="SharpDbTools.Data.PrimaryObjects.Procedures" xml:space="preserve"> |
||||
<value>Procedures</value> |
||||
</data> |
||||
<data name="SharpDbTools.Data.PrimaryObjects.Functions" xml:space="preserve"> |
||||
<value>Functions |
||||
</value> |
||||
</data> |
||||
<data name="SharpDbTools.Data.PrimaryObjects.Views" xml:space="preserve"> |
||||
<value>Views</value> |
||||
</data> |
||||
<data name="SharpDbTools.Data.PrimaryObjects.Users" xml:space="preserve"> |
||||
<value>Users</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.DbObjectNodeName" xml:space="preserve"> |
||||
<value>Db Objects</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.DbExplorerNodeName" xml:space="preserve"> |
||||
<value>Database Explorer</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.AddConnectionMenu" xml:space="preserve"> |
||||
<value>Add Connection</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.DeleteConnectionMenu" xml:space="preserve"> |
||||
<value>Delete Connection</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.SaveAllMenu" xml:space="preserve"> |
||||
<value>Save All</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.ConnectionPropertiesNodeName" xml:space="preserve"> |
||||
<value>Connection Properties</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.NoMetadataNodeName" xml:space="preserve"> |
||||
<value>No Metadata</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.SetConnectionStringMenu" xml:space="preserve"> |
||||
<value>Set Connection String</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.LoadMetadataFromConnectionMenu" xml:space="preserve"> |
||||
<value>Load Metadata From Connection</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.LoadMetadataFromFileMenu" xml:space="preserve"> |
||||
<value>Load Metadata From File</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.OpenSQLToolMenu" xml:space="preserve"> |
||||
<value>Open SQL Tool</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.ConnectionStringNodeName" xml:space="preserve"> |
||||
<value>Connection String:</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.InvariantNameNodeName" xml:space="preserve"> |
||||
<value>Invariant Name:</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.ConnectionSucceededMsg" xml:space="preserve"> |
||||
<value>Connection Succeeded</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.ConnectionFailedMsg" xml:space="preserve"> |
||||
<value>Connection Failed</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.TestButton" xml:space="preserve"> |
||||
<value>Test</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.SubmitButton" xml:space="preserve"> |
||||
<value>Submit</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.CancelButton" xml:space="preserve"> |
||||
<value>Cancel</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.DataSourceTypeLabel" xml:space="preserve"> |
||||
<value>Data Source Type:</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.ConnectionStringLabel" xml:space="preserve"> |
||||
<value>Connection String:</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.ConnectionStringTab" xml:space="preserve"> |
||||
<value>Connection String</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.TestResultTab" xml:space="preserve"> |
||||
<value>Test Result Message</value> |
||||
</data> |
||||
<data name="SharpDbTools.Forms.ConnectionStringDefinitionDialog" xml:space="preserve"> |
||||
<value>Set Up Connection String</value> |
||||
</data> |
||||
</root> |
@ -1,5 +0,0 @@
@@ -1,5 +0,0 @@
|
||||
<SyntaxModes version="1.0"> |
||||
<Mode file = "SQL.xshd" |
||||
name = "SQL" |
||||
extensions = ".sql"/> |
||||
</SyntaxModes> |
@ -1,6 +0,0 @@
@@ -1,6 +0,0 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00 |
||||
# SharpDevelop 2.1.0.1900 |
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpDbTools", "SharpDbTools.csproj", "{93B2D6DF-7588-40C0-8A35-CA0DD7328FC3}" |
||||
EndProject |
||||
Global |
||||
EndGlobal |
@ -1,20 +0,0 @@
@@ -1,20 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Dickon Field" email=""/>
|
||||
// <version>$Revision: 1760 $</version>
|
||||
// </file>
|
||||
|
||||
using System.Reflection; |
||||
|
||||
// Information about this assembly is defined by the following
|
||||
// attributes.
|
||||
//
|
||||
// change them to the information which is associated with the assembly
|
||||
// you compile.
|
||||
|
||||
[assembly: AssemblyTitle("SharpDbTools")] |
||||
[assembly: AssemblyDescription("Addin for SharpDevelop 2.0")] |
||||
[assembly: AssemblyConfiguration("")] |
||||
[assembly: AssemblyTrademark("")] |
||||
[assembly: AssemblyCulture("")] |
@ -1,109 +0,0 @@
@@ -1,109 +0,0 @@
|
||||
/* |
||||
* User: dickon |
||||
* Date: 13/12/2006 |
||||
* Time: 16:02 |
||||
* |
||||
*/ |
||||
|
||||
using System; |
||||
|
||||
using ICSharpCode.TextEditor; |
||||
using ICSharpCode.TextEditor.Gui.CompletionWindow; |
||||
using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.Core; |
||||
using System.Windows.Forms; |
||||
|
||||
namespace SharpDbTools.Forms.TextEditor |
||||
{ |
||||
/// <summary>
|
||||
/// Description of SQLTextEditorControl.
|
||||
/// </summary>
|
||||
public class SQLTextEditorControl: TextEditorControl |
||||
{ |
||||
public SQLTextEditorControl(): base() |
||||
{ |
||||
this.ActiveTextAreaControl.TextArea.KeyEventHandler += new ICSharpCode.TextEditor.KeyEventHandler(KeyPressed); |
||||
} |
||||
|
||||
|
||||
protected override void InitializeTextAreaControl(TextAreaControl control) |
||||
{ |
||||
LoggingService.Debug(this.GetType().Name + ": initialising TextArea for SQLTextEditorControl..."); |
||||
control.TextArea.KeyEventHandler += new ICSharpCode.TextEditor.KeyEventHandler(KeyPressed); |
||||
} |
||||
|
||||
bool inKeyPressed = false; |
||||
CodeCompletionWindow codeCompletionWindow = null; |
||||
private bool KeyPressed(char next) |
||||
{ |
||||
if (inKeyPressed) return false; |
||||
inKeyPressed = true; |
||||
LoggingService.Debug(this.GetType().Name + ": KeyPressed, handling character: " + next); |
||||
try { |
||||
// we already have a CodeCompletionWindow open, so it will handle
|
||||
// key presses at this point
|
||||
if (codeCompletionWindow != null && !codeCompletionWindow.IsDisposed) { |
||||
return false; // not handling it yet
|
||||
} |
||||
|
||||
// if (CodeCompletionOptions.EnableCodeCompletion) {
|
||||
// foreach (ICodeCompletionBinding ccBinding in CodeCompletionBindings) {
|
||||
// if (ccBinding.HandleKeyPress(this, ch))
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
// Lets just assume for now that we have only one binding, that is '.', which
|
||||
// will result in an attempt to show field name completions upon a table name
|
||||
// or alias
|
||||
|
||||
if (next == '.') { |
||||
ICompletionDataProvider completionDataProvider = new TestCodeCompletionProvider(); // TODO: create a simple provider that just returns a couple of strings
|
||||
codeCompletionWindow = |
||||
CodeCompletionWindow.ShowCompletionWindow(WorkbenchSingleton.MainForm, |
||||
this, this.FileName, completionDataProvider, next); |
||||
if (codeCompletionWindow != null) { |
||||
codeCompletionWindow.Closed += new EventHandler(CloseCodeCompletionWindow); |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
} catch(Exception ex) { |
||||
LoggingService.Error(this.GetType().FullName, ex); |
||||
} finally { |
||||
inKeyPressed = false; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
private void CloseCodeCompletionWindow(object sender, EventArgs args) |
||||
{ |
||||
|
||||
} |
||||
} |
||||
|
||||
class TestCodeCompletionProvider : AbstractCompletionDataProvider, ICompletionDataProvider |
||||
{ |
||||
/// <summary>
|
||||
/// Testing at this stage, aiming to get some test data into a code completion window
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="textArea"></param>
|
||||
/// <param name="charTyped"></param>
|
||||
/// <returns></returns>
|
||||
public override ICompletionData[] GenerateCompletionData(string fileName, TextArea textArea, char charTyped) |
||||
{ |
||||
Random r = new Random(); |
||||
return new DefaultCompletionData[] { new TestCompletionData("Test" + r.Next(), "Test1", 0), |
||||
new TestCompletionData("Test" + r.Next(), "Test2", 0) }; |
||||
} |
||||
} |
||||
|
||||
class TestCompletionData: DefaultCompletionData |
||||
{ |
||||
public TestCompletionData(string text, string description, int imageIndex): base(text, description, imageIndex) |
||||
{ |
||||
} |
||||
} |
||||
} |
@ -1,186 +0,0 @@
@@ -1,186 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Dickon Field" email=""/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
using SharpDbTools.Data; |
||||
|
||||
using SharpServerTools.Forms; |
||||
|
||||
namespace SharpDbTools.Forms |
||||
{ |
||||
/// <summary>
|
||||
/// Description of DatabaseExplorerNode.
|
||||
/// Hold minimal state - access state through the DbModelInfoService
|
||||
/// </summary>
|
||||
public class DatabaseExplorerTreeNode: TreeNode, IRebuildable, IRequiresRebuildSource, ISupportsDragDrop |
||||
{ |
||||
static DatabaseExplorerTreeNode() |
||||
{ |
||||
ResourceService.RegisterStrings("ICSharpCode.DataTools.AddIn.Resources.Strings", typeof(DatabaseExplorerTreeNode).Assembly); |
||||
} |
||||
|
||||
public DatabaseExplorerTreeNode(): base() |
||||
{ |
||||
this.Text = ResourceService.GetString("SharpDbTools.Forms.DbExplorerNodeName"); |
||||
ContextMenuStrip cMenu = new ContextMenuStrip(); |
||||
ToolStripMenuItem addConnectionMenuItem = |
||||
new ToolStripMenuItem(); |
||||
addConnectionMenuItem.Text = |
||||
ResourceService.GetString("SharpDbTools.Forms.AddConnectionMenu"); |
||||
addConnectionMenuItem.Click += new EventHandler(AddDbConnectionClickHandler); |
||||
|
||||
ToolStripMenuItem deleteConnectionMenuItem = |
||||
new ToolStripMenuItem(); |
||||
deleteConnectionMenuItem.Text = |
||||
ResourceService.GetString("SharpDbTools.Forms.DeleteConnectionMenu"); |
||||
deleteConnectionMenuItem.Click += new EventHandler(DeleteDbConnectionClickHandler); |
||||
|
||||
ToolStripMenuItem saveMetadataMenuItem = |
||||
new ToolStripMenuItem(); |
||||
saveMetadataMenuItem.Text = |
||||
ResourceService.GetString("SharpDbTools.Forms.SaveAllMenu"); |
||||
saveMetadataMenuItem.Click += new EventHandler(SaveDbModelInfoClickHandler); |
||||
|
||||
|
||||
|
||||
|
||||
cMenu.Items.AddRange(new ToolStripMenuItem[] |
||||
{ |
||||
addConnectionMenuItem, |
||||
deleteConnectionMenuItem, |
||||
saveMetadataMenuItem |
||||
} |
||||
); |
||||
this.ContextMenuStrip = cMenu; |
||||
} |
||||
|
||||
public void Rebuild() |
||||
{ |
||||
this.Nodes.Clear(); |
||||
foreach (string name in DbModelInfoService.Names) { |
||||
LoggingService.Debug(this.GetType().ToString() + " getting DbModelInfoTreeNode for node: " + name); |
||||
DbModelInfoTreeNode dbModelInfoNode = CreateDbModelInfoNode(name); |
||||
dbModelInfoNode.RebuildRequiredEvent += new RebuildRequiredEventHandler(RebuildRequiredNotify); |
||||
this.Nodes.Add(dbModelInfoNode); |
||||
} |
||||
} |
||||
|
||||
public event RebuildRequiredEventHandler RebuildRequiredEvent; |
||||
|
||||
/// <summary>
|
||||
/// DatabaseExplorerTreeNode chucks away any existing Nodes and recreates its tree when it
|
||||
/// is triggered.
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
private void RebuildRequiredNotify(object sender, RebuildRequiredEventArgs e) |
||||
{ |
||||
// adding this node because it wants to be rebuilt.
|
||||
e.AddNode(this); |
||||
this.FireRebuildRequired(this, e); |
||||
} |
||||
|
||||
private void FireRebuildRequired(object sender, RebuildRequiredEventArgs e) |
||||
{ |
||||
if (this.RebuildRequiredEvent != null) { |
||||
RebuildRequiredEvent(this, e); |
||||
} |
||||
} |
||||
|
||||
private DbModelInfoTreeNode CreateDbModelInfoNode(string name) |
||||
{ |
||||
return new DbModelInfoTreeNode(name); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Uses a dialog to get the logical name of a new Connection then
|
||||
/// adds a new DbModelInfo for it to the cache and updates the DatabaseServer
|
||||
/// Tree.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
|
||||
private void AddDbConnectionClickHandler(object sender, EventArgs e) |
||||
{ |
||||
LoggingService.Debug("add connection clicked"); |
||||
|
||||
// get the logical name of the new connection
|
||||
|
||||
string logicalName = MessageService.ShowInputBox("Connection name", "Please provide the name for your db connection:", ""); |
||||
if (String.IsNullOrEmpty(logicalName)) return; |
||||
|
||||
LoggingService.Debug("name received is: " + logicalName); |
||||
|
||||
// add a new DbModelInfo to the cache
|
||||
|
||||
DbModelInfoService.Add(logicalName, null, null); |
||||
|
||||
// rebuild the database server node
|
||||
|
||||
RebuildRequiredEventArgs e1 = new RebuildRequiredEventArgs(); |
||||
e1.AddNode(this as IRebuildable); |
||||
this.FireRebuildRequired(this, e1); |
||||
} |
||||
|
||||
private void DeleteDbConnectionClickHandler(object sender, EventArgs e) |
||||
{ |
||||
LoggingService.Debug("delete connection clicked"); |
||||
} |
||||
|
||||
private void SaveDbModelInfoClickHandler(object sender, EventArgs e) |
||||
{ |
||||
// save each DbModelInfo separately, confirming overwrite where necessary
|
||||
|
||||
LoggingService.Debug("save all metadata clicked - will iterate through each and attempt to save"); |
||||
IList<string> names = DbModelInfoService.Names; |
||||
foreach (string name in names) { |
||||
bool saved = DbModelInfoService.SaveToFile(name, false); |
||||
if (!saved) { |
||||
DialogResult result = MessageBox.Show("Overwrite existing file for connection: " + name + "?", |
||||
"File exists for connection", MessageBoxButtons.YesNo, |
||||
MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); |
||||
if (result.Equals(DialogResult.Yes)) { |
||||
DbModelInfoService.SaveToFile(name, true); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// If a DbModelInfoTreeNode is selected then the desired drag and drop behaviour
|
||||
/// is to pass the ConnectionString to drop target.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public void HandleMouseDownEvent(object sender, MouseEventArgs e) |
||||
{ |
||||
LoggingService.Debug(this.GetType().Name + " handling MouseDownEvent"); |
||||
TreeView parent = this.TreeView; |
||||
TreeNode currentlySelected = parent.SelectedNode; |
||||
|
||||
// If the user has selected a TreeNode for a specific connection, and has the right
|
||||
// mouse button down, then initiate a drag drop operation
|
||||
DbModelInfoTreeNode infoNode = currentlySelected as DbModelInfoTreeNode; |
||||
if (infoNode == null) return; |
||||
string logicalConnectionName = infoNode.LogicalConnectionName; |
||||
DbModelInfo info = DbModelInfoService.GetDbModelInfo(logicalConnectionName); |
||||
if (info == null) return; |
||||
string connectionString = info.ConnectionString; |
||||
LoggingService.Debug("drag drop operation initiated for ConnectionString: " + connectionString); |
||||
if (connectionString != null) { |
||||
parent.DoDragDrop(connectionString, DragDropEffects.Copy); |
||||
} |
||||
|
||||
} |
||||
} |
||||
} |
@ -1,305 +0,0 @@
@@ -1,305 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Dickon Field" email=""/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.Data.Common; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
using SharpDbTools.Data; |
||||
using SharpServerTools.Forms; |
||||
|
||||
namespace SharpDbTools.Forms |
||||
{ |
||||
/// <summary>
|
||||
/// Renders a view of the metadata and connection properties for a single
|
||||
/// database connection. It is an IRequiresRebuildSource and can emit
|
||||
/// RequiresRebuildEvents when the metadata etc are changed, but the
|
||||
/// DatabaseExplorerTreeNode disposes of these and constructs new ones
|
||||
/// when this occurs, so it is not an IRebuildable
|
||||
/// </summary>
|
||||
public class DbModelInfoTreeNode: TreeNode, IRequiresRebuildSource |
||||
{ |
||||
BackgroundWorker backgroundWorker; |
||||
ProgressEllipsis progress; |
||||
Timer timer; |
||||
const string fileLoadMessage = ": loading from file"; |
||||
const string connectionLoadMessage = ": loading from connection"; |
||||
string message; |
||||
|
||||
public DbModelInfoTreeNode(string name): base(name) |
||||
{ |
||||
// use tag to carry the logical connection name
|
||||
|
||||
this.Tag = name; |
||||
|
||||
// create and add the menustrip for this node
|
||||
|
||||
NodeAwareContextMenuStrip cMenu = new NodeAwareContextMenuStrip(this); |
||||
|
||||
// create menu items
|
||||
|
||||
ToolStripMenuItem setConnectionStringMenuItem = |
||||
new ToolStripMenuItem(); |
||||
setConnectionStringMenuItem.Text = ResourceService.GetString("SharpDbTools.Forms.SetConnectionStringMenu"); |
||||
setConnectionStringMenuItem.Click += new EventHandler(SetConnectionStringOnDbModelInfoClickHandler); |
||||
|
||||
ToolStripMenuItem loadMetadataFromConnectionMenuItem = |
||||
new ToolStripMenuItem(); |
||||
loadMetadataFromConnectionMenuItem.Text = ResourceService.GetString("SharpDbTools.Forms.LoadMetadataFromConnectionMenu"); |
||||
loadMetadataFromConnectionMenuItem.Click += new EventHandler(LoadMetadataFromConnectionClickHandler); |
||||
|
||||
ToolStripMenuItem loadMetadataFromFileMenuItem = |
||||
new ToolStripMenuItem(); |
||||
loadMetadataFromFileMenuItem.Text = ResourceService.GetString("SharpDbTools.Forms.LoadMetadataFromFileMenu"); |
||||
loadMetadataFromFileMenuItem.Click += new EventHandler(LoadMetadataFromFileClickHandler); |
||||
|
||||
ToolStripMenuItem openSQLToolMenuItem = new ToolStripMenuItem(); |
||||
openSQLToolMenuItem.Text = ResourceService.GetString("SharpDbTools.Forms.OpenSQLToolMenu"); |
||||
openSQLToolMenuItem.Click += new EventHandler(OpenSQLToolClickHandler); |
||||
|
||||
cMenu.Items.AddRange(new ToolStripMenuItem[] |
||||
{ |
||||
setConnectionStringMenuItem, |
||||
loadMetadataFromConnectionMenuItem, |
||||
loadMetadataFromFileMenuItem, |
||||
openSQLToolMenuItem |
||||
}); |
||||
|
||||
this.ContextMenuStrip = cMenu; |
||||
this.Nodes.Clear(); |
||||
TreeNode connectionPropsNode = CreateConnectionPropertiesNode(this.LogicalConnectionName); |
||||
TreeNode dbNode = CreateMetaDataNode(this.LogicalConnectionName); |
||||
this.Nodes.Add(connectionPropsNode); |
||||
this.Nodes.Add(dbNode); |
||||
|
||||
timer = new Timer(); |
||||
timer.Interval = 1000; |
||||
timer.Tick += new EventHandler(this.TimerClick); |
||||
progress = new ProgressEllipsis(4); |
||||
} |
||||
|
||||
public string LogicalConnectionName { |
||||
get { |
||||
return this.Text; |
||||
} |
||||
} |
||||
|
||||
public event RebuildRequiredEventHandler RebuildRequiredEvent; |
||||
|
||||
protected void FireRebuildRequired() |
||||
{ |
||||
// HERE: the null eventargs indicates no desire to be rebuilt - is this correct?
|
||||
if (RebuildRequiredEvent != null) { |
||||
// This object does not want to be rebuilt - it is discarded when there is
|
||||
// a change in the underlying model. So, an event is posted without a ref
|
||||
// to this object.
|
||||
RebuildRequiredEventArgs eventArgs = new RebuildRequiredEventArgs(); |
||||
RebuildRequiredEvent(this, eventArgs); |
||||
} |
||||
} |
||||
|
||||
private TreeNode CreateConnectionPropertiesNode(string name) |
||||
{ |
||||
// create sub TreeNodes for the connection string and invariant name if they exist
|
||||
LoggingService.Debug("Looking for a Db Model Info for connection with name: " + name); |
||||
DbModelInfo modelInfo = DbModelInfoService.GetDbModelInfo(name); |
||||
|
||||
if (modelInfo == null) { |
||||
LoggingService.Error("could not find a logical connection named: " + name); |
||||
throw new ArgumentException("this logical connection name is not defined: " + name); |
||||
} |
||||
string connectionString = modelInfo.ConnectionString; |
||||
string invariantName = modelInfo.InvariantName; |
||||
|
||||
TreeNode attributesNode = new TreeNode("Connection Properties"); |
||||
attributesNode.Text = ResourceService.GetString("SharpDbTools.Forms.ConnectionPropertiesNodeName"); |
||||
|
||||
if (connectionString != null) { |
||||
TreeNode cstringNode = new TreeNode(); |
||||
cstringNode.Text = ResourceService.GetString("SharpDbTools.Forms.ConnectionStringNodeName") + connectionString; |
||||
attributesNode.Nodes.Add(cstringNode); |
||||
} |
||||
|
||||
if (invariantName != null) { |
||||
TreeNode invNameNode = new TreeNode(); |
||||
invNameNode.Text = ResourceService.GetString("SharpDbTools.Forms.InvariantNameNodeName") + invariantName; |
||||
attributesNode.Nodes.Add(invNameNode); |
||||
} |
||||
|
||||
return attributesNode; |
||||
} |
||||
|
||||
private TreeNode CreateMetaDataNode(string name) |
||||
{ |
||||
LoggingService.Debug("creating metadata tree for connection with name: " + name); |
||||
TreeNode node = null; |
||||
// get the invariant name from the name, then get the FormsArtefactFactory
|
||||
DbModelInfo modelInfo = DbModelInfoService.GetDbModelInfo(name); |
||||
|
||||
if (modelInfo == null) { |
||||
LoggingService.Error("could not find a logical connection named: " + name); |
||||
throw new ArgumentException("this logical connection name is not defined: " + name); |
||||
} |
||||
|
||||
string invariantName = modelInfo.InvariantName; |
||||
LoggingService.Debug("got invariant name: " + invariantName + " for connection name: " + name); |
||||
|
||||
try { |
||||
LoggingService.Debug(this.GetType().ToString() |
||||
+ ": getting forms info for name: " |
||||
+ name + " and invariant name: " |
||||
+ invariantName); |
||||
FormsArtefactFactory factory = FormsArtefactFactories.GetFactory(invariantName); |
||||
node = factory.CreateMetaDataNode(name); |
||||
} catch(ArgumentException e) { |
||||
LoggingService.Debug(this.GetType().ToString() |
||||
+ " failed to create metadata node for connection: " |
||||
+ name + "\n" |
||||
+ e.Message + "\n" |
||||
+ e.GetType().ToString()); |
||||
node = new TreeNode("No Metadata"); |
||||
} |
||||
return node; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Uses a dialog to get the logical name of a new Connection then
|
||||
/// adds a new DbModelInfo for it to the cache and updates the DatabaseServer
|
||||
/// Tree.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
|
||||
private void SetConnectionStringOnDbModelInfoClickHandler(object sender, EventArgs e) |
||||
{ |
||||
string connectionLogicalName = (string)this.Tag; |
||||
LoggingService.Debug("add connection string clicked for item with name: " + connectionLogicalName); |
||||
|
||||
// use the ConnectionStringDefinitionDialog to get a connection string and invariant name
|
||||
ConnectionStringDefinitionDialog definitionDialog = new ConnectionStringDefinitionDialog(); |
||||
DialogResult result = definitionDialog.ShowDialog(); |
||||
|
||||
// if the dialog was cancelled then do nothing
|
||||
if (result == DialogResult.Cancel) { |
||||
return; |
||||
} |
||||
|
||||
// if the dialog was submitted and connection string has changed then clear the DbModelInfo metadata
|
||||
// note that is is not required for the Connection string to be valid - it may be work
|
||||
// in progress and a user might want to save a partially formed connection string
|
||||
|
||||
DbModelInfo dbModelInfo = DbModelInfoService.GetDbModelInfo(connectionLogicalName); |
||||
string connectionString = dbModelInfo.ConnectionString; |
||||
string newConnectionString = definitionDialog.ConnectionString; |
||||
|
||||
if (newConnectionString == null) { |
||||
return; |
||||
} |
||||
|
||||
dbModelInfo.ConnectionString = newConnectionString; |
||||
dbModelInfo.InvariantName = definitionDialog.InvariantName; |
||||
|
||||
// rebuild the database explorer node
|
||||
this.FireRebuildRequired(); |
||||
} |
||||
|
||||
private void LoadMetadataFromFileClickHandler(object sender, EventArgs e) |
||||
{ |
||||
LoggingService.Debug("load metadata from file clicked"); |
||||
this.backgroundWorker = new BackgroundWorker(); |
||||
backgroundWorker.DoWork += new DoWorkEventHandler(this.LoadMetadataFromFileDoWork); |
||||
backgroundWorker.RunWorkerCompleted += |
||||
new RunWorkerCompletedEventHandler(this.LoadMetadataFinished); |
||||
string logicalConnectionName = (string)this.Tag; |
||||
this.message = logicalConnectionName + fileLoadMessage; |
||||
this.ContextMenuStrip.Enabled = false; |
||||
timer.Start(); |
||||
this.backgroundWorker.RunWorkerAsync(logicalConnectionName); |
||||
} |
||||
|
||||
private void OpenSQLToolClickHandler(object sender, EventArgs e) |
||||
{ |
||||
SQLToolViewContent sqlToolViewContent = new SQLToolViewContent((string)this.Tag); |
||||
WorkbenchSingleton.Workbench.ShowView(sqlToolViewContent); |
||||
} |
||||
|
||||
private void TimerClick(object sender, EventArgs eventArgs) |
||||
{ |
||||
string ellipsis = progress.Text; |
||||
progress.performStep(); |
||||
string displayMsg = this.message + ellipsis; |
||||
SetText(displayMsg); |
||||
|
||||
} |
||||
|
||||
delegate void TextSetterDelegate(string text); |
||||
|
||||
public void SetText(string text) |
||||
{ |
||||
if (this.TreeView.InvokeRequired) { |
||||
this.TreeView.Invoke(new TextSetterDelegate(this.SetText), new object[] { text }); |
||||
return; |
||||
} |
||||
this.Text = text; |
||||
} |
||||
|
||||
private void LoadMetadataFromFileDoWork(object sender, DoWorkEventArgs args) |
||||
{ |
||||
string logicalConnectionName = args.Argument as string; |
||||
if (logicalConnectionName != null) { |
||||
DbModelInfoService.LoadFromFile(logicalConnectionName); |
||||
} |
||||
} |
||||
|
||||
private void LoadMetadataFinished(object sender, RunWorkerCompletedEventArgs args) |
||||
{ |
||||
if (this.TreeView.InvokeRequired) { |
||||
this.TreeView.Invoke(new EventHandler<RunWorkerCompletedEventArgs> |
||||
(this.LoadMetadataFinished)); |
||||
return; |
||||
} |
||||
this.timer.Stop(); |
||||
this.Text = (string)this.Tag; |
||||
this.ContextMenuStrip.Enabled = true; |
||||
this.backgroundWorker.Dispose(); |
||||
this.backgroundWorker = null; |
||||
this.FireRebuildRequired(); |
||||
} |
||||
|
||||
private void LoadMetadataFromConnectionClickHandler(object sender, EventArgs args) |
||||
{ |
||||
LoggingService.Debug("load metadata from connection clicked"); |
||||
this.backgroundWorker = new BackgroundWorker(); |
||||
backgroundWorker.DoWork += new DoWorkEventHandler(this.LoadMetadataFromConnectionDoWork); |
||||
backgroundWorker.RunWorkerCompleted += |
||||
new RunWorkerCompletedEventHandler(this.LoadMetadataFinished); |
||||
string logicalConnectionName = (string)this.Tag; |
||||
this.message = logicalConnectionName + connectionLoadMessage; |
||||
this.ContextMenuStrip.Enabled = false; |
||||
timer.Start(); |
||||
this.backgroundWorker.RunWorkerAsync(logicalConnectionName); |
||||
} |
||||
|
||||
private void LoadMetadataFromConnectionDoWork(object sender, DoWorkEventArgs args) |
||||
{ |
||||
string connectionLogicalName = args.Argument as string; |
||||
if (connectionLogicalName != null) { |
||||
try { |
||||
DbModelInfoService.LoadMetadataFromConnection(connectionLogicalName); |
||||
} |
||||
catch(DbException e) { |
||||
MessageService.ShowError(e, |
||||
"An Exception was thrown while trying to connect to: " + connectionLogicalName); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,52 +0,0 @@
@@ -1,52 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Dickon Field" email=""/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace SharpDbTools.Forms |
||||
{ |
||||
/// <summary>
|
||||
/// Description of FormsArtefactFactories.
|
||||
/// </summary>
|
||||
public static class FormsArtefactFactories |
||||
{ |
||||
public const string FORMS_ARTEFACT_FACTORIES_PATH = "/SharpServerTools/SharpDbTools/FormsArtefactFactory"; |
||||
public static Dictionary<string, FormsArtefactFactory> factories = new Dictionary<string, FormsArtefactFactory>(); |
||||
|
||||
static FormsArtefactFactories() |
||||
{ |
||||
AddInTreeNode node = |
||||
AddInTree.GetTreeNode(FORMS_ARTEFACT_FACTORIES_PATH); |
||||
List<Codon> codons = node.Codons; |
||||
foreach (Codon codon in codons) { |
||||
// create an instance of the relevant FormsArtefactFactory indexed by invariant name
|
||||
string invariant = codon.Id; |
||||
FormsArtefactFactory factory = (FormsArtefactFactory)node.BuildChildItem(invariant, null, null); |
||||
factories.Add(invariant, factory); |
||||
} |
||||
} |
||||
|
||||
public static FormsArtefactFactory GetFactory(string invariantName) |
||||
{ |
||||
LoggingService.Debug("Looking for FormsArtefactFactory for: " + invariantName); |
||||
|
||||
// to test this base it on hardcoded strings for the type of the factory
|
||||
|
||||
// TODO: drive this from the AddIn tree
|
||||
|
||||
FormsArtefactFactory factory = null; |
||||
factories.TryGetValue(invariantName, out factory); |
||||
if (factory == null) { |
||||
throw new ArgumentException("No FormsArtefactFactory found for InvariantName: " |
||||
+ invariantName); |
||||
} |
||||
return factory; |
||||
} |
||||
} |
||||
} |
@ -1,32 +0,0 @@
@@ -1,32 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Dickon Field" email=""/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace SharpDbTools.Forms |
||||
{ |
||||
/// <summary>
|
||||
/// Base class for one of the classes that each SharpDbTools plugin must support. Subclasses
|
||||
/// provide the UI artefacts required to build the metadata node for a particular
|
||||
/// datasource such as Oracle, SQLServer, MySQL etc.
|
||||
/// It makes sense to have a separate derived class for each datasource since the structure and
|
||||
/// relationship of db objects supported by each server is quite different, and therefore merits
|
||||
/// quite a different presentation and layout in the metadata tree.
|
||||
/// </summary>
|
||||
public abstract class FormsArtefactFactory |
||||
{ |
||||
public FormsArtefactFactory() |
||||
{ |
||||
} |
||||
|
||||
public abstract TreeNode CreateMetaDataNode(string name); |
||||
public abstract string[] GetDescribeTableFieldNames(); |
||||
public abstract string[] GetDescribeTableColumnHeaderNames(); |
||||
} |
||||
} |
@ -1,167 +0,0 @@
@@ -1,167 +0,0 @@
|
||||
/* |
||||
* User: dickon |
||||
* Date: 21/11/2006 |
||||
* Time: 19:12 |
||||
* |
||||
*/ |
||||
namespace SharpDbTools.Forms |
||||
{ |
||||
partial class SQLTool : System.Windows.Forms.UserControl |
||||
{ |
||||
/// <summary>
|
||||
/// Designer variable used to keep track of non-visual components.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null; |
||||
|
||||
/// <summary>
|
||||
/// Disposes resources used by the control.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing) |
||||
{ |
||||
if (disposing) { |
||||
if (components != null) { |
||||
components.Dispose(); |
||||
} |
||||
} |
||||
|
||||
/// <summary>
|
||||
base.Dispose(disposing); |
||||
} |
||||
/// This method is required for Windows Forms designer support.
|
||||
/// Do not change the method contents inside the source code editor. The Forms designer might
|
||||
/// not be able to load this method if it was changed manually.
|
||||
/// </summary>
|
||||
private void InitializeComponent() |
||||
{ |
||||
this.components = new System.ComponentModel.Container(); |
||||
this.sqlToolTabControl = new System.Windows.Forms.TabControl(); |
||||
this.editorTab = new System.Windows.Forms.TabPage(); |
||||
this.statusStrip = new System.Windows.Forms.StatusStrip(); |
||||
this.queryToolStripProgressBar = new System.Windows.Forms.ToolStripProgressBar(); |
||||
this.resultTab = new System.Windows.Forms.TabPage(); |
||||
this.resultDataGridView = new System.Windows.Forms.DataGridView(); |
||||
this.messageTab = new System.Windows.Forms.TabPage(); |
||||
this.messageTextBox = new System.Windows.Forms.TextBox(); |
||||
this.progressTimer = new System.Windows.Forms.Timer(this.components); |
||||
this.sqlToolTabControl.SuspendLayout(); |
||||
this.editorTab.SuspendLayout(); |
||||
this.statusStrip.SuspendLayout(); |
||||
this.resultTab.SuspendLayout(); |
||||
((System.ComponentModel.ISupportInitialize)(this.resultDataGridView)).BeginInit(); |
||||
this.messageTab.SuspendLayout(); |
||||
this.SuspendLayout(); |
||||
//
|
||||
// sqlToolTabControl
|
||||
//
|
||||
this.sqlToolTabControl.Controls.Add(this.editorTab); |
||||
this.sqlToolTabControl.Controls.Add(this.resultTab); |
||||
this.sqlToolTabControl.Controls.Add(this.messageTab); |
||||
this.sqlToolTabControl.Dock = System.Windows.Forms.DockStyle.Fill; |
||||
this.sqlToolTabControl.Location = new System.Drawing.Point(0, 0); |
||||
this.sqlToolTabControl.Name = "sqlToolTabControl"; |
||||
this.sqlToolTabControl.SelectedIndex = 0; |
||||
this.sqlToolTabControl.Size = new System.Drawing.Size(759, 452); |
||||
this.sqlToolTabControl.TabIndex = 0; |
||||
//
|
||||
// editorTab
|
||||
//
|
||||
this.editorTab.Controls.Add(this.statusStrip); |
||||
this.editorTab.Location = new System.Drawing.Point(4, 22); |
||||
this.editorTab.Name = "editorTab"; |
||||
this.editorTab.Padding = new System.Windows.Forms.Padding(3); |
||||
this.editorTab.Size = new System.Drawing.Size(751, 426); |
||||
this.editorTab.TabIndex = 0; |
||||
this.editorTab.Text = "Editor"; |
||||
this.editorTab.UseVisualStyleBackColor = true; |
||||
//
|
||||
// statusStrip
|
||||
//
|
||||
this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { |
||||
this.queryToolStripProgressBar}); |
||||
this.statusStrip.Location = new System.Drawing.Point(3, 401); |
||||
this.statusStrip.Name = "statusStrip"; |
||||
this.statusStrip.Size = new System.Drawing.Size(745, 22); |
||||
this.statusStrip.TabIndex = 0; |
||||
this.statusStrip.Text = "statusStrip1"; |
||||
//
|
||||
// queryToolStripProgressBar
|
||||
//
|
||||
this.queryToolStripProgressBar.Name = "queryToolStripProgressBar"; |
||||
this.queryToolStripProgressBar.Size = new System.Drawing.Size(100, 16); |
||||
this.queryToolStripProgressBar.Visible = false; |
||||
//
|
||||
// resultTab
|
||||
//
|
||||
this.resultTab.Controls.Add(this.resultDataGridView); |
||||
this.resultTab.Location = new System.Drawing.Point(4, 22); |
||||
this.resultTab.Name = "resultTab"; |
||||
this.resultTab.Padding = new System.Windows.Forms.Padding(3); |
||||
this.resultTab.Size = new System.Drawing.Size(751, 426); |
||||
this.resultTab.TabIndex = 1; |
||||
this.resultTab.Text = "Results"; |
||||
this.resultTab.UseVisualStyleBackColor = true; |
||||
//
|
||||
// resultDataGridView
|
||||
//
|
||||
this.resultDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; |
||||
this.resultDataGridView.Dock = System.Windows.Forms.DockStyle.Fill; |
||||
this.resultDataGridView.Location = new System.Drawing.Point(3, 3); |
||||
this.resultDataGridView.Name = "resultDataGridView"; |
||||
this.resultDataGridView.Size = new System.Drawing.Size(745, 420); |
||||
this.resultDataGridView.TabIndex = 0; |
||||
//
|
||||
// messageTab
|
||||
//
|
||||
this.messageTab.Controls.Add(this.messageTextBox); |
||||
this.messageTab.Location = new System.Drawing.Point(4, 22); |
||||
this.messageTab.Name = "messageTab"; |
||||
this.messageTab.Padding = new System.Windows.Forms.Padding(3); |
||||
this.messageTab.Size = new System.Drawing.Size(751, 426); |
||||
this.messageTab.TabIndex = 2; |
||||
this.messageTab.Text = "Messages"; |
||||
this.messageTab.UseVisualStyleBackColor = true; |
||||
//
|
||||
// messageTextBox
|
||||
//
|
||||
this.messageTextBox.Dock = System.Windows.Forms.DockStyle.Fill; |
||||
this.messageTextBox.Location = new System.Drawing.Point(3, 3); |
||||
this.messageTextBox.Multiline = true; |
||||
this.messageTextBox.Name = "messageTextBox"; |
||||
this.messageTextBox.Size = new System.Drawing.Size(745, 420); |
||||
this.messageTextBox.TabIndex = 0; |
||||
//
|
||||
// progressTimer
|
||||
//
|
||||
this.progressTimer.Tick += new System.EventHandler(this.ProgressTimerTick); |
||||
//
|
||||
// SQLTool
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); |
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; |
||||
this.Controls.Add(this.sqlToolTabControl); |
||||
this.Name = "SQLTool"; |
||||
this.Size = new System.Drawing.Size(759, 452); |
||||
this.sqlToolTabControl.ResumeLayout(false); |
||||
this.editorTab.ResumeLayout(false); |
||||
this.editorTab.PerformLayout(); |
||||
this.statusStrip.ResumeLayout(false); |
||||
this.statusStrip.PerformLayout(); |
||||
this.resultTab.ResumeLayout(false); |
||||
((System.ComponentModel.ISupportInitialize)(this.resultDataGridView)).EndInit(); |
||||
this.messageTab.ResumeLayout(false); |
||||
this.messageTab.PerformLayout(); |
||||
this.ResumeLayout(false); |
||||
} |
||||
private System.Windows.Forms.Timer progressTimer; |
||||
private System.Windows.Forms.ToolStripProgressBar queryToolStripProgressBar; |
||||
private System.Windows.Forms.StatusStrip statusStrip; |
||||
private System.Windows.Forms.TextBox messageTextBox; |
||||
private System.Windows.Forms.DataGridView resultDataGridView; |
||||
private System.Windows.Forms.TabControl sqlToolTabControl; |
||||
private System.Windows.Forms.TabPage messageTab; |
||||
private System.Windows.Forms.TabPage resultTab; |
||||
private System.Windows.Forms.TabPage editorTab; |
||||
|
||||
} |
||||
} |
@ -1,215 +0,0 @@
@@ -1,215 +0,0 @@
|
||||
/* |
||||
* User: dickon |
||||
* Contributions from: troy@ebswift.com |
||||
* Date: 21/11/2006 |
||||
* Time: 19:12 |
||||
* |
||||
*/ |
||||
|
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.Drawing; |
||||
using System.Windows.Forms; |
||||
using System.IO; |
||||
using System.Data.Common; |
||||
using System.Data; |
||||
|
||||
using ICSharpCode.TextEditor; |
||||
using ICSharpCode.Core; |
||||
|
||||
using SharpDbTools.Data; |
||||
using SharpDbTools.Forms.TextEditor; |
||||
|
||||
namespace SharpDbTools.Forms |
||||
{ |
||||
/// <summary>
|
||||
/// A generic sql query tool utilising the #D TextEditor and SharpDbTools DbModelInfo framework
|
||||
/// for metadata management
|
||||
/// </summary>
|
||||
public partial class SQLTool |
||||
{ |
||||
private string logicalConnectionName = null; |
||||
private SQLTextEditorControl sqlEditorControl = null; |
||||
private BackgroundWorker backgroundWorker; |
||||
private string lastSQL; |
||||
|
||||
public SQLTool(string logicalConnectionName) |
||||
{ |
||||
this.logicalConnectionName = logicalConnectionName; |
||||
|
||||
//
|
||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||
//
|
||||
InitializeComponent(); |
||||
|
||||
// add sqlEditor to the editor panel
|
||||
|
||||
sqlEditorControl = new SQLTextEditorControl(); |
||||
sqlEditorControl.Dock = DockStyle.Fill; |
||||
|
||||
// set up the highlighting manager for generic SQL
|
||||
|
||||
string appPath = Path.GetDirectoryName(Application.ExecutablePath); |
||||
SQLToolResourceSyntaxModeProvider provider = new SQLToolResourceSyntaxModeProvider(); |
||||
ICSharpCode.TextEditor.Document.HighlightingManager.Manager.AddSyntaxModeFileProvider(provider); |
||||
// this loads the SQL.xshd file that is compiled as a resource - written by Troy@ebswift.com
|
||||
sqlEditorControl.Document.HighlightingStrategy = |
||||
ICSharpCode.TextEditor.Document.HighlightingManager.Manager.FindHighlighter("SQL"); |
||||
|
||||
// setup the SQLTool in the tab control
|
||||
|
||||
this.editorTab.Controls.Add(sqlEditorControl); |
||||
|
||||
// add context behaviour to the editor control
|
||||
|
||||
ContextMenuStrip contextMenu = new ContextMenuStrip(); |
||||
|
||||
ToolStripMenuItem runSQLMenuItem = new ToolStripMenuItem("Run SQL"); |
||||
runSQLMenuItem.Click += new EventHandler(RunSQLClickHandler); |
||||
|
||||
contextMenu.Items.AddRange(new ToolStripMenuItem[] |
||||
{ |
||||
runSQLMenuItem |
||||
}); |
||||
sqlEditorControl.ContextMenuStrip = contextMenu; |
||||
} |
||||
|
||||
private void RunSQLClickHandler(object sender, EventArgs args) |
||||
{ |
||||
// 1. get a connection from the the logical connection name
|
||||
// 2. attempt to execute any SQL currently contained in the editor
|
||||
// 3. display either a result set in the result DataGridView, or
|
||||
// messages in the messages textbox in the message tab.
|
||||
LoggingService.Debug(this.GetType().Name + "-> RunSQLClickHandler"); |
||||
this.lastSQL = this.sqlEditorControl.Document.TextContent; |
||||
this.backgroundWorker = new BackgroundWorker(); |
||||
backgroundWorker.DoWork += DispatchSQL; |
||||
backgroundWorker.RunWorkerCompleted += DispatchSQLComplete; |
||||
backgroundWorker.RunWorkerAsync(); |
||||
} |
||||
|
||||
private void DispatchSQL(object sender, DoWorkEventArgs e) |
||||
{ |
||||
// use the logical connection name to map to the invariant name
|
||||
// in the DbModelInfoService
|
||||
DbModelInfo modelInfo = DbModelInfoService.GetDbModelInfo(this.logicalConnectionName); |
||||
string invariantName = modelInfo.InvariantName; |
||||
|
||||
// use the invariant name to get the DbProviderFactory from the DBProvidersService
|
||||
DbProvidersService dbProvidersService = DbProvidersService.GetDbProvidersService(); |
||||
DbProviderFactory factory = dbProvidersService.GetFactoryByInvariantName(invariantName); |
||||
|
||||
// get a connection from the DbProviderFactory
|
||||
DbConnection connection = factory.CreateConnection(); |
||||
|
||||
// use the logical connection name to map to the connection string
|
||||
// for this connection in the DbModelInfoService
|
||||
string connectionString = modelInfo.ConnectionString; |
||||
connection.ConnectionString = connectionString; |
||||
|
||||
|
||||
try { |
||||
// dispatch the sql on this connection
|
||||
// if result is successful invoke an update to the DataGridView of
|
||||
// SQLTool
|
||||
connection.Open(); |
||||
DbCommand command = connection.CreateCommand(); |
||||
LoggingService.Debug("getting sql command"); |
||||
command.CommandText = this.lastSQL; |
||||
LoggingService.Debug("dispatching sql: " + command.CommandText); |
||||
DispatchSQLStarting(); |
||||
DbDataReader reader = command.ExecuteReader(); |
||||
LoggingService.Debug("received ResultSet, showing in SQLTool..."); |
||||
this.SetDataGridViewContent(reader); |
||||
} |
||||
catch(Exception ex) { |
||||
// if the result is unsuccessful invoke an update to the message
|
||||
// view of SQLTool hopefully with the reason for the failure
|
||||
string msg = "caught exception: " + ex.GetType().Name |
||||
+ ": " + ex.Message; |
||||
LoggingService.Debug(msg); |
||||
LoggingService.Debug(ex.StackTrace); |
||||
this.AppendMessageContent(msg); |
||||
} |
||||
finally { |
||||
connection.Close(); |
||||
connection.Dispose(); |
||||
} |
||||
} |
||||
|
||||
delegate void AppendMessageContentCallback(string msg); |
||||
|
||||
private void AppendMessageContent(string msg) |
||||
{ |
||||
if (this.messageTextBox.InvokeRequired) { |
||||
AppendMessageContentCallback c = new AppendMessageContentCallback(AppendMessageContent); |
||||
this.Invoke(c, new object[] { msg }); |
||||
} else { |
||||
// string currentText = this.messageTextBox.Text;
|
||||
// this.messageTextBox.Clear;
|
||||
// // Font font = this.messageTextBox.Font;
|
||||
// // redisplay currentText using a modified Font with grey colour
|
||||
// // then reset Font back to original
|
||||
// // TODO: implement Font colour changes
|
||||
this.messageTextBox.AppendText(msg); |
||||
this.messageTextBox.AppendText("\n"); |
||||
this.sqlToolTabControl.SelectTab(this.messageTab); |
||||
} |
||||
} |
||||
|
||||
delegate void SetDataGridViewContentCallback(DbDataReader reader); |
||||
|
||||
private void SetDataGridViewContent(DbDataReader reader) |
||||
{ |
||||
if (this.resultDataGridView.InvokeRequired) { |
||||
SetDataGridViewContentCallback c = new SetDataGridViewContentCallback(SetDataGridViewContent); |
||||
this.Invoke(c, new object[] { reader }); |
||||
} else { |
||||
string tableName = reader.GetSchemaTable().TableName; |
||||
this.resultDataGridView.ClearSelection(); |
||||
DataTable data = new DataTable(); |
||||
data.BeginInit(); |
||||
data.Load(reader); |
||||
data.EndInit(); |
||||
this.resultDataGridView.DataSource = data; |
||||
this.sqlToolTabControl.SelectTab(this.resultTab); |
||||
} |
||||
} |
||||
|
||||
private void DispatchSQLStarting() |
||||
{ |
||||
if (this.InvokeRequired) { |
||||
MethodInvoker c = new MethodInvoker(DispatchSQLStarting); |
||||
this.Invoke(c, new object[] {}); |
||||
} else { |
||||
this.queryToolStripProgressBar.Visible = true; |
||||
this.progressTimer.Enabled = true; |
||||
} |
||||
} |
||||
|
||||
void ProgressTimerTick(object sender, System.EventArgs e) |
||||
{ |
||||
// insert calls under Invoke to doPerform on statusStrip.progressBar
|
||||
if (this.InvokeRequired) { |
||||
EventHandler handler = new EventHandler(ProgressTimerTick); |
||||
this.Invoke(handler, new object[] {sender, e}); |
||||
} else { |
||||
if (this.queryToolStripProgressBar.Value >= this.queryToolStripProgressBar.Maximum) |
||||
this.queryToolStripProgressBar.Value = 0; |
||||
this.queryToolStripProgressBar.PerformStep(); |
||||
} |
||||
|
||||
} |
||||
|
||||
public void DispatchSQLComplete(object sender, RunWorkerCompletedEventArgs args) |
||||
{ |
||||
if (this.InvokeRequired) { |
||||
RunWorkerCompletedEventHandler c = new RunWorkerCompletedEventHandler(DispatchSQLComplete); |
||||
this.Invoke(c, new object[] {sender, args}); |
||||
} else { |
||||
this.progressTimer.Enabled = false; |
||||
this.queryToolStripProgressBar.Visible = false; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,126 +0,0 @@
@@ -1,126 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<root> |
||||
<!-- |
||||
Microsoft ResX Schema |
||||
|
||||
Version 2.0 |
||||
|
||||
The primary goals of this format is to allow a simple XML format |
||||
that is mostly human readable. The generation and parsing of the |
||||
various data types are done through the TypeConverter classes |
||||
associated with the data types. |
||||
|
||||
Example: |
||||
|
||||
... ado.net/XML headers & schema ... |
||||
<resheader name="resmimetype">text/microsoft-resx</resheader> |
||||
<resheader name="version">2.0</resheader> |
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
||||
<value>[base64 mime encoded serialized .NET Framework object]</value> |
||||
</data> |
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
||||
<comment>This is a comment</comment> |
||||
</data> |
||||
|
||||
There are any number of "resheader" rows that contain simple |
||||
name/value pairs. |
||||
|
||||
Each data row contains a name, and value. The row also contains a |
||||
type or mimetype. Type corresponds to a .NET class that support |
||||
text/value conversion through the TypeConverter architecture. |
||||
Classes that don't support this are serialized and stored with the |
||||
mimetype set. |
||||
|
||||
The mimetype is used for serialized objects, and tells the |
||||
ResXResourceReader how to depersist the object. This is currently not |
||||
extensible. For a given mimetype the value must be set accordingly: |
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format |
||||
that the ResXResourceWriter will generate, however the reader can |
||||
read any of the formats listed below. |
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64 |
||||
value : The object must be serialized with |
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter |
||||
: and then encoded with base64 encoding. |
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64 |
||||
value : The object must be serialized with |
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
||||
: and then encoded with base64 encoding. |
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64 |
||||
value : The object must be serialized into a byte array |
||||
: using a System.ComponentModel.TypeConverter |
||||
: and then encoded with base64 encoding. |
||||
--> |
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> |
||||
<xsd:element name="root" msdata:IsDataSet="true"> |
||||
<xsd:complexType> |
||||
<xsd:choice maxOccurs="unbounded"> |
||||
<xsd:element name="metadata"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" use="required" type="xsd:string" /> |
||||
<xsd:attribute name="type" type="xsd:string" /> |
||||
<xsd:attribute name="mimetype" type="xsd:string" /> |
||||
<xsd:attribute ref="xml:space" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="assembly"> |
||||
<xsd:complexType> |
||||
<xsd:attribute name="alias" type="xsd:string" /> |
||||
<xsd:attribute name="name" type="xsd:string" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="data"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> |
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
||||
<xsd:attribute ref="xml:space" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
<xsd:element name="resheader"> |
||||
<xsd:complexType> |
||||
<xsd:sequence> |
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
||||
</xsd:sequence> |
||||
<xsd:attribute name="name" type="xsd:string" use="required" /> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
</xsd:choice> |
||||
</xsd:complexType> |
||||
</xsd:element> |
||||
</xsd:schema> |
||||
<resheader name="resmimetype"> |
||||
<value>text/microsoft-resx</value> |
||||
</resheader> |
||||
<resheader name="version"> |
||||
<value>2.0</value> |
||||
</resheader> |
||||
<resheader name="reader"> |
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
</resheader> |
||||
<resheader name="writer"> |
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
||||
</resheader> |
||||
<metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> |
||||
<value>17, 17</value> |
||||
</metadata> |
||||
<metadata name="progressTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> |
||||
<value>122, 17</value> |
||||
</metadata> |
||||
</root> |
@ -1,54 +0,0 @@
@@ -1,54 +0,0 @@
|
||||
/* |
||||
* User: dickon |
||||
* Date: 06/12/2006 |
||||
* Time: 12:53 |
||||
* |
||||
*/ |
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Xml; |
||||
using System.Reflection; |
||||
using System.IO; |
||||
|
||||
using ICSharpCode.TextEditor.Document; |
||||
|
||||
namespace SharpDbTools.Forms |
||||
{ |
||||
/// <summary>
|
||||
/// Implementation specifically for SQLTool, based on
|
||||
/// a copy-and-paste reuse of ICSharpCode.TextEditor.ResourceSyntaxModeProvider
|
||||
/// </summary>
|
||||
public class SQLToolResourceSyntaxModeProvider: ISyntaxModeFileProvider |
||||
{ |
||||
List<SyntaxMode> syntaxModes = null; |
||||
|
||||
public ICollection<SyntaxMode> SyntaxModes { |
||||
get { |
||||
return syntaxModes; |
||||
} |
||||
} |
||||
|
||||
public SQLToolResourceSyntaxModeProvider() |
||||
{ |
||||
Assembly assembly = this.GetType().Assembly; |
||||
Stream syntaxModeStream = assembly.GetManifestResourceStream("SharpDbTools.Resources.SyntaxModes.xml"); |
||||
if (syntaxModeStream != null) { |
||||
syntaxModes = SyntaxMode.GetSyntaxModes(syntaxModeStream); |
||||
} else { |
||||
syntaxModes = new List<SyntaxMode>(); |
||||
} |
||||
} |
||||
|
||||
public XmlTextReader GetSyntaxModeFile(SyntaxMode syntaxMode) |
||||
{ |
||||
Assembly assembly = this.GetType().Assembly; |
||||
return new XmlTextReader(assembly.GetManifestResourceStream("SharpDbTools.Resources." + syntaxMode.FileName)); |
||||
} |
||||
|
||||
public void UpdateSyntaxModeList() |
||||
{ |
||||
// resources don't change during runtime
|
||||
} |
||||
} |
||||
} |
@ -1,49 +0,0 @@
@@ -1,49 +0,0 @@
|
||||
/* |
||||
* User: dickon |
||||
* Date: 21/11/2006 |
||||
* Time: 22:46 |
||||
* |
||||
*/ |
||||
|
||||
using System; |
||||
using System.Data; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace SharpDbTools.Forms |
||||
{ |
||||
/// <summary>
|
||||
/// Description of SQLEditorQueryToolViewContent.
|
||||
/// </summary>
|
||||
public class SQLToolViewContent : AbstractViewContent |
||||
{ |
||||
string logicalConnectionName; |
||||
SQLTool sqlTool; |
||||
|
||||
public SQLToolViewContent(string logicalConnectionName) |
||||
{ |
||||
this.TitleName = "SQL Tool: " + logicalConnectionName; |
||||
this.logicalConnectionName = logicalConnectionName; |
||||
sqlTool = new SQLTool(this.logicalConnectionName); |
||||
} |
||||
|
||||
public override System.Windows.Forms.Control Control { |
||||
get { |
||||
return this.sqlTool; |
||||
} |
||||
} |
||||
|
||||
public override bool IsReadOnly { |
||||
get { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
public override bool IsViewOnly { |
||||
get { |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,72 +0,0 @@
@@ -1,72 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Dickon Field" email=""/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Data; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
|
||||
namespace SharpDbTools.Forms |
||||
{ |
||||
/// <summary>
|
||||
/// Description of TableDescribeViewContent.
|
||||
/// </summary>
|
||||
public class TableDescribeViewContent : AbstractViewContent |
||||
{ |
||||
DataTable tableInfo; |
||||
DataGridView tableInfoDataGridView; |
||||
|
||||
|
||||
public TableDescribeViewContent(DataTable tableInfo, |
||||
string tableName, |
||||
string[] fieldsToDisplay, |
||||
string[] columnHeaderNames) |
||||
{ |
||||
this.TitleName = "table: " + tableName; |
||||
this.tableInfo = tableInfo; |
||||
this.tableInfoDataGridView = new DataGridView(); |
||||
DataGridView v = this.tableInfoDataGridView; |
||||
|
||||
v.AutoGenerateColumns = false; |
||||
v.AutoSize = true; |
||||
|
||||
v.DataSource = this.tableInfo; |
||||
//v.DataMember = TableNames.Columns;
|
||||
|
||||
for (int i = 0; i < fieldsToDisplay.Length; i++ ) { |
||||
DataGridViewColumn c = new DataGridViewTextBoxColumn(); |
||||
c.DataPropertyName = fieldsToDisplay[i]; |
||||
c.Name = columnHeaderNames[i]; |
||||
v.Columns.Add(c); |
||||
} |
||||
v.AllowUserToAddRows = false; |
||||
v.AllowUserToDeleteRows = false; |
||||
v.AllowUserToResizeRows = false; |
||||
v.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells; |
||||
v.AutoResizeColumns(); |
||||
} |
||||
|
||||
public override System.Windows.Forms.Control Control { |
||||
get { |
||||
return this.tableInfoDataGridView; |
||||
} |
||||
} |
||||
|
||||
public override bool IsReadOnly { |
||||
get { |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
public override bool IsViewOnly { |
||||
get { |
||||
return true; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,62 +0,0 @@
@@ -1,62 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Dickon Field" email=""/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Data; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using SharpDbTools.Data; |
||||
using SharpServerTools.Forms; |
||||
|
||||
namespace SharpDbTools.Forms |
||||
{ |
||||
/// <summary>
|
||||
/// specialisation of the TreeNode to add context menu and click handling
|
||||
/// to invoke the DescribeTable component for Oracle tables.
|
||||
/// </summary>
|
||||
|
||||
public class TableTreeNode: TreeNode |
||||
{ |
||||
string logicalConnectionName; |
||||
|
||||
public TableTreeNode(string objectName, string logicalConnectionName): base(objectName) |
||||
{ |
||||
this.logicalConnectionName = logicalConnectionName; |
||||
NodeAwareContextMenuStrip cMenu = new NodeAwareContextMenuStrip(this); |
||||
|
||||
ToolStripMenuItem invokeDescriberMenuItem = new ToolStripMenuItem("Describe"); |
||||
invokeDescriberMenuItem.Click += new EventHandler(DescribeTableClickHandler); |
||||
|
||||
|
||||
|
||||
cMenu.Items.AddRange(new ToolStripMenuItem[] |
||||
{ |
||||
invokeDescriberMenuItem |
||||
}); |
||||
this.ContextMenuStrip = cMenu; |
||||
} |
||||
|
||||
public void DescribeTableClickHandler(object sender, EventArgs args) |
||||
{ |
||||
ToolStripMenuItem item = sender as ToolStripMenuItem; |
||||
NodeAwareContextMenuStrip s = item.Owner as NodeAwareContextMenuStrip; |
||||
string tableName = s.TreeNode.Text; |
||||
LoggingService.Debug("describe table clicked for: " + logicalConnectionName + " and table name: " + tableName); |
||||
DataTable tableInfo = DbModelInfoService.GetTableInfo(logicalConnectionName, tableName); |
||||
string invariantName = DbModelInfoService.GetDbModelInfo(logicalConnectionName).InvariantName; |
||||
// TODO: get field names and column header names from factory
|
||||
FormsArtefactFactory factory = FormsArtefactFactories.GetFactory(invariantName); |
||||
|
||||
TableDescribeViewContent tableDescribeViewContent = |
||||
new TableDescribeViewContent(tableInfo, tableName, factory.GetDescribeTableFieldNames(), |
||||
factory.GetDescribeTableColumnHeaderNames()); |
||||
WorkbenchSingleton.Workbench.ShowView(tableDescribeViewContent); |
||||
} |
||||
} |
||||
} |
@ -1,107 +0,0 @@
@@ -1,107 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Dickon Field" email=""/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Data; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.Core; |
||||
using SharpDbTools.Data; |
||||
using SharpDbTools.Forms; |
||||
|
||||
namespace SharpDbTools.Oracle.Forms |
||||
{ |
||||
/// <summary>
|
||||
/// Description of MetaDataNodeBuilder.
|
||||
/// TODO: currently this is just a flat list - need to reflect ownership
|
||||
/// relationships such as schema etc
|
||||
/// </summary>
|
||||
public class OracleFormsArtefactFactory : FormsArtefactFactory |
||||
{ |
||||
public OracleFormsArtefactFactory() |
||||
{ |
||||
} |
||||
|
||||
public override TreeNode CreateMetaDataNode(string logicalConnectionName) |
||||
{ |
||||
LoggingService.Debug(this.GetType().ToString() |
||||
+ ": creating MetaDataNode for: " + logicalConnectionName); |
||||
// create root node of the metadata collections tree
|
||||
|
||||
string nodeName = ResourceService.GetString("SharpDbTools.Forms.DbObjectNodeName"); |
||||
TreeNode metaNode = new TreeNode(nodeName); |
||||
|
||||
// retrieve the metadata for this logical connection name
|
||||
|
||||
DbModelInfo info = DbModelInfoService.GetDbModelInfo(logicalConnectionName); |
||||
|
||||
// retrieve the table listing the metadata collections
|
||||
|
||||
DataTable metadataCollectionsTable = info.Tables[MetadataNames.MetaDataCollections]; |
||||
|
||||
// if it exists then populate the tree
|
||||
|
||||
if (metadataCollectionsTable != null) { |
||||
LoggingService.Debug(this.GetType().ToString() + ": found metadata collections table, " + |
||||
" building node..."); |
||||
for (int i = 0; i < MetadataNames.PrimaryObjects.Length; i++) { |
||||
string metadataCollectionName = MetadataNames.PrimaryObjects[i]; |
||||
LoggingService.Debug("looking for metadata: " + metadataCollectionName); |
||||
DataTable metaCollectionTable = info.Tables[metadataCollectionName]; |
||||
if (metaCollectionTable == null) continue; |
||||
LoggingService.Debug("found metadata collection: " + metadataCollectionName); |
||||
string nodeDisplayNameKey = "SharpDbTools.Data.PrimaryObjects." + metadataCollectionName; |
||||
string nodeDisplayName = ResourceService.GetString(nodeDisplayNameKey); |
||||
TreeNode collectionNode = new TreeNode(nodeDisplayName); |
||||
collectionNode.Name = logicalConnectionName + ":Collection:" + metadataCollectionName; |
||||
metaNode.Nodes.Add(collectionNode); |
||||
foreach (DataRow dbObjectRow in metaCollectionTable.Rows) { |
||||
TreeNode objectNode = null; |
||||
switch(metadataCollectionName) { |
||||
case "Tables": |
||||
//LoggingService.Debug("found table row");
|
||||
objectNode = new TableTreeNode((string)dbObjectRow[1], logicalConnectionName); |
||||
break; |
||||
case "Users": |
||||
//LoggingService.Debug("found users row");
|
||||
objectNode = new TreeNode((string)dbObjectRow[0]); |
||||
break; |
||||
default: |
||||
//LoggingService.Debug("found " + metadataCollectionName + " row");
|
||||
if (dbObjectRow.ItemArray.Length > 1) { |
||||
objectNode = new TreeNode((string)dbObjectRow[1]); |
||||
} else { |
||||
objectNode = new TreeNode((string)dbObjectRow[0]); |
||||
} |
||||
break; |
||||
} |
||||
collectionNode.Nodes.Add(objectNode); |
||||
} |
||||
} |
||||
} |
||||
return metaNode; |
||||
} |
||||
|
||||
public override string[] GetDescribeTableFieldNames() |
||||
{ |
||||
return tableFieldsToDisplay; |
||||
} |
||||
public override string[] GetDescribeTableColumnHeaderNames() |
||||
{ |
||||
return tableFieldsColumnHeaders; |
||||
} |
||||
|
||||
private static string[] tableFieldsToDisplay = |
||||
new string [] {"COLUMN_NAME", "DATATYPE", |
||||
"LENGTH", "PRECISION", "SCALE", "NULLABLE"}; |
||||
private static string[] tableFieldsColumnHeaders = |
||||
new string[] { "Column", "Type", "Length", "Precision", "Scale", "Nullable" }; |
||||
|
||||
|
||||
} |
||||
|
||||
} |
@ -1,123 +0,0 @@
@@ -1,123 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Dickon Field" email=""/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Data; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.Core; |
||||
using SharpDbTools.Data; |
||||
using SharpDbTools.Forms; |
||||
|
||||
namespace SharpDbTools.SQLServer.Forms |
||||
{ |
||||
/// <summary>
|
||||
/// Creates a TreeNode that displays the metadata for a SQLServer database
|
||||
/// Uses:
|
||||
/// <item>DbModelInfo and DbModelInfoService: to access the metadata</item>
|
||||
/// <item>TableTreeNode: to display Table metadata - this has 'Describe'
|
||||
/// behaviour associated with it, accessed via a right mouse menu</item>
|
||||
/// Going forward this should reflect the structure and relationship
|
||||
/// of SQLServer objects - for now it is generic
|
||||
/// </summary>
|
||||
public class SQLServerFormsArtefactFactory : FormsArtefactFactory |
||||
{ |
||||
public SQLServerFormsArtefactFactory() |
||||
{ |
||||
} |
||||
|
||||
public override TreeNode CreateMetaDataNode(string logicalConnectionName) |
||||
{ |
||||
LoggingService.Debug(this.GetType().ToString() |
||||
+ ": creating MetaDataNode for: " + logicalConnectionName); |
||||
// create root node of the metadata collections tree
|
||||
|
||||
string nodeName = ResourceService.GetString("SharpDbTools.Forms.DbObjectNodeName"); |
||||
TreeNode metaNode = new TreeNode(nodeName); |
||||
|
||||
// retrieve the metadata for this logical connection name
|
||||
|
||||
DbModelInfo info = DbModelInfoService.GetDbModelInfo(logicalConnectionName); |
||||
|
||||
// retrieve the table listing the metadata collections
|
||||
|
||||
DataTable metadataCollectionsTable = info.Tables[MetadataNames.MetaDataCollections]; |
||||
|
||||
// if it exists then populate the tree
|
||||
|
||||
if (metadataCollectionsTable != null) { |
||||
LoggingService.Debug(this.GetType().ToString() + ": found metadata collections table, " + |
||||
" building node..."); |
||||
for (int i = 0; i < MetadataNames.PrimaryObjects.Length; i++) { |
||||
string metadataCollectionName = MetadataNames.PrimaryObjects[i]; |
||||
LoggingService.Debug("looking for metadata: " + metadataCollectionName); |
||||
DataTable metaCollectionTable = info.Tables[metadataCollectionName]; |
||||
if (metaCollectionTable == null) continue; |
||||
LoggingService.Debug("found metadata collection: " + metadataCollectionName); |
||||
string nodeDisplayNameKey = "SharpDbTools.Data.PrimaryObjects." + metadataCollectionName; |
||||
string nodeDisplayName = ResourceService.GetString(nodeDisplayNameKey); |
||||
TreeNode collectionNode = new TreeNode(nodeDisplayName); |
||||
metaNode.Nodes.Add(collectionNode); |
||||
|
||||
if (metaCollectionTable != null) { |
||||
foreach (DataRow dbObjectRow in metaCollectionTable.Rows) { |
||||
TreeNode objectNode = null; |
||||
|
||||
// if there is only one field in the metadata table then it is almost certainly
|
||||
// the name of the item - so if not we need to then figure out what it is
|
||||
if (dbObjectRow.ItemArray.Length > 1) { |
||||
|
||||
// if it is a table metadata collection then create a node
|
||||
// with the option to invoke the DescribeTableViewContent -
|
||||
// that's what a TableTreeNode gives us right now
|
||||
// TODO: provide describe functions amongst others for
|
||||
// other metadata types
|
||||
|
||||
switch (metadataCollectionName) { |
||||
case "Tables": |
||||
objectNode = new TableTreeNode((string)dbObjectRow[2], logicalConnectionName); |
||||
break; |
||||
case "Functions": |
||||
// do nothing - there are no functions in SQLServer
|
||||
break; |
||||
case "Users": |
||||
objectNode = new TreeNode((string)dbObjectRow[1]); |
||||
break; |
||||
default: |
||||
objectNode = new TreeNode((string)dbObjectRow[2]); |
||||
break; |
||||
} |
||||
} else { |
||||
objectNode = new TreeNode((string)dbObjectRow[0]); |
||||
} |
||||
collectionNode.Nodes.Add(objectNode); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
return metaNode; |
||||
} |
||||
|
||||
public override string[] GetDescribeTableFieldNames() |
||||
{ |
||||
return tableFieldsToDisplay; |
||||
} |
||||
public override string[] GetDescribeTableColumnHeaderNames() |
||||
{ |
||||
return tableFieldsColumnHeaders; |
||||
} |
||||
|
||||
private static string[] tableFieldsToDisplay = |
||||
new string [] {"COLUMN_NAME", "DATA_TYPE", |
||||
"CHARACTER_OCTET_LENGTH", "NUMERIC_PRECISION", "NUMERIC_SCALE", "IS_NULLABLE"}; |
||||
private static string[] tableFieldsColumnHeaders = |
||||
new string[] { "Column", "Type", "Length", "Precision", "Scale", "Nullable" }; |
||||
|
||||
|
||||
} |
||||
|
||||
} |
@ -1,98 +0,0 @@
@@ -1,98 +0,0 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Dickon Field" email=""/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Data; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.Core; |
||||
using SharpDbTools.Data; |
||||
using SharpDbTools.Forms; |
||||
|
||||
namespace SharpDbTools.SQLite.Forms |
||||
{ |
||||
/// <summary>
|
||||
/// Description of MetaDataNodeBuilder.
|
||||
/// TODO: currently this is just a flat list - need to reflect ownership
|
||||
/// relationships such as schema etc
|
||||
/// </summary>
|
||||
public class SQLiteFormsArtefactFactory : FormsArtefactFactory |
||||
{ |
||||
public SQLiteFormsArtefactFactory() |
||||
{ |
||||
} |
||||
|
||||
public override TreeNode CreateMetaDataNode(string logicalConnectionName) |
||||
{ |
||||
LoggingService.Debug(this.GetType().ToString() |
||||
+ ": creating MetaDataNode for: " + logicalConnectionName); |
||||
// create root node of the metadata collections tree
|
||||
|
||||
string nodeName = ResourceService.GetString("SharpDbTools.Forms.DbObjectNodeName"); |
||||
TreeNode metaNode = new TreeNode(nodeName); |
||||
|
||||
// retrieve the metadata for this logical connection name
|
||||
|
||||
DbModelInfo info = DbModelInfoService.GetDbModelInfo(logicalConnectionName); |
||||
|
||||
// retrieve the table listing the metadata collections
|
||||
|
||||
DataTable metadataCollectionsTable = info.Tables[MetadataNames.MetaDataCollections]; |
||||
|
||||
// if it exists then populate the tree
|
||||
|
||||
if (metadataCollectionsTable != null) { |
||||
LoggingService.Debug(this.GetType().ToString() + ": found metadata collections table, " + |
||||
" building node..."); |
||||
for (int i = 0; i < MetadataNames.PrimaryObjects.Length; i++) { |
||||
string metadataCollectionName = MetadataNames.PrimaryObjects[i]; |
||||
LoggingService.Debug("looking for metadata: " + metadataCollectionName); |
||||
DataTable metaCollectionTable = info.Tables[metadataCollectionName]; |
||||
if (metaCollectionTable == null) continue; |
||||
LoggingService.Debug("found metadata collection: " + metadataCollectionName); |
||||
string nodeDisplayNameKey = "SharpDbTools.Data.PrimaryObjects." + metadataCollectionName; |
||||
string nodeDisplayName = ResourceService.GetString(nodeDisplayNameKey); |
||||
TreeNode collectionNode = new TreeNode(nodeDisplayName); |
||||
collectionNode.Name = logicalConnectionName + ":Collection:" + metadataCollectionName; |
||||
metaNode.Nodes.Add(collectionNode); |
||||
foreach (DataRow dbObjectRow in metaCollectionTable.Rows) { |
||||
TreeNode objectNode = null; |
||||
switch(metadataCollectionName) { |
||||
case "Tables": |
||||
//LoggingService.Debug("found table row");
|
||||
objectNode = new TableTreeNode((string)dbObjectRow[2], logicalConnectionName); |
||||
break; |
||||
default: |
||||
objectNode = new TreeNode((string)dbObjectRow[2]); |
||||
break; |
||||
} |
||||
collectionNode.Nodes.Add(objectNode); |
||||
} |
||||
} |
||||
} |
||||
return metaNode; |
||||
} |
||||
|
||||
public override string[] GetDescribeTableFieldNames() |
||||
{ |
||||
return tableFieldsToDisplay; |
||||
} |
||||
public override string[] GetDescribeTableColumnHeaderNames() |
||||
{ |
||||
return tableFieldsColumnHeaders; |
||||
} |
||||
|
||||
private static string[] tableFieldsToDisplay = |
||||
new string [] {"COLUMN_NAME", "DATATYPE", |
||||
"LENGTH", "PRECISION", "SCALE", "NULLABLE"}; |
||||
private static string[] tableFieldsColumnHeaders = |
||||
new string[] { "Column", "Type", "Length", "Precision", "Scale", "Nullable" }; |
||||
|
||||
|
||||
} |
||||
|
||||
} |
@ -1,24 +0,0 @@
@@ -1,24 +0,0 @@
|
||||
<AddIn name = "SharpDbTools" |
||||
author = "Dickon Field" |
||||
url = "" |
||||
description = "A collection of components and tools to help develop db-aware apps... and more"> |
||||
|
||||
<Manifest> |
||||
<Identity name = "ICSharpCode.SharpServerTools"/> |
||||
</Manifest> |
||||
|
||||
<Runtime> |
||||
<Import assembly = "SharpDbTools.dll"/> |
||||
<Import assembly = "SharpServerTools.dll"/> |
||||
<Import assembly="OracleSharpDbToolsProvider.dll"/> |
||||
</Runtime> |
||||
|
||||
<Path name = "/SharpDevelop/Workbench/Pads"> |
||||
<Pad id = "SharpServerToolsPad" |
||||
category = "Main" |
||||
title = "Server Explorer" |
||||
icon = "PadIcons.Output" |
||||
shortcut = "Control|Alt|D" |
||||
class = "SharpServerTools.Forms.ServerBrowserTool"/> |
||||
</Path> |
||||
</AddIn> |
Loading…
Reference in new issue