Пример #1
0
    protected void LoadSuggestions()
    {
        List <UserFriendsBO> list       = FriendsBLL.getAllSuggestions(userid).Take(4).ToList();
        List <UserFriendsBO> scoredlist = FriendsBLL.RecommendationScoring(list, userid);

        if (scoredlist.Count == 0)
        {
            GridViewSuggestions.DataSource = list;
        }
        else
        {
            GridViewSuggestions.DataSource = scoredlist;
        }
        GridViewSuggestions.DataBind();

        //lbtnFriends.Text = "Friends(" + FriendsBLL.countFriends(userid, Global.CONFIRMED).ToString() + ")";
        //lbtnRequest.Text = "Requests(" + FriendsBLL.countFriendRequests(userid, Global.PENDING).ToString() + ")";
    }
Пример #2
0
    protected void LoadSuggestions(string FilterByListName)
    {
        list  = new List <UserFriendsBO>();
        list2 = new List <UserFriendsBO>();
        List <UserFriendsBO> userlist = new List <UserFriendsBO>();
        List <UserFriendsBO> reclist  = new List <UserFriendsBO>();

        list = getfriends_list(FilterByListName);

        foreach (UserFriendsBO Useritem in list)
        {
            if (VerifyUserItem(Useritem.FirstName, Useritem.LastName))
            {
                userlist.Add(Useritem);
                fid = Useritem.FriendUserId;
            }
            else
            {
                list2.Add(Useritem);
            }
        }

        List <UserFriendsBO> mutualfriendslist     = FriendsBLL.getMutualFriends(Userid, fid, Global.CONFIRMED);
        IEqualityComparer <UserFriendsBO> comparer = new UserFriendsComparer();
        List <UserFriendsBO> l3     = list2.Except(mutualfriendslist, comparer).ToList();
        List <UserFriendsBO> PSlist = FriendsBLL.getPSFriends(fid);
        List <UserFriendsBO> l4     = l3.Except(PSlist, comparer).ToList();

        AllSuggestionsDataList.DataSource = l4;
        AllSuggestionsDataList.DataBind();
        MutualDataList.DataSource = mutualfriendslist;
        MutualDataList.DataBind();

        string belongsto = ListViewBLL.getListName(Userid, fid);

        foreach (UserFriendsBO Useritem in l4)
        {
            Useritem.Score = 0;
            string belongsto1 = ListViewBLL.getListName(Userid, Useritem.FriendUserId);
            string belongsto2 = ListViewBLL.getListName(Useritem.FriendUserId, Userid);

            if (belongsto1.Equals(belongsto) || belongsto2.Equals(belongsto))//if no value specified by user by default true
            {
                Useritem.Score += 1 * Global.WEIGHT_LIST;
            }
        }
        List <UserFriendsBO> scoredlist = FriendsBLL.RecommendationScoring(l4, fid);

        reclist = scoredlist.Take(6).ToList();
        RecSuggestionsDataList.DataSource = reclist;
        RecSuggestionsDataList.DataBind();

        l4 = l4.Except(reclist, comparer).ToList();

        PagedDataSource objPds = new PagedDataSource();

        objPds.DataSource       = l4;
        objPds.AllowPaging      = true;
        objPds.PageSize         = 6;
        objPds.CurrentPageIndex = CurrentPage;
        lblCurrentPage.Text     = "Page: " + (CurrentPage + 1).ToString() + " of " + objPds.PageCount.ToString();

        cmdPrev.Enabled = !objPds.IsFirstPage;
        cmdNext.Enabled = !objPds.IsLastPage;

        AllSuggestionsDataList.DataSource = objPds;
        AllSuggestionsDataList.DataBind();
    }
