Exemple #1
0
        public void DoWork()
        {
            _logger.Info("======================= Runnning DistributorUpdateWorker =======================");
            try
            {
                // Process in batches to avoid high memory issue
                int totalRecords    = _distributorService.CountDistributorLogs();
                int numberOfBatches = (int)Math.Ceiling((double)totalRecords / _appSettings.DistributorUpdateBatchSize);
                _logger.Info(string.Format("Found {0} records - Processing in {1} batch(es)", totalRecords, numberOfBatches));

                for (int i = 0; i < numberOfBatches; i++)
                {
                    _logger.Info(string.Format("### Processing batch {0}", i + 1));
                    var scannableDistributorLogs = _distributorService.GetScannableDistibutorLogs(_appSettings.DistributorUpdateBatchSize);
                    Process(scannableDistributorLogs);
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Failed on running DistributorUpdateWorker", ex);
            }
            _logger.Info("======================= Stopping DistributorUpdateWorker =======================");
        }