Esempio n. 1
0
        private void tableCopyTriggerTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (tableCopyInProgress == false)
            {
                tableCopyInProgress        = true;
                tableCopyTimerTriggerCount = 0;

                try
                {
                    List <TableCopier> tableCopierList = MongoDB_DAL.GetListOfTableCopiers();

                    foreach (var item in tableCopierList)
                    {
                        item.FetchDataAndImport();
                    }

                    tableCopyInProgress        = false;
                    tableCopyTimerTriggerCount = 0;
                }
                catch (Exception ex)
                {
                    tableCopierServiceLog.Error(ex);
                }
            }
            else
            {
                tableCopyTimerTriggerCount++;
                if (tableCopyTimerTriggerCount >= Convert.ToInt32(ConfigurationManager.AppSettings["TableCopyTimerCounter"].ToString()))
                {
                    tableCopyTimerTriggerCount = 0;
                    tableCopyInProgress        = false;
                }
            }
        }
Esempio n. 2
0
        ////uncomment below code and comment above codes for debugging
        //public void Run()
        //{
        //    OnStart(null);
        //}

        protected override void OnStart(string[] args)
        {
            try
            {
                tableCopierServiceLog.Info("******Started Running Vegam_Database_Table_CopierService*****");

                InitializeTypeMapDictionary();

                tableCopyTriggerTimer.Interval = int.Parse(ConfigurationManager.AppSettings["TableCopyTimerInterval"]);
                tableCopyTriggerTimer.Elapsed += tableCopyTriggerTimer_Elapsed;

                MongoDB_DAL.MongoDB_Initialize();

                try
                {
                    List <TableCopier> tableCopierList = MongoDB_DAL.GetListOfTableCopiers();

                    foreach (var item in tableCopierList)
                    {
                        item.FetchDataAndImport();
                    }
                }
                catch (Exception ex)
                {
                    tableCopierServiceLog.Error(ex);
                }

                tableCopyTriggerTimer.Start();
            }
            catch (Exception ex)
            {
                tableCopierServiceLog.Error(ex);
            }
        }