private void PopulateDataSchema(TreeNode parentNode) { try { var itemCache = new SortedList<string, DataTreeItem>(); //Current Tables foreach (var t in this.CurrentDatabase.EntityList) { var dti = new DataTreeItem(t.Name, t) { SourceItem = t }; if (this.NewDatabase.EntityList.Count(x => x.Name.ToLower() == t.Name.ToLower()) > 0) dti.Name = this.NewDatabase.EntityList.First(x => x.Name.ToLower() == t.Name.ToLower()).Name; //Check for deleted status if (this.NewDatabase.EntityList.Count(x => x.Name.ToLower() == t.Name.ToLower()) == 0) dti.State = nHydrate.DataImport.ImportStateConstants.Deleted; else if (this.NewDatabase.EntityList.First(x => x.Name.ToLower() == t.Name.ToLower()).CorePropertiesHash != t.CorePropertiesHash) { dti.State = nHydrate.DataImport.ImportStateConstants.Modified; dti.TargetItem = this.NewDatabase.EntityList.First(x => x.Name.ToLower() == t.Name.ToLower()); } else if (this.NewDatabase.EntityList.First(x => x.Name.ToLower() == t.Name.ToLower()).FieldList.GetCorePropertiesHash() != t.FieldList.GetCorePropertiesHash()) { dti.State = nHydrate.DataImport.ImportStateConstants.Modified; dti.TargetItem = this.NewDatabase.EntityList.First(x => x.Name.ToLower() == t.Name.ToLower()); } if (!itemCache.ContainsKey(t.Name.ToLower())) itemCache.Add(t.Name.ToLower(), dti); } //Added Tables foreach (var t in this.NewDatabase.EntityList) { if (this.CurrentDatabase.EntityList.Count(x => x.Name.ToLower() == t.Name.ToLower()) == 0) itemCache.Add(t.Name.ToLower(), new DataTreeItem(t.Name, nHydrate.DataImport.ImportStateConstants.Added) { TargetItem = t }); } //Now add to tree foreach (var tableKey in itemCache.Keys) { var tableNode = new TreeNode(itemCache[tableKey].Name); tableNode.Checked = false; tableNode.ImageIndex = 3; tableNode.Tag = itemCache[tableKey]; parentNode.Nodes.Add(tableNode); var oldTable = this.CurrentDatabase.EntityList.FirstOrDefault(x => x.Name.ToLower() == tableKey.ToLower()); var newTable = this.NewDatabase.EntityList.FirstOrDefault(x => x.Name.ToLower() == tableKey.ToLower()); if (oldTable == null) oldTable = new nHydrate.DataImport.Entity(); if (newTable == null) newTable = new nHydrate.DataImport.Entity(); //Create list of all columns (new and old) var columns = new SortedList<string, DataTreeItem>(); foreach (var column in oldTable.FieldList) { var dti = new DataTreeItem(column.Name); //Check for deleted status if (this.NewDatabase.EntityList.Count(x => x.Name.ToLower() == itemCache[oldTable.Name.ToLower()].Name.ToLower()) > 0) { var statusTable = this.NewDatabase.EntityList.FirstOrDefault(x => x.Name.ToLower() == itemCache[oldTable.Name.ToLower()].Name.ToLower()); if (statusTable != null) { var statusColumn = statusTable.FieldList.FirstOrDefault(x => x.Name.ToLower() == column.Name.ToLower()); if (statusColumn == null) dti.State = nHydrate.DataImport.ImportStateConstants.Deleted; else if (column.CorePropertiesHash != statusColumn.CorePropertiesHash) dti.State = nHydrate.DataImport.ImportStateConstants.Modified; } } columns.Add(column.Name.ToLower(), dti); } } } catch (Exception ex) { throw; } }
private void PopulateDataSchema(TreeNode parentNode) { try { var itemCache = new SortedList <string, DataTreeItem>(); //Current Tables foreach (var t in this.CurrentDatabase.EntityList) { var dti = new DataTreeItem(t.Name, t) { SourceItem = t }; if (this.NewDatabase.EntityList.Count(x => x.Name.Match(t.Name)) > 0) { dti.Name = this.NewDatabase.EntityList.First(x => x.Name.Match(t.Name)).Name; } //Check for deleted status if (this.NewDatabase.EntityList.Count(x => x.Name.Match(t.Name)) == 0) { dti.State = nHydrate.DataImport.ImportStateConstants.Deleted; } else if (this.NewDatabase.EntityList.First(x => x.Name.Match(t.Name)).CorePropertiesHash != t.CorePropertiesHash) { dti.State = nHydrate.DataImport.ImportStateConstants.Modified; dti.TargetItem = this.NewDatabase.EntityList.First(x => x.Name.Match(t.Name)); } else if (this.NewDatabase.EntityList.First(x => x.Name.Match(t.Name)).FieldList.GetCorePropertiesHash() != t.FieldList.GetCorePropertiesHash()) { dti.State = nHydrate.DataImport.ImportStateConstants.Modified; dti.TargetItem = this.NewDatabase.EntityList.First(x => x.Name.Match(t.Name)); } if (!itemCache.ContainsKey(t.Name.ToLower())) { itemCache.Add(t.Name.ToLower(), dti); } } //Added Tables foreach (var t in this.NewDatabase.EntityList) { if (this.CurrentDatabase.EntityList.Count(x => x.Name.Match(t.Name)) == 0) { itemCache.Add(t.Name.ToLower(), new DataTreeItem(t.Name, nHydrate.DataImport.ImportStateConstants.Added) { TargetItem = t }); } } //Now add to tree foreach (var tableKey in itemCache.Keys) { var tableNode = new TreeNode(itemCache[tableKey].Name); tableNode.Checked = false; tableNode.ImageIndex = 3; tableNode.Tag = itemCache[tableKey]; parentNode.Nodes.Add(tableNode); var oldTable = this.CurrentDatabase.EntityList.FirstOrDefault(x => x.Name.Match(tableKey)); var newTable = this.NewDatabase.EntityList.FirstOrDefault(x => x.Name.Match(tableKey)); if (oldTable == null) { oldTable = new nHydrate.DataImport.Entity(); } if (newTable == null) { newTable = new nHydrate.DataImport.Entity(); } //Create list of all columns (new and old) var columns = new SortedList <string, DataTreeItem>(); foreach (var column in oldTable.FieldList) { var dti = new DataTreeItem(column.Name); //Check for deleted status if (this.NewDatabase.EntityList.Count(x => x.Name.ToLower() == itemCache[oldTable.Name.ToLower()].Name.ToLower()) > 0) { var statusTable = this.NewDatabase.EntityList.FirstOrDefault(x => x.Name.ToLower() == itemCache[oldTable.Name.ToLower()].Name.ToLower()); if (statusTable != null) { var statusColumn = statusTable.FieldList.FirstOrDefault(x => x.Name.ToLower() == column.Name.ToLower()); if (statusColumn == null) { dti.State = nHydrate.DataImport.ImportStateConstants.Deleted; } else if (column.CorePropertiesHash != statusColumn.CorePropertiesHash) { dti.State = nHydrate.DataImport.ImportStateConstants.Modified; } } } columns.Add(column.Name.ToLower(), dti); } } } catch (Exception ex) { throw; } }