public Boolean DwBuildActiveDepenencyLists()
 {
     if (DsDwMap != null)
     {
         AppendLogLine("Rebuilding Active Depenency Lists...");
         AppendLogLine(string.Format("Total Dependency Links:{0}", DsDwMap.BuildActiveDepenencyLists()));
         return(true);
     }
     else
     {
         return(false);
     }
 }
        public void InitializeDsDwMap()
        {
            if (DwRebuildDsDwTableMap)
            {
                AppendLogLine("Rebuilding table map...");
                DsDwMapChanged = true;
                DsDwMap        = null;
            }
            if (DsDwMap == null)
            {
                DsDwMap = new DsDwMap_M();
            }
            else
            {
                SycDwTableViewMapList();
            }
            foreach (TableView_M aTableView in DwTableViewList)
            {
                if ((aTableView != null) && (!DsDwMap.DsDwTableMapList.Any(tm => tm.DsObjectId == aTableView.ObjectId)))
                {
                    DsDwMapChanged = true;
                    AppendLogLine(string.Format("Processing table/view: {0}...", aTableView.Name));
                    DsDwTableMap_M aDsDwTableMap = new DsDwTableMap_M
                    {
                        DsIsTable      = aTableView.IsTable,
                        DsTableName    = aTableView.Name,
                        DsSchemaName   = aTableView.Schema,
                        DwTableName    = aTableView.Name,
                        DwSchemaName   = aTableView.Schema,
                        DsRowCount     = aTableView.RowCount,
                        DsObjectId     = aTableView.ObjectId,
                        DsDatabaseName = DsDbName,
                        DsServerName   = DsDbServerName
                    };
                    DsDwMap.DsDwTableMapList.Add(aDsDwTableMap);

                    TableViewBase aTableViewBase;
                    if (aTableView.IsTable)
                    {
                        aTableViewBase = _DsDb.Tables.Cast <Table>().FirstOrDefault(t => t.ID == aTableView.ObjectId);
                    }
                    else
                    {
                        aTableViewBase =
                            _DsDb.Views.Cast <Microsoft.SqlServer.Management.Smo.View>()
                            .FirstOrDefault(t => t.ID == aTableView.ObjectId);
                    }

                    if (aTableViewBase != null)
                    {
                        foreach (Column aColumn in aTableViewBase.Columns)
                        {
                            DsDwColumnMap_M aDsDwColumnMap = new DsDwColumnMap_M
                            {
                                DsColumn = new DsDwColumn_M(aColumn),
                                DwColumn = new DsDwColumn_M(aColumn),
                                Include  = true
                            };

                            if (aColumn.InPrimaryKey)
                            {
                                aDsDwColumnMap.Transformation = DsDwColumnTransformation.BusinesKey;
                                aDsDwTableMap.DsDwColumnMapList.Insert(0, aDsDwColumnMap);
                            }
                            else
                            {
                                aDsDwColumnMap.Transformation = DsDwColumnTransformation.Scd1;
                                aDsDwTableMap.DsDwColumnMapList.Add(aDsDwColumnMap);
                            }
                        }
                        if (aTableView.IsTable)
                        {
                            AddExistingForeignKeysTable((Table)aTableViewBase, aDsDwTableMap);
                        }

                        if (!aTableView.IsTable) //this is a view
                        {
                            aTableViewBase =
                                _DsDb.Views.Cast <Microsoft.SqlServer.Management.Smo.View>()
                                .FirstOrDefault(t => t.ID == aTableView.ObjectId);

                            ParseViewSql aParseViewSql = new ParseViewSql();

                            Microsoft.SqlServer.Management.Smo.View aView =
                                (aTableViewBase as Microsoft.SqlServer.Management.Smo.View);

                            if (aParseViewSql.ParseView(aView.TextHeader + aView.TextBody))
                            {
                                FillColumnAndForeignKeyInfoView(aParseViewSql.ColumnList, aDsDwTableMap);
                            }
                        }
                        AddDwSupportColumns(aDsDwTableMap);
                    }
                }
                else
                {
                    //Update DbName and ServerName
                    DsDwTableMap_M aUpdateDsDwTableMap = DsDwMap.DsDwTableMapList.FirstOrDefault(tm => tm.DsObjectId == aTableView.ObjectId);
                    if (aUpdateDsDwTableMap != null)
                    {
                        aUpdateDsDwTableMap.DsDatabaseName = DsDbName;
                        aUpdateDsDwTableMap.DsServerName   = DsDbServerName;
                    }
                }
            }
            if (DsDwMapChanged || true)
            {
                AppendLogLine(string.Format("Always rebuilding foreign key links."));
                DsDwMap.ConfigureForeignKeyTransformations();
            }
            else
            {
                AppendLogLine(string.Format("Map not changed, not rebuilding foreign key links."));
            }
            DsDwMapChanged = false;
            NotifyPropertyChanged("DsDwMap");
        }