public override IEnumerable <string> GetOperator(OperateRightEventArgs e)
        {
            var result = base.GetOperator(e);

            if (result == null)
            {
                return(null);
            }
            IFunctionRight funcRight = WebGlobalVariable.SessionGbl.AppRight.FunctionRight;

            TkDebug.AssertNotNull(funcRight, "系统没有配置功能权限", this);
            var nextResult = from item in result
                             where funcRight.IsSubFunction(item, FunctionKey)
                             select item;

            return(nextResult);
        }
Beispiel #2
0
        protected void CheckFunctionRight()
        {
            ISupportFunction functionSource = Source as ISupportFunction;

            if (functionSource != null)
            {
                IFunctionRight functionRight = SessionGbl.AppRight.FunctionRight;
                switch (functionSource.FunctionType)
                {
                case FunctionRightType.Admin:
                    if (!functionRight.IsAdmin())
                    {
                        throw new NoFunctionRightException();
                    }
                    break;

                case FunctionRightType.Function:
                    if (!functionRight.IsFunction(functionSource.FunctionKey))
                    {
                        throw new NoFunctionRightException();
                    }
                    break;

                case FunctionRightType.SubFunction:
                    if (Style.Style == PageStyle.List || Style.Style == PageStyle.Detail ||
                        MetaDataUtil.Equals(Style, DbListSource.TabStyle))
                    {
                        // List和Detail不禁止子功能权限,子功能权限主要控制Insert,Update这些操作。如果想禁止查看数据,考虑使用DataRight过滤
                        break;
                    }
                    var subKey = GetSubFunctionKey();
                    if (!functionRight.IsSubFunction(subKey, functionSource.FunctionKey))
                    {
                        throw new NoFunctionRightException();
                    }
                    break;

                case FunctionRightType.None:
                    break;
                }
            }
        }