Browse Source

Started new style Server control, incorporating dbtool

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2814 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Dickon Field 18 years ago
parent
commit
0ac8486042
  1. 24
      src/AddIns/DisplayBindings/ServerTools/ICSharpCode.ServerTools.addin
  2. 154
      src/AddIns/DisplayBindings/ServerTools/ICSharpCode.ServerTools.csproj
  3. 57
      src/AddIns/DisplayBindings/ServerTools/Properties/AssemblyInfo.cs
  4. 71
      src/AddIns/DisplayBindings/ServerTools/Properties/Resources.Designer.cs
  5. 117
      src/AddIns/DisplayBindings/ServerTools/Properties/Resources.resx
  6. 30
      src/AddIns/DisplayBindings/ServerTools/Properties/Settings.Designer.cs
  7. 7
      src/AddIns/DisplayBindings/ServerTools/Properties/Settings.settings
  8. 63
      src/AddIns/DisplayBindings/ServerTools/ServerBrowserHost.cs
  9. 27
      src/AddIns/DisplayBindings/ServerTools/ServerControl.xaml
  10. 80
      src/AddIns/DisplayBindings/ServerTools/ServerControl.xaml.cs
  11. 10
      src/Libraries/ICSharpCode.DataTools/ICSharpCode.DataTools.csproj
  12. 112
      src/Libraries/ICSharpCode.DataTools/OleDbUtils.cs
  13. 26
      src/SharpDevelop.sln

24
src/AddIns/DisplayBindings/ServerTools/ICSharpCode.ServerTools.addin

@ -0,0 +1,24 @@
<AddIn name = "ICSharpCode.ServerTools"
author = "Dickon Field"
url = "www.softwarefabric.com"
description = "A collection of components and tools to help develop db-aware apps... and more">
<Manifest>
<Identity name = "ICSharpCode.ServerTools"/>
</Manifest>
<Runtime>
<Import assembly ="ICSharpCode.ServerTools.dll"/>
<Import assembly="MyMeta.dll"/>
<Import assembly="ICSharpCode.DataTools.dll"/>
</Runtime>
<Path name = "/SharpDevelop/Workbench/Pads">
<Pad id = "SharpServerToolsPad"
category = "Main"
title = "Server Explorer"
icon = "ServerTool.Server"
shortcut = "Control|Alt|D"
class = "ICSharpCode.ServerTools.ServerControl"/>
</Path>
</AddIn>

154
src/AddIns/DisplayBindings/ServerTools/ICSharpCode.ServerTools.csproj

@ -0,0 +1,154 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{8CF1EB90-324F-4AA9-BAA2-DEF87392CE86}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ICSharpCode.ServerTools</RootNamespace>
<AssemblyName>ICSharpCode.ServerTools</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\..\AddIns\AddIns\DisplayBindings\ServerTools\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UIAutomationProvider">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="PresentationFramework">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsFormsIntegration">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Page Include="ServerControl.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="ServerControl.xaml.cs">
<DependentUpon>ServerControl.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<ProjectReference Include="..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
<Name>ICSharpCode.SharpDevelop</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Main\Core\Project\ICSharpCode.Core.csproj">
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project>
<Name>ICSharpCode.Core</Name>
</ProjectReference>
<COMReference Include="ADODB">
<Guid>{EF53050B-882E-4776-B643-EDA472E8E3F2}</Guid>
<VersionMajor>2</VersionMajor>
<VersionMinor>7</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
</COMReference>
<COMReference Include="MSDASC">
<Guid>{2206CEB0-19C1-11D1-89E0-00C04FD7A829}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
</COMReference>
<None Include="ICSharpCode.ServerTools.addin" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="ServerBrowserHost.cs" />
<Compile Include="Todo.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Libraries\ICSharpCode.DataTools\ICSharpCode.DataTools.csproj">
<Project>{6CC3DF82-E815-483F-B4B5-85191064D981}</Project>
<Name>ICSharpCode.DataTools</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

57
src/AddIns/DisplayBindings/ServerTools/Properties/AssemblyInfo.cs

@ -0,0 +1,57 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SharpServerTools.Servers")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SharpServerTools.Servers")]
[assembly: AssemblyCopyright("Copyright © 2007")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("TestServerControl")]

71
src/AddIns/DisplayBindings/ServerTools/Properties/Resources.Designer.cs generated

@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.1378
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ICSharpCode.ServerTools.Servers.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SharpServerTools.Servers.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

