private void bw_DoWork(object sender, DoWorkEventArgs e) { // kiem tra la co cuoc goi moi hoac cuoc goi dang theo doi thi thuc hien if ((g_ListCuocGoiLogInComing != null) && (g_ListCuocGoiLogInComing.Count > 0)) { XacDinhCuocGoiNho_InCom(); XacDinhCuocGoiCoDuration_VOC(); } // Xoa nhung truong hop du thua g_iCount++; if (g_iCount > 300) { // Xoa nhung cuoc du thua DeleteNhungCuocDuThua(); g_iCount = 0; } if (DateTime.Now.Hour == 3 && DateTime.Now.Minute == 1 && DateTime.Now.Second < 5) { CaptureCuocGoiDi(); TaxiCapture.DeletePhoneCallVocFile_CuocGoiDi(g_FileVOCPath); } }
/// <summary> /// Khoi tao du lieu luc dau /// </summary> private void Init() { // Lay thong tin he thong ThongTinCauHinh.LayThongTinCauHinh(); if (ThongTinCauHinh.SoDauCuaTongDai.Length > 0) { g_HasSoDauTongDai = true; } else { g_HasSoDauTongDai = false; } g_ConnecString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"]; g_FileLogIncomingPath = Configuration.LogIncomingPath(); g_FileInComPath = Configuration.InComFilenamePath(); g_FileVOCPath = Configuration.VocFilePath(); if ((!FileTools.IsExsitFile(g_FileLogIncomingPath)) || (!FileTools.IsExsitFile(g_FileInComPath)) || (!FileTools.IsExsitFile(g_FileVOCPath))) { MessageBox.Show("Không tồn tại file thông tin cuộc gọi.Liên lạc với quản trị hệ thống.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); return; } // check connection if (!DieuHanhTaxi.CheckConnection()) { MessageBox.Show("Không kết nối được với cơ sở dữ liệu.Cần liên lạc với quản trị hệ thống.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); return; } /// end check connection timerCapture = new System.Timers.Timer(500); // nửa giây quét một lần. timerCapture.Elapsed += new System.Timers.ElapsedEventHandler(timerCapture_Elapsed); timerCapture.Enabled = true; try { // Xoa toan bo du lieu hien tai cua he thong phan cung TaxiCapture.DeletePhoneCallInCom(DateTime.Now, g_FileInComPath); TaxiCapture.DeletePhoneCallLogIncomming(DateTime.Now, g_FileLogIncomingPath); TaxiCapture.DeletePhoneCallVocFile(DateTime.Now, g_FileVOCPath); } catch (Exception ex) { MessageBox.Show("Có lỗi thiết lập (reset) các cuộc gọi.Cần liên lạc với quản trị hệ thống.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } CaptureCuocGoiDi(); TaxiCapture.DeletePhoneCallVocFile_CuocGoiDi(g_FileVOCPath); g_bKetThucBackgroundWork = true; g_bTimerHoanThanh = true; g_iKhoiDongLai = 0; }