private void PopulateViews(TreeNode parentNode) { try { var itemCache = new SortedList<string, DataTreeItem>(); //Current Items foreach (var view in this.CurrentDatabase.ViewList) { var dti = new DataTreeItem(view.Name, view) { SourceItem = view }; if (this.NewDatabase.ViewList.Count(x => x.Name == view.Name) > 0) dti.Name = this.NewDatabase.ViewList.FirstOrDefault(x => x.Name == view.Name).Name; //Check for deleted status if (this.NewDatabase.ViewList.Count(x => x.Name == view.Name) == 0) dti.State = nHydrate.DataImport.ImportStateConstants.Deleted; else if (this.NewDatabase.ViewList.First(x => x.Name == view.Name).CorePropertiesHash != view.CorePropertiesHash) { dti.State = nHydrate.DataImport.ImportStateConstants.Modified; dti.TargetItem = this.NewDatabase.ViewList.First(x => x.Name == view.Name); } else if (this.NewDatabase.ViewList.First(x => x.Name == view.Name).FieldList.GetCorePropertiesHash() != view.FieldList.GetCorePropertiesHash()) { dti.State = nHydrate.DataImport.ImportStateConstants.Modified; dti.TargetItem = this.NewDatabase.ViewList.First(x => x.Name == view.Name); } if (!itemCache.ContainsKey(view.Name.ToLower())) itemCache.Add(view.Name.ToLower(), dti); } //Added Items foreach (var t in this.NewDatabase.ViewList) { if (this.CurrentDatabase.ViewList.Count(x => x.Name == t.Name) == 0) itemCache.Add(t.Name.ToLower(), new DataTreeItem(t.Name, nHydrate.DataImport.ImportStateConstants.Added) { TargetItem = t }); } //Now add to tree foreach (var viewKey in itemCache.Keys) { var viewNode = new TreeNode(itemCache[viewKey].Name); viewNode.Checked = false; viewNode.ImageIndex = 4; viewNode.Tag = itemCache[viewKey]; parentNode.Nodes.Add(viewNode); var oldView = this.CurrentDatabase.ViewList.FirstOrDefault(x => x.Name == viewKey); var newView = this.NewDatabase.ViewList.FirstOrDefault(x => x.Name == viewKey); if (oldView == null) oldView = new nHydrate.DataImport.View(); if (newView == null) newView = new nHydrate.DataImport.View(); //Create list of all columns (new and old) var columns = new SortedList<string, DataTreeItem>(); foreach (var column in oldView.FieldList) { var dti = new DataTreeItem(column.Name); //Check for deleted status if (this.NewDatabase.ViewList.Count(x => x.Name == itemCache[oldView.Name.ToLower()].Name) > 0) { var statusColumn = this.NewDatabase.ViewList.First(x => x.Name == itemCache[oldView.Name.ToLower()].Name).FieldList.FirstOrDefault(x => x.Name == column.Name); 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 PopulateViews(TreeNode parentNode) { try { var itemCache = new SortedList <string, DataTreeItem>(); //Current Items foreach (var view in this.CurrentDatabase.ViewList) { var dti = new DataTreeItem(view.Name, view) { SourceItem = view }; if (this.NewDatabase.ViewList.Count(x => x.Name == view.Name) > 0) { dti.Name = this.NewDatabase.ViewList.FirstOrDefault(x => x.Name == view.Name).Name; } //Check for deleted status if (this.NewDatabase.ViewList.Count(x => x.Name == view.Name) == 0) { dti.State = nHydrate.DataImport.ImportStateConstants.Deleted; } else if (this.NewDatabase.ViewList.First(x => x.Name == view.Name).CorePropertiesHash != view.CorePropertiesHash) { dti.State = nHydrate.DataImport.ImportStateConstants.Modified; dti.TargetItem = this.NewDatabase.ViewList.First(x => x.Name == view.Name); } else if (this.NewDatabase.ViewList.First(x => x.Name == view.Name).FieldList.GetCorePropertiesHash() != view.FieldList.GetCorePropertiesHash()) { dti.State = nHydrate.DataImport.ImportStateConstants.Modified; dti.TargetItem = this.NewDatabase.ViewList.First(x => x.Name == view.Name); } if (!itemCache.ContainsKey(view.Name.ToLower())) { itemCache.Add(view.Name.ToLower(), dti); } } //Added Items foreach (var t in this.NewDatabase.ViewList) { if (this.CurrentDatabase.ViewList.Count(x => x.Name == t.Name) == 0) { itemCache.Add(t.Name.ToLower(), new DataTreeItem(t.Name, nHydrate.DataImport.ImportStateConstants.Added) { TargetItem = t }); } } //Now add to tree foreach (var viewKey in itemCache.Keys) { var viewNode = new TreeNode(itemCache[viewKey].Name); viewNode.Checked = false; viewNode.ImageIndex = 4; viewNode.Tag = itemCache[viewKey]; parentNode.Nodes.Add(viewNode); var oldView = this.CurrentDatabase.ViewList.FirstOrDefault(x => x.Name == viewKey); var newView = this.NewDatabase.ViewList.FirstOrDefault(x => x.Name == viewKey); if (oldView == null) { oldView = new nHydrate.DataImport.View(); } if (newView == null) { newView = new nHydrate.DataImport.View(); } //Create list of all columns (new and old) var columns = new SortedList <string, DataTreeItem>(); foreach (var column in oldView.FieldList) { var dti = new DataTreeItem(column.Name); //Check for deleted status if (this.NewDatabase.ViewList.Count(x => x.Name == itemCache[oldView.Name.ToLower()].Name) > 0) { var statusColumn = this.NewDatabase.ViewList.First(x => x.Name == itemCache[oldView.Name.ToLower()].Name).FieldList.FirstOrDefault(x => x.Name == column.Name); 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; } }