/// <summary>
 /// 检查权限(检查软件权限)
 /// </summary>
 /// <param name="softid"></param>
 /// <param name="url"></param>
 protected void CheckHasRight(int softid, string url)
 {
     if (!AvailableSofts.Exists(a => a.ID == softid) || !loginService.CheckUrlRight(url))
     {
         throw new NotRightException();
     }
 }
Beispiel #2
0
        /// <summary>
        /// 验证是否有管理员权限(没有权限抛出NotRightException异常)
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="softId"></param>
        /// <returns></returns>
        internal User HaveAdminRightForUserGrantSoft(int userId, int softId)
        {
            User user = HaveAdminRightForUserGrant(userId);

            if (LoginUser.AccountType == UserTypeOptions.ProductAdmin && !AvailableSofts.Exists(a => a.ID == softId))
            {
                throw new NotRightException();
            }
            return(user);
        }
Beispiel #3
0
        /// <summary>
        /// 获取指定用户指定产品的渠道列表
        /// </summary>
        /// <param name="softId"></param>
        /// <param name="platforms"></param>
        /// <param name="includeChannelIds">是否包含渠道ID</param>
        /// <returns></returns>
        public List <Channel> GetAvailableChannels(int softId, MobileOption[] platforms, bool includeChannelIds)
        {
            if (!AvailableSofts.Exists(a => a.ID == softId))
            {
                return(new List <Channel>());
            }

            if (LoginUser.AccountType == UserTypeOptions.Channel || LoginUser.AccountType == UserTypeOptions.ChannelPartner)
            {
                string cacheKey = string.Format("net91com.Reports.UserRights.URLoginService.GetAvailableChannels_{0}_{1}", LoginUser.ID, softId);
                if (CacheHelper.Contains(cacheKey))
                {
                    return(CacheHelper.Get <List <Channel> >(cacheKey));
                }

                List <Channel> channels = DAChannelsHelper.GetChannels(LoginUser.ID, softId);
                CacheHelper.Set <List <Channel> >(cacheKey, channels, CacheTimeOption.TenMinutes, CacheExpirationOption.AbsoluteExpiration);
                return(channels);
            }
            else
            {
                List <Channel> channels;
                string         cacheKey = string.Format("net91com.Reports.UserRights.URLoginService.GetAvailableChannels_{0}_{1}", softId, includeChannelIds);
                if (CacheHelper.Contains(cacheKey))
                {
                    channels = CacheHelper.Get <List <Channel> >(cacheKey);
                }
                else
                {
                    channels = DAChannelsHelper.GetChannels(softId, includeChannelIds);
                    CacheHelper.Set <List <Channel> >(cacheKey, channels, CacheTimeOption.TenMinutes, CacheExpirationOption.AbsoluteExpiration);
                }
                if (!includeChannelIds || platforms == null || platforms.Length == 0 ||
                    platforms.Contains(MobileOption.None))
                {
                    return(channels);
                }

                List <Channel> result = new List <Channel>();
                for (int i = 0; i < channels.Count; i++)
                {
                    if (channels[i].Platform == MobileOption.None || platforms.Contains(channels[i].Platform))
                    {
                        result.Add(channels[i]);
                    }
                }
                return(result);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 获取用户渠道ID权限
        /// </summary>
        /// <param name="softId"></param>
        /// <param name="channelType"></param>
        /// <param name="channels"></param>
        /// <param name="mustLogin">有些地方不需要登录也可以请求</param>
        /// <returns></returns>
        public List <int> GetAvailableChannelIds(int softId, ChannelTypeOptions channelType, int[] channels, bool mustLogin = true)
        {
            if (mustLogin)
            {
                if (!AvailableSofts.Exists(a => a.ID == softId))
                {
                    return(new List <int>());
                }

                if (LoginUser.AccountType == UserTypeOptions.Channel ||
                    LoginUser.AccountType == UserTypeOptions.ChannelPartner)
                {
                    return(DAChannelsHelper.GetChannelIds(LoginUser.ID, softId, channelType, channels));
                }
            }
            return(DAChannelsHelper.GetChannelIds(softId, channelType, channels));
        }