示例#1
0
        /// <summary>
        /// 集成指定目录的权限
        /// </summary>
        /// <param name="dbsDefine">指定的DBS目录</param>
        public void InheritNodeAuth(S_T_DBSDefine dbsDefine)
        {
            var entities = FormulaHelper.GetEntities <BaseConfigEntities>();

            entities.S_T_DBSSecurity.Delete(d => d.DBSDefineID == this.ID);
            foreach (var security in dbsDefine.S_T_DBSSecurity.ToList())
            {
                var sec = new S_T_DBSSecurity();
                sec.ID          = FormulaHelper.CreateGuid();
                sec.RoleCode    = security.RoleCode;
                sec.RoleName    = security.RoleName;
                sec.AuthType    = security.AuthType;
                sec.RoleType    = security.RoleType;
                sec.DBSDefineID = this.ID;
                this.S_T_DBSSecurity.Add(sec);
                sec.S_T_DBSDefine = this;
            }
            this.InheritAuth = true.ToString();
        }
示例#2
0
        /// <summary>
        /// 根据角色来设置DBS对象的权限
        /// </summary>
        /// <param name="roleCode">角色编码</param>
        /// <param name="roleName">角色名称</param>
        /// <param name="authType">权限类别</param>
        public void SetAuth(string roleCode, string roleName, string authType, string roleType)
        {
            var security = this.S_T_DBSSecurity.FirstOrDefault(d => d.RoleCode == roleCode);

            if (security == null)
            {
                security          = new S_T_DBSSecurity();
                security.ID       = FormulaHelper.CreateGuid();
                security.RoleCode = roleCode;
                security.RoleName = roleName;
                security.RoleType = roleType;
                this.S_T_DBSSecurity.Add(security);
            }
            security.AuthType = authType;
            this.InheritAuth  = false.ToString();
            foreach (var child in this.AllChildren.Where(d => d.InheritAuth == true.ToString()).ToList())
            {
                child.InheritNodeAuth(this);
            }
        }