Пример #1
0
        /// <summary>
        /// Timer Elapsed event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void objInsertionTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (this.dbOpertion)
            {
                return;
            }
            this.dbOpertion = true;
            this.isDumping  = !this.isDumping;
            //// dump all the location details in database.

            try
            {
                DataTable dt = new DataTable();
                if (this.isDumping)
                {
                    if (this.activeStorage.Count > 0)
                    {
                        dt = DataAccessUtility.ToDataTable <LocationDetails>(this.activeStorage.ToList());
                    }
                }
                else
                {
                    if (this.passiveStorage.Count > 0)
                    {
                        dt = DataAccessUtility.ToDataTable <LocationDetails>(this.passiveStorage.ToList());
                    }
                }

                if (dt != null && dt.Rows.Count > 0)
                {
                    if (this.trackingRepository.BulkInsertion(dt))
                    {
                        if (this.isDumping)
                        {
                            this.activeStorage.Clear();
                        }
                        else
                        {
                            this.passiveStorage.Clear();
                        }

                        ////TODO: log the operation with details like number data dump
                    }
                    else
                    {
                        ////TODO: log the operation
                    }
                }
            }
            catch
            {
                ////TODO: log the error
            }
            finally
            {
                this.dbOpertion = false;
            }
        }