117
src/AddIns/DisplayBindings/ServerTools/Properties/Resources.resx

@ -0,0 +1,117 @@
<?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.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: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" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</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" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</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>

30
src/AddIns/DisplayBindings/ServerTools/Properties/Settings.Designer.cs generated

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.1378
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ICSharpCode.ServerTools.Servers.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

7
src/AddIns/DisplayBindings/ServerTools/Properties/Settings.settings

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

63
src/AddIns/DisplayBindings/ServerTools/ServerBrowserHost.cs

@ -0,0 +1,63 @@
// <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 System.Windows.Forms.Integration;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.ServerTools.Servers;
namespace ICSharpCode.ServerTools.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 ServerBrowserHost : AbstractPadContent
{
ElementHost ctl;
/// <summary>
/// ServerBrowserTool hosts one or more TreeViews providing views of types
/// of server. Currently it shows only relational database servers.
/// </summary>
public ServerBrowserHost()
{
LoggingService.Debug("Loading ServerBrowserHost");
ctl = new ElementHost();
ServerControl serverControl = new ServerControl();
ctl.Child = serverControl;
}
/// <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();
}
}
}

27
src/AddIns/DisplayBindings/ServerTools/ServerControl.xaml

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<UserControl
x:Class="ICSharpCode.ServerTools.ServerControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="300"
Width="300">
<DockPanel>
<ToolBar
DockPanel.Dock="Top"
Name="serverToolBar"
Grid.Column="0"
Grid.Row="0">
<Button
Name="refreshButton">R</Button>
<Button
Name="stopRefreshButton">S</Button>
<Button
Name="addConnectionButton"
Click="addConnectionButton_Click">A</Button>
</ToolBar>
<TreeView
Name="serverTree">
<TreeViewItem
Name="dbTree"
Header="Data Connections"></TreeViewItem>
</TreeView>
</DockPanel>
</UserControl>

80
src/AddIns/DisplayBindings/ServerTools/ServerControl.xaml.cs

@ -0,0 +1,80 @@
using System;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data;
using System.Data.OleDb;
using System.Data.Common;
using System.Configuration;
using System.Collections.Generic;
using ICSharpCode.DataTools;
namespace ICSharpCode.ServerTools
{
/// <summary>
/// Interaction logic for UserControl1.xaml
/// </summary>
public partial class ServerControl : UserControl
{
public ServerControl()
{
InitializeComponent();
Refresh();
}
public void Refresh()
{
ConnectionStringSettingsCollection c
= OleDbConnectionUtil.GetConnectionSettingsCollection();
this.dbTree.Items.Clear();
foreach (ConnectionStringSettings s in c)
{
TreeViewItem n = new TreeViewItem();
//n.Name = s.Name;
n.Header = s.Name;
this.dbTree.Items.Add(n);
}
}
/// <summary>
/// Uses the DataLink dialog to define a new Oledb connection string,
/// tests it, and adds it to the exe config.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void addConnectionButton_Click(object sender, RoutedEventArgs e)
{
MSDASC.DataLinks mydlg = new MSDASC.DataLinks();
OleDbConnection oleCon = new OleDbConnection();
ADODB._Connection aDOcon;
//Cast the generic object that PromptNew returns to an ADODB._Connection.
aDOcon = (ADODB._Connection)mydlg.PromptNew();
oleCon.ConnectionString = aDOcon.ConnectionString;
oleCon.Open();
if (oleCon.State.ToString() == "Open")
{
// TODO: add the oledb connection to the local config and
// refresh
OleDbConnectionUtil.Put("any name", oleCon.ConnectionString);
this.Refresh();
oleCon.Close();
}
else
{
MessageBox.Show("Connection Failed");
}
}
}
}

10
src/Libraries/ICSharpCode.DataTools/ICSharpCode.DataTools.csproj

@ -40,6 +40,16 @@
<Compile Include="OleDbUtils.cs" /> <Compile Include="OleDbUtils.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
<Name>ICSharpCode.SharpDevelop</Name>
</ProjectReference>
<ProjectReference Include="..\..\Main\Core\Project\ICSharpCode.Core.csproj">
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project>
<Name>ICSharpCode.Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

112
src/Libraries/ICSharpCode.DataTools/OleDbUtils.cs

