Esempio n. 1
0
        public override bool TryFetchItem(out IEnumerable <PriceChangeHistory> item)
        {
            try
            {
                _logger.Debug($"Trying to fetch current prices");
                IEnumerable <PriceChangeHistory> changedPrices = _currentPriceService.ListPriceChanges();
                IEnumerable <long> stores = changedPrices.GroupBy(cp => cp.Store)
                                            .Select(p => p.First())
                                            .Select(s => s.Store);

                if (changedPrices.Count() > 0)
                {
                    foreach (long store in stores)
                    {
                        try
                        {
                            IEnumerable <PriceChangeHistory> priceChangesForStore = changedPrices.Where(c => c.Store == store);

                            long notificationId        = CreateNotification(store, priceChangesForStore);
                            IEnumerable <long> userIds = GetStoreUsers(store);
                            AssignNotificationToStoreUsers(notificationId, userIds);
                            PublishNotification(notificationId);
                            _currentPriceService.CheckedPricesChangesAsNotified(priceChangesForStore);
                        }
                        catch (Exception ex)
                        {
                            _logger.Error($"Price changes notification can not be created/published for storeId={store}." + ex);
                        }
                    }
                }

                _logger.Debug($"Process EInvoice started");
                try
                {
                    _saleInvoiceService.ProcessCashRegisterEInvoice();
                    _logger.Debug($"Process EInvoice ended");
                }
                catch (Exception ex)
                {
                    _logger.Error($"Process EInvoice error : {ex.Message}");
                }


                _logger.Debug($"Fetch complete.");
                item = null;
                return(false);
            }
            catch (Exception ex)
            {
                _logger.Error("Trying to fetch current prices", ex);
                // Wait a little to prevent high CPU situations
                _cancelSpinEvent.WaitOne(10000);
                item = null;
                return(false);
            }
        }
Esempio n. 2
0
 public override bool TryFetchItem(out IEnumerable <EInvoiceClient> item)
 {
     try
     {
         _saleInvoiceService.ProcessCashRegisterEInvoice();
         item = null;
         return(false);
     }
     catch (Exception ex)
     {
         _logger.Error("Trying to fetch EInvoiceClient", ex);
         _cancelSpinEvent.WaitOne(10000);
         item = null;
         return(false);
     }
 }