static void Main(string[] args)
        {
            // get configuration
            var    configSection = Config.GetSection("RabbitMQ");
            string host          = configSection["Host"];
            string userName      = configSection["UserName"];
            string password      = configSection["Password"];
            string exchange      = configSection["Exchange"];

            // start time manager
            RabbitMQMessagePublisher messagePublisher = new RabbitMQMessagePublisher(host, userName, password, exchange);
            TimeManager manager = new TimeManager(messagePublisher);

            manager.Start();

            if (_env == "Development")
            {
                Log.Information("TimeService service started.");
                Console.WriteLine("Press any key to stop...");
                Console.ReadKey(true);
                manager.Stop();
            }
            else
            {
                Log.Information("Time service started.");
                while (true)
                {
                    Thread.Sleep(10000);
                }
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            try
            {
                ServiceRuntime.RegisterServiceAsync("TimeServiceType",
                                                    context => new tim.TimeService(context)).GetAwaiter().GetResult();

                tim.ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(tim.TimeService).Name);

                // get configuration
                var    configSection = Config.GetSection("RabbitMQ");
                string host          = configSection["Host"];
                string userName      = configSection["UserName"];
                string password      = configSection["Password"];

                // start time manager
                RabbitMQMessagePublisher messagePublisher = new RabbitMQMessagePublisher(host, userName, password, "Pitstop");
                TimeManager manager = new TimeManager(messagePublisher);
                manager.Start();

                // Prevents this host process from terminating so services keep running.
                Thread.Sleep(Timeout.Infinite);
            }
            catch (Exception e)
            {
                tim.ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString());
                throw;
            }
        }
        public AdvertisementService(IConfiguration config, RabbitMQMessagePublisher messagePublisher)
        {
            var client   = new MongoClient(config.GetConnectionString("CarChampDb"));
            var database = client.GetDatabase("CarChampDb");

            ads = database.GetCollection <AdvertisementModel>("advertisements");
            this._messagePublisher = messagePublisher;
        }
        public MaintenanceService(IConfiguration config, RabbitMQMessagePublisher messagePublisher)
        {
            var client   = new MongoClient(config.GetConnectionString("CarChampDb"));
            var database = client.GetDatabase("CarChampDb");

            maintenances           = database.GetCollection <MaintenanceModel>("maintenances");
            this._messagePublisher = messagePublisher;
        }
Beispiel #5
0
        public CarManagementService(IConfiguration config, RabbitMQMessagePublisher messagePublisher)
        {
            var client   = new MongoClient(config.GetConnectionString("CarChampDb"));
            var database = client.GetDatabase("CarChampDB");

            cars = database.GetCollection <CarModel>("Cars");
            this._messagePublisher = messagePublisher;
        }
Beispiel #6
0
 public CarController(RabbitMQMessagePublisher messagePublisher, CarManagementService carService)
 {
     _messagePublisher = messagePublisher;
     _carService       = carService;
 }
 public AdvertisementController(RabbitMQMessagePublisher messagePublisher, AdvertisementService advertisementService)
 {
     _messagePublisher     = messagePublisher;
     _advertisementService = advertisementService;
 }
Beispiel #8
0
 public MaintenanceController(RabbitMQMessagePublisher messagePublisher, MaintenanceService maintenanceService)
 {
     _messagePublisher   = messagePublisher;
     _maintenanceService = maintenanceService;
 }