private void btnsetup_Click(object sender, EventArgs e)
 {
     lbstatus.Text = "đang setup...";
     if (txtcookiefile.Text.Length < 3 || txtemail.Text.Length < 3)
     {
         AppExtension.MessageBoxShow("Thiếu file đầu vào email hoặc cookie !", 3);
         return;
     }
     new Thread(() =>
     {
         SetupData();
     }).Start();
 }
 private void btnstart_Click(object sender, EventArgs e)
 {
     //AppExtension.MessageBoxShow("thiếu cmn file rồi", 2);
     //AppExtension.MessageBoxShow("good", 1);
     //AppExtension.MessageBoxShow("lỗi gì đó", 3);
     //string namefb = Regex.Match(txtemail.Text, "uid.*?(\\d+)").Groups[1].Value;\
     //string test = Facebook.FacebookDateCreated("100055700742809", "AQHi6kC3ZdPS:AQEQ6yi5NMrE");
     PathError   = Application.StartupPath + "\\data\\fail\\" + "error_mail_" + DateFormat + ".txt";
     PathSuccess = Application.StartupPath + "\\data\\success\\" + "success_" + DateFormat + ".txt";
     if (isSetupsucces == false)
     {
         AppExtension.MessageBoxShow("chưa setup data ! vui lòng bấm setup data...", 2);
         return;
     }
     isstop           = false;
     btnstart.Enabled = false;
     btnstop.Enabled  = true;
     lbstatus.Text    = "đang chạy...";
     try
     {
         new Thread(() =>
         {
             string[] ListEmail = File.ReadAllLines(txtemail.Text);
             ParallelOptions parallelOptions        = new ParallelOptions();
             parallelOptions.MaxDegreeOfParallelism = Convert.ToInt32(numthread.Value);
             //  parallelOptions.CancellationToken = cts.Token;
             int row = 0;
             Parallel.ForEach(ListEmail, parallelOptions, (string emailLine, ParallelLoopState state) =>
             {
                 if (isstop == true)
                 {
                     state.Break();
                 }
                 dtgrvdata.Invoke((MethodInvoker) delegate()
                 {
                     row = dtgrvdata.Rows.Add();
                 });
                 GetInfoFacebook(emailLine, row);
                 AppExtension.DataGridScroll(dtgrvdata);
                 Thread.Sleep(TimeSpan.FromSeconds(Convert.ToDouble(numsleep.Value)));
             });
             btnstart.Enabled = true;
             btnstop.Enabled  = false;
             lbstatus.Text    = "chạy xong !";
         }).Start();
     }
     catch
     { }
 }
 private void lbquesnumthread_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     AppExtension.MessageBoxShow(AppExtension.ShowFaq(2), 1);
 }
        private void SetupData()
        {
            isSetupsucces = false;
            DateFormat    = DateTime.Now.ToString("dd-mm-yyy hh-mm");
            TempdataSave  = Application.StartupPath + "\\data\\temp\\" + "temp_fbdata_" + DateFormat + ".txt";
            string[] CookiesFile = File.ReadAllLines(txtcookiefile.Text);
            string   c*k         = "";

            foreach (string cookie in CookiesFile)
            {
                c*k = cookie;
                if (c*k.Contains("useragent="))
                {
                    c*k = Regex.Replace(cookie, "useragent=([a-zA-Z0-9]{100,300})", "");
                }
                Facebook facebook = new Facebook();
                facebook.Cookie = c*k;
                string FacebookIdentifyCodeStatus = facebook.FacebookIdentifyCode();
                if (FacebookIdentifyCodeStatus == "die" || FacebookIdentifyCodeStatus == "error")
                {
                    goto END_W;
                }
                string FacebookTokenStatus = "";
                if (cbbtypetoken.SelectedIndex != 1)
                {
                    FacebookTokenStatus = facebook.FacebookTokenNormal();
                }
                else
                {
                    FacebookTokenStatus = facebook.FacebookTokenBussine();
                }
                if (FacebookTokenStatus == "die" || FacebookTokenStatus == "error")
                {
                    goto END_W;
                }
                string FacebookIdPageStatus = facebook.FacebookPageid();
                if (FacebookIdPageStatus == "die" || FacebookIdPageStatus == "not_a_page" || FacebookIdPageStatus == "error")
                {
                    goto END_W;
                }
                foreach (string Idpage in facebook.Listidpage)
                {
                    string ContentSave = facebook.Token + DataSeperator + cookie + DataSeperator + Idpage + DataSeperator + facebook.fb_dtsg + DataSeperator + facebook.jazoest + DataSeperator + facebook.fb_av + DataSeperator + facebook.fb_eav;
                    File.AppendAllText(TempdataSave, ContentSave + "\r\n");
                }
                END_W :;
            }
            if (!File.Exists(TempdataSave))
            {
                isSetupsucces = false;
                AppExtension.MessageBoxShow("lỗi setup ! có thể toàn bộ cookie đã die hoặc không thể lấy data...", 3);
                return;
            }
            else
            {
                int CountData  = Convert.ToInt32(File.ReadAllLines(TempdataSave).Length);
                int CountEmail = Convert.ToInt32(File.ReadAllLines(txtemail.Text).Length);
                if (CountEmail >= 50)
                {
                    if (CountData <= 1)
                    {
                        isSetupsucces = false;
                        AppExtension.MessageBoxShow("dữ liệu facebook quá ít ! nhỏ hơn 1, nên không thể chạy ! vui lòng thêm cookie...", 3);
                        return;
                    }
                }
            }
            isSetupsucces = true;
            btnstart.PerformClick();
        }
 private void lbquestimesleep_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     AppExtension.MessageBoxShow(AppExtension.ShowFaq(1), 1);
 }