예제 #1
0
        /// <summary>
        /// 处理用户模块
        /// </summary>
        /// <param name="systemModel"></param>
        /// <param name="userModel"></param>
        /// <param name="userId"></param>
        /// <param name="instanceKey"></param>
        private static void ProcessUserModel(Model systemModel, Model userModel, int userId, string instanceKey)
        {
            foreach (var child in systemModel.Childs)
            {
                if (String.IsNullOrWhiteSpace(child.ActionKey) ||
                    AccessServices.CheckAction(userId, instanceKey, child.ActionKey))
                {
                    var childUserModel = child.Clone();
                    ProcessUserModel(child, childUserModel, userId, instanceKey);

                    //有下级或当前级非目录
                    if (!String.IsNullOrEmpty(childUserModel.Url) || childUserModel.Childs.Count > 0)
                    {
                        userModel.Childs.Add(childUserModel);
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// 检查用户在指定的域中是否有指定的操作
        /// </summary>
        public static bool CheckAction(int userId, string instanceKey, string actionKey)
        {
            if (String.IsNullOrEmpty(instanceKey) || String.IsNullOrEmpty(actionKey))
            {
                return(false);
            }

            Access user = AccessServices.GetUser(userId, instanceKey);

            if (user == null)
            {
                return(false);
            }

            //判断用户在域实例中是否有权限
            bool canDoAction = user.CheckAction(instanceKey, actionKey);

            return(canDoAction);
        }