public async Task <PaginatedResponseExtended <IEnumerable <UserInformationBaseExtendedResponse>, int> > GetMutualFriends(PaginatedRequest <string> request, SystemSession session)
        {
            var serviceRequest = new MutualFriend
            {
                UserId     = session.UserId,
                TargetType = "F",
                TargetUser = request.Data,
                PageIndex  = request.PageIndex,
                PageSize   = request.PageSize
            };

            var data = await Task.Factory.StartNew(() => Client.UserService.getMutualFriends(serviceRequest, session.GetSession())).ConfigureAwait(false);

            var result = new PaginatedResponseExtended <IEnumerable <UserInformationBaseExtendedResponse>, int>
            {
                Page = data.MutualFriends.Select(x => new UserInformationBaseExtendedResponse
                {
                    UserId     = x.UserId,
                    UserName   = x.UserName,
                    UserTypeId = (SystemUserType)x.UserTypeId,
                    FirstName  = x.FirstName,
                    LastName   = x.LastName,
                    Image      = x.Picture,
                    Title      = x.Title
                }),
                HasNextPage = data.HasNextPage,
                Information = data.Count
            };

            return(result);
        }
Exemple #2
0
    public List <MutualFriend> GetMutualFriends(string WebMemberID)
    {
        member = (Member)Session["Member"];

        if (member == null)
        {
            Utility.RememberMeLogin();
        }

        Member MutualMember = Member.GetMemberViaWebMemberID(WebMemberID);

        if (member == null)
        {
            return(new List <MutualFriend>());
        }

        List <Member>       MutualMembers = Friend.GetMutualFriends(MutualMember, member);
        List <MutualFriend> MutualFriends = new List <MutualFriend>();

        for (int i = 0; i < MutualFriends.Count; i++)
        {
            MutualFriend MutualFriend = new MutualFriend();
            MutualFriend.Name     = MutualMembers[i].FirstName;
            MutualFriend.PhotoURL = MutualMembers[i].DefaultPhoto.FullyQualifiedURL;

            MutualFriends.Add(MutualFriend);
        }

        return(MutualFriends);
    }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            startAccount = "";
            destAccount  = "";

            if (comboBoxChooseAccount.SelectedIndex == -1)
            {
                MessageBox.Show("Choose an account to begin with");
            }
            else
            {
                startAccount = comboBoxChooseAccount.SelectedItem.ToString();
            }

            networkGraph = new Graph(startAccount);
            List <string> acc = new List <string>();

            foreach (string item in people)
            {
                if (item != startAccount)
                {
                    acc.Add(item);
                }
            }

            String[] account = acc.ToArray();

            for (int i = 0; i < account.Length; i++)
            {
                networkGraph.InsertNode(account[i]);
            }

            for (int i = 1; i < fileContent.Length; i++)
            {
                int j = 0;

                while (fileContent[i][j] != ' ')
                {
                    j++;
                }

                networkGraph.InsertEdge(fileContent[i].Substring(0, j), fileContent[i].Substring(j + 1, fileContent[i].Length - j - 1));
            }

            if (comboBoxExploreFriends.SelectedIndex != -1)
            {
                destAccount = comboBoxExploreFriends.SelectedItem.ToString();

                if (radioButtonBFS.Checked)
                {
                    bfs = new BreadthFirstSearch(networkGraph, startAccount);
                    bfs.RunBFS();
                    bfsPath = bfs.Path(destAccount);
                    bfsPath.Reverse();
                    int    level     = bfs.PrintLevel(destAccount);
                    string resultBFS = "Nama akun: " + startAccount + " dan " + destAccount + "\r\n";
                    if (level != -1)
                    {
                        resultBFS += level.ToString() + "th degree connection \r\n";
                        resultBFS += dfs.PrintStringDFS(dfsPath);
                    }
                    else
                    {
                        resultBFS += "Tidak ada jalur koneksi yang tersedia \r\n";
                        resultBFS += "Anda harus memulai koneksi baru itu sendiri. \r\n";
                    }
                    textBoxResult.Text = resultBFS;
                    //colorGraph(fileContent, bfsPath);
                }

                else if (radioButtonDFS.Checked)
                {
                    dfs = new DepthFirstSearch(networkGraph, startAccount);
                    dfs.RunDFS();
                    dfsPath = dfs.Path(destAccount);
                    dfsPath.Reverse();
                    int    degree    = dfs.PrintInterval(destAccount);
                    string resultDFS = "";
                    resultDFS += "Nama akun: " + startAccount + " dan " + destAccount + "\r\n";
                    if (degree != -1)
                    {
                        resultDFS += degree.ToString() + "th degree connection \r\n";
                        resultDFS += dfs.PrintStringDFS(dfsPath);
                    }
                    else
                    {
                        resultDFS += "Tidak ada jalur koneksi yang tersedia \r\n";
                        resultDFS += "Anda harus memulai koneksi baru itu sendiri. \r\n";
                    }
                    textBoxResult.Text = resultDFS;
                    //colorGraph(fileContent, dfsPath);
                }
                else
                {
                    MessageBox.Show("Please select an algorithm");
                }
            }
            else
            {
                friendRec = new MutualFriend(networkGraph, startAccount);
                //friendRec.FindMutualFriend();
                string resultFriend = "Daftar rekomendasi teman untuk akun " + startAccount + "\r\n";
                resultFriend           += friendRec.PrintHasil();
                textBoxResult.Multiline = true;
                textBoxResult.Text      = resultFriend;
                MessageBox.Show(resultFriend);
            }

            //colorGraph(fileContent, startAccount, destAccount);
        }
Exemple #4
0
    public List<MutualFriend> GetMutualFriends(string WebMemberID)
    {
        member = (Member)Session["Member"];

        if (member == null)
        {
            Utility.RememberMeLogin();
        }

        Member MutualMember = Member.GetMemberViaWebMemberID(WebMemberID);

        if (member == null)
        {
            return new List<MutualFriend>();
        }

        List<Member> MutualMembers = Friend.GetMutualFriends(MutualMember, member);
        List<MutualFriend> MutualFriends = new List<MutualFriend>();

        for (int i = 0; i < MutualFriends.Count; i++)
        {
            MutualFriend MutualFriend = new MutualFriend();
            MutualFriend.Name = MutualMembers[i].FirstName;
            MutualFriend.PhotoURL = MutualMembers[i].DefaultPhoto.FullyQualifiedURL;

            MutualFriends.Add(MutualFriend);
        }

        return MutualFriends;
    }