Esempio n. 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         CsvRow row = new CsvRow();
         if (m_name_new_group.Text == "")
         {
             MessageBox.Show("Chưa nhập tên nhóm mới");
             return;
         }
         if (m_lb_me_list_group.CheckedItems.Count <= 0)
         {
             MessageBox.Show("Chưa chọn group");
             return;
         }
         row.Add(m_name_new_group.Text.Trim());
         for (int i = 0; i < m_lb_me_list_group.CheckedItems.Count; i++)
         {
             groups v_g = (groups)m_lb_me_list_group.CheckedItems[i];
             row.Add(v_g.Id);
         }
         CsvFile writer = new CsvFile();
         writer.WriteRow(row, "Group.csv");
         MessageBox.Show("Tạo nhóm group thành công !");
         //load_nhom();
     }
     catch (Exception v_e)
     {
         MessageBox.Show("Có tý tẹo vấn đề. Bạn chụp ảnh và gửi để chúng tôi hỗ trợ nhé!" + v_e.ToString());
     }
 }
Esempio n. 2
0
        private void m_cmd_from_list_Click(object sender, EventArgs e)
        {
            OpenFileDialog fdlg = new OpenFileDialog();

            fdlg.Title            = "Select file";
            fdlg.InitialDirectory = @"c:\";
            fdlg.Filter           = "Excel Sheet(*.xls)|*.xls|All Files(*.*)|*.*";
            fdlg.FilterIndex      = 1;
            fdlg.RestoreDirectory = true;
            if (fdlg.ShowDialog() == DialogResult.OK)
            {
                Application.DoEvents();
            }
            string           pathConn      = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fdlg.FileName + ";Extended Properties=\"Excel 8.0;HDR=Yes;\";";
            OleDbConnection  conn          = new OleDbConnection(pathConn);
            OleDbDataAdapter myDataAdapter = new OleDbDataAdapter("Select * from [" + "Sheet1" + "$]", conn);
            DataTable        dt            = new DataTable();

            myDataAdapter.Fill(dt);
            List <groups> v_list = new List <groups>();

            foreach (DataRow item in dt.Rows)
            {
                groups v_g = new groups();
                v_g.Id   = item["Id"].ToString();
                v_g.Name = item["Name"].ToString();
                v_list.Add(v_g);
            }
            m_lb_group_list.DataSource    = v_list;
            m_lb_group_list.ValueMember   = "Id";
            m_lb_group_list.DisplayMember = "Name";
            m_chk_all_group.Text          = "Tất cả " + v_list.Count.ToString() + " group";
        }
Esempio n. 3
0
        private void m_cmd_tim_kiem_Click(object sender, EventArgs e)
        {
            FacebookClient fb           = new FacebookClient(globalInfo.access_token);
            List <groups>  v_list_group = new List <groups>();

            if (m_txt_tim_kiem.Text.Trim().Length > 0)
            {
                dynamic result = fb.Get("search?q=" + m_txt_tim_kiem.Text.Trim() + "&type=group");
                foreach (var g in (JsonArray)result["data"])
                {
                    groups group = new groups()
                    {
                        Id = (string)(((JsonObject)g)["id"]), Name = (string)(((JsonObject)g)["name"])
                    };
                    v_list_group.Add(group);
                }
                m_cbl_group.DataSource    = v_list_group;
                m_cbl_group.DisplayMember = "Name";
                m_cbl_group.ValueMember   = "Id";
            }
            else
            {
                MessageBox.Show("Bạn phải nhập từ khóa tìm kiếm");
            }
        }
Esempio n. 4
0
        public void Display_post()
        {
            try
            {
                FacebookClient fb    = new FacebookClient(globalInfo.access_token);
                var            roles = new List <groups>();
                dynamic        data  = fb.Get("/me/likes?fields=id,name&limit=500");

                foreach (var v_g in (JsonArray)data["data"])
                {
                    groups group = new groups()
                    {
                        Id = (string)(((JsonObject)v_g)["id"]), Name = (string)(((JsonObject)v_g)["name"])
                    };
                    roles.Add(group);
                }
                m_SortedList = roles.OrderBy(o => o.Name).ToList();
                for (int i = 0; i < m_SortedList.Count; i++)
                {
                    m_cbl_group.Items.Add(m_SortedList[i].Name);
                }
            }
            catch (Exception v_e)
            {
                MessageBox.Show("Có tý tẹo vấn đề. Bạn chụp ảnh và gửi để chúng tôi hỗ trợ nhé!" + v_e.ToString());
            }
        }
