コード例 #1
0
        private async Task ExecuteInner(EventArgs e, string statusBarMessage, bool commit, string successMessage = null)
        {
            try
            {
                OperationStarted?.Invoke(statusBarMessage, e);

                using (var cn = GetConnection.Invoke(tbDest.Text))
                {
                    await SqlDialect.ExecuteAsync(cn, tbScriptOutput.Text, commit);

                    if (commit)
                    {
                        ScriptExecuted?.Invoke(this, new EventArgs());
                        if (_manualEdits)
                        {
                            MessageBox.Show("Changes applied successfully.", "Script Executed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }

                    if (!string.IsNullOrEmpty(successMessage))
                    {
                        MessageBox.Show(successMessage, "SQL Test", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    if (!_manualEdits && commit)
                    {
                        await GenerateScriptAsync();
                    }
                }
            }
            catch (Exception exc)
            {
                if (MessageBox.Show(exc.Message + "\r\n\r\nClick OK to create test case.", "Script Error", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    frmSaveTestCase.PromptSaveZipFile(false, exc.Message, _sourceModel, _destModel, _diff);
                }
            }
            finally
            {
                OperationComplete?.Invoke(this, new EventArgs());
            }
        }