コード例 #1
0
        private void _queryRunner_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (timerElapsedEventInProgress == false)
            {
                timerElapsedEventInProgress = true;
                timerTriggerCount           = 0;

                try
                {
                    List <TableCopier> configSettings = MongoDbDal.GetListOfTableCopiers();

                    foreach (var tab in configSettings)
                    {
                        tab.ImportNextBatch();
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                }
            }
            else
            {
                timerTriggerCount++;
                if (timerTriggerCount >= maxNumberOfRetries)
                {
                    timerTriggerCount           = 0;
                    timerElapsedEventInProgress = false;
                }
            }
        }
コード例 #2
0
        protected override void OnStart(string[] args)
        {
            try
            {
                Log.Info("******Started Running the Query Scheduler*****");
                TypeMap = Helper.InitializeTypeHash();
                //_queryRunner.Interval = int.Parse(ConfigurationManager.AppSettings["ScheduleInterval"]);
                _queryRunner.Interval = 5000;
                _queryRunner.Elapsed += _queryRunner_Elapsed;;

                MongoDbDal.MongoDB_Initialize();

                try
                {
                    List <TableCopier> configSettings = MongoDbDal.GetListOfTableCopiers();

                    foreach (var tab in configSettings)
                    {
                        tab.ImportNextBatch();
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                }


                _queryRunner.Start();
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
        }
コード例 #3
0
        public void ImportNextBatch()
        {
            DataTable sourceData = GetTableDataWithFitler();

            if (sourceData.Rows.Count == 0)
            {
                return;
            }
            DataRow[] successfullInserts = null;
            if (sourceData != null)
            {
                successfullInserts = SaveDataTableDestinationDb(sourceData);
                switch (CopyType)
                {
                case TableCopyType.StatusBased:

                    //Updating the source table with a flag to indicate that these records are already migrated so that we dont create duplicate records in the next iteration
                    UpdateSourceTableWithSuccessFlag(successfullInserts);
                    break;

                case TableCopyType.SequenceBased:
                    var te1 = successfullInserts.OrderByDescending(z => int.Parse(z.Field <string>("FDATE"))).ThenByDescending(z => int.Parse(z.Field <string>("FTIME")));
                    break;

                case TableCopyType.TimeStampBased:
                    var te = successfullInserts.OrderByDescending(z => int.Parse(z.Field <string>("FDATE"))).ThenByDescending(z => int.Parse(z.Field <string>("FTIME")));
                    LastSyncDate = te.First().Field <string>("FDATE");
                    LastSyncTime = te.First().Field <string>("FTIME");

                    MongoDbDal.UpdateLastSyncDateTime(CopierId, LastSyncDate, LastSyncTime);
                    break;

                default:
                    break;
                }
            }
            else
            {
                Log.Info(" could not get data from source table: " + SourceTableName);
            }
        }