Esempio n. 5
0
        private void m_bgw_DoWork(object sender, DoWorkEventArgs e)
        {
            float length = m_cbl_group.CheckedItems.Count;

            m_pgb_group.Invoke((Action)(() => m_pgb_group.Maximum = m_cbl_group.CheckedItems.Count));
            for (int i = 0; i < length; i++)
            {
                m_bgw.ReportProgress(i + 1);
                try
                {
                    request v_r = new request();
                    groups  v_g = (groups)m_cbl_group.CheckedItems[i];
                    v_r.group_id = v_g.Id;
                    v_r.user_id  = m_uid;
                    v_r.dtsg     = m_dtsg;
                    v_r.request_2_fb("https://www.facebook.com/ajax/groups/membership/r2j.php", "POST");
                    if (i + 1 < m_cbl_group.CheckedItems.Count)
                    {
                        Thread.Sleep(20000);
                    }
                }
                catch (Exception)
                {
                }
            }
            m_bgw.ReportProgress(100);
        }
Esempio n. 6
0
        private void post_2_facebook(groups item)
        {
            dynamic result;
            string  v_path      = Directory.GetCurrentDirectory();
            string  v_url_image = "";

            try
            {
                if (m_b_upload)
                {
                    v_url_image = "http://bkindex.uphero.com/" + Path.GetFileName(m_txt_url_image.Text);
                    //m_b_upload = false;
                }
                else
                {
                    v_url_image = m_txt_url_image.Text;
                }
                if (m_b_has_image)
                {
                    FacebookClient fb         = new FacebookClient(globalInfo.access_token);
                    dynamic        parameters = new ExpandoObject();
                    parameters.url     = v_url_image;
                    parameters.message = m_txt_message.Text;
                    result             = fb.Post(item.Id + "/photos", parameters);
                }
                else
                {
                    FacebookClient fb         = new FacebookClient(globalInfo.access_token);
                    dynamic        parameters = new ExpandoObject();
                    parameters.message     = m_txt_message.Text;
                    parameters.link        = m_txt_url_image.Text;
                    parameters.picture     = link;
                    parameters.caption     = caption;
                    parameters.description = description;
                    result = fb.Post(item.Id + "/feed", parameters);
                }
                string p_id = result["id"];
                System.IO.StreamWriter file = new System.IO.StreamWriter(v_path + "\\postId.txt", true);
                file.WriteLine(m_uid + "_" + p_id);
                file.WriteLine(item.Name);
                if (m_txt_message.Text.Length > 30)
                {
                    file.WriteLine(m_txt_message.Text.Substring(0, 30));
                }
                else
                {
                    file.WriteLine(m_txt_message.Text.Trim());
                }
                file.Close();
            }
            catch (Exception)
            {
            }
        }
Esempio n. 7
0
        private void m_text_search_group_TextChanged(object sender, EventArgs e)
        {
            try
            {
                m_status_search = false;
                List <groups> v_filterList  = new List <groups>();
                List <groups> v_checkedlist = new List <groups>();

                //1. Lấy danh sách các group thỏa mãn tìm kiếm
                FacebookClient fb        = new FacebookClient(access_token);
                var            me_groups = new List <groups>();
                dynamic        data      = fb.Get("/me/groups");
                foreach (var friend in (JsonArray)data["data"])
                {
                    groups group = new groups()
                    {
                        Id = (string)(((JsonObject)friend)["id"]), Name = (string)(((JsonObject)friend)["name"])
                    };
                    me_groups.Add(group);
                }
                foreach (groups v_group in me_groups)
                {
                    if (v_group.Name.ToLower().Contains(m_text_search_group.Text.ToLower()))
                    {
                        int index = v_filterList.FindIndex(item => item.Id == v_group.Id);
                        if (index < 0)
                        {
                            v_filterList.Add(v_group);
                        }
                    }
                }

                //2. Đưa danh sách lên LIST
                if (m_text_search_group.Text.Trim().Length == 0)
                {
                    m_lb_me_list_group.DataSource = me_groups;
                }
                else
                {
                    m_lb_me_list_group.DataSource = v_filterList;
                }
                m_lb_me_list_group.DisplayMember = "Name";
                m_lb_me_list_group.ValueMember   = "Id";
                m_status_search = true;
            }
            catch (Exception v_e)
            {
                MessageBox.Show("Có tý tẹo vấn đề. Bạn chụp ảnh và gửi để chúng tôi hỗ trợ nhé!" + v_e.ToString());
            }
        }
