Exemplo n.º 1
0
        /// <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;
        }