private void dmbuucuc() { da_dmbclay bc = new da_dmbclay(); DataTable dt = new DataTable(); dt = bc.DanhSachBuuCucKhongsoLieu(Cl_KetNoi.hamketnoisql(), txttungay.Text); listbuucuc.DataSource = dt; }
private void btnchaylaithongtinphat_Click(object sender, EventArgs e) { Thread chay = new Thread(() => { txtlog.Text = ""; da_dmbclay bc = new da_dmbclay(); DataTable tablebuucuc = new DataTable(); tablebuucuc = bc.DanhSachBuuCucKhongsoLieu(Cl_KetNoi.hamketnoisql(), txttungay.Text); DataTable tbc = (DataTable)listbuucuc.DataSource; lblbuucuckhongsolieu.Text = "Số lượng bưu cục không số liệu :" + tablebuucuc.Rows.Count.ToString() + "/" + tbc.Rows.Count.ToString(); if (tablebuucuc.Rows.Count > 0) { #region // lay thông tin phát ChromePerformanceLoggingPreferences perfLogPrefs = new ChromePerformanceLoggingPreferences(); perfLogPrefs.AddTracingCategories(new string[] { "devtools.timeline" }); ChromeOptions options = new ChromeOptions(); options.AddArguments("--disable-notifications"); options.PerformanceLoggingPreferences = perfLogPrefs; options.SetLoggingPreference(LogType.Driver, LogLevel.All); options.SetLoggingPreference("performance", LogLevel.All); options.AddAdditionalCapability(CapabilityType.EnableProfiling, true, true); PropretiesCollection.driver = new ChromeDriver(options); PropretiesCollection.driver.Navigate().GoToUrl("http://thongtinphat.vnpost.vn/Security/SignIn"); // PropretiesCollection.driver.Manage().Window.Size = new Size(480, 720); ThongTinPhat t = new ThongTinPhat(); t.login(txttaikhoan.Text, txtmatkhau.Text, txttungay.Text.Trim(), txttungay.Text.Trim()); txtlog.Text = txtlog.Text + "\r\n" + "Login thành công bắt đầu quét dữ liệu" + "-->" + DateTime.Now.ToString(); lblxuly.Text = "0"; int i = 1; foreach (DataRow r in tablebuucuc.Rows) { string mabuucuc = r["mabuucuc"].ToString(); string tenbuucuc = r["buucuc"].ToString(); txtlog.Text = txtlog.Text + "\r\n" + "Bắt đầu đọc dữ liệu bưu cục " + mabuucuc + "-" + tenbuucuc + "-->" + DateTime.Now.ToString();; DataTable dt = new DataTable(); dt = t.ThongTin(mabuucuc, int.Parse(txttimernghi.Value.ToString())); txtlog.Text = txtlog.Text + "\r\n" + "Bưu cục " + tenbuucuc + " Có số lượng bản ghi là:" + dt.Rows.Count.ToString() + "-->" + DateTime.Now.ToString(); if (dt.Rows.Count > 0) { #region // ghi dữ liệu vào csdl SMP da_smp_mau ghi = new da_smp_mau(); ghi.CapNhat(Cl_KetNoi.hamketnoisql(), dt, txttungay.Text, mabuucuc); txtlog.Text = txtlog.Text + "\r\n" + "Ghi thành công dữ liệu cho bưu cục :" + tenbuucuc + "-->" + DateTime.Now.ToString(); #endregion } lblxuly.Text = "Xử lý :" + i.ToString() + "/" + tablebuucuc.Rows.Count.ToString(); i++; ScrollToBottom(txtlog); } txtlog.Text = txtlog.Text + "\r\n" + "Đã Xong!" + "-->" + DateTime.Now.ToString(); da_smp_mau dlngay = new da_smp_mau(); DataTable tableBC = new DataTable(); tableBC = dlngay.DanhSachSoLieu(Cl_KetNoi.hamketnoisql(), txttungay.Text); listbuucuc.DataSource = tableBC; //chạy xong tắt chome PropretiesCollection.driver.Close(); #endregion } else { MessageBox.Show("Lỗi không có danh sách bưu cục cần lấy dữ liệu"); return; } } ); chay.Start(); }