Exemplo n.º 1
0
        private void btnlaythongtinchatluong_Click(object sender, EventArgs e)
        {
            Thread chay = new Thread(() =>
            {
                hamxoafile(@"C:\TempExcel");
                #region     // lay thông tin phát
                ChromePerformanceLoggingPreferences perfLogPrefs = new ChromePerformanceLoggingPreferences();
                perfLogPrefs.AddTracingCategories(new string[] { "devtools.timeline" });
                ChromeOptions options = new ChromeOptions();
                var downloadDirectory = @"C:\TempExcel";
                options.AddUserProfilePreference("download.default_directory", downloadDirectory);
                options.AddUserProfilePreference("download.prompt_for_download", false);
                options.AddUserProfilePreference("disable-popup-blocking", "true");

                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://chatluong.vnpost.vn");
                ChatLuong cl = new ChatLuong();
                cl.XuLy(txttaikhoanchatluong.Text, txtpasschatluong.Text, txtngaychatluong.Text, txtngaychatluong.Text, 1);
                //chạy xong tắt chome
                PropretiesCollection.driver.Close();

                #region         //xử lý luôn file excel down về lưu vào csdl
                string fileexcel   = @"C:\TempExcel\" + "Chat Luong cong doan phat theo buu cuc phat.xlsx";
                DuLieuExcel dExcel = new DuLieuExcel();
                DataTable DuLieu   = new DataTable();
                dExcel.TenFile     = fileexcel;
                DuLieu             = dExcel.Doc().Tables[0];
                if (DuLieu.Rows.Count > 0)
                {
                }
                hamxoafile(@"C:\TempExcel");
                #endregion

                #endregion
            }
                                     );

            chay.Start();
        }
Exemplo n.º 2
0
        private void btnimport_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.RestoreDirectory = true;
            dlg.Filter           = "Excel 2003|*.xls|Excel 2007|*.xlsx|All files (*.*)|*.*";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                DuLieuExcel dExcel = new DuLieuExcel();
                DataTable   DuLieu = new DataTable();

                DuLieu = Excel_To_DataTable(dlg.FileName, 0);
                if (DuLieu.Rows.Count > 0)
                {
                    foreach (DataRow r in DuLieu.Rows)
                    {
                        #region // truyền biến
                        string UID      = r["UID"].ToString();
                        string USERNAME = r["USERNAME"].ToString();
                        string PASSWORD = r["PASSWORD"].ToString();
                        string SECRET   = r["SECRET"].ToString();
                        string COOKIES  = r["COOKIES"].ToString();
                        int    DAY      = 0;
                        try
                        {
                            DAY = int.Parse(r["DAY"].ToString());
                        }
                        catch { }
                        int MONTH = 0;
                        try
                        {
                            MONTH = int.Parse(r["MONTH"].ToString());
                        }
                        catch { }
                        int YEAR = 0;
                        try
                        {
                            YEAR = int.Parse(r["YEAR"].ToString());
                        }
                        catch { }
                        string FULLNAME            = r["FULLNAME"].ToString();
                        string GENDER              = r["GENDER"].ToString();
                        string AVATAR              = r["AVATAR"].ToString();
                        string COVER               = r["COVER"].ToString();
                        string HOME                = r["HOME"].ToString();
                        string CITY                = r["CITY"].ToString();
                        string BIO                 = r["BIO"].ToString();
                        string WORK                = r["WORK"].ToString();
                        string UNIVERSITY          = r["UNIVERSITY"].ToString();
                        string SCHOOL              = r["SCHOOL"].ToString();
                        string FRIENDS             = r["FRIENDS"].ToString();
                        string ISP                 = r["ISP"].ToString();
                        string TIME_REGISTER       = r["TIME_REGISTER"].ToString();
                        string GMAIL_USERNAME      = r["GMAIL_USERNAME"].ToString();
                        string GMAIL_PASSWORD      = r["GMAIL_PASSWORD"].ToString();
                        string GMAIL_RECOVERY      = r["GMAIL_RECOVERY"].ToString();
                        string GMAIL_TIME_REGISTER = r["GMAIL_TIME_REGISTER"].ToString();
                        int    IDPhone             = -1;
                        #endregion


                        daSqllite kt   = new daSqllite();
                        DataSet   ttkt = new DataSet();
                        ttkt = kt.KiemTraMail(USERNAME);
                        if (ttkt.Tables[0].Rows.Count > 0)
                        {
                        }
                        else
                        {
                            #region // thêm vào csdl
                            daSqllite them = new daSqllite();
                            them.Insert(UID, USERNAME, PASSWORD, SECRET, COOKIES, DAY,
                                        MONTH, YEAR, FULLNAME, GENDER, AVATAR, COVER,
                                        HOME, CITY, BIO, WORK, UNIVERSITY, SCHOOL, FRIENDS,
                                        ISP, TIME_REGISTER, GMAIL_USERNAME,
                                        GMAIL_PASSWORD, GMAIL_RECOVERY, GMAIL_TIME_REGISTER, IDPhone);
                            #endregion
                        }
                    }
                    #region // sau khi xong load lại dữ liệu
                    hienthi();
                    #endregion
                }
            }
        }