コード例 #1
0
        private bool RunActionAsSql(DbDiffAction action)
        {
            string sql = action.GenerateSql(m_dstDb);

            if (SqlConfirmForm.Run(sql))
            {
                m_dstDb.Connection.Invoke(() =>
                {
                    var con  = m_dstDb.Connection.SystemConnection;
                    var tran = con.BeginTransaction();
                    var sqlo = new ConnectionSqlOutputStream(con, tran, m_dstDb.Dialect);
                    try
                    {
                        con.ExecuteNonQueries(sql, m_dstDb.Connection.Dialect, tran, null);
                    }
                    catch
                    {
                        tran.Rollback();
                        throw;
                    }
                    tran.Commit();
                });
                //var dmp = m_dstDb.Dialect.CreateDumper(sqlo, new SqlFormatProperties());
                //dmp.TargetDb = m_dstDb;
                //m_dstDb.Connection.Invoke(() => action.GenerateScript(dmp));
                return(true);
            }
            return(false);
        }
コード例 #2
0
 public void CallChangedAction(DbDiffAction action)
 {
     if (ChangedAction != null)
     {
         ChangedAction(action);
     }
 }
コード例 #3
0
 private void objectListView1_SelectedIndexChanged(object sender, EventArgs e)
 {
     m_shownAction = (DbDiffAction)objectListTables.SelectedObject;
     UpdateDiff();
     UpdateColumns();
     UpdateConstraints();
     UpdateAlterCode();
     UpdateActions();
     objectListTables.Focus();
 }
コード例 #4
0
 void m_diff_ChangedAction(DbDiffAction obj)
 {
     objectListIndexesKeys.RefreshObject(obj);
     objectListColumns.RefreshObject(obj);
     objectListViewActions.RefreshObject(obj);
     objectListTables.RefreshObject(obj);
     if (m_shownAction != null && m_shownAction.Elements.Contains(obj))
     {
         UpdateAlterCode();
     }
     UpdateSynCount();
 }
コード例 #5
0
        private void RefreshNotDownload()
        {
            //m_srcData.Clear();
            //m_dstData.Clear();

            m_shownAction    = null;
            codeEditor1.Text = "";
            //treeActions.Nodes.Clear();

            m_src = null;
            m_dst = null;

            if (m_downloadedSrc != null && m_downloadedDst != null)
            {
                var opts = CreateDbDiffOptions();
                if (m_diff != null)
                {
                    m_diff.ChangedAction -= m_diff_ChangedAction;
                }
                m_diff = new DatabaseDiff(m_downloadedSrc, m_downloadedDst, opts, m_dstDb.Dialect);
                m_diff.ChangedAction += new Action <DbDiffAction>(m_diff_ChangedAction);
                opts.DiffLogger       = NopLogger.Instance;
                m_src = m_diff.Source;
                m_dst = m_diff.Target;
                //treeSource.Root = new DbDefViewTreeNode(m_src, m_srcDb.Dialect);
                //treeTarget.Root = new DbDefViewTreeNode(m_dst, m_dstDb.Dialect);
                RefreshObjectList();
                //m_diff.Actions.FillTreeNodes(treeActions.Nodes);
                //UsageStats.Usage("compare_db",
                //    "src", m_src.ToString(),
                //    "dst", m_dst.ToString(),
                //    "actions", m_diff.Actions.Elements.Count.ToString());
            }
            else
            {
                if (m_diff != null)
                {
                    m_diff.ChangedAction -= m_diff_ChangedAction;
                }
                m_diff = null;
                //treeSource.Root = null;
                //treeTarget.Root = null;
                //if (m_downloadedSrc != null) treeSource.Root = new DbDefViewTreeNode(m_downloadedSrc, m_srcDb.Dialect);
                //if (m_downloadedDst != null) treeTarget.Root = new DbDefViewTreeNode(m_downloadedDst, m_srcDb.Dialect);
            }
            UpdateTitles();
        }
コード例 #6
0
 private void UpdateAlterCode()
 {
     if (m_shownAction != null)
     {
         try
         {
             codeEditor1.Text = m_shownAction.GenerateSql(m_dstDb);
         }
         catch (Exception err)
         {
             codeEditor1.Text = Texts.Get("s_error") + ":" + err.Message;
         }
     }
     else
     {
         m_shownAction    = null;
         codeEditor1.Text = "";
     }
 }
コード例 #7
0
 public DatabaseDiff(IDatabaseStructure src, IDatabaseStructure dst, DbDiffOptions options, ISqlDialect dialect)
 {
     m_dialect = dialect;
     m_src     = new DatabaseStructure(src);
     m_dst     = new DatabaseStructure(dst);
     if (m_src.Dialect != null && m_src.Dialect.DialectName != dialect.DialectName)
     {
         dialect.MigrateDatabase(m_src, dialect.GetDefaultMigrationProfile(), null);
     }
     m_actions = new DbDiffAction(this);
     //m_actions = new DiffActionDatabase(this, m_src, m_dst);
     m_options = options;
     RebuildGroupIdDictionary();
     if (m_src.GroupId != m_dst.GroupId)
     {
         CreatePairing();
     }
     CreateActions();
 }
コード例 #8
0
        private void CreateActions()
        {
            m_plan           = new AlterPlan();
            m_plan.Structure = m_dst; // optimalization ... plan fill not download extra data
            DbDiffTool.AlterDatabase(Plan, new DbObjectPairing(m_dst, m_src), m_options);
            DbDiffAction lastAlterTable = null;

            foreach (var op in m_plan.Operations)
            {
                DbDiffAction act;
                if (op.ParentTable != null)
                {
                    // this operation should be added to ALTER TABLE operation
                    if (lastAlterTable == null || lastAlterTable.ParentTable != op.ParentTable)
                    {
                        lastAlterTable             = new DbDiffAction(this);
                        lastAlterTable.ParentTable = op.ParentTable;
                        lastAlterTable.AfterCreate();
                        m_actions.Elements.Add(lastAlterTable);
                    }
                    act           = new DbDiffAction(this);
                    act.Operation = op;
                    act.IsChecked = true;
                    act.AfterCreate();
                    lastAlterTable.Elements.Add(act);
                }
                else
                {
                    act            = new DbDiffAction(this);
                    act.Operation  = op;
                    lastAlterTable = null;
                    act.AfterCreate();
                    m_actions.Elements.Add(act);
                }
            }
            //this.AlterDatabase(m_dst, m_src, m_options);
        }