StrataFrame Forum

Is there a way to know that the DatabaseMigrator.DeployMetaData is finished programatically

http://forum.strataframe.net/Topic20760.aspx

By Cory Cookson - 11/14/2008

Hello all,

I am trying to build, deploy, and the run another process against a Database all under one button.  The problem is that I don't know when the DeployMetaData is finished before moving on.

Is there a way for me to know that the process has finished from within c#?

As always thanks for the help Wink

-Cory

By Ivan George Borges - 11/14/2008

Hi Cory.

Would the DDT Profile Scripts be the case?

Have a look at the help file under the Database Deployment Toolkit / Profile Scripts. You can tell it to run Pre or Post Deployment.

By Trent L. Taylor - 11/14/2008

If you are trying to do this all through T-SQL, then Ivan's suggestion of the Profile scripts may be helpful.  However, if you are just wanting to do something outside of the DDT altogether, and I assume that you are using the database Migrator, then there are events that tell you each phase of what is going on, including when the meta-data has been completed.  For a sample of these events, look at the Database Installer Sample.
By Cory Cookson - 11/14/2008

Howdy,

I am currently having issues opening the solution for the Database INstaller (tells me that the vbproj files don't exists) but I have opened up the files in the solution seperately as well as serached the project files through Widows search for "BuildComplete" as this is the event that I'd like to use and am unable to find an example of it.

Could someone post an example of how to create the event handler and use this event?

Thanks for all the help,

Cory

By Ivan George Borges - 11/14/2008

Cory.

Not sure why you can't open the solution. Maybe you could try installing them again.

Anyway, if you can open the project, go to the SampleDataInstallerClass and have a look at the code of the DataProgress.vc (or DataProgress.cs, as I think you are doing C#) and check how the _DatabaseSetup is declared as MicroFour.StrataFrame.DBEngine.SQL.DatabaseMigrator.

If you check the "Handled Events" region, you will find a _DatabaseSetup_DeployDataComplete routine, that closes the form when done.

    ''' <summary>
    ''' Indicates that the data deployment started by the DeployData command is complete
    ''' </summary>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub _DatabaseSetup_DeployDataComplete(ByVal e As MicroFour.StrataFrame.DBEngine.SQL.SQLManagerEventArgs) Handles _DatabaseSetup.DeployDataComplete
        '-- Since we are finished, close the form with a good result
        DialogResult = Windows.Forms.DialogResult.OK
    End Sub

By Cory Cookson - 11/14/2008

I think I understand, however in c# there is no withevents for the databaseMigrator object and I'm having considerable issues making the event handler for it.  Here is what I have.  The Question mark indicates where I have no idea what to enter.  As always I appreciate the help:

private DatabaseMigrator _DatabaseSetup;

public DataDeployment()

{

this._DatabaseSetup.BuildComplete += new DatabaseMigrator.BuildCompleteEventHandler(?);

}

By Ivan George Borges - 11/14/2008

I assume you were not able to open the C# SampleDataInstallerClass project.

But here are the lines for the _DatabaseSetup, although I think you would get some more ideas having a look at the DataProgress.cs.

private MicroFour.StrataFrame.DBEngine.SQL.DatabaseMigrator _DatabaseSetup;

//-- Create the handlers

_DatabaseSetup.DeployDataComplete += new MicroFour.StrataFrame.DBEngine.SQL.DatabaseMigrator.DeployDataCompleteEventHandler(_DatabaseSetup_DeployDataComplete);

/// <summary>

/// Indicates that the data deployment started by the DeployData command is complete

/// </summary>

/// <param name="e"></param>

/// <remarks></remarks>

private void _DatabaseSetup_DeployDataComplete(MicroFour.StrataFrame.DBEngine.SQL.SQLManagerEventArgs e)

{

//-- Since we are finished, close the form with a good result

DialogResult = System.Windows.Forms.DialogResult.OK;

}

By Cory Cookson - 11/14/2008

No I'm not able to open the sample code at all.

I appreciate the help.

By Cory Cookson - 11/14/2008

I was able to use the samples Ivan produced to get the needed event to fire. 

Thanks Ivan!

-Cory

By Ivan George Borges - 11/14/2008

Glad you got it going, Cory! Cool