Esempio n. 1
0
        /// <summary>
        /// 可能感兴趣的人
        /// </summary>
        /// <returns></returns>
        public ActionResult Interested()
        {
            IUser CurrentUser = UserContext.CurrentUser;

            if (CurrentUser == null)
            {
                return(Redirect(SiteUrls.Instance().Login()));
            }

            // 没有感兴趣的人时,推荐人气用户,需去除已关注用户和自己
            //根据点击数取热门用户
            IEnumerable <IUser> topUsers = userService.GetTopUsers(100, SortBy_User.HitTimes);

            //已关注用户
            IEnumerable <long> followedUserIds = followService.GetTopFollowedUserIds(CurrentUser.UserId, 1000);

            //黑名单用户
            IEnumerable <long> stopUserIds = new PrivacyService().GetStopedUsers(CurrentUser.UserId).Select(n => n.Key);

            //去除已关注用户和加黑名单用户
            IEnumerable <IUser> hotUsers = topUsers.Where(n => !followedUserIds.Contains(n.UserId) && n.UserId != CurrentUser.UserId && !stopUserIds.Contains(n.UserId)).Take(Math.Min(8, topUsers.Count()));

            ViewData["userName"] = CurrentUser.UserName;
            pageResourceManager.InsertTitlePart("可能感兴趣的人");

            return(View(hotUsers));
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PrivacyCommands"/> class.
 /// </summary>
 /// <param name="feedback">The user feedback service.</param>
 /// <param name="privacy">The privacy service.</param>
 /// <param name="context">The command context.</param>
 /// <param name="channelAPI">The channel API.</param>
 public PrivacyCommands
 (
     FeedbackService feedback,
     PrivacyService privacy,
     ICommandContext context,
     IDiscordRestChannelAPI channelAPI
 )
 {
     _feedback   = feedback;
     _privacy    = privacy;
     _context    = context;
     _channelAPI = channelAPI;
 }
Esempio n. 3
0
        protected override void InitialiseInnerServices()
        {
            base.InitialiseInnerServices();
            Quorum             = new QuorumChainService(Client);
            Permission         = new PermissionService(Client);
            Privacy            = new PrivacyService(Client);
            Raft               = new RaftService(Client);
            IBFT               = new IBFTService(Client);
            ContractExtensions = new ContractExtensionsService(Client);
            DebugQuorum        = new DebugQuorumService(Client);

            base.TransactionManager.DefaultGasPrice = 0;
        }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PrivacyCommands"/> class.
 /// </summary>
 /// <param name="feedback">The user feedback service.</param>
 /// <param name="client">The Discord client instance.</param>
 /// <param name="database">The database.</param>
 /// <param name="privacy">The privacy service.</param>
 /// <param name="content">The content service.</param>
 public PrivacyCommands
 (
     UserFeedbackService feedback,
     DiscordSocketClient client,
     CoreDatabaseContext database,
     PrivacyService privacy,
     ContentService content
 )
 {
     _feedback = feedback;
     _client   = client;
     _privacy  = privacy;
 }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PrivacyCommands"/> class.
 /// </summary>
 /// <param name="feedback">The user feedback service.</param>
 /// <param name="client">The Discord client instance.</param>
 /// <param name="database">The database.</param>
 /// <param name="privacy">The privacy service.</param>
 /// <param name="content">The content service.</param>
 public PrivacyCommands
 (
     UserFeedbackService feedback,
     DiscordSocketClient client,
     GlobalInfoContext database,
     PrivacyService privacy,
     ContentService content
 )
 {
     this.Feedback = feedback;
     this.Client   = client;
     this.Database = database;
     this.Privacy  = privacy;
     this.Content  = content;
 }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConsentCheckingPreExecutionEvent"/> class.
 /// </summary>
 /// <param name="privacy">The privacy service.</param>
 /// <param name="commandService">The command service.</param>
 /// <param name="options">The responder options.</param>
 /// <param name="interactionAPI">The interaction API.</param>
 /// <param name="tokenizerOptions">The tokenizer options.</param>
 /// <param name="treeSearchOptions">The tree search options.</param>
 /// <param name="feedback">The feedback service.</param>
 public ConsentCheckingPreExecutionEvent
 (
     PrivacyService privacy,
     CommandService commandService,
     IOptions <CommandResponderOptions> options,
     IDiscordRestInteractionAPI interactionAPI,
     IOptions <TokenizerOptions> tokenizerOptions,
     IOptions <TreeSearchOptions> treeSearchOptions,
     FeedbackService feedback
 )
 {
     _privacy           = privacy;
     _commandService    = commandService;
     _interactionAPI    = interactionAPI;
     _feedback          = feedback;
     _options           = options.Value;
     _tokenizerOptions  = tokenizerOptions.Value;
     _treeSearchOptions = treeSearchOptions.Value;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandBehaviour"/> class.
 /// </summary>
 /// <param name="client">The discord client.</param>
 /// <param name="services">The available services.</param>
 /// <param name="feedback">The feedback service.</param>
 /// <param name="privacy">The privacy service.</param>
 /// <param name="content">The content service.</param>
 /// <param name="commands">The command service.</param>
 /// <param name="help">The help service.</param>
 public CommandBehaviour
 (
     DiscordSocketClient client,
     IServiceProvider services,
     UserFeedbackService feedback,
     PrivacyService privacy,
     ContentService content,
     CommandService commands,
     HelpService help
 )
     : base(client)
 {
     _services = services;
     _feedback = feedback;
     _privacy  = privacy;
     _content  = content;
     _commands = commands;
     _help     = help;
 }
Esempio n. 8
0
        /// <summary>
        /// 可能感兴趣的人
        /// </summary>
        /// <returns></returns>
        public ActionResult Interested()
        {
            IUser CurrentUser = UserContext.CurrentUser;

            if (CurrentUser == null)
            {
                return(Redirect(SiteUrls.Instance().Login()));
            }

            // 没有感兴趣的人时,推荐人气用户,需去除已关注用户和自己
            //根据点击数取热门用户
            IEnumerable <IUser> topUsers = userService.GetTopUsers(100, SortBy_User.HitTimes);

            //已关注用户
            IEnumerable <long> followedUserIds = followService.GetTopFollowedUserIds(CurrentUser.UserId, 1000);

            //黑名单用户
            IEnumerable <long> stopUserIds = new PrivacyService().GetStopedUsers(CurrentUser.UserId).Select(n => n.Key);

            //去除已关注用户和加黑名单用户
            IEnumerable <IUser> hotUsers = topUsers.Where(n => !followedUserIds.Contains(n.UserId) && n.UserId != CurrentUser.UserId && !stopUserIds.Contains(n.UserId)).Take(Math.Min(8, topUsers.Count()));

            //设置当前登录用户对当前页用户的关注情况
            Dictionary <long, bool> isCurrentUserFollowDic = new Dictionary <long, bool>();

            foreach (var user in hotUsers)
            {
                //如果当前登录用户关注了该用户
                if (followService.IsFollowed(CurrentUser.UserId, user.UserId))
                {
                    isCurrentUserFollowDic.Add(user.UserId, true);
                }
                else
                {
                    isCurrentUserFollowDic.Add(user.UserId, false);
                }
            }
            ViewData["isCurrentUserFollowDic"] = isCurrentUserFollowDic;
            ViewData["userName"] = CurrentUser.UserName;
            pageResourceManager.InsertTitlePart("可能感兴趣的人");

            return(View(hotUsers));
        }
 public PrivacyPolicyController(
     SecurityService securityService,
     ISubjectRepository subjectRepository,
     IResourceRepository resourceRepository,
     ConditionalExpressionService conditionalExpressionService,
     IPrivacyPolicyRepository privacyPolicyRepository,
     PrivacyService privacyService,
     IPrivacyDomainRepository privacyDomainRepository,
     ILogger <PrivacyPolicyController> logger)
 {
     _securityService              = securityService;
     _subjectRepository            = subjectRepository;
     _resourceRepository           = resourceRepository;
     _conditionalExpressionService = conditionalExpressionService;
     _privacyPolicyRepository      = privacyPolicyRepository;
     _privacyService          = privacyService;
     _privacyDomainRepository = privacyDomainRepository;
     _logger = logger;
 }
Esempio n. 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AmbassadorCommandBehaviour"/> class.
 /// </summary>
 /// <param name="client">The discord client.</param>
 /// <param name="serviceScope">The service scope in use.</param>
 /// <param name="logger">The logging instance for this type.</param>
 /// <param name="feedback">The feedback service.</param>
 /// <param name="privacy">The privacy service.</param>
 /// <param name="content">The content service.</param>
 /// <param name="commands">The command service.</param>
 /// <param name="help">The help service.</param>
 /// <param name="portraits">The portrait service.</param>
 public AmbassadorCommandBehaviour
 (
     DiscordSocketClient client,
     IServiceScope serviceScope,
     ILogger <AmbassadorCommandBehaviour> logger,
     UserFeedbackService feedback,
     PrivacyService privacy,
     ContentService content,
     CommandService commands,
     HelpService help,
     PortraitService portraits
 )
     : base(client, serviceScope, logger, commands)
 {
     _feedback  = feedback;
     _privacy   = privacy;
     _content   = content;
     _help      = help;
     _portraits = portraits;
 }
Esempio n. 11
0
        private void GetCurrentLines(LineStatus[] reference, ref LineStatus[] currentLines)
        {
            int currentLineCompteur = 0;

            foreach (LineStatus ls in reference)
            {
                LineStatus newLine   = new LineStatus();
                LineStatus cacheLine = null;
                if (ls.directoryNumber != "" && Global.cacheMgr.Contains(ls.directoryNumber))
                {
                    cacheLine = Global.cacheMgr.GetData(ls.directoryNumber) as LineStatus;
                }
                newLine.directoryNumber = ls.directoryNumber;
                if (cacheLine == null)
                {
                    newLine.status       = Status.unknown;
                    newLine.doNotDisturb = false;
                    newLine.forward      = "";
                    newLine.mwiOn        = false;
                    newLine.monitored    = "";
                }
                else
                {
                    if (PrivacyService.IsPrivate(cacheLine.directoryNumber))
                    {
                        newLine.status = Status.hidden;
                    }
                    else
                    {
                        newLine.status = cacheLine.status;
                    }
                    newLine.doNotDisturb = cacheLine.doNotDisturb;
                    newLine.forward      = cacheLine.forward;
                    newLine.mwiOn        = cacheLine.mwiOn;
                    newLine.monitored    = cacheLine.monitored;
                }
                currentLines[currentLineCompteur] = newLine;
                currentLineCompteur++;
            }
        }
Esempio n. 12
0
        private void AuthorizeCore(AuthorizationContext filterContext)
        {
            string spaceKey = UserContext.CurrentSpaceKey(filterContext);

            if (string.IsNullOrEmpty(spaceKey))
            {
                filterContext.Result = new HttpNotFoundResult();
                return;
            }
            IUserService userService      = DIContainer.Resolve <IUserService>();
            User         currentSpaceUser = userService.GetFullUser(spaceKey);

            if (currentSpaceUser == null)
            {
                filterContext.Result = new HttpNotFoundResult();
                return;
            }
            IUser currentUser = UserContext.CurrentUser;
            //判断空间访问隐私
            PrivacyService privacyService = new PrivacyService();

            if (!privacyService.Validate(currentSpaceUser.UserId, currentUser != null ? currentUser.UserId : 0, PrivacyItemKeys.Instance().VisitUserSpace()))
            {
                if (currentUser == null)
                {
                    if (filterContext.HttpContext.Request.IsAjaxRequest())
                    {
                        filterContext.Result = new RedirectResult(SiteUrls.Instance().Login(false, SiteUrls.LoginModal._LoginInModal));
                    }
                    else
                    {
                        filterContext.Result = new RedirectResult(SiteUrls.Instance().Login(true));
                    }
                }
                else
                {
                    filterContext.Result = new RedirectResult(SiteUrls.Instance().PrivacyHome(currentSpaceUser.UserName) /* 跳向无权访问页 */);
                }
                return;
            }

            //判断该用户是否有访问该空间的权限
            if (!RequireOwnerOrAdministrator)
            {
                return;
            }
            //匿名用户要求先登录跳转
            if (currentUser == null)
            {
                if (filterContext.HttpContext.Request.IsAjaxRequest())
                {
                    filterContext.Result = new RedirectResult(SiteUrls.Instance().Login(false, SiteUrls.LoginModal._LoginInModal));
                }
                else
                {
                    filterContext.Result = new RedirectResult(SiteUrls.Instance().Login(true));
                }
                return;
            }

            if (currentSpaceUser.UserId == currentUser.UserId)
            {
                //if (currentUser.IsBanned)
                //{
                //    IAuthenticationService authenticationService = DIContainer.ResolvePerHttpRequest<IAuthenticationService>();
                //    authenticationService.SignOut();
                //    filterContext.Result = new RedirectResult(SiteUrls.Instance().SystemMessage(filterContext.Controller.TempData, new SystemMessageViewModel
                //      {
                //          Title = "帐号被封禁!",
                //          Body = "由于您的非法操作,您的帐号已被封禁,如有疑问,请联系管理员",
                //          StatusMessageType = StatusMessageType.Error
                //      }));
                //}
                return;
            }
            if (currentUser.IsInRoles(RoleNames.Instance().SuperAdministrator(), RoleNames.Instance().ContentAdministrator()))
            {
                return;
            }
            filterContext.Result = new RedirectResult(SiteUrls.Instance().SystemMessage(filterContext.Controller.TempData, new SystemMessageViewModel
            {
                Title             = "无权访问",
                Body              = "您无权访问此页面,只有空间主人或管理员才能访问",
                StatusMessageType = StatusMessageType.Hint
            }) /* 跳向无权访问页 */);
        }
Esempio n. 13
0
        /// <summary>
        /// 搜索“毕业于同一学校”的用户/// </summary>
        /// <param name="userId">当前用户的ID</param>
        /// <param name="pageIndex">分页页码</param>
        /// <param name="pageSize">分页大小</param>
        /// <param name="schoolNameDic">存储用户ID到学校名称列表的映射,用于页面列表输出</param>
        /// <returns></returns>
        public PagingDataSet <User> SearchInterestedWithSchools(long userId, int pageIndex, int pageSize, out Dictionary <long, IEnumerable <string> > schoolNameDic)
        {
            //Dictionary,用于页面列表输出
            schoolNameDic = new Dictionary <long, IEnumerable <string> >();

            //无效用户ID,直接返回空列表
            if (userId <= 0)
            {
                return(new PagingDataSet <User>(new List <User>()));
            }

            Query  query  = null;
            Filter filter = null;
            Sort   sort   = null;

            //先搜索出当前用户的学校名称
            //使用LuceneSearchBuilder构建Lucene需要Query、Filter、Sort
            LuceneSearchBuilder searchBuilder = new LuceneSearchBuilder();

            searchBuilder.WithField(UserIndexDocument.UserId, userId.ToString(), true);
            searchBuilder.BuildQuery(out query, out filter, out sort);

            IEnumerable <Document> docs = searchEngine.Search(query, filter, sort, 1);

            //索引中无此用户,直接返回空列表
            if (docs == null || docs.Count() == 0)
            {
                return(new PagingDataSet <User>(new List <User>()));
            }

            string[] mySchoolNames = docs.First <Document>().GetValues(UserIndexDocument.School);

            //当前用户无学校,直接返回空列表
            if (mySchoolNames != null && mySchoolNames.Count() == 0)
            {
                return(new PagingDataSet <User>(new List <User>()));
            }

            //查找有相同学校名称的用户
            //先查询当前用户关注的人(包括“悄悄关注”的用户),此处需要调用数据库查询,因为索引中没有存储“是否悄悄关注”属性
            IEnumerable <long> myFollowedUserIds = followService.GetPortionFollowedUserIds(userId);
            //黑名单用户
            IEnumerable <long> stopUserIds = new PrivacyService().GetStopedUsers(userId).Select(n => n.Key);

            //使用LuceneSearchBuilder构建Lucene需要Query、Filter、Sort
            searchBuilder = new LuceneSearchBuilder(1);
            //搜索条件需要排除掉当前用户本身
            searchBuilder.WithPhrases(UserIndexDocument.School, mySchoolNames.Distinct().Take(3).ToList())
            .NotWithField(UserIndexDocument.UserId, userId.ToString())                            //排除掉当前用户
            .NotWithFields(UserIndexDocument.UserId, myFollowedUserIds.Select(n => n.ToString())) //排除掉已关注用户
            .NotWithFields(UserIndexDocument.UserId, stopUserIds.Select(n => n.ToString()));      //排除掉黑名单用户
            searchBuilder.BuildQuery(out query, out filter, out sort);

            PagingDataSet <Document> searchResult = searchEngine.Search(query, filter, sort, pageIndex, pageSize);

            docs = searchResult.ToList <Document>();

            //如果没有使用相同学校名称的用户,直接返回空列表
            if (docs == null || docs.Count() == 0)
            {
                return(new PagingDataSet <User>(new List <User>()));
            }

            //“相同学校名称”的用户ID列表
            List <long> sameUserIds = new List <long>();

            foreach (Document doc in docs)
            {
                //比较获取“相同的学校名称”
                List <string> sameSchoolNames = new List <string>();
                string[]      schoolNames     = doc.GetValues(UserIndexDocument.School);
                foreach (string mySchoolName in mySchoolNames)
                {
                    foreach (string schoolName in schoolNames)
                    {
                        if (schoolName.Equals(mySchoolName) || schoolName.Contains(mySchoolName))
                        {
                            sameSchoolNames.Add(mySchoolName);
                            break;
                        }
                    }
                }

                long sameUserId = long.Parse(doc.Get(UserIndexDocument.UserId));
                sameUserIds.Add(sameUserId);

                //加入Dictionary,用于页面列表输出
                if (!schoolNameDic.ContainsKey(sameUserId))
                {
                    schoolNameDic.Add(sameUserId, sameSchoolNames);
                }
            }

            //批量查询“相同学校名称”的用户列表
            IEnumerable <User> sameUsers = userService.GetFullUsers(sameUserIds).Where(n => n.IsCanbeFollow == true && n.IsActivated == true && n.IsBanned == false);

            //组装分页对象
            PagingDataSet <User> users = new PagingDataSet <User>(sameUsers)
            {
                TotalRecords  = searchResult.TotalRecords,
                PageSize      = searchResult.PageSize,
                PageIndex     = searchResult.PageIndex,
                QueryDuration = searchResult.QueryDuration
            };

            return(users);
        }
Esempio n. 14
0
 public PrivacyCommand(PrivacyService service, EntityConvertor entityConvertor)
 {
     _entityConvertor = entityConvertor;
     _service         = service;
 }
Esempio n. 15
0
        // ReSharper restore PrivateFieldCanBeConvertedToLocalVariable

        /// <summary>
        /// Initializes a new instance of the <see cref="AmbassadorClient"/> class.
        /// </summary>
        /// <param name="content">The content service.</param>
        public AmbassadorClient([NotNull] ContentService content)
        {
            this.Client = Type.GetType("Mono.Runtime") is null
                                ? new DiscordSocketClient()
                                : new DiscordSocketClient(new DiscordSocketConfig {
                WebSocketProvider = () => new WebSocketSharpProvider()
            });

            this.Client.Log += OnDiscordLogEvent;

            this.Commands      = new CommandService();
            this.Commands.Log += OnDiscordLogEvent;

            this.DiscordIntegration = new DiscordService();
            this.Content            = content;
            this.Commands           = new CommandService();
            this.OwnedEntities      = new OwnedEntityService();
            this.Roleplays          = new RoleplayService(this.Commands, this.OwnedEntities);
            this.Transformation     = new TransformationService(this.Content);

            this.Characters = new CharacterService(this.Commands, this.OwnedEntities, this.Content, this.Transformation);
            this.Characters.DiscoverPronounProviders();

            this.Feedback    = new UserFeedbackService();
            this.Dossiers    = new DossierService(this.Content);
            this.Interactive = new InteractiveService(this.Client);

            this.Lua   = new LuaService(this.Content);
            this.Kinks = new KinkService(this.Feedback);

            this.Permissions = new PermissionService();

            this.Privacy = new PrivacyService();

            this.Services = new ServiceCollection()
                            .AddSingleton(this.Client)
                            .AddSingleton(this.DiscordIntegration)
                            .AddSingleton(this.Content)
                            .AddSingleton(this.Commands)
                            .AddSingleton(this.Roleplays)
                            .AddSingleton(this.Characters)
                            .AddSingleton(this.Feedback)
                            .AddSingleton(this.Dossiers)
                            .AddSingleton(this.Interactive)
                            .AddSingleton(this.Transformation)
                            .AddSingleton(this.Lua)
                            .AddSingleton(this.Kinks)
                            .AddSingleton(this.Permissions)
                            .AddSingleton(this.Privacy)
                            .AddDbContextPool <GlobalInfoContext>(builder => GlobalInfoContext.ConfigureOptions(builder))
                            .BuildServiceProvider();

            this.Transformation = this.Transformation
                                  .WithDescriptionBuilder
                                  (
                ActivatorUtilities.CreateInstance <TransformationDescriptionBuilder>(this.Services)
                                  );

            this.Client.MessageReceived += OnMessageReceived;
            this.Client.MessageUpdated  += OnMessageUpdated;
        }
 public XboxLiveServices(XboxLiveUser user)
 {
     this.privacyService = new PrivacyService(user);
 }
Esempio n. 17
0
        /// <summary>
        /// 搜索共同关注的人
        /// </summary>
        /// <param name="userId">粉丝的用户ID</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">分页大小</param>
        /// <param name="followedUserIdDic">每个相同关注用户中共同关注的用户ID列表</param>
        /// <param name="followedUserDic">每个共同关注的用户的ID与User的映射</param>
        /// <returns>符合搜索条件的User分页集合</returns>
        public PagingDataSet <User> SearchInterestedWithFollows(long userId, int pageIndex, int pageSize, out Dictionary <long, IEnumerable <long> > followedUserIdDic, out Dictionary <long, User> followedUserDic)
        {
            followedUserIdDic = new Dictionary <long, IEnumerable <long> >();
            followedUserDic   = new Dictionary <long, User>();

            if (userId <= 0)
            {
                return(new PagingDataSet <User>(new List <User>()));
            }

            //先查询当前用户关注的人(包括“悄悄关注”的用户),此处需要调用数据库查询,因为索引中没有存储“是否悄悄关注”属性
            IEnumerable <long> myFollowedUserIds = followService.GetPortionFollowedUserIds(userId);

            if (myFollowedUserIds != null && myFollowedUserIds.Count() == 0)
            {
                return(new PagingDataSet <User>(new List <User>()));
            }

            //黑名单用户
            IEnumerable <long> stopUserIds = new PrivacyService().GetStopedUsers(userId).Select(n => n.Key);

            //搜索“我”关注的人中包含“共同关注的人”的用户
            //使用LuceneSearchBuilder构建Lucene需要Query、Filter、Sort
            Query  query  = null;
            Filter filter = null;
            Sort   sort   = null;
            LuceneSearchBuilder searchBuilder = new LuceneSearchBuilder();

            searchBuilder.WithFields(FollowedUserIds, myFollowedUserIds.Select(n => n.ToString()), true)
            .NotWithField(UserId, userId.ToString())                                         //排除掉当前用户
            .NotWithFields(UserId, myFollowedUserIds.Select(n => n.ToString()))              //排除掉已关注用户
            .NotWithFields(UserIndexDocument.UserId, stopUserIds.Select(n => n.ToString())); //排除掉黑名单用户
            searchBuilder.BuildQuery(out query, out filter, out sort);

            PagingDataSet <Document> searchResult = searchEngine.Search(query, filter, sort, pageIndex, pageSize);
            IEnumerable <Document>   docs         = searchResult.ToList <Document>();

            if (docs == null || docs.Count() == 0)
            {
                return(new PagingDataSet <User>(new List <User>()));
            }

            List <long> sameFollowedUserIdList = new List <long>();

            //解析出搜索结果中的用户ID
            List <long> followerUserIds = new List <long>();

            foreach (Document doc in docs)
            {
                long followerUserId = long.Parse(doc.Get(UserId));
                followerUserIds.Add(followerUserId);

                //“我”关注的人关注的人
                string[] followedUserIds = doc.GetValues(FollowedUserIds);

                //比较获取“共同关注的人”
                IEnumerable <long> sameFollowedUserIds = myFollowedUserIds.Intersect <long>(followedUserIds.Select(n => Convert.ToInt64(n)));
                if (!followedUserIdDic.ContainsKey(followerUserId))
                {
                    followedUserIdDic.Add(followerUserId, sameFollowedUserIds);
                }

                sameFollowedUserIdList.AddRange(sameFollowedUserIds);
            }

            //批量查询“共同关注的用户”列表
            IEnumerable <User> followerUserList = userService.GetFullUsers(followerUserIds).Where(n => n.IsCanbeFollow == true && n.IsActivated == true && n.IsBanned == false);

            //组装分页对象
            PagingDataSet <User> users = new PagingDataSet <User>(followerUserList)
            {
                TotalRecords  = searchResult.TotalRecords,
                PageSize      = searchResult.PageSize,
                PageIndex     = searchResult.PageIndex,
                QueryDuration = searchResult.QueryDuration
            };

            //批量查询“共同关注的用户”关注的“共同关注用户”列表
            IEnumerable <User> sameFollowedUserList = userService.GetFullUsers(sameFollowedUserIdList.Distinct());

            followedUserDic = sameFollowedUserList.ToDictionary(n => n.UserId);

            return(users);
        }
Esempio n. 18
0
 public override void TestInitialize()
 {
     base.TestInitialize();
     MockXboxLiveData.Load(Environment.CurrentDirectory + "\\Privacy\\MockDataForPrivacyTests.json");
     this.privacyService = XboxLive.Instance.PrivacyService;
 }