public void RefreshSnapshot(String Server, int SnapshotId) { TreeNode[] nodes = m_ExplorerTree.Nodes[0].Nodes.Find(Server, false); Sql.Snapshot Snapshot = Sql.Snapshot.GetSnapShot(SnapshotId); if (nodes.GetLength(0) == 1 && Snapshot != null) { foreach (TreeNode snapshotnode in nodes[0].Nodes) { if (snapshotnode.Tag != null && snapshotnode.Tag.GetType() == typeof(Sql.Snapshot)) { if (((Sql.Snapshot)snapshotnode.Tag).SnapshotId == SnapshotId) { if (((Sql.Snapshot)snapshotnode.Tag).Status != Snapshot.Status) { m_Repository.RefreshRegisteredServers(); RefreshServerInTree(Server); } snapshotnode.Text = snapshotnode.Name = Snapshot.SnapshotName; snapshotnode.ImageIndex = snapshotnode.SelectedImageIndex = Snapshot.IconIndex; snapshotnode.Tag = Snapshot; RefreshCurrentView(); return; } } } } }
public void AddSnapshotToServer(String Server, int SnapshotId) { TreeNode[] nodes = m_ExplorerTree.Nodes[0].Nodes.Find(Server, false); Sql.Snapshot snap = Sql.Snapshot.GetSnapShot(SnapshotId); if (nodes.GetLength(0) == 1 && snap != null) { AddSnapshotToServer(nodes[0], Sql.Snapshot.GetSnapShot(SnapshotId)); } }
public void SetCurrentSnapshot(Sql.RegisteredServer server, int SnapshotId) { bool isFound = false; m_ExplorerBar.SelectedGroup = m_ExplorerBar.Groups[Utility.Constants.ExplorerBar_GroupKey_Explore]; if (server == null || !Sql.RegisteredServer.IsServerRegistered(server.ConnectionName)) { m_RefreshServersEvent(false, string.Empty); } else { TreeNode serverNode = m_ExplorerTree.Nodes[0].Nodes[server.ConnectionName]; if (serverNode != null) { TreeNode selectedNode = null; foreach (TreeNode node in serverNode.Nodes) { if (node.Tag != null && node.Tag.GetType() == typeof(Sql.Snapshot)) { if (((Sql.Snapshot)node.Tag).SnapshotId == SnapshotId) { isFound = true; selectedNode = node; break; } } } // if we didn't find it, then try to add it, or get current on something if (!isFound) { Sql.Snapshot snap = Sql.Snapshot.GetSnapShot(SnapshotId); if (snap == null) { // If we don't find the snapshot, then go back to the server node selectedNode = m_ExplorerTree.Nodes[0].Nodes[server.ConnectionName]; } else { TreeNode snapshotNode = AddSnapshotToServer(serverNode, snap); selectedNode = snapshotNode; } } m_ExplorerTree.SelectedNode = selectedNode; } } }
public TreeNode AddSnapshotToServer(TreeNode ServerNode, Sql.Snapshot Snapshot) { TreeNode snapshotnode = new TreeNode(Snapshot.SnapshotName); snapshotnode.Name = Snapshot.SnapshotName; snapshotnode.ImageIndex = snapshotnode.SelectedImageIndex = Snapshot.IconIndex; snapshotnode.Tag = Snapshot; //Add the found snapshot to the list in order by date or in the last position int nodeIdx = ServerNode.Nodes.Count; foreach (TreeNode node in ServerNode.Nodes) { if (node.Tag != null && node.Tag.GetType() == typeof(Sql.Snapshot)) { // make sure it isn't already in the tree if (((Sql.Snapshot)node.Tag).SnapshotId == Snapshot.SnapshotId) { return(node); } else if (((Sql.Snapshot)node.Tag).StartTime < Snapshot.StartTime) { nodeIdx = node.Index; break; } } else { nodeIdx = node.Index; break; } } ServerNode.Nodes.Insert(nodeIdx, snapshotnode); return(snapshotnode); }