예제 #1
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                try
                {
                    // We ultimately resolve the actual services we use from the scope we create below.
                    // This ensures that all services that were registered with services.AddScoped<T>()
                    // will be disposed at the end of the service scope (the current iteration).
                    using var scope = _serviceScopeFactory.CreateScope();
                    var orderRepository = scope.ServiceProvider.GetRequiredService <IAsyncRepository <Order> >();
                    var getOrder        = await orderRepository.FirstAsync(new UnconvertedOrderSpecification());

                    IOrderConverter orderConverter = ApplicationConstants.OrderHandlers[getOrder.SystemType];
                    await orderRepository.UpdateAsync(orderConverter.Convert(getOrder));

                    // _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
                }
                catch (Exception exception)
                {
                    _eventsFactory.ExceptionThrow.Raise(exception);
                }

                await Task.Delay(5000, stoppingToken);
            }
        }
예제 #2
0
 public OrdersController(IOrdersRepository ordersRepository,
                         IOrderConverter orderConverter, IOrderPriceCalculator orderPriceCalculator)
 {
     this.ordersRepository     = ordersRepository;
     this.orderConverter       = orderConverter;
     this.orderPriceCalculator = orderPriceCalculator;
 }
예제 #3
0
 public DocumentService(IOrderConverter orderConverter, IOrderRepository orderRepository,
                        IReportConverter reportConverter, IReportRepository reportRepository,
                        ICarRepository carRepository, IWorkerRepository workerRepository)
 {
     _orderConverter   = orderConverter;
     _orderRepository  = orderRepository;
     _reportConverter  = reportConverter;
     _reportRepository = reportRepository;
     _carRepository    = carRepository;
     _workerRepository = workerRepository;
 }