Exemplo n.º 1
0
        /// <summary>
        /// 获取用户资源权限
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="softId"></param>
        /// <returns></returns>
        public List <ChannelRight> GetUserChannelRights(int userId, int softId)
        {
            //权限判断
            loginService.HaveAdminRightForUserGrantSoft(userId, softId);

            return(DAChannelsHelper.GetUserChannelRights(userId, softId));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 授予用户特定渠道权限
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="softId"></param>
        /// <param name="channelRights"></param>
        public void AddUserChannelRights(int userId, int softId, List <ChannelRight> channelRights)
        {
            //权限判断
            loginService.HaveAdminRightForUserGrantSoft(userId, softId);

            DAChannelsHelper.AddUserChannelRights(userId, softId, channelRights);

            //记录登录日志
            loginService.AddLog(
                "AddUserChannelRights",
                string.Format("添加用户渠道权限(UserID={0},SoftID={1})", userId, softId));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取指定渠道有权限的用户列表
        /// </summary>
        /// <param name="softId"></param>
        /// <param name="channelRight"></param>
        /// <returns></returns>
        public List <int> GetUserIds(int softId, ChannelRight channelRight)
        {
            loginService.HaveAdminRight(DACommonHelper.REPORT_SYS_ID);

            if (loginService.LoginUser.AccountType == UserTypeOptions.ProductAdmin &&
                !loginService.AvailableSofts.Exists(a => a.ID == softId))
            {
                throw new NotRightException();
            }

            return(DAChannelsHelper.GetUserIds(softId, channelRight));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 获取没带子渠道的渠道列表(全部产品)
        /// </summary>
        /// <returns></returns>
        public Dictionary <int, List <Channel> > GetAvailableChannelsWithoutSubChannels()
        {
            string cacheKey = string.Format("net91com.Reports.UserRights.URLoginService.GetAvailableChannelsWithoutSubChannels_{0}", LoginUser.ID);

            if (CacheHelper.Contains(cacheKey))
            {
                return(CacheHelper.Get <Dictionary <int, List <Channel> > >(cacheKey));
            }
            Dictionary <int, List <Channel> > channels = DAChannelsHelper.GetChannelsWithoutSubChannels(LoginUser.ID);

            CacheHelper.Set <Dictionary <int, List <Channel> > >(cacheKey, channels, CacheTimeOption.TenMinutes, CacheExpirationOption.AbsoluteExpiration);
            return(channels);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 授予用户特定渠道权限
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="softId"></param>
        /// <param name="channelRight"></param>
        public void DeleteUserChannelRight(int userId, int softId, ChannelRight channelRight)
        {
            //权限判断
            loginService.HaveAdminRightForUserGrantSoft(userId, softId);

            DAChannelsHelper.DeleteUserChannelRight(userId, softId, channelRight);

            //记录登录日志
            loginService.AddLog(
                "DeleteUserChannelRight",
                string.Format("删除用户渠道权限(UserID={0},SoftID={1},ChannelType={2},ChannelID={3})", userId, softId,
                              channelRight.ChannelType, channelRight.ChannelID));
        }
Exemplo n.º 6
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);
            }
        }
Exemplo n.º 7
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));
        }
Exemplo n.º 8
0
        /// <summary>
        /// 获取指定产品的渠道列表
        /// </summary>
        /// <param name="softId"></param>
        /// <param name="includeChannelIds">是否包含渠道ID</param>
        /// <returns></returns>
        public List <Channel> GetChannels(int softId, bool includeChannelIds)
        {
            if (loginService.LoginUser.AccountType == UserTypeOptions.Channel ||
                loginService.LoginUser.AccountType == UserTypeOptions.ChannelPartner)
            {
                throw new NotRightException();
            }

            if ((loginService.LoginUser.AccountType == UserTypeOptions.ProductAdmin ||
                 loginService.LoginUser.AccountType == UserTypeOptions.General) &&
                !loginService.AvailableSofts.Exists(a => a.ID == softId))
            {
                throw new NotRightException();
            }

            return(DAChannelsHelper.GetChannels(softId, includeChannelIds));
        }
Exemplo n.º 9
0
        /// <summary>
        /// 获取指定产品的渠道列表(KEY则为渠道类型加ID值)
        /// </summary>
        /// <param name="softId"></param>
        /// <param name="includeChannelIds"></param>
        /// <returns></returns>
        public Dictionary <string, Channel> GetChannelDict(int softId, bool includeChannelIds)
        {
            string cacheKey = string.Format("net91com.Reports.UserRights.URChannelsService.GetChannelDict_{0}_{1}",
                                            softId, includeChannelIds);

            if (CacheHelper.Contains(cacheKey))
            {
                return(CacheHelper.Get <Dictionary <string, Channel> >(cacheKey));
            }
            Dictionary <string, Channel> channelDict = new Dictionary <string, Channel>();
            List <Channel> channels = DAChannelsHelper.GetChannels(softId, includeChannelIds);

            foreach (Channel channel in channels)
            {
                string key = channel.ChannelType.ToString() + channel.ID.ToString();
                channelDict[key] = channel;
            }
            CacheHelper.Set <Dictionary <string, Channel> >(cacheKey, channelDict, Core.CacheTimeOption.TenMinutes,
                                                            Core.CacheExpirationOption.AbsoluteExpiration);
            return(channelDict);
        }
Exemplo n.º 10
0
 /// <summary>
 /// 获取指定软件指定渠道绑定的渠道ID列表(未登录)
 /// </summary>
 /// <param name="softId"></param>
 /// <param name="channelType"></param>
 /// <param name="channels"></param>
 /// <returns></returns>
 public List <int> GetChannelIds(int softId, ChannelTypeOptions channelType, int[] channels)
 {
     return(DAChannelsHelper.GetChannelIds(softId, channelType, channels));
 }