public CCTVHierarchyNode GetHierarchy(string hierarchyName = _defaultHierarchy) { if (!hierarchyName.Equals(_currentTree, StringComparison.OrdinalIgnoreCase)) { _rootNode = null; _currentTree = hierarchyName; ClientHub.RegisterHierarchy(hierarchyName, TimeSpan.FromSeconds(5), hierUpdated); } //目前只能获取默认节点树。 if (_rootNode == null) { CCTVHierarchyNode[] roots = ClientHub.GetAllHierarchyRoots(); if (roots != null && roots.Length > 0) { if (_fromConfig) { if (UserManager.Instance?.CurrentUser != null && !string.IsNullOrWhiteSpace(UserManager.Instance.CurrentUser.UserName)) { ClientHub.UpdateDefault(CCTVInfoType.UserPrivilege); var priv = ClientHub.GetUserPrivilege(UserManager.Instance.CurrentUser.UserName); if (priv != null && priv.AccessibleNodes != null) { roots = HierarchyInfoUtil.FilterNodes(roots, priv.AccessibleNodes).ToArray(); } } } if (roots.Length == 1) { _rootNode = roots[0]; } else { string id = Guid.NewGuid().ToString(); _rootNode = new CCTVHierarchyNode() { Name = "根节点", Id = id, Type = NodeType.Server, ElementId = id, Children = roots }; } } } return(_rootNode); //if (rootNode == null) // ClientHub.UpdateRegistered<HierarchyInfo>(); //return rootNode; }
public CCTVHierarchyNode GetHierarchyRoot() { return(ClientHub?.GetAllHierarchyRoots()?.First()); }