コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="argument"></param>
        public override void Execute(string argument)
        {
            string[] args = argument.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            ExceptionHelper.FalseThrow(args.Length > 0, "查询人员的角色必须提供登录名");

            OguObjectCollection <IUser> users = QueryHelper.QueryUser(args[0]);

            foreach (IUser user in users)
            {
                if (args.Length > 1)
                {
                    user.Roles[args[1]].ToList().ForEach(obj => OutputHelper.OutputPermissionInfo(obj));
                }
                else
                {
                    List <IRole> roles = user.Roles.GetAllRoles();

                    foreach (IRole role in roles)
                    {
                        if (role.Application != null)
                        {
                            Console.WriteLine("Application");
                            OutputHelper.OutputPermissionInfo(role.Application);
                        }

                        Console.WriteLine("Role");
                        OutputHelper.OutputPermissionInfo(role);
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="argument"></param>
        public override void Execute(string argument)
        {
            string[] args = argument.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            ExceptionHelper.FalseThrow(args.Length > 0, "查询人员的权限必须提供登录名");

            OguObjectCollection <IUser> users = QueryHelper.QueryUser(args[0]);

            foreach (IUser user in users)
            {
                if (args.Length > 1)
                {
                    user.Permissions[args[1]].ToList().ForEach(obj => OutputHelper.OutputPermissionInfo(obj));
                }
                else
                {
                    Dictionary <IApplication, PermissionCollection> appRoles = user.Permissions.GetAllAppPermissions();

                    foreach (KeyValuePair <IApplication, PermissionCollection> kp in appRoles)
                    {
                        Console.WriteLine("Application");
                        OutputHelper.OutputPermissionInfo(kp.Key);

                        if (kp.Value.Count > 0)
                        {
                            Console.WriteLine("Permissions");
                            kp.Value.ForEach(obj => OutputHelper.OutputPermissionInfo(obj));
                        }
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="argument"></param>
        public override void Execute(string argument)
        {
            ApplicationCollection applications = PermissionMechanismFactory.GetMechanism().GetApplications(argument);

            ExceptionHelper.FalseThrow(applications.Count > 0, "不能查询到CodeName为\"{0}\"应用", argument);

            applications[0].Permissions.ForEach(p => OutputHelper.OutputPermissionInfo(p));
        }
コード例 #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="argument"></param>
        public override void Execute(string argument)
        {
            string[] args = argument.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            ExceptionHelper.FalseThrow(args.Length > 1, "查询人员的角色对应的权限必须提供应用的CodeName和角色的CodeName");

            IApplication app = AppAdminMechanism.Instance.GetAllApplications().Find(a => a.CodeName == args[0]);

            (app != null).FalseThrow("不能找到CodeName为{0}的应用", args[0]);

            PermissionCollection permissions = AppAdminMechanism.Instance.GetRolesPermissions(app, args[1]);

            permissions.ForEach(permission => OutputHelper.OutputPermissionInfo(permission));
        }
コード例 #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="argument"></param>
        public override void Execute(string argument)
        {
            string[] arguments = argument.Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);

            ExceptionHelper.FalseThrow(arguments.Length > 1, "参数太少,必须提供两个参数,用逗号或空格分开");

            ApplicationCollection applications = PermissionMechanismFactory.GetMechanism().GetApplications(arguments[0]);

            ExceptionHelper.FalseThrow(applications.Count > 0, "不能查询到CodeName为\"{0}\"应用", arguments[0]);

            ExceptionHelper.FalseThrow(applications[0].Permissions.ContainsKey(arguments[1]),
                                       "在应用\"{0}\"中不能查询到CodeName为\"{1}\"的权限", arguments[0], arguments[1]);

            applications[0].Permissions[arguments[1]].RelativeRoles.ForEach(r => OutputHelper.OutputPermissionInfo(r));
        }
コード例 #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="argument"></param>
 public override void Execute(string argument)
 {
     PermissionMechanismFactory.GetMechanism().GetAllApplications().ToList().ForEach(
         obj => OutputHelper.OutputPermissionInfo(obj));
 }