Exemplo n.º 1
0
        private void ProcessScanner(object arrControl)
        {
            try {
                //----- Add control process from
                ArrayList    arr1             = (ArrayList)arrControl;
                Label        lbl_message      = (Label)arr1[0];
                DataGridView dv_moi           = (DataGridView)arr1[1];
                Label        lbl_moi          = (Label)arr1[2];
                Label        lbl_scanner_khoa = (Label)arr1[3];
                Label        lbl_handoi       = (Label)arr1[4];

                bool dosaugioihang = false;

                /*===============================================================*/
                while (true)
                {
                    dm_scanner_ct link = null;

                    try {
                        if (_queue.CountQueue1() == 0)
                        {
                            break;
                        }
                        link = _queue.DequeueLinks1();


                        if (!Utilities_scanner.hasProcess ||
                            //Utilities_scanner._gioihan_lienket <= _queue.CountLinksAll() ||
                            Utilities_scanner._dosau <= ConvertType.ToInt(link.dosau))
                        {
                            if (Utilities_scanner._dosau <= ConvertType.ToInt(link.dosau))
                            {
                                dosaugioihang = true;
                            }

                            break;
                        }
                    }
                    catch { break; }
                    if (null != link)
                    {
                        int solanlap = 0;
                        Utilities_scanner.getwebBrowserFindLink(link, ref _queue, ref arrControl, ref solanlap);

                        /*khóa 1 lần*/
                        //if (!_block && _queue.CountQueue1() > 0) {
                        //    if (!Utilities_scanner.hasProcess ||
                        //        Utilities_scanner._gioihan_lienket <= _queue.CountLinksAll() ||
                        //         Utilities_scanner._dosau <= ConvertType.ToInt(link.dosau)) {
                        //             if (Utilities_scanner._dosau <= ConvertType.ToInt(link.dosau))
                        //                 dosaugioihang = true;
                        //        break;
                        //    }


                        //    //_block = true;
                        //    for (int i = 0; i < ConvertType.ToInt(txtSoLuong.Text); i++) {
                        //        ParameterizedThreadStart par;
                        //        Control.CheckForIllegalCrossThreadCalls = false;

                        //        par = new ParameterizedThreadStart(CacTieuTrinh);
                        //        theardProcess = new Thread(par);
                        //        theardProcess.Name = string.Format("TieuTrinh_{0}", i);

                        //        theardProcess.Start(arrControl);
                        //    }
                        //}
                    }
                    //lbl_handoi.Text = string.Format("Hàng Đợi : {0}",  _queue.CountQueue1());
                    //lbl_handoi.Update();

                    lbl_handoi.BeginInvoke((MethodInvoker) delegate() {
                        lbl_handoi.Text = string.Format("Hàng Đợi : {0}", _queue.CountQueue1());
                        lbl_handoi.Update();
                    });
                }
                //if (!Utilities_scanner.hasProcess) {
                //    lbl_scanner_khoa.Text += string.Format("Tạm dừng do người dùng....");
                //    lbl_scanner_khoa.Update();
                //    return;
                //}
                //else if (_queue.CountQueue1() == 0) {
                //    lbl_scanner_khoa.Text += string.Format("Hoành tất việc dò tìm....");
                //    lbl_scanner_khoa.Update();
                //    return;
                //}
                //else if (Utilities_scanner._gioihan_lienket <= _queue.CountLinksAll()) {
                //    lbl_scanner_khoa.Text += string.Format("{0} Đã hoàn thành việc dò tìm tới giới hạn liên kết {0}", Utilities_scanner._gioihan_lienket);
                //    lbl_scanner_khoa.Update();
                //    return;
                //}  else if (dosaugioihang) {
                //    lbl_scanner_khoa.Text += string.Format("{0} Đã hoàn thành việc dò tìm tới độ sâu giới hạn {0}", Utilities_scanner._dosau);
                //    lbl_scanner_khoa.Update();
                //    return;
                //}
                //else {
                //    lbl_scanner_khoa.Text += string.Format("Đã kết thúc tiến trình : {0}", theardProcess.Name);
                //    lbl_scanner_khoa.Update();
                //    return;
                //}
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message, "ProcessScanner");
            }
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (chk_dienthoai.Checked)
            {
                PleaseWait objPleaseWait = null;
                //TODO: Stuff
                objPleaseWait = new PleaseWait();
                objPleaseWait.Show();
                objPleaseWait.Update();
                if (radioButton1.Checked)
                {
                    SQLDatabase.ExcNonQuery("update vinabiz set ttlh_dienthoaididong1='',ttlh_dienthoaididong2='',ttlh_dienthoaididong3=''");
                }
                List <vinabiz> dm = SQLDatabase.Loadvinabiz("select  * from vinabiz where len(ttlh_dienthoai1) > 0 and ttlh_dienthoaididong1=''");
                foreach (vinabiz item in dm)
                {
                    string strPhone1 = item.ttlh_dienthoai1;
                    //string strPhone1 = "012 6619 03 11";
                    //List<string> arrPhone = Utilities_scanner.getPhoneHTML(new List<string>() { strPhone1 }, _dauso, _regexs);
                    List <string> arrPhone = Utilities_scanner.getPhoneHTML(strPhone1, _dauso, _regexs); /*chuyen v 2017*/
                    if (arrPhone.Count() != 0)
                    {
                        if (arrPhone.Count() != 0)
                        {
                            item.ttlh_dienthoaididong1 = arrPhone.FirstOrDefault();
                        }
                        if (arrPhone.Count() >= 2)
                        {
                            item.ttlh_dienthoaididong2 = arrPhone[1];
                        }
                        if (arrPhone.Count() >= 3)
                        {
                            item.ttlh_dienthoaididong3 = arrPhone[2];
                        }

                        SQLDatabase.UpdateChuanHoa_ttlh_dienthoai(item);
                    }
                }
                objPleaseWait.Close();
                MessageBox.Show("Đã chuẩn hoá xong 'Điện Thoại'");
            }
            if (chk_dienthoai_khachhang.Checked)
            {
                PleaseWait objPleaseWait = null;
                objPleaseWait = new PleaseWait();
                objPleaseWait.Show();
                objPleaseWait.Update();
                if (radioButton1.Checked)
                {
                    SQLDatabase.ExcNonQuery("update vinabiz set ttlh_dienthoai_nguoidaidien_didong=''");
                }
                List <vinabiz> dm = SQLDatabase.Loadvinabiz("select  *  from vinabiz where len(ttlh_dienthoai_nguoidaidien) > 0 and ttlh_dienthoai_nguoidaidien_didong=''");
                foreach (vinabiz item in dm)
                {
                    string strPhone1 = item.ttlh_dienthoai_nguoidaidien;
                    //List<string> arrPhone = Utilities_scanner.getPhoneHTML(new List<string>() { strPhone1 }, _dauso, _regexs);
                    List <string> arrPhone = Utilities_scanner.getPhoneHTML(strPhone1, _dauso, _regexs);
                    if (arrPhone.Count() != 0)
                    {
                        item.ttlh_dienthoai_nguoidaidien_didong = arrPhone.FirstOrDefault();
                        SQLDatabase.UpdateChuanHoa_ttlh_dienthoai_nguoidaidien_didong(item);
                    }
                }
                objPleaseWait.Close();
                MessageBox.Show("Đã chuẩn hoá xong 'Điện thoại_Khách Hàng'");
            }
            if (chk_dienthoai_giamdoc.Checked)
            {
                PleaseWait objPleaseWait = null;
                objPleaseWait = new PleaseWait();
                objPleaseWait.Show();
                objPleaseWait.Update();
                if (radioButton1.Checked)
                {
                    SQLDatabase.ExcNonQuery("update vinabiz set ttlh_dienthoaigiamdoc_didong=''");
                }
                List <vinabiz> dm = SQLDatabase.Loadvinabiz("select * from vinabiz where len(ttlh_dienthoaigiamdoc) > 0 and ttlh_dienthoaigiamdoc_didong=''");
                foreach (vinabiz item in dm)
                {
                    string        strPhone1 = item.ttlh_dienthoaigiamdoc;
                    List <string> arrPhone  = Utilities_scanner.getPhoneHTML(strPhone1, _dauso, _regexs);
                    if (arrPhone.Count() != 0)
                    {
                        item.ttlh_dienthoaigiamdoc_didong = arrPhone.FirstOrDefault();
                        SQLDatabase.UpdateChuanHoa_ttlh_dienthoaigiamdoc(item);
                    }
                }
                objPleaseWait.Close();
                MessageBox.Show("Đã chuẩn hoá xong 'Điện Thoại_Giám Đốc'");
            }
            if (chk_dienthoai_ketoan.Checked)
            {
                PleaseWait objPleaseWait = null;
                objPleaseWait = new PleaseWait();
                objPleaseWait.Show();
                objPleaseWait.Update();
                if (radioButton1.Checked)
                {
                    SQLDatabase.ExcNonQuery("update vinabiz set ttlh_dienthoaiketoan_didong=''");
                }
                List <vinabiz> dm = SQLDatabase.Loadvinabiz("select  * from vinabiz where len(ttlh_dienthoaiketoan) > 0 and ttlh_dienthoaiketoan_didong=''");
                foreach (vinabiz item in dm)
                {
                    string        strPhone1 = item.ttlh_dienthoaiketoan;
                    List <string> arrPhone  = Utilities_scanner.getPhoneHTML(strPhone1, _dauso, _regexs);
                    if (arrPhone.Count() != 0)
                    {
                        item.ttlh_dienthoaiketoan_didong = arrPhone.FirstOrDefault();
                        SQLDatabase.UpdateChuanHoa_ttlh_dienthoaiketoan(item);
                    }
                }
                objPleaseWait.Close();
                MessageBox.Show("Đã chuẩn hoá xong 'Điện Thoại_Kế Toán'");
            }
        }