private void FormChonSo_Load(object sender, EventArgs e) { ham_chay = new LThread2(); ham_chay.time_delay = 1000; ham_chay.StartedEvent += new LThread2.startDelegate(delegate (string arg) { if (chapnhan == true) start_all_thread(); else stop_all_thread(); if (giay > 60*1000) { giay = 0; this.Invoke(new MethodInvoker(delegate () { webBrowser1.Refresh(); })); } else giay += ham_chay.time_delay; }); ham_chay.Start(); webBrowser1 = _windowManager.New(false); webBrowser1.Navigate("http://10.149.34.168/ccbs/login.htm"); webBrowser1.DocumentCompleted+= new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted); DataTable dt = mysql_db.ExcelLoad("Cài đặt"); if (dt.Rows.Count > 0) { username = dt.Rows[0]["ten_dang_nhap"].ToString(); password = dt.Rows[0]["mat_khau"].ToString(); } LoadListLink(); LoadDSSoDaDK(); webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(checkDocument); this.txtcode.KeyPress += new System.Windows.Forms.KeyPressEventHandler(CheckEnter); btnChonSoAuto.Enabled = false; } private void start_all_thread() { taotientrinh(); for (int i = 0; i < ham_chay_tien_trinh.Length; i++) { if (ham_chay_tien_trinh[i] != null) { if (ham_chay_tien_trinh[i].bwIsRun == false) { //ham_chay.time_delay = 100 + i * 50; //Thread.Sleep(100); ham_chay_tien_trinh[i].Start(); //Thread.Sleep(200); } } } } private void stop_all_thread() { for (int i = 0; i < ham_chay_tien_trinh.Length; i++) if (ham_chay_tien_trinh[i] != null) ham_chay_tien_trinh[i].Stop(); } private void BatDau(string output, int idxThread) { new Thread(() => { ham_chay_tien_trinh[idxThread].Stop(); }).Start(); string str = ""; myLink = output.ToString().Replace("\r\n", string.Empty).Split(new char[] { ' ' }); ; if (this.count >= myLink.Count()) { this.count = 0; str = myLink[0]; } else { str = myLink[this.count]; } int num = new Random().Next(0x186a0, 0x5f5e0ff); try { string str2; string str3; HtmlElementCollection elementsByTagName; if (!str.Contains("*")) { new Thread(() => { chapnhan = false; stop_all_thread(); }); this.Invoke(new MethodInvoker(delegate () { if (chapnhan == false) return; try { str2 = "http://chonso.vinaphone.com.vn/numstore/main?iutlomLork=portal/ajax_ds_thuebao_1&qok{yueoj=&y{hexgtmk=84" + str.Substring(0, str.Length - 7) + "&yuezh=" + str.Substring(str.Length - 7); str3 = this.code(str2); this.webBrowser2.Document.GetElementById("txtsomay").InnerText = "84" + str; if (str3.Contains(str)) { elementsByTagName = this.webBrowser2.Document.GetElementsByTagName("input"); foreach (HtmlElement element in elementsByTagName) { if (element.GetAttribute("id").Equals("cmdQuetlai")) { element.InvokeMember("Click"); } //SendKeys.Send("{N}"); } this.cbxLinkChonSo.Text = this.cbxLinkChonSo.Text.Replace(str, ""); this.cbxLinkChonSo.Text = this.cbxLinkChonSo.Text.Replace(" ", " "); this.webBrowser2.Document.GetElementById("txtCode").InnerText = ""; this.webBrowser2.Document.GetElementById("txtsomay").InnerText = ""; DataTable dtDaDK = mysql_db.ExcelLoad("Đã Đăng Ký"); int so_cu = dtDaDK.Rows.Count; DataRow nr = dtDaDK.NewRow(); nr["so_da_dk"] = "84" + str; dtDaDK.Rows.Add(nr.ItemArray); if (so_cu != dtDaDK.Rows.Count) { mysql_db.ExcelSave(dtDaDK, "Đã Đăng Ký"); LoadDSSoDaDK(); } this.tone(); chapnhan = false; } } catch (Exception ex) { } })); Button.CheckForIllegalCrossThreadCalls = false; HienNut(); txtcode.Text = ""; } else { int values = 0; values = (str.Length - str.Split(new char[] { '*' })[1].Length) - 1; //str2 = "http://chonso.vinaphone.com.vn/numstore/main?iutlomLork=portal/ajax_ds_thuebao_1&qok{yueoj=&y{hexgtmk=84" + str.Split(new char[] { '*' })[0].Substring(1) + "&yzgz{y=2&vgmket{s=8&vgmkexki=&yuezh=*99*" + str.Split(new char[] { '*' })[1]; str2 = "http://chonso.vinaphone.com.vn/numstore/main?iutlomLork=portal/ajax_ds_thuebao_1&qok{yueoj=&y{hexgtmk=84" + str.Split(new char[] { '*' })[0].Substring(0, values) + "&yzgz{y=2&vgmket{s=1&vgmkexki=&yuezh=*" + str.Split(new char[] { '*' })[1]; str3 = this.code(str2); if (str3 == "") return; List list = new List(); MatchCollection matchs = Regex.Matches(str3, "(.*?)", RegexOptions.Singleline); foreach (Match match in matchs) { if (!list.Contains(match.Groups[1].Value)) { string str5 = match.Groups[1].Value; if (str5.Contains("javascript:foward_thongtin")) { string[] strArray = str5.Split(new char[] { '\'' }); if (strArray[3] == "0") { string str6 = strArray[1]; this.Invoke(new MethodInvoker(delegate () { try { this.webBrowser2.Document.GetElementById("txtsomay").InnerText = str6; elementsByTagName = this.webBrowser2.Document.GetElementsByTagName("input"); foreach (HtmlElement element in elementsByTagName) { if (element.GetAttribute("id").Equals("cmdQuetlai")) { element.InvokeMember("Click"); } } //SendKeys.Send("{N}"); this.cbxLinkChonSo.Text = this.cbxLinkChonSo.Text.Replace(" ", " "); this.webBrowser2.Document.GetElementById("txtCode").InnerText = ""; this.webBrowser2.Document.GetElementById("txtsomay").InnerText = ""; this.tone(); DataTable dtDaDK = mysql_db.ExcelLoad("Đã Đăng Ký"); int so_cu = dtDaDK.Rows.Count; DataRow nr = dtDaDK.NewRow(); nr["so_da_dk"] = str6; dtDaDK.Rows.Add(nr.ItemArray); if (so_cu != dtDaDK.Rows.Count) { mysql_db.ExcelSave(dtDaDK, "Đã Đăng Ký"); LoadDSSoDaDK(); chapnhan = false; } } catch { } })); Button.CheckForIllegalCrossThreadCalls = false; HienNut(); txtcode.Text = ""; break; } } } } } } catch (Exception ex) { } } private void taotientrinh() { try { DataTable dtDSLink = mysql_db.ExcelLoad("Danh Sách link"); int tong_dong = dtDSLink.Rows.Count; stop_all_thread(); if (so_tien_trinh != tong_dong) { ham_chay_tien_trinh = new LThread2[tong_dong]; for (int idx = 0; idx < tong_dong; idx++) { int local_idx = idx; ham_chay_tien_trinh[idx] = new LThread2(); ham_chay_tien_trinh[idx].StartedEvent += new LThread2.startDelegate(delegate (string arg) { BatDau(dtDSLink.Rows[local_idx]["duong_dan"].ToString(), local_idx); }); } } so_tien_trinh = tong_dong; } catch (Exception ex) { } }