Exemplo n.º 1
0
        /// <summary>
        /// 创建一颗树
        /// </summary>
        /// <param name="treeID">树标识</param>
        /// <param name="treeName">树名称</param>
        /// <param name="leafLimit">叶数量上限</param>
        /// <param name="depthLimit">深度上限</param>
        /// <param name="shareToAll">是否为共享树</param>
        /// <param name="treeType">树类型默认:2=一般树</param>
        public void CreateATree(int treeID, string treeName, int leafLimit, int depthLimit, bool shareToAll, byte treeType = 2)
        {
            var treeEntity = treesRepo.Table.FirstOrDefault(c => c.TreeID == treeID);

            if (treeEntity != null)
            {
                throw new Exception($"已存在Tree={treeID}");
            }
            IIRAPNamespaceSet nameSet = IRAPNamespaceSetFactory.CreatInstance(Enums.NamespaceType.Sys);
            int nameID = nameSet.GetNameID(0, treeName, 30);
            var etree  = new ModelTreeEntity()
            {
                TreeID     = (short)treeID,
                NameID     = nameID,
                LeafLimit  = leafLimit,
                DepthLimit = depthLimit,
                ShareToAll = shareToAll,
                TreeType   = treeType
            };

            treesRepo.Insert(etree);
            treesRepo.SaveChanges();
            return;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取NameID
        /// </summary>
        /// <param name="nameDesc"></param>
        /// <returns></returns>
        private int GetNameID(string nameDesc)
        {
            IIRAPNamespaceSet nameSet = IRAPNamespaceSetFactory.CreatInstance(Enums.NamespaceType.Sys);

            return(nameSet.GetNameID(0, nameDesc, 30));
        }