protected override Task ExecuteAsync(CancellationToken stoppingToken)
        {
            using (var scope = _serviceScopeFactory.CreateScope())
            {
                #region RabbitMQ
                var appSettings = scope.ServiceProvider.GetRequiredService <AppSettings>();

                var rabbitMQ = appSettings.ConnectionStrings.RabbitMQ;

                var factory = new ConnectionFactory()
                {
                    HostName = rabbitMQ.HostName, UserName = rabbitMQ.UserName, Password = rabbitMQ.Password
                };
                _connection = factory.CreateConnection();
                _connection.ConnectionShutdown += _connection_ConnectionShutdown;
                #endregion

                #region MongoDB
                _userRepo         = scope.ServiceProvider.GetRequiredService <IUserRepository>();
                _customerRepo     = scope.ServiceProvider.GetRequiredService <ICustomerRepository>();
                _pizzaRepo        = scope.ServiceProvider.GetRequiredService <IPizzaRepository>();
                _requestRepo      = scope.ServiceProvider.GetRequiredService <IRequestRepository>();
                _requestPizzaRepo = scope.ServiceProvider.GetRequiredService <IRequestPizzaRepository>();

                PreemptiveInsertsMongoDB(scope);
                #endregion

                stoppingToken.ThrowIfCancellationRequested();

                rabbitMQ.Queues.ToList().ForEach(e => CreateChannel(e));
            }

            return(Task.CompletedTask);
        }
Esempio n. 2
0
 public RequestRepository(SQLContext ctx, IPizzaRepository p, IRequestPizzaRepository rp, IRabbitMQPublisher r) : base(ctx, r)
 {
     _pizzaRepo        = p;
     _requestPizzaRepo = rp;
 }
Esempio n. 3
0
 public RequestRepository(IMongoDBContext db, IPizzaRepository p, IRequestPizzaRepository rp)
 {
     _db = db;
     _pizzaRepository        = p;
     _requestPizzaRepository = rp;
 }