Пример #3
0
    protected void GetSuggestionsByCriteria()
    {
        string HomeTownValue   = HomeTownTextBox.Text;
        string EmployerValue   = EmployerTextBox.Text;
        string UniversityValue = EducationTextBox.Text;
        string LocationValue   = LocationTextBox.Text;
        string SchoolValue     = SchoolTextBox.Text;

        bool hometownmatches     = false;
        bool employermatches     = false;
        bool unimatches          = false;
        bool locationmatches     = false;
        bool schoolmatches       = false;
        bool mutualfriendmatches = false;



        List <UserFriendsBO> filteredlist = new List <UserFriendsBO>();
        List <UserFriendsBO> list         = new List <UserFriendsBO>();

        list = FriendsBLL.getAllSuggestions(Userid);
        List <UserFriendsBO> scoredlist = FriendsBLL.RecommendationScoring(list, Userid);

        foreach (UserFriendsBO Useritem in scoredlist)
        {
            ArrayList uEmployers  = new ArrayList();
            ArrayList uUniversity = new ArrayList();
            ArrayList uSchool     = new ArrayList();
            ArrayList sEmployers  = new ArrayList();
            ArrayList sUniversity = new ArrayList();
            ArrayList sSchool     = new ArrayList();
            ArrayList uMF         = new ArrayList();

            hometownmatches     = false;
            employermatches     = false;
            unimatches          = false;
            locationmatches     = false;
            schoolmatches       = false;
            mutualfriendmatches = false;

            sEmployers  = EmployerBLL.getEmployersByUserId(Useritem.FriendUserId);
            sUniversity = UniversityDAL.getUnisByUserId(Useritem.FriendUserId);
            sSchool     = SchoolBLL.getSchoolsByUserId(Useritem.FriendUserId);

            if (HomeTownValue.Equals(""))//if no value specified by user by default true
            {
                hometownmatches = true;
            }
            else
            {
                if (Useritem.Hometown != null)
                {
                    hometownmatches = Useritem.Hometown.Equals(HomeTownValue);
                }
            }
            bool mfchecked = false;

            for (int i = 0; i < GridViewMutualFriends.Rows.Count; i++)
            {
                GridViewRow row = GridViewMutualFriends.Rows[i];
                // 0 means the first column if your Select column is not first write it 's correct index
                CheckBox chk = row.Cells[0].FindControl("CheckBox1") as CheckBox;
                if (chk != null && chk.Checked)
                {
                    mfchecked = true;
                    Label  lbl   = (Label)GridViewMutualFriends.Rows[i].Cells[0].FindControl("Label1");
                    string value = lbl.Text;
                    uMF.Add(value);

                    //ListViewBLL.UpdateFriendListSearch(value, list);
                }
            }

            foreach (string umf in uMF)
            {
                if (Useritem.MutualFriendName.Equals(umf))
                {
                    mutualfriendmatches = true;
                }
            }



            //}
            if (mfchecked == false)
            {
                mutualfriendmatches = true;
            }

            bool empchecked = false;

            for (int i = 0; i < GridViewEmps.Rows.Count; i++)
            {
                GridViewRow row = GridViewEmps.Rows[i];
                CheckBox    chk = row.Cells[0].FindControl("CheckBox1") as CheckBox;
                if (chk != null && chk.Checked)
                {
                    empchecked = true;
                    Label  lbl   = (Label)GridViewEmps.Rows[i].Cells[0].FindControl("Label1");
                    string value = lbl.Text;
                    uEmployers.Add(value);
                }
            }
            foreach (string semp in sEmployers)
            {
                foreach (string uemp in uEmployers)
                {
                    if (semp.Equals(uemp))
                    {
                        employermatches = true;
                    }
                }
            }
            //}
            if (empchecked == false)
            {
                if (EmployerValue.Equals(""))
                {
                    employermatches = true;
                }
                else
                {
                    foreach (string semp in sEmployers)
                    {
                        if (semp.Equals(EmployerValue))
                        {
                            employermatches = true;
                        }
                    }
                }
            }
            bool unichecked = false;

            for (int i = 0; i < GridViewUnis.Rows.Count; i++)
            {
                GridViewRow row = GridViewUnis.Rows[i];
                // 0 means the first column if your Select column is not first write it 's correct index
                CheckBox chk = row.Cells[0].FindControl("CheckBox1") as CheckBox;
                if (chk != null && chk.Checked)
                {
                    unichecked = true;
                    Label  lbl   = (Label)GridViewUnis.Rows[i].Cells[0].FindControl("Label1");
                    string value = lbl.Text;
                    uUniversity.Add(value);

                    //ListViewBLL.UpdateFriendListSearch(value, list);
                }
            }
            foreach (string suni in sUniversity)
            {
                foreach (string uuni in uUniversity)
                {
                    if (suni.Equals(uuni))
                    {
                        unimatches = true;
                    }
                }
            }
            //}
            if (unichecked == false)
            {
                if (UniversityValue.Equals(""))
                {
                    unimatches = true;
                }
                else
                {
                    foreach (string sUni in sUniversity)
                    {
                        if (sUni.Equals(UniversityValue))
                        {
                            unimatches = true;
                        }
                    }
                }
            }

            bool schoolchecked = false;

            for (int i = 0; i < GridViewSchool.Rows.Count; i++)
            {
                GridViewRow row = GridViewSchool.Rows[i];
                // 0 means the first column if your Select column is not first write it 's correct index
                CheckBox chk = row.Cells[0].FindControl("CheckBox1") as CheckBox;
                if (chk != null && chk.Checked)
                {
                    schoolchecked = true;
                    Label  lbl   = (Label)GridViewSchool.Rows[i].Cells[0].FindControl("Label1");
                    string value = lbl.Text;
                    uSchool.Add(value);

                    //ListViewBLL.UpdateFriendListSearch(value, list);
                }
            }
            foreach (string sschool in sSchool)
            {
                foreach (string uschool in uSchool)
                {
                    if (sschool.Equals(uSchool))
                    {
                        schoolmatches = true;
                    }
                }
            }
            //}
            if (schoolchecked == false)
            {
                if (SchoolValue.Equals(""))
                {
                    schoolmatches = true;
                }
                else
                {
                    foreach (string sschool in sSchool)
                    {
                        if (sschool.Equals(SchoolValue))
                        {
                            schoolmatches = true;
                        }
                    }
                }
            }

            if (LocationValue.Equals(""))
            {
                locationmatches = true;
            }
            else
            {
                if (Useritem.Location != null)
                {
                    locationmatches = Useritem.Location.Equals(LocationValue);
                }
            }
            if (hometownmatches && employermatches && unimatches && locationmatches && schoolmatches && mutualfriendmatches)
            {
                filteredlist.Add(Useritem);
            }
        }
        GridViewFriendsList.DataSource = null;
        GridViewFriendsList.DataBind();
        if (!MutualFriendsFetched)
        {
            //get the top 2 mutual friends for filter options//only for the first time
            foreach (UserFriendsBO uitem in filteredlist)
            {
                if (uitem.MutualFriendsCount > 0)
                {
                    if (!mutualFriends.Contains(uitem.MutualFriendName))
                    {
                        mutualFriends.Add(uitem.MutualFriendName);
                    }
                }
            }
            MutualFriendsFetched = true;
        }
        GridViewFriendsList.DataSource = filteredlist;
        GridViewFriendsList.DataBind();
    }