예제 #1
0
        private void btnTieuCuc_Click(object sender, EventArgs e)
        {
            //lưu thông tin tài khoản
            tblUserFB newu = new tblUserFB();

            newu.IDUser = lsIDUserBinhLuan[LsNguoiDungBL.FocusedItem.Index].ToString();
            newu.Name   = LsNguoiDungBL.FocusedItem.Text;
            UserFB.Them(newu);
            //lưu thông tin tài khoản
            //lưu dữ liệu bình luận
            tblCommentPost newcp = new tblCommentPost();

            newcp.IDComment   = lsIDBinhLuan[LsNguoiDungBL.FocusedItem.Index].ToString();
            newcp.IDPost      = idpost;
            newcp.IDUser      = lsIDUserBinhLuan[LsNguoiDungBL.FocusedItem.Index].ToString();
            newcp.Status      = -5;
            newcp.Description = lsNoiDungBL[LsNguoiDungBL.FocusedItem.Index].ToString();
            newcp.TimeComment = lsTimeBinhLuan[LsNguoiDungBL.FocusedItem.Index];
            CommentPost.Them(newcp);
            //kết thúc lưu dữ liệu bình luận
            // loai bỏ item trong danh sách
            lsIDBinhLuan.RemoveAt(LsNguoiDungBL.FocusedItem.Index);
            lsNoiDungBL.RemoveAt(LsNguoiDungBL.FocusedItem.Index);
            lsIDUserBinhLuan.RemoveAt(LsNguoiDungBL.FocusedItem.Index);
            LsNguoiDungBL.Items.RemoveAt(LsNguoiDungBL.FocusedItem.Index);
            //kết thúc loại bỏ item trong danh sách
            txtNoiDungBinhLuan.Text = null;
        }
        //kết thúc tìm kiếm bài viết theo idpage

        //cập nhật thông tin người dùng
        public static void UpdateTTNguoiDung()
        {
            DataTable dt = UserFB.LoadDuLieuChuaUpdate();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                try
                {
                    WebBrowser web = new WebBrowser();
                    web.Navigate("https://mobile.facebook.com" + dt.Rows[i]["IDUser"]);
                    while (web.ReadyState != WebBrowserReadyState.Complete)
                    {
                        Application.DoEvents();
                    }
                    string htmlcontent = web.DocumentText;
                    htmlcontent = htmlcontent.Replace("amp;", "");
                    string idnumber = htmlcontent.Substring(htmlcontent.IndexOf("&id=") + 4);
                    idnumber = idnumber.Remove(idnumber.IndexOf("&"));
                    string linkimg = htmlcontent.Substring(htmlcontent.IndexOf("u_0_") + 10);
                    linkimg = linkimg.Substring(linkimg.IndexOf("https://z-p3-scontent.fhan7-1"));
                    linkimg = linkimg.Remove(linkimg.IndexOf("\""));
                    tblUserFB ufb = new tblUserFB();
                    ufb.IDUser   = dt.Rows[i]["IDUser"].ToString();
                    ufb.IDNumber = idnumber;
                    ufb.ImgLink  = linkimg;
                    UserFB.Sua(ufb);
                }
                catch { }
            }
            //cập nhật thông tin trạng thái người dùng
            MessageBox.Show("Đã cập nhật thành công");
        }
        //kết thúc cập nhật thông tin người dùng
        //tính điểm người dùng facebook
        public static void UpdateStatusUserFB()
        {
            DataTable dt = UserFB.LoadDuLieu();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                UserFB.CapNhatStatus(dt.Rows[i]["IDUser"].ToString());
            }
            MessageBox.Show("Đã cập nhật thành công điểm");
        }
