Example #1
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();
        }