Пример #1
0
        public Permissions GetPermissionsByModule(string module_code)
        {
            if (_dicModulePermissions == null)
            {
                _dicModulePermissions = new Dictionary <string, Permissions>();
            }

            if (_dicModulePermissions.ContainsKey(module_code))
            {
                return(_dicModulePermissions[module_code]);
            }

            Permissions    _Permissions = new Permissions();
            CPModuleEntity _Module      = CPModuleService.Instance.CreateQuery()
                                          .Where(o => o.Code == module_code)
                                          .ToSingle();

            if (_Module == null)
            {
                _dicModulePermissions[module_code] = _Permissions;

                return(_Permissions);
            }

            return(GetPermissionsByRef("CP.MODULE", _Module.ID));
        }
Пример #2
0
        public string GetAllowAccessModule()
        {
            string result = string.Empty;

            int userId = CPLogin.CurrentUser.ID;

            // Get user role
            CPUserRoleEntity userRole = CPUserRoleService.Instance.CreateQuery()
                                        .Where(o => o.UserID == userId)
                                        .ToSingle();

            if (userRole == null)
            {
                return(result);
            }

            List <CPAccessEntity> access = CPAccessService.Instance.CreateQuery()
                                           .Where(o => o.RoleID == userRole.RoleID)
                                           .ToList();

            if (access == null)
            {
                return(result);
            }

            ArrayList arrayList = new ArrayList();

            foreach (CPAccessEntity a in access)
            {
                CPModuleEntity module = CPModuleService.Instance.CreateQuery()
                                        .Where(o => o.ID == a.RefID)
                                        .ToSingle();
                if (module != null)
                {
                    arrayList.Add(module.Code);
                }
            }
            result = string.Join(",", arrayList.ToArray());

            return(result);
        }