Exemplo n.º 1
0
        public bool OnCheckPerformed(CheckEventArgs args)
        {
            //if it has proposed fix it will be an SQL select query - probably
            if (args.ProposedFix != null)
            {
                if (_yesToAll)
                {
                    return(true);
                }

                //we will handle this one instead of the checksui
                SQLPreviewWindow window = new SQLPreviewWindow("Send Query?", "The following query is about to be submitted:", args.ProposedFix);
                try
                {
                    return(window.ShowDialog() == DialogResult.OK);
                }
                finally
                {
                    _yesToAll = window.YesToAll;
                }
            }

            if (args.Result == CheckResult.Fail)
            {
                fetchDataResultedInNoErrors = false;//don't tell them everything was fine because it wasn't
            }
            return(checksUI1.OnCheckPerformed(args));
        }
Exemplo n.º 2
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            var preview = new SQLPreviewWindow("Confirm happiness with SQL",
                                               "The following SQL is about to be executed:", _createSql);

            MasterDatabaseScriptExecutor executor = null;

            if (string.IsNullOrWhiteSpace(tbDatabase.Text) || string.IsNullOrWhiteSpace(tbServer.Text))
            {
                MessageBox.Show("You must specify both a Server and a Database");
                return;
            }
            else
            {
                executor = new MasterDatabaseScriptExecutor(tbServer.Text, tbDatabase.Text, tbUsername.Text, tbPassword.Text);
            }

            if (_completed)
            {
                MessageBox.Show("Setup completed already, review progress messages then close Form");
                return;
            }

            if (_tCreateDatabase != null && _tCreateDatabase.IsAlive)
            {
                MessageBox.Show("Setup already underaway, Thread State is:" + _tCreateDatabase.ThreadState);
                return;
            }

            if (preview.ShowDialog() == DialogResult.OK)
            {
                _tCreateDatabase = new Thread(
                    () =>
                {
                    var memory = new ToMemoryCheckNotifier(checksUI1);

                    if (executor.CreateDatabase(_createSql, _initialVersionNumber, memory))
                    {
                        _completed = executor.PatchDatabase(_patches, memory, silentlyApplyPatchCallback);
                        GenerateConnectionStringThenCopy();

                        var worst = memory.GetWorst();
                        if (worst == CheckResult.Success || worst == CheckResult.Warning)
                        {
                            if (MessageBox.Show("Succesfully created database, close form?", "Success", MessageBoxButtons.YesNo) == DialogResult.Yes)
                            {
                                _programaticClose = true;
                                Invoke(new MethodInvoker(Close));
                            }
                        }
                    }
                    else
                    {
                        _completed = false;    //failed to create database
                    }
                }
                    );
                _tCreateDatabase.Start();
            }
        }
Exemplo n.º 3
0
        private bool PreviewPatch(Patch patch)
        {
            if (_yesToAll)
                return true;

            var preview = new SQLPreviewWindow(patch.locationInAssembly,"The following SQL Patch will be run:", patch.EntireScript);
            try
            {
                return preview.ShowDialog()==DialogResult.OK;
            }
            finally
            {
                _yesToAll = preview.YesToAll;
            }

        }
Exemplo n.º 4
0
        private bool PreviewPatch(Patch patch)
        {
            if (_yesToAll)
            {
                return(true);
            }

            var preview = new SQLPreviewWindow(patch.locationInAssembly, "The following SQL Patch will be run:", patch.GetScriptBody());

            try
            {
                return(preview.ShowDialog() == DialogResult.OK);
            }
            finally
            {
                _yesToAll = preview.YesToAll;
            }
        }
Exemplo n.º 5
0
        private bool UserAcceptSql(string sql)
        {
            if (_yesToAll)
            {
                return(true);
            }

            var window = new SQLPreviewWindow("Confirm happiness with SQL",
                                              "The following SQL is about to be executed:", sql);

            try
            {
                return(window.ShowDialog() == DialogResult.OK);
            }
            finally
            {
                _yesToAll = window.YesToAll;
            }
        }
Exemplo n.º 6
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            var db = serverDatabaseTableSelector1.GetDiscoveredDatabase();

            if (db == null)
            {
                MessageBox.Show(
                    "You must pick an empty database or enter the name of a new one (that doesn't exist yet)");
                return;
            }

            if (_completed)
            {
                MessageBox.Show("Setup completed already, review progress messages then close Form");
                return;
            }

            if (_tCreateDatabase != null && !_tCreateDatabase.IsCompleted)
            {
                MessageBox.Show("Setup already underaway");
                return;
            }

            var createSql = _patcher.GetInitialCreateScriptContents(db);
            var patches   = _patcher.GetAllPatchesInAssembly(db);

            var preview = new SQLPreviewWindow("Confirm happiness with SQL",
                                               "The following SQL is about to be executed:", createSql.EntireScript);

            var executor = new MasterDatabaseScriptExecutor(db);

            if (preview.ShowDialog() == DialogResult.OK)
            {
                _tCreateDatabase = Task.Run(() =>

                {
                    var memory = new ToMemoryCheckNotifier(checksUI1);

                    if (executor.CreateDatabase(createSql, memory))
                    {
                        _completed = executor.PatchDatabase(patches, memory, silentlyApplyPatchCallback);

                        DatabaseCreatedIfAny = db;

                        var worst = memory.GetWorst();
                        if (worst == CheckResult.Success || worst == CheckResult.Warning)
                        {
                            if (MessageBox.Show("Succesfully created database, close form?", "Success", MessageBoxButtons.YesNo) == DialogResult.Yes)
                            {
                                _programaticClose = true;
                                Invoke(new MethodInvoker(Close));
                            }
                        }
                    }
                    else
                    {
                        _completed = false;    //failed to create database
                    }
                }
                                            );
            }
        }