Esempio n. 8
0
 private void m_cbl_list_group_ItemCheck(object sender, ItemCheckEventArgs e)
 {
     if (!m_check_bang_tay)
     {
         return;
     }
     if (e.NewValue == CheckState.Checked)
     {
         groups v_g = new groups();
         v_g = (groups)m_cbl_list_group.Items[e.Index];
         m_lst_group_chon_bang_tay.Add(v_g.Id);
     }
     else
     {
         m_lst_group_chon_bang_tay.Remove(m_lst_group_chon_bang_tay.Find(x => x == ((groups)m_cbl_list_group.Items[e.Index]).Id));
     }
 }
Esempio n. 9
0
        private void comment2Top5(groups ip_group)
        {
            List <string>  v_id_post = new List <string>();
            FacebookClient fb        = new FacebookClient(globalInfo.access_token);
            dynamic        result    = fb.Get(ip_group.Id + "/feed?fields=id&limit=5");

            foreach (var pid in (JsonArray)result["data"])
            {
                string id = (string)(((JsonObject)pid)["id"]);
                v_id_post.Add(id);
            }
            foreach (string item in v_id_post)
            {
                dynamic parameters = new ExpandoObject();
                parameters.message = m_txt_message.Text;
                var v_result = fb.Post("/" + item + "/comments", parameters);
            }
        }
Esempio n. 10
0
        private void load_group_list()
        {
            if (m_lb_friend_list.Items.Count > 0)
            {
                m_chk_all_group.Checked = false;
                FacebookClient fb = new FacebookClient(access_token);

                dynamic data = fb.Get("/me/groups");
                foreach (var friend in (JsonArray)data["data"])
                {
                    groups group = new groups()
                    {
                        Id = (string)(((JsonObject)friend)["id"]), Name = (string)(((JsonObject)friend)["name"])
                    };
                    me_groups.Add(group);
                }

                var    roles = new List <groups>();
                string pid   = ((groups)m_lb_friend_list.SelectedItem).Id;
                data = fb.Get("/" + pid + "/groups");
                foreach (var friend in (JsonArray)data["data"])
                {
                    groups gr = new groups()
                    {
                        Id = (string)(((JsonObject)friend)["id"]), Name = (string)(((JsonObject)friend)["name"])
                    };
                    var s = (from a in me_groups where a.Id == gr.Id select a).ToList();
                    if (s.Count == 0)
                    {
                        roles.Add(gr);
                    }
                }

                roles = roles.OrderBy(o => o.Name).ToList();
                m_lb_group_list.DataSource    = roles;
                m_lb_group_list.DisplayMember = "Name";
                m_lb_group_list.ValueMember   = "Id";
                m_chk_all_group.Text          = "Tất cả " + m_lb_group_list.Items.Count.ToString() + " group";
                // load group của tài khoản lên form tạo nhóm group.
                m_lb_me_list_group.DataSource    = me_groups;
                m_lb_me_list_group.DisplayMember = "Name";
                m_lb_me_list_group.ValueMember   = "ID";
            }
        }
Esempio n. 11
0
        private void load_friend_list()
        {
            FacebookClient fb = new FacebookClient(access_token);

            dynamic data = fb.Get("/me/friends");

            foreach (var friend in (JsonArray)data["data"])
            {
                groups group = new groups()
                {
                    Id = (string)(((JsonObject)friend)["id"]), Name = (string)(((JsonObject)friend)["name"])
                };
                m_SortedList.Add(group);
            }
            m_SortedList = m_SortedList.OrderBy(o => o.Name).ToList();
            m_lb_friend_list.DataSource    = m_SortedList;
            m_lb_friend_list.DisplayMember = "Name";
            m_lb_friend_list.ValueMember   = "Id";
        }
Esempio n. 12
0
        public void displayMyGroup()
        {
            FacebookClient fb = new FacebookClient(globalInfo.access_token);

            dynamic data = fb.Get("/me/groups");

            foreach (var friend in (JsonArray)data["data"])
            {
                groups group = new groups()
                {
                    Id = (string)(((JsonObject)friend)["id"]), Name = (string)(((JsonObject)friend)["name"])
                };
                m_SortedList.Add(group);
            }
            m_SortedList              = m_SortedList.OrderBy(o => o.Name).ToList();;
            m_lb_groups.DataSource    = m_SortedList;
            m_lb_groups.DisplayMember = "Name";
            m_lb_groups.ValueMember   = "Id";
            this.ShowDialog();
        }