예제 #4
0
        private void LoadNguoiDung()
        {
            DataTable nguoitichcuc = UserFB.LoadDuLieuTichCuc();
            DataTable nguoitieucuc = UserFB.LoadDuLieuTieuCuc();

            lsNguoiDungTichCuc.Items.Clear();
            lsNguoiDungTieuCuc.Items.Clear();
            ImageList imglisttichcuc = new ImageList();

            imglisttichcuc.ImageSize = new Size(40, 40);
            ImageList imglisttieucuc = new ImageList();

            imglisttieucuc.ImageSize = new Size(40, 40);
            for (int i = 0; i < nguoitichcuc.Rows.Count; i++)
            {
                lsNguoiDungTichCuc.Items.Add(nguoitichcuc.Rows[i]["Name"].ToString(), i);
                idnguoidungtichcuc.Add(nguoitichcuc.Rows[i]["IDNumber"].ToString());
                WebClient webClient = new WebClient();
                string    urlimg    = nguoitichcuc.Rows[i]["ImgLink"].ToString();
                byte[]    data;
                try
                {
                    data = webClient.DownloadData(urlimg);
                }
                catch
                {
                    urlimg = "https://z-p3-scontent.fhan7-1.fna.fbcdn.net/v/t1.0-1/cp0/e15/q65/c19.0.64.64/p64x64/10354686_10150004552801856_220367501106153455_n.jpg?_nc_cat=1&efg=eyJpIjoiYiJ9&oh=aa3384ecfcdd7529ca4458c6c4fd5ad9&oe=5C23A3FC";
                    data   = webClient.DownloadData(urlimg);
                }

                MemoryStream mem = new MemoryStream(data);
                imglisttichcuc.Images.Add(Image.FromStream(mem));
            }
            for (int i = 0; i < nguoitieucuc.Rows.Count; i++)
            {
                try
                {
                    lsNguoiDungTieuCuc.Items.Add(nguoitieucuc.Rows[i]["Name"].ToString(), i);
                    idnguoidungtieucuc.Add(nguoitieucuc.Rows[i]["IDNumber"].ToString());
                    WebClient    webClient = new WebClient();
                    string       url       = nguoitieucuc.Rows[i]["ImgLink"].ToString();
                    byte[]       data      = webClient.DownloadData(nguoitieucuc.Rows[i]["ImgLink"].ToString());
                    MemoryStream mem       = new MemoryStream(data);
                    imglisttieucuc.Images.Add(Image.FromStream(mem));
                }
                catch { }
            }
            lsNguoiDungTichCuc.SmallImageList = imglisttichcuc;
            lsNguoiDungTieuCuc.SmallImageList = imglisttieucuc;
        }
        public void DataModelTestsFB()
        {
            var    response = "{\"id\":\"123\",\"first_name\": \"Micheal\",\"gender\": \"male\",\"last_name\": \"Catala\",\"email\": \"abc.com\",\"link\": \"[email protected]\",\"location\": {\"name\":\"India\"},\"verified\": true,\"name\": \"Micheal Catala\",\"picture\": {\"data\": {\"height\": 50,\"url\": \"[email protected]\",\"width\": 50}}}";
            UserFB user     = JsonConvert.DeserializeObject <UserFB>(response);

            response = "{\"id\": \"123\",\"category\": \"Test\",\"checkins\": 0,\"link\": \"abc/123\",\"name\": \"Testing\",\"likes\":3,\"description\":\"Page Desciption\"}";
            UserLocationFB location = JsonConvert.DeserializeObject <UserLocationFB>(response);

            response = "{\"data\":[{\"id\": \"notif_4\",\"from\": {\"name\": \"Micheal Catala\",\"id\": \"1012\"},\"created_time\": \"2018-03-07T07:28:33+0000\",\"updated_time\": \"2018-03-07T07:32:13+0000\",\"title\": \"Micheal Catala and Onkar Singh commented on your post.\",\"link\": \"link\",\"unread\": 1,\"object\": {\"created_time\": \"2018-03-07T07:27:52+0000\",\"message\": \"Running from Job Manager\",\"story\": \"story\",\"id\": \"123\"}}],\"paging\": {\"previous\": \"abc\",},\"summary\": {\"unseen_count\": 2,\"updated_time\": \"2018-04-23T06:03:45+0000\"}}";
            NotificationFB notification = JsonConvert.DeserializeObject <NotificationFB>(response);

            response = "{\"data\":[{\"id\":\"abc\",\"name\":\"abc\",\"type\":\"abc\",\"offset\":1,\"length\":1}],\"paging\": {\"previous\": \"abc\",}}";
            MessageTagsFB tags = JsonConvert.DeserializeObject <MessageTagsFB>(response);

            response = "{\"id\":\"abc\",\"name\":\"abc\",\"access_token\":\"abc\"}";
            PageFB page = JsonConvert.DeserializeObject <PageFB>(response);
        }
예제 #6
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            // cập nhật thông tin bài viết
            tblPost p = new tblPost();

            p.IDPost       = idpost;
            p.TimePost     = DateTime.Parse(timepost);
            p.CountComment = tongsocomment;
            p.CountLike    = int.Parse(tongsoluonglike);
            if (danhgia == "Tích cực")
            {
                p.Status = "Tích cực";
            }
            else
            {
                p.Status = "Tiêu cực";
            }
            Post.Sua(p);
            // kết thúc cập nhật thông tin bài viết

            //thêm tài khoản người dùng
            for (int i = 0; i < lsIDTichCuc.Count; i++)
            {
                tblUserFB   newu  = new tblUserFB();
                tblLikePost newlp = new tblLikePost();
                newu.IDUser = lsIDTichCuc[i].ToString();
                newu.Name   = lsNameTichCuc[i].ToString();
                UserFB.Them(newu);
                newlp.IDPost   = idpost;
                newlp.IDUserFB = lsIDTichCuc[i].ToString();
                newlp.Status   = 1;
                LikePost.Them(newlp);
            }
            for (int i = 0; i < lsIDTieuCuc.Count; i++)
            {
                tblUserFB   newu  = new tblUserFB();
                tblLikePost newlp = new tblLikePost();
                newu.IDUser = lsIDTieuCuc[i].ToString();
                newu.Name   = lsNameTieuCuc[i].ToString();
                UserFB.Them(newu);
                newlp.IDPost   = idpost;
                newlp.IDUserFB = lsIDTieuCuc[i].ToString();
                newlp.Status   = -1;
                LikePost.Them(newlp);
            }
            //thêm từ những người bình luận
            for (int i = 0; i < LsNguoiDungBL.Items.Count; i++)
            {
                tblUserFB newu = new tblUserFB();
                newu.IDUser = lsIDUserBinhLuan[i];
                newu.Name   = LsNguoiDungBL.Items[i].Text;
                UserFB.Them(newu);

                //lưu người dùng bình luận vào sql
                tblCommentPost newcommentpost = new tblCommentPost();
                newcommentpost.IDPost      = idpost;
                newcommentpost.IDComment   = lsIDBinhLuan[i].ToString();
                newcommentpost.IDUser      = lsIDUserBinhLuan[i];
                newcommentpost.Description = lsNoiDungBL[i];
                newcommentpost.Status      = 0;

                CommentPost.Them(newcommentpost);
                //kết thúc lưu người dùng bình luận
            }
            //kết thúc thêm tài khoản
            MessageBox.Show("Đã lưu tất cả thông tin!");
        }