Пример #1
0
 private void btnCancel_Click(object sender, EventArgs e)
 {
     SqlServerToSQLite.CancelConversion();
 }
Пример #2
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            string sqlConnString;

            if (cbxIntegrated.Checked)
            {
                sqlConnString = GetSqlServerConnectionString(txtSqlAddress.Text, (string)cboDatabases.SelectedItem);
            }
            else
            {
                sqlConnString = GetSqlServerConnectionString(txtSqlAddress.Text, (string)cboDatabases.SelectedItem, txtUserDB.Text, txtPassDB.Text);
            }

            string sqlitePath = txtSQLitePath.Text.Trim();

            this.Cursor = Cursors.WaitCursor;
            SqlConversionHandler handler = new SqlConversionHandler(delegate(bool done,
                                                                             bool success, int percent, string msg) {
                Invoke(new MethodInvoker(delegate() {
                    UpdateSensitivity();
                    lblMessage.Text   = msg;
                    pbrProgress.Value = percent;

                    if (done)
                    {
                        btnStart.Enabled = true;
                        this.Cursor      = Cursors.Default;
                        UpdateSensitivity();

                        if (success)
                        {
                            MessageBox.Show(this,
                                            msg,
                                            "Conversion Finished",
                                            MessageBoxButtons.OK,
                                            MessageBoxIcon.Information);
                            pbrProgress.Value = 0;
                            lblMessage.Text   = string.Empty;
                        }
                        else
                        {
                            if (!_shouldExit)
                            {
                                MessageBox.Show(this,
                                                msg,
                                                "Conversion Failed",
                                                MessageBoxButtons.OK,
                                                MessageBoxIcon.Error);
                                pbrProgress.Value = 0;
                                lblMessage.Text   = string.Empty;
                            }
                            else
                            {
                                Application.Exit();
                            }
                        }
                    }
                }));
            });
            SqlTableSelectionHandler selectionHandler = new SqlTableSelectionHandler(delegate(List <TableSchema> schema)
            {
                List <TableSchema> updated = null;
                Invoke(new MethodInvoker(delegate
                {
                    // Allow the user to select which tables to include by showing him the
                    // table selection dialog.
                    TableSelectionDialog dlg = new TableSelectionDialog();
                    DialogResult res         = dlg.ShowTables(schema, this);
                    if (res == DialogResult.OK)
                    {
                        updated = dlg.IncludedTables;
                    }
                }));
                return(updated);
            });

            FailedViewDefinitionHandler viewFailureHandler = new FailedViewDefinitionHandler(delegate(ViewSchema vs)
            {
                string updated = null;
                Invoke(new MethodInvoker(delegate
                {
                    ViewFailureDialog dlg = new ViewFailureDialog();
                    dlg.View         = vs;
                    DialogResult res = dlg.ShowDialog(this);
                    if (res == DialogResult.OK)
                    {
                        updated = dlg.ViewSQL;
                    }
                    else
                    {
                        updated = null;
                    }
                }));

                return(updated);
            });

            string password = txtPassword.Text.Trim();

            if (!cbxEncrypt.Checked)
            {
                password = null;
            }
            SqlServerToSQLite.ConvertSqlServerToSQLiteDatabase(sqlConnString, sqlitePath, password, handler,
                                                               selectionHandler, viewFailureHandler, cbxTriggers.Checked);
        }