Exemplo n.º 1
0
        public bool IncludeChildrenSection(int parentID, enumTypeHierarchy parentType, ICollection <FreeHierarchyTreeItem> children)
        {
            var isExistsSeeDbRights = false;

            foreach (var section in GlobalSectionsDictionary.SectionsList.Values.Where(s => s.TypeParentHierarchy == parentType && s.ParentId == parentID))
            {
                UserRightsForTreeObject right;
                if (!Manager.User.AccumulateRightsAndVerify(section, EnumObjectRightType.SeeDbObjects, HierObject.GetObjectRightType(), out right))
                {
                    continue;
                }

                isExistsSeeDbRights = true;


                var newItem = new FreeHierarchyTreeItem(Descriptor, section, false, string.Empty, Descriptor.GetMinIdAndDecrement(), this, true,
                                                        nodeRights: right, freeHierItemType: EnumFreeHierarchyItemType.Section);

                children.Add(newItem);
                Descriptor.Tree.TryAdd(newItem.FreeHierItem_ID, newItem);
                newItem.Descriptor.Tree = Descriptor.Tree;
                newItem.LoadStaticChildren(true);
            }

            return(isExistsSeeDbRights);
        }
Exemplo n.º 2
0
        public bool IncludeChildrenOPCNodes(ICollection <FreeHierarchyTreeItem> children, bool isSelected = false, HashSet <long> selectedNodes = null,
                                            bool includeChildren = true)
        {
            if (HierObject == null)
            {
                return(false);
            }
            Descriptor.NeedFindUaNode = true;
            var mainNode = HierObject as TUANode;
            var result   = false;

            if (mainNode == null || mainNode.DependentNodes == null)
            {
                return(false);
            }
            IsUaNodesInitializet = true;
            var uadependentnodes = UAHierarchyDictionaries.UANodesDict.GetValues(
                new HashSet <long>(mainNode.DependentNodes
                                   .Where(c => c.UAReferenceType != EnumOpcReferenceType.HasTypeDefinition)
                                   .Select(c => c.UANodeId)), Manager.UI.ShowMessage);

            //Перебор всех зависимых OPC узлов
            foreach (var dependentNode in uadependentnodes)
            {
                UserRightsForTreeObject right;
                var isExistsRight = Manager.User.AccumulateRightsAndVerify(dependentNode, EnumObjectRightType.SeeDbObjects, HierObject.GetObjectRightType(), out right);


                var selected = isSelected || (selectedNodes != null && selectedNodes.Contains(dependentNode.UANodeId));

                var newItem = new FreeHierarchyTreeItem(Descriptor, dependentNode, selected, string.Empty, Descriptor.GetMinIdAndDecrement(), this, true,
                                                        nodeRights: right, freeHierItemType: EnumFreeHierarchyItemType.UANode);

                var isExistsChildSeeDbObjects = false;
                if (children.Any(i => i.GetKey == newItem.GetKey))
                {
                    // newItem.Dispose();
                    return(result);
                }
                if (includeChildren)
                {
                    isExistsChildSeeDbObjects = newItem.IncludeChildrenOPCNodes(newItem.Children, isSelected, selectedNodes);
                }

                //У объекта есть права на просмотр, или на дочерний объект
                if (isExistsRight || isExistsChildSeeDbObjects)
                {
                    children.Add(newItem);
                    Descriptor.Tree.TryAdd(newItem.FreeHierItem_ID, newItem);

                    result = true;
                }
                else
                {
                    newItem.Dispose();
                }
            }

            return(result);
        }