Browse Source

added another basic project for SQLServer plugin to SharpDbTools, and the necessary files to create the plugin for it.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2006 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts 2.1-Beta2
Dickon Field 19 years ago
parent
commit
d58c19d2a1
  1. 31
      src/AddIns/Misc/SharpServerTools/SQLServerDbToolsProvider/Config/AssemblyInfo.cs
  2. 61
      src/AddIns/Misc/SharpServerTools/SQLServerDbToolsProvider/SQLServerDbToolsProvider.csproj
  3. 7
      src/AddIns/Misc/SharpServerTools/SQLServerDbToolsProvider/SQLServerDbToolsProvider.sln
  4. 115
      src/AddIns/Misc/SharpServerTools/SQLServerDbToolsProvider/Src/Forms/SQLServerFormsArtefactFactory.cs
  5. 6
      src/AddIns/Misc/SharpServerTools/ServerBrowserTool/SharpServerTools.addin
  6. 6
      src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Data/DbModelInfoService.cs
  7. 24
      src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Forms/FormsArtefactFactories.cs

31
src/AddIns/Misc/SharpServerTools/SQLServerDbToolsProvider/Config/AssemblyInfo.cs

@ -0,0 +1,31 @@
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("SQLServerDbToolsProvider")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SQLServerDbToolsProvider")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("1.0.*")]

61
src/AddIns/Misc/SharpServerTools/SQLServerDbToolsProvider/SQLServerDbToolsProvider.csproj

@ -0,0 +1,61 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>SQLServerDbToolsProvider</RootNamespace>
<AssemblyName>SQLServerDbToolsProvider</AssemblyName>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8C692BAF-108E-4346-B41E-6EE7D20E2E9D}</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>bin\Release\</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.Xml" />
<Reference Include="System.Data" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="Config\AssemblyInfo.cs" />
<Compile Include="Src\Forms\SQLServerFormsArtefactFactory.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Src" />
<Folder Include="Config" />
<Folder Include="Src\Forms" />
<ProjectReference Include="..\..\..\..\Main\Core\Project\ICSharpCode.Core.csproj">
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project>
<Name>ICSharpCode.Core</Name>
</ProjectReference>
<ProjectReference Include="..\SharpDbTools\SharpDbTools.csproj">
<Project>{93B2D6DF-7588-40C0-8A35-CA0DD7328FC3}</Project>
<Name>SharpDbTools</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

7
src/AddIns/Misc/SharpServerTools/SQLServerDbToolsProvider/SQLServerDbToolsProvider.sln

@ -0,0 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.1.0.2001
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SQLServerDbToolsProvider", "SQLServerDbToolsProvider.csproj", "{8C692BAF-108E-4346-B41E-6EE7D20E2E9D}"
EndProject
Global
EndGlobal

115
src/AddIns/Misc/SharpServerTools/SQLServerDbToolsProvider/Src/Forms/SQLServerFormsArtefactFactory.cs

@ -0,0 +1,115 @@
// <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>
/// Description of MetaDataNodeBuilder.
/// TODO: currently this is just a flat list - need to reflect ownership
/// relationships such as schema etc
/// </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
TreeNode metaNode = new TreeNode("Db Objects");
// retrieve the metadata for this logical connection name
DbModelInfo info = DbModelInfoService.GetDbModelInfo(logicalConnectionName);
// retrieve the table listing the metadata collections
DataTable metadataCollectionsTable = info.Tables[TableNames.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 < TableNames.PrimaryObjects.Length; i++) {
string metadataCollectionName = TableNames.PrimaryObjects[i];
LoggingService.Debug("looking for metadata: " + metadataCollectionName);
DataTable metaCollectionTable = info.Tables[metadataCollectionName];
LoggingService.Debug("found metadata collection: " + metadataCollectionName);
TreeNode collectionNode = new TreeNode(metadataCollectionName);
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" };
}
}

6
src/AddIns/Misc/SharpServerTools/ServerBrowserTool/SharpServerTools.addin

