Ejemplo n.º 1
0
 protected void LoadMySingleFriends(User.eGenderSearch gender)
 {
     var user = PageBase.GetCurrentUserSession();
     var genderFriendsSearch = new QuickSingleFriendsSearch
     {
         UsersCount = RepeatColumns * LimitRows,
         PageNumber = 0,
         MaxAge = Math.Min(user.IncomingMessagesRestrictions.AgeTo, Config.Users.MaxAge),
         MinAge = Math.Max(user.IncomingMessagesRestrictions.AgeFrom, Config.Users.MinAge),
         MatchmakerUsername = user.Username,
         FriendGender = gender
     };
     Results = genderFriendsSearch.GetResults();
 }
Ejemplo n.º 2
0
        private void MySingleFriends(User.eGenderSearch gender)
        {
            if (HttpContext.Current == null)
                HttpContext.Current = itsContext;
            ProcessMenuButtonClick(lnkQuickFriendsSearch,
                "Quick Friends Search",
                "Friends Search Results", false);

            if (CurrentUserSession == null) return;

            var search = new QuickSingleFriendsSearch
                             {
                                 MatchMaker = CurrentUserSession,
                                 MatchmakerUsername = CurrentUserSession.Username,
                                 FriendGender = gender
                             };
            //if (CurrentUserSession != null) search.ExcludeUsername.Add(CurrentUserSession.Username);
            //if (MatchmakerHelper.IsMatchToFriendAlredySelected) search.ExcludeUsername.Add(MatchmakerHelper.MatchToUsername);            
            SearchResults.Results = new FacebookAndUsersMergeResults
                                        {
                                            Usernames = search.GetResults().Usernames,
                                            FacebookIds = null
                                        };
        }
        //protected void Page_PreRenderComplete(object sender, EventArgs e)
        protected override void OnPreRender(EventArgs e)
        {
            DataListGenderFriends.RepeatColumns = RepeatColumns;
        //}

        //protected override void OnPreRender(EventArgs e)
        //{
        //    base.OnPreRender(e);

            #region Load New Users (thumbnails)
            UserSession matchmaker = PageBase.GetCurrentUserSession();
            DataTable dtGenderFriends;

            string cacheKey = String.Format("GenderFriendsWebPart_{0}_{1}_{2}_{3}_{4}", matchmaker.Username,
                SearchGender == User.eGenderSearch.All ? "null" : SearchGender.ToString(), MinAge, MaxAge, LimitRows);
            if (Cache[cacheKey] != null && Cache[cacheKey] is DataTable && Global.GetSessionState()["theme"] == null)
            {
                dtGenderFriends = (DataTable)Cache[cacheKey];
            }
            else
            {
                var genderFriendsSearch = new QuickSingleFriendsSearch
                                   {
                                       UsersCount = RepeatColumns * LimitRows,
                                       PageNumber = 0,
                                       MinAge = MinAge,
                                       MaxAge = MaxAge,
                                       MatchmakerUsername = matchmaker.Username
                                   };
                if (SearchGender != User.eGenderSearch.All)
                    genderFriendsSearch.FriendGender = SearchGender;
                UserSearchResults friendsResults = genderFriendsSearch.GetResults();
                dtGenderFriends = new DataTable();
                dtGenderFriends.Columns.Add("Username");
                dtGenderFriends.Columns.Add("ImageId", typeof(int));
                dtGenderFriends.Columns.Add("Age");
                dtGenderFriends.Columns.Add("Gender");
                dtGenderFriends.Columns.Add("InterestedIn");
                dtGenderFriends.Columns.Add("Country");
                dtGenderFriends.Columns.Add("City");
                
                if (friendsResults != null && friendsResults.Usernames != null)
                {
                    foreach (string username in friendsResults.Usernames)
                    {
                        int imageId = 0;
                        User user = null;

                        try { user = User.Load(username); }
                        catch (NotFoundException){continue;}

                        imageId = Photo.GetTopOrPrimaryOrDefaultId(username);

                        string age = !Config.Users.DisableAgeInformation ? user.Age.ToString() : String.Empty;
                        string gender = !Config.Users.DisableGenderInformation ? user.Gender.ToString() : String.Empty;
                        string interestedIn = !Config.Users.DisableGenderInformation ? user.InterestedIn.ToString() : String.Empty;
                        dtGenderFriends.Rows.Add(
                            new object[]
                                {
                                    username, imageId, age, gender, interestedIn, user.Country, user.City
                                });
                    }

                    Cache.Add(cacheKey, dtGenderFriends, null, DateTime.Now.Add(TimeSpan.FromMinutes(10)),
                              Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null);
                }
            }

            DataListGenderFriends.DataSource = dtGenderFriends;
            DataListGenderFriends.DataBind();
            //base.Page_PreRenderComplete(sender, e);
            base.OnPreRender(e);
            #endregion
        }