tide.Northwind.Connection

So tide – it stands for Technician Integrated Data Environment. Technician is a project name with some history for me, and the name tide itself has been with this project since day one.

The next plugin we create for this Northwind demo, following our branding provider, will be a connection plugin. After adding another new Hydra Plugin Module project, we’ll add a Hydra Visual Plugin (as opposed to the Non-Visual Plugin we created previously). We’ll add the same tide.PluginInterfaces assembly reference and namespace, this time opting to implement tide.PluginInterfaces.IOptionsPage.

The tide host application has a built in options dialog. This dialog resembles the Office 2007 options dialog. Any Visual Plugins that implement IOptionsPage have a category button added for them on the left hand side of the options dialog, and surface the functionality necessary in the host’s options dialog in order to display a page of preferences, loading and saving settings as necessary.

Our Northwind connection plugin will also make use of a few classes in the tide.Utilities namespace. These classes allow for very simple encryption, decryption, serialization and de-serialization of application settings.

The connection plugin will also use the Microsoft.Data.ConnectionUI.Dialog assembly. This is a simple way for us to provide a visual interface for defining a SQL server connection.

Our complete IOptionPage implementation is as simple as this:

private SimpleSettings simpleSettings;
private SqlConnectionProperties connectionProperties;

public void LoadOptions()
{
    SetupSettingStorage();

    string connectionString = simpleSettings.GetSetting(
        "Northwind/ConnectionString", "");
    if (connectionString != "")
        connectionString =
            SimpleEncryption.SimpleDecrypt(connectionString);
    connectionProperties.ConnectionStringBuilder.ConnectionString =
        connectionString;

    sqlConnectionUIControl1.Initialize(
        connectionProperties);
    sqlConnectionUIControl1.LoadProperties();
}

private void SetupSettingStorage()
{
    ApplicationSettings applicationSettings =
        new ApplicationSettings((IHostApplication)Host);
    simpleSettings = new SimpleSettings(
        applicationSettings.SettingsFileName);
    connectionProperties = new SqlConnectionProperties();
    SimpleEncryption.PassPhrase = "northwindpassphrase";
}

public bool SaveOptions()
{
    string connectionString =
        connectionProperties.ConnectionStringBuilder.ConnectionString;
    simpleSettings.SetSetting("Northwind/ConnectionString",
        SimpleEncryption.SimpleEncrypt(connectionString));
    return true;
}

public bool SaveOptionsEnabled()
{
    return true;
}

public string Caption()
{
    return "Northwind Connection";
}

Running the tide host application with our new connection provider plugin should display a new page in the application options dialog:

Options (9)

Keep an eye out for the next tide blog post, which will cover the first steps in creating a plugin for viewing, editing, adding, deleting, and saving customer changes within the Northwind database (it’s only a handful of code). Without having to write any additional source, this plugin will have the ability to print customers and export customer lists to XLS, PDF, and more.

Advertisements

3 thoughts on “tide.Northwind.Connection

  1. Pingback: tide.Northwind.Branding « Development Technobabble

  2. Pingback: What is tide? « Development Technobabble

  3. Pingback: tide.Northwind.Customers – Part 1 « Development Technobabble

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s