/// <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); } }
/// <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)); }
/// <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); }