Пример #1
0
        /// <summary>
        /// 复制空间配置及控件授权
        /// </summary>
        /// <param name="rootSpace"></param>
        /// <param name="newRootSpace"></param>
        /// <param name="context"></param>
        private void CopySpaceDefine(S_T_SpaceDefine rootSpace, S_T_SpaceDefine newRootSpace, BaseConfigEntities context)
        {
            var childSpace = rootSpace.Children;

            foreach (var space in childSpace)
            {
                var newSpace = space.Clone <S_T_SpaceDefine>();
                newSpace.ID       = FormulaHelper.CreateGuid();
                newSpace.ParentID = newRootSpace.ID;
                newSpace.FullID   = newRootSpace.FullID + "." + newSpace.ID;
                newSpace.ModeID   = newRootSpace.ModeID;
                context.Set <S_T_SpaceDefine>().Add(newSpace);

                //空间权限
                var spaceAuth = context.Set <S_T_SpaceAuth>().Where(c => c.SpaceID == space.ID);
                if (spaceAuth != null)
                {
                    foreach (var auth in spaceAuth)
                    {
                        var newAuth = auth.Clone <S_T_SpaceAuth>();
                        newAuth.SpaceID = newSpace.ID;
                        context.Set <S_T_SpaceAuth>().Add(newAuth);
                    }
                }

                if (space.Children != null)
                {
                    CopySpaceDefine(space, newSpace, context);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// 增加功能节点
        /// </summary>
        /// <param name="feature">功能注册对象</param>
        public void AddFeature(S_D_Feature feature)
        {
            if (this.Children.Exists(d => d.Type == SpaceNodeType.Feature.ToString() && d.Code == feature.Code))
            {
                throw new Formula.Exceptions.BusinessException("已经存在的功能【" + feature.Name + "】不能重复增加");
            }
            var child = new S_T_SpaceDefine();

            if (String.IsNullOrEmpty(child.ID))
            {
                child.ID = FormulaHelper.CreateGuid();
            }
            child.Type              = SpaceNodeType.Feature.ToString();
            child.ParentID          = this.ID;
            child.FullID            = this.FullID + "." + child.ID;
            child.ModeID            = this.ModeID;
            child.Name              = feature.Name;
            child.Code              = feature.Code;
            child.LinkUrl           = feature.LinkUrl;
            child.FeatureID         = feature.ID;
            child.RelateWBSAttrCode = feature.RelateWBSAttrCode;
            child.DefineType        = SpaceDefineType.Static.ToString();
            if (this.S_T_ProjectMode == null)
            {
                throw new Formula.Exceptions.BusinessException("没有找到指定的管理模型对象无法新增Feature对象");
            }
            this.S_T_ProjectMode.S_T_SpaceDefine.Add(child);
        }
Пример #3
0
 /// <summary>
 /// 增加子编目节点
 /// </summary>
 /// <param name="child">子节点对象</param>
 public void AddChild(S_T_SpaceDefine child)
 {
     child.ValidateEntity();
     if (String.IsNullOrEmpty(child.ID))
     {
         child.ID = FormulaHelper.CreateGuid();
     }
     child.Type   = SpaceNodeType.Catalog.ToString();
     child.FullID = this.FullID + "." + child.ID;
     child.ModeID = this.ModeID;
     if (this.S_T_ProjectMode == null)
     {
         throw new Formula.Exceptions.BusinessException("没有找到指定的管理模型对象无法新增SpaceDefine子节点");
     }
     this.S_T_ProjectMode.S_T_SpaceDefine.Add(child);
 }
Пример #4
0
        /// <summary>
        /// 增加根节点
        /// </summary>
        /// <param name="root">根节点对象</param>
        public static void AddRoot(S_T_SpaceDefine root)
        {
            root.ValidateEntity();
            var entities    = FormulaHelper.GetEntities <BaseConfigEntities>();
            var projectMode = entities.S_T_ProjectMode.FirstOrDefault(d => d.ID == root.ModeID);

            if (projectMode == null)
            {
                throw new Formula.Exceptions.BusinessException("未能找到ID为【】的管理模式对象,无法增加SpaceDefine根");
            }
            var spaceDefine = projectMode.S_T_SpaceDefine.FirstOrDefault(d => String.IsNullOrEmpty(d.ParentID) && d.Code == root.Code && d.ID != root.ID);

            if (spaceDefine != null)
            {
                throw new Formula.Exceptions.BusinessException("【" + projectMode.Name + "】的管理对象已经拥有编号为【" + root.Code + "】的SpaceDefine根,不能重复增加");
            }
            if (String.IsNullOrEmpty(root.ID))
            {
                root.ID = FormulaHelper.CreateGuid();
            }
            root.FullID = root.ID;
            root.Type   = "Root";
            projectMode.S_T_SpaceDefine.Add(root);
        }
Пример #5
0
 /// <summary>
 /// 增加Space空间定义根
 /// </summary>
 /// <param name="define">根节点定义对象</param>
 public void AddRootSpaceDefine(S_T_SpaceDefine define)
 {
     Project.Logic.Domain.S_T_SpaceDefine.AddRoot(define);
 }