Пример #1
0
        public ObservableCollection <Newegg.Oversea.Silverlight.Core.Components.RoleAttribute> GetAttributesByRoleName(string roleName, string applicationId)
        {
            ObservableCollection <Newegg.Oversea.Silverlight.Core.Components.RoleAttribute> result = null;

            if (this.m_roleAttributes != null && this.m_roleAttributes.Count > 0)
            {
                result = new ObservableCollection <Newegg.Oversea.Silverlight.Core.Components.RoleAttribute>();
                foreach (var attr in this.m_roleAttributes)
                {
                    if (UtilityHelper.AreEqualIgnoreCase(roleName, attr.RoleName) && UtilityHelper.AreEqualIgnoreCase(attr.ApplicationId, applicationId))
                    {
                        result.Add(attr);
                    }
                }
            }
            return(result);
        }
Пример #2
0
        public bool HasFunction(string functionKey)
        {
            if (UtilityHelper.IsNullOrEmpty(functionKey))
            {
                throw new ArgumentNullException("functionKey");
            }
            if (m_cachedAuthFunctionList == null)
            {
                m_cachedAuthFunctionList = new List <AuthFunction>();
            }

            foreach (AuthFunction function in m_cachedAuthFunctionList)
            {
                if (UtilityHelper.AreEqualIgnoreCase(functionKey, function.Key))
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #3
0
        //[Obsolete("该方法已经过期,请使用新的HasFunctionByAppName(string key,string appName)来替代该方法。")]
        //public bool HasFunction(string functionKey,string applicationId)
        //{
        //    if (UtilityHelper.IsNullOrEmpty(functionKey))
        //    {
        //        throw new ArgumentNullException("functionKey");
        //    }
        //    if (m_cachedAuthFunctionList == null)
        //    {
        //        m_cachedAuthFunctionList = new List<AuthFunction>();
        //    }

        //    foreach (AuthFunction function in m_cachedAuthFunctionList)
        //    {
        //        if (UtilityHelper.AreEqualIgnoreCase(functionKey, function.Key) && UtilityHelper.AreEqualIgnoreCase(function.ApplicationId, applicationId))
        //        {
        //            return true;
        //        }
        //    }

        //    return false;
        //}

        //public bool HasFunctionByAppName(string functionKey, string appName)
        //{
        //    if (UtilityHelper.IsNullOrEmpty(functionKey))
        //    {
        //        throw new ArgumentNullException("functionKey");
        //    }

        //    KS_Application result = CPApplication.Current.KS_Applications.SingleOrDefault(app => UtilityHelper.AreEqualIgnoreCase(app.Name, appName));

        //    if (result == null)
        //    {
        //        throw new ArgumentException("Application Name can not found, please pre-load function list.");
        //    }

        //    if (m_cachedAuthFunctionList == null)
        //    {
        //        m_cachedAuthFunctionList = new List<AuthFunction>();
        //    }

        //    foreach (AuthFunction function in m_cachedAuthFunctionList)
        //    {
        //        if (UtilityHelper.AreEqualIgnoreCase(functionKey, function.Key) && UtilityHelper.AreEqualIgnoreCase(function.ApplicationId, result.Id))
        //        {
        //            return true;
        //        }
        //    }

        //    return false;
        //}

        //public bool HasRole(string roleName, string appName)
        //{
        //    if (UtilityHelper.IsNullOrEmpty(roleName))
        //    {
        //        throw new ArgumentNullException("applicationId");
        //    }
        //    if (m_cachedRoles == null)
        //    {
        //        m_cachedRoles = new ObservableCollection<Role>();
        //    }

        //    KS_Application result = CPApplication.Current.KS_Applications.SingleOrDefault(app => UtilityHelper.AreEqualIgnoreCase(app.Name, appName));

        //    if (result == null)
        //    {
        //        throw new ArgumentException("Application Name can not found, please pre-load function list.");
        //    }

        //    foreach (Role role in m_cachedRoles)
        //    {
        //        if (UtilityHelper.AreEqualIgnoreCase(roleName, role.RoleName)
        //            && UtilityHelper.AreEqualIgnoreCase(role.ApplicationID, result.Id))
        //        {
        //            return true;
        //        }
        //    }

        //    return false;
        //}

        public bool HasFunctionForPage(string url)
        {
            if (UtilityHelper.IsNullOrEmpty(url))
            {
                throw new ArgumentNullException("url");
            }
            if (m_cachedAuthUris == null)
            {
                throw new ArgumentException("Page list isn't ready, please pre-load page list.");
            }

            foreach (var item in m_cachedAuthUris)
            {
                if (UtilityHelper.AreEqualIgnoreCase(url, item.URL))
                {
                    return(true);
                }
            }

            return(false);
        }