@ -11,6 +11,7 @@
<Import assembly = "SharpDbTools.dll"/> <Import assembly = "SharpDbTools.dll"/>
<Import assembly = "ServerBrowserTool.dll"/> <Import assembly = "ServerBrowserTool.dll"/>
<Import assembly="OracleDbToolsProvider.dll"/> <Import assembly="OracleDbToolsProvider.dll"/>
<Import assembly="SqlServerDbToolsProvider.dll"/>
</Runtime> </Runtime>
<Path name = "/SharpDevelop/Workbench/Pads"> <Path name = "/SharpDevelop/Workbench/Pads">
@ -27,6 +28,11 @@
class = "SharpDbTools.Oracle.Forms.OracleFormsArtefactFactory"/> class = "SharpDbTools.Oracle.Forms.OracleFormsArtefactFactory"/>
</Path> </Path>
<Path name = "/SharpServerTools/SharpDbTools/FormsArtefactFactory">
<Class id = "System.Data.SqlClient"
class = "SharpDbTools.SQLServer.Forms.SQLServerFormsArtefactFactory"/>
</Path>
<Path name = "/SharpServerTools/ServerTool"> <Path name = "/SharpServerTools/ServerTool">
<Class id = "DatabaseExplorer" <Class id = "DatabaseExplorer"
class = "SharpDbTools.Forms.DatabaseExplorerTreeNode"/> class = "SharpDbTools.Forms.DatabaseExplorerTreeNode"/>

6
src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Data/DbModelInfoService.cs

@ -130,6 +130,9 @@ namespace SharpDbTools.Data
connection.Open(); connection.Open();
DataTable schemaInfo = connection.GetSchema(); DataTable schemaInfo = connection.GetSchema();
if (schemaInfo != null) {
LoggingService.Debug("retrieved schema info with " + schemaInfo.Rows.Count + " rows");
}
// clear the DbModelInfo prior to refreshing from the connection // clear the DbModelInfo prior to refreshing from the connection
modelInfo.ClearMetaData(); modelInfo.ClearMetaData();
@ -140,9 +143,12 @@ namespace SharpDbTools.Data
foreach (DataRow collectionRow in schemaInfo.Rows) { foreach (DataRow collectionRow in schemaInfo.Rows) {
String collectionName = (string)collectionRow[0]; String collectionName = (string)collectionRow[0];
LoggingService.Debug("loading metadata for collection: " + collectionName);
DataTable nextMetaData = connection.GetSchema(collectionName); DataTable nextMetaData = connection.GetSchema(collectionName);
modelInfo.Merge(nextMetaData); modelInfo.Merge(nextMetaData);
} }
LoggingService.Debug("completed load of metadata, committing changes");
modelInfo.AcceptChanges();
return modelInfo; return modelInfo;
} }
catch(Exception e) { catch(Exception e) {

24
src/AddIns/Misc/SharpServerTools/SharpDbTools/Src/Forms/FormsArtefactFactories.cs

@ -47,30 +47,6 @@ namespace SharpDbTools.Forms
+ invariantName); + invariantName);
} }
return factory; return factory;
// switch (invariantName)
// {
// case "System.Data.OracleClient":
// Type type = Type.GetType("SharpDbTools.Oracle.Forms.OracleFormsArtefactFactory, OracleDbToolsProvider");
// FormsArtefactFactory factory = (FormsArtefactFactory)Activator.CreateInstance(type);
// LoggingService.Debug("Found FormsArtefactFactory for: " + invariantName);
// return factory;
// default:
// LoggingService.Debug("Failed to find FormsArtefactFactory for: " + invariantName);
// throw new ArgumentException("There is no FormsArtefactFactory for invariant name: " +
// invariantName);
// }
// TODO: retrieve the relevant factory from file-base config
// TODO: >>>>>>>>>>>>>>>>>>> NEXT: retrieve an XML element with mapping
// from invariant name to class name of FormsArtefactProvider
// options include specific config file or use of .net process config.
// 1. load the config file for DbTools FormsArtefacts
// 2. find the string name of the type of the FormsArtefactsFactory implementation
// corresponding to invariatName
// 3. use Type.GetType to create an instance of it and return it to the caller
} }
} }
} }

Loading…
Cancel
Save