public void Form1_OnNewHome() { ISynchronizeInvoke i = (ISynchronizeInvoke)this; if (i.InvokeRequired) { NewHome dd = new NewHome(Form1_OnNewHome); i.BeginInvoke(dd, null); return; } DanhSachBuuCuc(Cl_KetNoi.hamketnoisql()); }
private void khoitao() { //txttungay.Text = DateTime.Now.ToString("MM/dd/yyyy"); //txtngaychatluong.Text = DateTime.Now.ToString("MM/dd/yyyy"); //dmbuucuc(); if (!Directory.Exists(@"C:\TempExcel")) { Directory.CreateDirectory(@"C:\TempExcel"); } // OnNewHome += new NewHome(Form1_OnNewHome);//tab //load data vao datagrid DanhSachBuuCuc(Cl_KetNoi.hamketnoisql()); }
private void btnganbuucucthugom_Click(object sender, EventArgs e) { Thread chay = new Thread(() => { 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("https://pns.vnpost.vn/tin/thiet-lap-buu-cuc-thu-gom-tu-dong.html"); PNS login = new PNS(); login.login(txttaikhoanpns.Text, txtpasspns.Text); da_dmkhachhangmcs mcs = new da_dmkhachhangmcs(); DataTable dt = new DataTable(); dt = mcs.DanhSachkhachhangmcs(Cl_KetNoi.hamketnoisqlhtkh2015()); if (dt.Rows.Count > 0) { foreach (DataRow r in dt.Rows) { string macrm = r["MaCRM"].ToString(); string dienthoai = r["DienThoai"].ToString(); string trungtam = r["IDCapTren"].ToString(); string mabuucuc = r["MaBuuCuc"].ToString(); PNS them = new PNS(); int kq = them.GanTuDong(macrm, dienthoai, trungtam, mabuucuc); if (kq == 1) { da_dmkhachhangmcs xacnhan = new da_dmkhachhangmcs(); xacnhan.DaTruyen(Cl_KetNoi.hamketnoisqlhtkh2015(), macrm, dienthoai); } } } }); chay.Start(); }
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(); }