Skip to content

Instantly share code, notes, and snippets.

@yvanin
Last active November 8, 2019 06:19
Show Gist options
  • Save yvanin/ab40548fc6bf7a1d8a68 to your computer and use it in GitHub Desktop.
Save yvanin/ab40548fc6bf7a1d8a68 to your computer and use it in GitHub Desktop.

Revisions

  1. yvanin revised this gist Apr 17, 2015. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,6 @@ public static ActionResult TestDbConnection(Session session)
    ```xml
    <Fragment>
    <UI>
    ...
    <Dialog Id="TestDbConnectionResultDlg" Width="200" Height="80" Title="Testing DB Connection...">
    <Control Id="OK" Type="PushButton" X="75" Y="50" Width="56" Height="17" Default="yes" Cancel="yes" Text="OK">
    <Publish Event="EndDialog" Value="Return">1</Publish>
  2. yvanin revised this gist Apr 17, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    **Custom action (in C# dll)**:

    ```c-sharp
    ```csharp
    [CustomAction]
    public static ActionResult TestDbConnection(Session session)
    {
  3. yvanin revised this gist Apr 17, 2015. 1 changed file with 7 additions and 5 deletions.
    12 changes: 7 additions & 5 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    **Custom action (in C# dll)**:

    ```c-sharp
    [CustomAction]
    public static ActionResult TestDbConnection(Session session)
    {
    @@ -17,9 +18,9 @@ public static ActionResult TestDbConnection(Session session)
    return ActionResult.Success;
    }
    }

    ```
    **Popup that will display the test result message (in .wxs file)**:

    ```xml
    <Fragment>
    <UI>
    ...
    @@ -31,10 +32,11 @@ public static ActionResult TestDbConnection(Session session)
    </Dialog>
    </UI>
    </Fragment>

    ```
    **Button that will trigger sql connection test (in .wxs file)**:

    ```xml
    <Control Id="TestDbConnection" Type="PushButton" X="20" Y="100" Height="16" Width="45" Text="Test">
    <Publish Event="SpawnDialog" Value="TestDbConnectionResultDlg" Order="2">1</Publish>
    <Publish Event="DoAction" Value="TestDbConnection" Order="1">1</Publish>
    </Control>
    </Control>
    ```
  4. yvanin renamed this gist Apr 17, 2015. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions gistfile1.txt → gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    Custom action (in C# dll):
    **Custom action (in C# dll)**:

    [CustomAction]
    public static ActionResult TestDbConnection(Session session)
    @@ -18,7 +18,7 @@ public static ActionResult TestDbConnection(Session session)
    }
    }

    Popup that will display the test result message (in .wxs file):
    **Popup that will display the test result message (in .wxs file)**:

    <Fragment>
    <UI>
    @@ -32,9 +32,9 @@ Popup that will display the test result message (in .wxs file):
    </UI>
    </Fragment>

    Button that will trigger sql connection test (in .wxs file):
    **Button that will trigger sql connection test (in .wxs file)**:

    <Control Id="TestDbConnection" Type="PushButton" X="20" Y="100" Height="16" Width="45" Text="Test">
    <Publish Event="SpawnDialog" Value="TestDbConnectionResultDlg" Order="2">1</Publish>
    <Publish Event="DoAction" Value="TestDbConnection" Order="1">1</Publish>
    </Control>
    <Control Id="TestDbConnection" Type="PushButton" X="20" Y="100" Height="16" Width="45" Text="Test">
    <Publish Event="SpawnDialog" Value="TestDbConnectionResultDlg" Order="2">1</Publish>
    <Publish Event="DoAction" Value="TestDbConnection" Order="1">1</Publish>
    </Control>
  5. yvanin created this gist Apr 17, 2015.
    40 changes: 40 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    Custom action (in C# dll):

    [CustomAction]
    public static ActionResult TestDbConnection(Session session)
    {
    using (var connection = new SqlConnection(session["CONNECTION_STRING"]))
    {
    try
    {
    connection.Open();
    session["TEST_DB_CONNECTION_RESULT"] = "Connection succeeded.";
    }
    catch
    {
    session["TEST_DB_CONNECTION_RESULT"] = "Connection failed!";
    }
    return ActionResult.Success;
    }
    }

    Popup that will display the test result message (in .wxs file):

    <Fragment>
    <UI>
    ...
    <Dialog Id="TestDbConnectionResultDlg" Width="200" Height="80" Title="Testing DB Connection...">
    <Control Id="OK" Type="PushButton" X="75" Y="50" Width="56" Height="17" Default="yes" Cancel="yes" Text="OK">
    <Publish Event="EndDialog" Value="Return">1</Publish>
    </Control>
    <Control Id="Text" Type="Text" X="20" Y="12" Width="160" Height="40" Text="[TEST_DB_CONNECTION_RESULT]" />
    </Dialog>
    </UI>
    </Fragment>

    Button that will trigger sql connection test (in .wxs file):

    <Control Id="TestDbConnection" Type="PushButton" X="20" Y="100" Height="16" Width="45" Text="Test">
    <Publish Event="SpawnDialog" Value="TestDbConnectionResultDlg" Order="2">1</Publish>
    <Publish Event="DoAction" Value="TestDbConnection" Order="1">1</Publish>
    </Control>