Exemplo n.º 1
0
    protected void LoadUserEmployersFilterItems(string userid)
    {
        ArrayList sEmployers;

        sEmployers = EmployerBLL.getEmployersByUserId(userid);
        GridViewEmps.DataSource = sEmployers;

        GridViewEmps.DataBind();
    }
Exemplo n.º 2
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();
    }