Example #1
0
        private void StartComparision()
        {
            ProgressForm progress      = null;
            string       errorLocation = null;

            try
            {
                if ((!String.IsNullOrEmpty(ProjectSelectorHandler.GetSourceDatabaseName()) &&
                     (!String.IsNullOrEmpty(ProjectSelectorHandler.GetDestinationDatabaseName()))))
                {
                    Options = Options ?? this.ProjectSelectorHandler.GetDefaultProjectOptions();
                    IGenerator        sourceGenerator      = this.ProjectSelectorHandler.SetSourceGenerator(SourceSelector.ConnectionString, Options);
                    IGenerator        destinationGenerator = this.ProjectSelectorHandler.SetDestinationGenerator(DestinationSelector.ConnectionString, Options);
                    IDatabaseComparer databaseComparer     = this.ProjectSelectorHandler.GetDatabaseComparer();

                    progress = new ProgressForm("Source Database", "Destination Database", destinationGenerator, sourceGenerator, databaseComparer);
                    progress.ShowDialog(this);
                    if (progress.Error != null)
                    {
                        throw new SchemaException(progress.Error.Message, progress.Error);
                    }

                    selectedOrigin      = progress.Source;
                    selectedDestination = progress.Destination;

                    txtSyncScript.ConfigurationManager.Language = this.ProjectSelectorHandler.GetScriptLanguage();
                    txtSyncScript.IsReadOnly = false;
                    txtSyncScript.Styles.LineNumber.BackColor = Color.White;
                    txtSyncScript.Styles.LineNumber.IsVisible = false;
                    errorLocation                       = "Generating Synchronized Script";
                    txtSyncScript.Text                  = selectedDestination.ToSqlDiff(this._selectedSchemas).ToSQL();
                    txtSyncScript.IsReadOnly            = true;
                    schemaTreeView1.DatabaseSource      = selectedDestination;
                    schemaTreeView1.DatabaseDestination = selectedOrigin;
                    schemaTreeView1.OnSelectItem       += new SchemaTreeView.SchemaHandler(schemaTreeView1_OnSelectItem);
                    schemaTreeView1_OnSelectItem(schemaTreeView1.SelectedNode);
                    textBox1.Text = selectedOrigin.ActionMessage.Message;

                    btnCopy.Enabled      = true;
                    btnSaveAs.Enabled    = true;
                    btnUpdateAll.Enabled = true;
                }
                else
                {
                    MessageBox.Show(Owner, "Please select a valid connection string", "ERROR", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                if (errorLocation == null && progress != null)
                {
                    errorLocation = String.Format("{0} (while {1})", progress.ErrorLocation, progress.ErrorMostRecentProgress ?? "initializing");
                }

                throw new SchemaException("Error " + (errorLocation ?? " Comparing Databases"), ex);
            }
        }