Esempio n. 1
0
        /// <summary>
        /// Once the data is loaded into the application this timer will begin. This timer event will begin
        /// running condition checks and then making a call to remove the data that is not needed from the database.
        /// </summary>
        /// <param name="sender">The data removal timer</param>
        /// <param name="e">The tick event of the timer</param>
        private void DataRemovalTimer_Tick(object sender, EventArgs e)
        {
            if (DatabaseDataRemovalUtils.DataRemoved)
            {
                DatabaseDataRemovalUtils.DataRemoved = false;
                DataRemovalTimer.Stop();

                if (AccessDatabaseUtils.US_PRPO_TableExists && AccessDatabaseUtils.MX_PRPO_TableExists)
                {
                    ShowPage(Pages.CountrySelector);
                }
                else if (AccessDatabaseUtils.US_PRPO_TableExists)
                {
                    ConfigureToUnitedStates();
                    BeginDataLoadProcess();
                }
                else // only the mexico file exists.
                {
                    ConfigureToMexico();
                    BeginDataLoadProcess();
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Once the data is loaded into the application this timer will begin. This timer event will begin
        /// running condition checks and then making a call to remove the data that is not needed from the database.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DataRemovalTimer_Tick(object sender, EventArgs e)
        {
            if (!PRPO_DB_Utils.DataRemovalProcessStarted)
            {
                PRPO_DB_Utils.DataRemovalProcessStarted = true;

                if (AccessUtils.US_PRPO_TableExists)
                {
                    PRPO_DB_Utils.ScheduledDataRemovals++;

                    usThread = new Thread(() =>
                    {
                        PRPO_DB_Utils.RemoveData(PRPOCommands.DatabaseTables.MainTables.US_PRPO);
                    });
                    usThread.Start();
                }

                if (AccessUtils.MX_PRPO_TableExists)
                {
                    PRPO_DB_Utils.ScheduledDataRemovals++;

                    mxThread = new Thread(() =>
                    {
                        PRPO_DB_Utils.RemoveData(PRPOCommands.DatabaseTables.MainTables.MX_PRPO);
                    });
                    mxThread.Start();
                }
            }


            if (PRPO_DB_Utils.DataRemoved)
            {
                DataRemovalTimer.Stop();
                PRPO_DB_Utils.DataRemoved = false;

                if (PRPO_DB_Utils.DatabaseConnection != null & PRPO_DB_Utils.DatabaseConnection.State == System.Data.ConnectionState.Open)
                {
                    btn_DatabaseConnectionStatus.Image = Properties.Resources.databaseConn_Connected_Icon;
                }
                else
                {
                    MessageBox.Show("There was an error while attempting to connect to the database", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }



                if (AccessUtils.US_PRPO_TableExists && AccessUtils.MX_PRPO_TableExists)
                {
                    pnl_CountrySelector.BringToFront();
                }
                else if (AccessUtils.US_PRPO_TableExists)
                {
                    Overall.SelectedCountry = AccessInfo.MainTables.US_PRPO;
                    PRPO_DB_Utils.DataLoadProcessStarted = false;
                    PRPO_DB_Utils.DataLoaded             = false;
                    PRPO_DB_Utils.CompletedDataLoads     = 0;
                    PRPO_DB_Utils.ScheduledDataLoads     = 0;
                    DataLoaderTimer.Start();
                }
                else // only the mexico file exists.
                {
                    Overall.SelectedCountry = AccessInfo.MainTables.MX_PRPO;
                    PRPO_DB_Utils.DataLoadProcessStarted = false;
                    PRPO_DB_Utils.DataLoaded             = false;
                    PRPO_DB_Utils.CompletedDataLoads     = 0;
                    PRPO_DB_Utils.ScheduledDataLoads     = 0;
                    DataLoaderTimer.Start();
                }
            }
        }