internal void OpenTable(NamedSmoObject objectToSelect, SqlConnectionInfo connection) { try { IExplorerHierarchy hierarchy = GetHierarchyForConnection(connection); if (hierarchy == null) { return; // there is nothing we can really do if we don't have one of these } HierarchyTreeNode databasesNode = GetUserDatabasesNode(hierarchy.Root); var resultNode = FindNodeForSmoObject(databasesNode, objectToSelect); //MSSQLController.Current.SearchWindow.Activate(); if (resultNode != null) { OpenTable(resultNode, connection); } } catch (Exception ex) { log.Error("Error opening table: " + objectToSelect.Name, ex); } }
// ugly reflection hack private IExplorerHierarchy GetHierarchyForConnection(SqlConnectionInfo connection) { IExplorerHierarchy hierarchy = null; if (!Is2008R2) { Type t = GetObjectExplorer().GetType(); var getHierarchyMethod = t.GetMethod("GetHierarchy", BindingFlags.Instance | BindingFlags.NonPublic); hierarchy = getHierarchyMethod.Invoke(GetObjectExplorer(), new Object[] { connection, String.Empty }) as IExplorerHierarchy; } else { var objectTreeControl = GetTreeControl_for2008R2Only(); var objTreeRype = objectTreeControl.GetType(); var getHierarchyMethod = objTreeRype.GetMethod("GetHierarchy", BindingFlags.Instance | BindingFlags.Public); hierarchy = getHierarchyMethod.Invoke(objectTreeControl, new Object[] { connection, String.Empty }) as IExplorerHierarchy; } // VS2008 here we have additional param String.Empty - need Dependency Injection in order to make it work? return(hierarchy); }
internal void SelectSMOObjectInObjectExplorer(NamedSmoObject objectToSelect, SqlConnectionInfo connection) { if (objectToSelect.State == SqlSmoState.Dropped) { log.Info("Trying to locate dropped object:" + objectToSelect.Name); return; } IExplorerHierarchy hierarchy = GetHierarchyForConnection(connection); if (hierarchy == null) { return; // there is nothing we can really do if we don't have one of these } HierarchyTreeNode databasesNode = GetUserDatabasesNode(hierarchy.Root); var resultNode = FindNodeForSmoObject(databasesNode, objectToSelect); if (resultNode != null) { SelectNode(resultNode); } }
// select server on object window public void SelectServer(SqlConnectionInfo connection) { IExplorerHierarchy hierarchy = GetHierarchyForConnection(connection); SelectNode(hierarchy.Root); }
public ObjectExplorerServer(INodeInformation nodeInformation, IExplorerHierarchy hierarchy) { NodeInformation = nodeInformation; Hierarchy = hierarchy; }