Exemple #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            SearchDataWorker worker = null;
            string           sql;

            if (tbcSearch.SelectedTab == tbpExact)
            {
                string colName = (string)cboColumnName.SelectedItem;

                if (cbxValue.Checked)
                {
                    sql = FormatColumnValue(colName);
                }
                else
                {
                    sql = SQLiteParser.Utils.QuoteIfNeeded(colName) + " IS NULL";
                }
            }
            else
            {
                sql = txtSQL.Text.Trim();
            }
            worker = new SearchDataWorker(_isLeft, _diff, _changes, _rowIndex, -1, sql);

            ProgressDialog dlg = new ProgressDialog();

            dlg.Start(this, worker);

            if (dlg.Result != null)
            {
                _matchedRowIndex = (long)dlg.Result;
            }
            if (_matchedRowIndex == -1 && dlg.Error == null)
            {
                if (_rowIndex > 0)
                {
                    DialogResult res = MessageBox.Show(this, "No match was found, do you want to search from the beginning?",
                                                       "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                    if (res == DialogResult.Yes)
                    {
                        worker = new SearchDataWorker(_isLeft, _diff, _changes, 0, _rowIndex - 1, sql);
                        dlg    = new ProgressDialog();
                        dlg.Start(this, worker);
                        if (dlg.Result != null)
                        {
                            _matchedRowIndex = (long)dlg.Result;
                        }
                        if (_matchedRowIndex != -1 || dlg.Error != null)
                        {
                            this.DialogResult = DialogResult.OK;
                        }
                        else
                        {
                            MessageBox.Show(this, "No match was found", "Search Completed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                else
                {
                    MessageBox.Show(this, "No match was found", "Search Completed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                this.DialogResult = DialogResult.OK;
            }
        }
Exemple #2
0
        private void btnCompareData_Click(object sender, EventArgs e)
        {
            // Before comparing data we have to check if there are any BLOB columns
            // in the any common columns of the tables. If there are any - we have to
            // ask the user if he wants to compare BLOB fields or not.
            SQLiteCreateTableStatement   leftTable  = _item.LeftDdlStatement as SQLiteCreateTableStatement;
            SQLiteCreateTableStatement   rightTable = _item.RightDdlStatement as SQLiteCreateTableStatement;
            List <SQLiteColumnStatement> common     = Utils.GetCommonColumns(leftTable, rightTable);
            bool allowBlobComparison = false;

            if (Utils.ContainsBlobColumn(common))
            {
                DialogResult res = MessageBox.Show(this,
                                                   "At least one column that will be compared is a BLOB.\r\nComparing BLOB fields can potentially take " +
                                                   "a lot of time to perform.\r\nDo you want to disable BLOB content comparison in order\r\nto make " +
                                                   "the comparison go faster?",
                                                   "Disable BLOB Contents Comparison?",
                                                   MessageBoxButtons.YesNo,
                                                   MessageBoxIcon.Warning);
                if (res == DialogResult.No)
                {
                    allowBlobComparison = true;
                }
            }

            string errmsg;

            if (!Utils.IsTableComparisonAllowed(leftTable, rightTable,
                                                out errmsg, allowBlobComparison))
            {
                MessageBox.Show(this, errmsg, "Data comparison is not allowed",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            TableCompareWorker worker = new TableCompareWorker(
                leftTable, rightTable, _leftdb, _rightdb, allowBlobComparison);
            ProgressDialog dlg = new ProgressDialog();

            dlg.Start(this, worker);
            if (dlg.Error != null)
            {
                if (dlg.Error.GetType() != typeof(UserCancellationException))
                {
                    _item.ErrorMessage = dlg.Error.Message;
                }
                return;
            }
            _tableChanges = (TableChanges)dlg.Result;
            if (!tbcViews.TabPages.Contains(tbpData))
            {
                tbcViews.TabPages.Add(tbpData);
            }

            // Update the schema comparison item
            panel1.Visible     = false;
            _item.ErrorMessage = null;
            _item.TableChanges = _tableChanges;
            if (SchemaChanged != null)
            {
                SchemaChanged(this, EventArgs.Empty);
            }

            // Set the table changes object into the table diff control
            UpdateDataTab();

            tbcViews.SelectedTab = tbpData;
        }