コード例 #1
0
ファイル: DatabaseAnalyser.cs プロジェクト: dbshell/dbshell
 public void FullAnalysis()
 {
     CheckInput();
     if (Structure != null) throw new Exception("DBSH-00126 Structure must not be filled");
     if (ChangeSet != null) throw new Exception("DBSH-00127 ChangeSet must not be filled");
     Structure = new DatabaseInfo();
     if (FilterOptions == null) FilterOptions = new DatabaseAnalyserFilterOptions();
     DoRunAnalysis();
     SortStructureItems();
 }
コード例 #2
0
        public void IncrementalAnalysis()
        {
            CheckInput();
            if (Structure == null)
            {
                throw new Exception("DBSH-00128 Structure required");
            }
            if (ChangeSet == null)
            {
                throw new Exception("DBSH-00129 ChangeSet required");
            }
            if (FilterOptions != null)
            {
                throw new Exception("DBSH-00130 FilterOptions must not be filled");
            }
            FilterOptions = ChangeSet.CreateFilter();

            foreach (var item in ChangeSet.Items)
            {
                switch (item.Action)
                {
                case DatabaseChangeAction.Remove:
                    Structure.RemoveObjectById(item.ObjectId);
                    break;

                case DatabaseChangeAction.Change:
                    if (item.ObjectType == DatabaseObjectType.Table)
                    {
                        var tbl = Structure.FindObjectById(item.ObjectId) as TableInfo;
                        if (tbl != null)
                        {
                            tbl.Columns.Clear();
                            tbl.ForeignKeys.Clear();
                            tbl.Indexes.Clear();
                            tbl.Uniques.Clear();
                            tbl.Checks.Clear();
                            tbl.PrimaryKey = null;
                            tbl.FullName   = item.NewName;
                        }
                    }
                    else
                    {
                        Structure.RemoveObjectById(item.ObjectId);
                    }
                    break;
                }
            }

            DoRunAnalysis();
            SortStructureItems();
        }
コード例 #3
0
ファイル: DatabaseChangeSet.cs プロジェクト: dbshell/dbshell
        public DatabaseAnalyserFilterOptions CreateFilter()
        {
            var res = new DatabaseAnalyserFilterOptions();
            res.SetEmptyFilter();

            foreach(var item in Items)
            {
                switch (item.Action)
                {
                    case DatabaseChangeAction.Add:
                    case DatabaseChangeAction.Change:
                        res[item.ObjectType].Add(item.ObjectId);
                        break;
                }
            }

            return res;
        }
コード例 #4
0
 public void FullAnalysis()
 {
     CheckInput();
     if (Structure != null)
     {
         throw new Exception("DBSH-00126 Structure must not be filled");
     }
     if (ChangeSet != null)
     {
         throw new Exception("DBSH-00127 ChangeSet must not be filled");
     }
     Structure = new DatabaseInfo();
     if (FilterOptions == null)
     {
         FilterOptions = new DatabaseAnalyserFilterOptions();
     }
     DoRunAnalysis();
     SortStructureItems();
 }
コード例 #5
0
        public DatabaseAnalyserFilterOptions CreateFilter()
        {
            var res = new DatabaseAnalyserFilterOptions();

            res.SetEmptyFilter();

            foreach (var item in Items)
            {
                switch (item.Action)
                {
                case DatabaseChangeAction.Add:
                case DatabaseChangeAction.Change:
                    res[item.ObjectType].Add(item.ObjectId);
                    break;
                }
            }

            return(res);
        }
コード例 #6
0
ファイル: DatabaseAnalyser.cs プロジェクト: dbshell/dbshell
        public void IncrementalAnalysis()
        {
            CheckInput();
            if (Structure == null) throw new Exception("DBSH-00128 Structure required");
            if (ChangeSet == null) throw new Exception("DBSH-00129 ChangeSet required");
            if (FilterOptions != null) throw new Exception("DBSH-00130 FilterOptions must not be filled");
            FilterOptions = ChangeSet.CreateFilter();

            foreach (var item in ChangeSet.Items)
            {
                switch (item.Action)
                {
                    case DatabaseChangeAction.Remove:
                        Structure.RemoveObjectById(item.ObjectId);
                        break;
                    case DatabaseChangeAction.Change:
                        if (item.ObjectType == DatabaseObjectType.Table)
                        {
                            var tbl = Structure.FindObjectById(item.ObjectId) as TableInfo;
                            if (tbl != null)
                            {
                                tbl.Columns.Clear();
                                tbl.ForeignKeys.Clear();
                                tbl.Indexes.Clear();
                                tbl.Uniques.Clear();
                                tbl.Checks.Clear();
                                tbl.PrimaryKey = null;
                                tbl.FullName = item.NewName;
                            }
                        }
                        else
                        {
                            Structure.RemoveObjectById(item.ObjectId);
                        }
                        break;
                }
            }

            DoRunAnalysis();
            SortStructureItems();
        }