Exemplo n.º 1
0
        private void BindgridGroup(ListFbGroupSearch model)
        {
            try
            {
                var items = (from p in model.FbGroupSearch
                             select new
                {
                    p.id,
                    p.name,
                    avata = p.cover == null ? null : ConvertType.GetImageFromUrl(p.cover.source),
                    p.description
                }).ToList();

                var source = new BindingSource();
                source.DataSource = items;

                gridGroup.Invoke((Action) delegate
                {
                    gridGroup.DataSource = source;
                });
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "BindgridPage");
            }
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string requestUriString = "";
            string strToken         = "";

            try
            {
                if (txtSearch.Text == "")
                {
                    MessageBox.Show("Vui Lòng nhập thông tin tìm kiếm", "Thông báo");
                    return;
                }
                strToken = Facebook.Token(_arrController);
                if (strToken == "")
                {
                    MessageBox.Show("Bạn đã hết Quata token để thực thi việc gọi API của Facebook \n Vui lòng nạp Acc mới hay chờ đến ngày hôm sau.", "Thông báo");
                    return;
                }
                ;
                string strNoidungtimkiem = Uri.EscapeDataString(txtSearch.Text);

                switch (tabControl1.SelectedIndex)
                {
                case 1:     /*Page*/
                    requestUriString = string.Format(@"https://graph.facebook.com/search?q={0}&type={1}&limit={2}&fields={3}&access_token={4}", strNoidungtimkiem, "page", LimitTopSearch.Value, Facebook.SelectPage(), strToken);
                    new Waiting((MethodInvoker) delegate {
                        ListFbPageSearch model = TheardFacebookWriter.FbSearchByPage(requestUriString, _arrController, strToken, _gioihantimkiemfb);
                        if (model.FbPageSearch.Count() != 0)
                        {
                            BindgridPage(model);
                            return;
                        }
                    }, "Vui Lòng Chờ...").ShowDialog();

                    break;

                case 0:
                    requestUriString = string.Format(@"https://graph.facebook.com/search?q={0}&type={1}&limit={2}&fields={3}&access_token={4}", strNoidungtimkiem, "user", LimitTopSearch.Value, Facebook.SelectUser(), strToken);
                    new Waiting((MethodInvoker) delegate {
                        ListFbUserSearch model = TheardFacebookWriter.FbSearchByUser(requestUriString, _arrController, strToken, _gioihantimkiemfb);
                        if (model.FbUserSearch.Count() != 0)
                        {
                            BindgridUser(model);
                            //return;
                        }
                    }, "Vui Lòng Chờ...").ShowDialog();
                    break;

                case 2:    /*group*/
                    requestUriString = string.Format(@"https://graph.facebook.com/search?q={0}&limit={1}&fields={2}&type={3}&access_token={4}", strNoidungtimkiem, LimitTopSearch.Value, Facebook.SelectGroup(), "group", strToken);
                    new Waiting((MethodInvoker) delegate {
                        ListFbGroupSearch model = TheardFacebookWriter.FbSearchByGroup(requestUriString, _arrController, strToken, _gioihantimkiemfb);
                        if (model.FbGroupSearch.Count() != 0)
                        {
                            BindgridGroup(model);
                            //return;
                        }
                    }, "Vui Lòng Chờ...").ShowDialog();
                    break;
                }
                MessageBox.Show(string.Format("Đã xử lý"), "Thông Báo");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "button1_Click");
            }
        }