Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2006 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts 2.1-Beta2
7 changed files with 226 additions and 24 deletions
@ -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.*")] |
||||||
@ -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> |
||||||
@ -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 |
||||||
@ -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" }; |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
Loading…
Reference in new issue