@ -1,16 +1,22 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Configuration; using System.Configuration;
using System.Data.Common; using System.Data.Common;
using System.Data; using System.Data;
using System.Data.OleDb; using System.Data.OleDb;
using System.IO;
using System.Xml.Serialization;
using ICSharpCode.Core;
using log = ICSharpCode.Core.LoggingService;
namespace ICSharpCode.DataTools namespace ICSharpCode.DataTools
{ {
public static class OleDbConnectionUtil public static class OleDbConnectionUtil
{ {
/// <summary> /// <summary>
/// Returns a single connection, unopened /// Returns a single connection, unopened
/// </summary> /// </summary>
@ -18,11 +24,16 @@ namespace ICSharpCode.DataTools
/// <returns>An OleDbConnection object if the connectioName refers to an oledb connection, otherwise null</returns> /// <returns>An OleDbConnection object if the connectioName refers to an oledb connection, otherwise null</returns>
/// <exception cref="ArgumentException">thrown if the name of the connection is found, /// <exception cref="ArgumentException">thrown if the name of the connection is found,
/// but is not a valid oledb connection string</exception> /// but is not a valid oledb connection string</exception>
///
public const string CONNECTION_STRINGS_FILE = "Connections.conf";
private static ConnectionStringSettingsCollection cssc;
public static bool TryGet(string connectionName, out OleDbConnection conn) public static bool TryGet(string connectionName, out OleDbConnection conn)
{ {
try try
{ {
ConnectionStringSettingsCollection settingsCollection = getConnectionSettingsCollection(); ConnectionStringSettingsCollection settingsCollection = GetConnectionSettingsCollection();
ConnectionStringSettings settings = settingsCollection[connectionName]; ConnectionStringSettings settings = settingsCollection[connectionName];
string connString = settings.ConnectionString; string connString = settings.ConnectionString;
OleDbConnectionStringBuilder builder = new OleDbConnectionStringBuilder(connString); // ArgumentException thrown here OleDbConnectionStringBuilder builder = new OleDbConnectionStringBuilder(connString); // ArgumentException thrown here
@ -38,22 +49,12 @@ namespace ICSharpCode.DataTools
public static void Put(string name, string connectionString) public static void Put(string name, string connectionString)
{ {
// check that it is an oledb connection string // check that it is an oledb connection string
OleDbConnectionStringBuilder builder = new OleDbConnectionStringBuilder(name); OleDbConnectionStringBuilder builder = new OleDbConnectionStringBuilder(connectionString);
Configuration config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
ConnectionStringsSection s = config.ConnectionStrings;
ConnectionStringSettingsCollection c = s.ConnectionStrings;
ConnectionStringSettings st = new ConnectionStringSettings(name, connectionString); ConnectionStringSettings st = new ConnectionStringSettings(name, connectionString);
c.Add(st); cssc.Add(st);
} }
// TODO: test what happens when you set an OleDbConnection's connection string to a wrong value - probably
// nothing until you try and open it? Could also try constructing and OleDbConnectionStringBuilder with the
// string and see if it parses ok.
/// <summary> /// <summary>
/// Returns all Connections unopened /// Returns all Connections unopened
/// </summary> /// </summary>
@ -63,7 +64,7 @@ namespace ICSharpCode.DataTools
{ {
// iterate through all connection strings trying to create a connection // iterate through all connection strings trying to create a connection
// from each. If an exception is thrown by the OleDbFactory then do not return it // from each. If an exception is thrown by the OleDbFactory then do not return it
ConnectionStringSettingsCollection settingsCollection = getConnectionSettingsCollection(); ConnectionStringSettingsCollection settingsCollection = GetConnectionSettingsCollection();
List<OleDbConnection> results = new List<OleDbConnection>(); List<OleDbConnection> results = new List<OleDbConnection>();
foreach (ConnectionStringSettings c in settingsCollection) foreach (ConnectionStringSettings c in settingsCollection)
{ {
@ -73,7 +74,7 @@ namespace ICSharpCode.DataTools
OleDbConnection conn = new OleDbConnection(builder.ConnectionString); OleDbConnection conn = new OleDbConnection(builder.ConnectionString);
results.Add(conn); results.Add(conn);
} }
catch(ArgumentException) catch (ArgumentException)
{ {
// do nothing, this is acceptable // do nothing, this is acceptable
} }
@ -82,13 +83,78 @@ namespace ICSharpCode.DataTools
} }
} }
private static ConnectionStringSettingsCollection getConnectionSettingsCollection() public static ConnectionStringSettingsCollection GetConnectionSettingsCollection()
{ {
Configuration config = if (cssc != null)
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal); {
ConnectionStringsSection connSection = config.ConnectionStrings; return cssc;
ConnectionStringSettingsCollection settingsCollection = connSection.ConnectionStrings; }
return settingsCollection;
cssc = new ConnectionStringSettingsCollection();
// Does the connections file exist - if not return an emptry collection
string configPath = PropertyService.ConfigDirectory;
string filePath = Path.Combine(configPath, CONNECTION_STRINGS_FILE);
if (!File.Exists(filePath))
{
return cssc;
}
try
{
using (Stream sr = new FileStream(filePath, FileMode.Open))
{
while (sr.Length > 0)
{
XmlSerializer x = new XmlSerializer(typeof(ConnectionStringSettings));
ConnectionStringSettings cs = (ConnectionStringSettings)x.Deserialize(sr);
cssc.Add(cs);
}
}
}
catch (Exception)
{
// again, if the file contains some extraneous data it must have been corrupted or
// manually edited - in this case ignore it
log.Debug("bad data found trying to read in the ConnectionSettingsCollection from file - "
+ "please check the content of the file at: " + filePath);
}
return cssc;
}
/// <summary>
/// Save whatever is in the cache to disc - overwriting whatever is there
/// </summary>
public static void Save()
{
string configPath = PropertyService.ConfigDirectory;
string filePath = Path.Combine(configPath, CONNECTION_STRINGS_FILE);
try
{
File.Delete(filePath);
}
catch (Exception)
{
// this should just indicate that the file does not exist
log.Info("no connection settings file found while saving - will create a new one");
}
using (Stream sw = new FileStream(filePath, FileMode.CreateNew))
{
XmlSerializer xs = new XmlSerializer(typeof(ConnectionStringSettings));
foreach (ConnectionStringSettings cs in cssc)
{
try
{
xs.Serialize(sw, cs);
}
catch
{
log.Debug("failed to write ConnectionStringSettings: " + cs.ToString());
}
}
}
} }
} }
} }

26
src/SharpDevelop.sln

@ -1,7 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 10.00 Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008 # Visual Studio 2008
# SharpDevelop 3.0.0.2745 # SharpDevelop 3.0.0.2813
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AddIns", "AddIns", "{14A277EE-7DF1-4529-B639-7D1EF334C1C5}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AddIns", "AddIns", "{14A277EE-7DF1-4529-B639-7D1EF334C1C5}"
ProjectSection(SolutionItems) = postProject ProjectSection(SolutionItems) = postProject
EndProjectSection EndProjectSection
@ -60,18 +60,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComponentInspector.Core", "
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourceToolkit", "AddIns\Misc\ResourceToolkit\Project\ResourceToolkit.csproj", "{461606BD-E824-4D0A-8CBA-01810B1F5E02}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourceToolkit", "AddIns\Misc\ResourceToolkit\Project\ResourceToolkit.csproj", "{461606BD-E824-4D0A-8CBA-01810B1F5E02}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SharpServerTools", "SharpServerTools", "{6CEEC0D9-FA00-4EE3-9A1C-39B7ACC882FD}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServerBrowserTool", "AddIns\Misc\SharpServerTools\ServerBrowserTool\ServerBrowserTool.csproj", "{D721EAA4-8A40-4EF0-A011-5862159BE621}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataTools.AddIn", "AddIns\Misc\SharpServerTools\SharpDbTools\DataTools.AddIn.csproj", "{93B2D6DF-7588-40C0-8A35-CA0DD7328FC3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataTools.Model", "AddIns\Misc\SharpServerTools\DataTools.Model\DataTools.Model.csproj", "{51783FC4-D8D2-4BFB-A1F1-AC8857CF3ED0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataTools.UI", "AddIns\Misc\SharpServerTools\DataTools.UI\DataTools.UI.csproj", "{87C0E3D9-0DFD-4F6D-8E38-408AAF73F4EE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Backends", "Backends", "{FEB825FA-4AD8-425D-8E4A-B5A18EE1B81C}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Backends", "Backends", "{FEB825FA-4AD8-425D-8E4A-B5A18EE1B81C}"
ProjectSection(SolutionItems) = postProject ProjectSection(SolutionItems) = postProject
EndProjectSection EndProjectSection
@ -102,6 +90,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Display Bindings", "Display
ProjectSection(SolutionItems) = postProject ProjectSection(SolutionItems) = postProject
EndProjectSection EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.ServerTools", "AddIns\DisplayBindings\ServerTools\ICSharpCode.ServerTools.csproj", "{8CF1EB90-324F-4AA9-BAA2-DEF87392CE86}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourceEditor", "AddIns\DisplayBindings\ResourceEditor\Project\ResourceEditor.csproj", "{CBC6C247-747B-4908-B09A-4D2E0F640B6B}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourceEditor", "AddIns\DisplayBindings\ResourceEditor\Project\ResourceEditor.csproj", "{CBC6C247-747B-4908-B09A-4D2E0F640B6B}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FormsDesigner", "AddIns\DisplayBindings\FormsDesigner\Project\FormsDesigner.csproj", "{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FormsDesigner", "AddIns\DisplayBindings\FormsDesigner\Project\FormsDesigner.csproj", "{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}"
@ -534,12 +524,15 @@ Global
{8D732610-8FC6-43BA-94C9-7126FD7FE361}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8D732610-8FC6-43BA-94C9-7126FD7FE361}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8D732610-8FC6-43BA-94C9-7126FD7FE361}.Release|Any CPU.Build.0 = Release|Any CPU {8D732610-8FC6-43BA-94C9-7126FD7FE361}.Release|Any CPU.Build.0 = Release|Any CPU
{8D732610-8FC6-43BA-94C9-7126FD7FE361}.Release|Any CPU.ActiveCfg = Release|Any CPU {8D732610-8FC6-43BA-94C9-7126FD7FE361}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8CF1EB90-324F-4AA9-BAA2-DEF87392CE86}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8CF1EB90-324F-4AA9-BAA2-DEF87392CE86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8CF1EB90-324F-4AA9-BAA2-DEF87392CE86}.Release|Any CPU.Build.0 = Release|Any CPU
{8CF1EB90-324F-4AA9-BAA2-DEF87392CE86}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(NestedProjects) = preSolution GlobalSection(NestedProjects) = preSolution
{4EA396ED-64AD-4AD0-A67A-AB363F3E0C79} = {14A277EE-7DF1-4529-B639-7D1EF334C1C5} {4EA396ED-64AD-4AD0-A67A-AB363F3E0C79} = {14A277EE-7DF1-4529-B639-7D1EF334C1C5}
{FEB825FA-4AD8-425D-8E4A-B5A18EE1B81C} = {14A277EE-7DF1-4529-B639-7D1EF334C1C5} {FEB825FA-4AD8-425D-8E4A-B5A18EE1B81C} = {14A277EE-7DF1-4529-B639-7D1EF334C1C5}
{CE5B42B7-6E8C-4385-9E97-F4023FC16BF2} = {14A277EE-7DF1-4529-B639-7D1EF334C1C5} {CE5B42B7-6E8C-4385-9E97-F4023FC16BF2} = {14A277EE-7DF1-4529-B639-7D1EF334C1C5}
{6CEEC0D9-FA00-4EE3-9A1C-39B7ACC882FD} = {CE5B42B7-6E8C-4385-9E97-F4023FC16BF2}
{461606BD-E824-4D0A-8CBA-01810B1F5E02} = {CE5B42B7-6E8C-4385-9E97-F4023FC16BF2} {461606BD-E824-4D0A-8CBA-01810B1F5E02} = {CE5B42B7-6E8C-4385-9E97-F4023FC16BF2}
{BDDDCD01-D2FE-4EAD-9425-4B6B91922C7C} = {CE5B42B7-6E8C-4385-9E97-F4023FC16BF2} {BDDDCD01-D2FE-4EAD-9425-4B6B91922C7C} = {CE5B42B7-6E8C-4385-9E97-F4023FC16BF2}
{3EAA45A9-735C-4AC7-A799-947B93EA449D} = {CE5B42B7-6E8C-4385-9E97-F4023FC16BF2} {3EAA45A9-735C-4AC7-A799-947B93EA449D} = {CE5B42B7-6E8C-4385-9E97-F4023FC16BF2}
@ -563,10 +556,6 @@ Global
{E6F4983F-DE41-4AEC-88E7-1FA9AFB4E6FF} = {BDDDCD01-D2FE-4EAD-9425-4B6B91922C7C} {E6F4983F-DE41-4AEC-88E7-1FA9AFB4E6FF} = {BDDDCD01-D2FE-4EAD-9425-4B6B91922C7C}
{869951D5-A0D6-4DC6-9F1D-E6B9A12AC446} = {BDDDCD01-D2FE-4EAD-9425-4B6B91922C7C} {869951D5-A0D6-4DC6-9F1D-E6B9A12AC446} = {BDDDCD01-D2FE-4EAD-9425-4B6B91922C7C}
{000E4F64-5D0D-4EB1-B0BF-1A62ADBC6EAD} = {BDDDCD01-D2FE-4EAD-9425-4B6B91922C7C} {000E4F64-5D0D-4EB1-B0BF-1A62ADBC6EAD} = {BDDDCD01-D2FE-4EAD-9425-4B6B91922C7C}
{87C0E3D9-0DFD-4F6D-8E38-408AAF73F4EE} = {6CEEC0D9-FA00-4EE3-9A1C-39B7ACC882FD}
{51783FC4-D8D2-4BFB-A1F1-AC8857CF3ED0} = {6CEEC0D9-FA00-4EE3-9A1C-39B7ACC882FD}
{93B2D6DF-7588-40C0-8A35-CA0DD7328FC3} = {6CEEC0D9-FA00-4EE3-9A1C-39B7ACC882FD}
{D721EAA4-8A40-4EF0-A011-5862159BE621} = {6CEEC0D9-FA00-4EE3-9A1C-39B7ACC882FD}
{7C96B65D-28A5-4F28-A35B-8D83CE831EE8} = {FEB825FA-4AD8-425D-8E4A-B5A18EE1B81C} {7C96B65D-28A5-4F28-A35B-8D83CE831EE8} = {FEB825FA-4AD8-425D-8E4A-B5A18EE1B81C}
{e1b288a2-08ee-4318-8bbb-8ab72c69e33e} = {FEB825FA-4AD8-425D-8E4A-B5A18EE1B81C} {e1b288a2-08ee-4318-8bbb-8ab72c69e33e} = {FEB825FA-4AD8-425D-8E4A-B5A18EE1B81C}
{DBCF20A1-BA13-4582-BFA9-74DE4D987B73} = {FEB825FA-4AD8-425D-8E4A-B5A18EE1B81C} {DBCF20A1-BA13-4582-BFA9-74DE4D987B73} = {FEB825FA-4AD8-425D-8E4A-B5A18EE1B81C}
@ -585,6 +574,7 @@ Global
{6B717BD1-CD5E-498C-A42E-9E6A4584DC48} = {4EA396ED-64AD-4AD0-A67A-AB363F3E0C79} {6B717BD1-CD5E-498C-A42E-9E6A4584DC48} = {4EA396ED-64AD-4AD0-A67A-AB363F3E0C79}
{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57} = {4EA396ED-64AD-4AD0-A67A-AB363F3E0C79} {7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57} = {4EA396ED-64AD-4AD0-A67A-AB363F3E0C79}
{CBC6C247-747B-4908-B09A-4D2E0F640B6B} = {4EA396ED-64AD-4AD0-A67A-AB363F3E0C79} {CBC6C247-747B-4908-B09A-4D2E0F640B6B} = {4EA396ED-64AD-4AD0-A67A-AB363F3E0C79}
{8CF1EB90-324F-4AA9-BAA2-DEF87392CE86} = {4EA396ED-64AD-4AD0-A67A-AB363F3E0C79}
{DFB936AD-90EE-4B4F-941E-4F4A636F0D92} = {0D37CE59-B0EF-4F3C-B9EB-8557E53A448B} {DFB936AD-90EE-4B4F-941E-4F4A636F0D92} = {0D37CE59-B0EF-4F3C-B9EB-8557E53A448B}
{DC1CCE11-CB91-40FA-9C47-4D9EB5D67BFD} = {0D37CE59-B0EF-4F3C-B9EB-8557E53A448B} {DC1CCE11-CB91-40FA-9C47-4D9EB5D67BFD} = {0D37CE59-B0EF-4F3C-B9EB-8557E53A448B}
{8C59E80D-C4E4-4F36-9AD8-47C40F6E58B4} = {DB137F0B-9B62-4232-AE92-F7BE0280B8D3} {8C59E80D-C4E4-4F36-9AD8-47C40F6E58B4} = {DB137F0B-9B62-4232-AE92-F7BE0280B8D3}

Loading…
Cancel
Save