Example #1
0
        public OpenWeatherMapClient(string configPath)
        {
            JsonFileContent config = new JsonFileContent(configPath);

            _client = new RestClient((string)config.Value("OpenWeatherMapUrl"));
            _key    = (string)config.Value("OpenWeatherMapKey");
        }
Example #2
0
        public MongoDatabaseClient(string configPath, string database, string collection)
        {
            var databaseConfig = new JsonFileContent(configPath);
            var url            = databaseConfig.Value("databaseUrl").ToString();

            _client     = new MongoClient(url);
            _database   = _client.GetDatabase(database);
            _collection = _database.GetCollection <BsonDocument>(collection);
        }
Example #3
0
 public LocationIqClient(string apiConfigPath)
 {
     _configs           = new JsonFileContent(apiConfigPath);
     _client            = new RestClient((string)_configs.Value("LocationIqUrl"));
     _key               = (string)_configs.Value("LocationIqKey");
     _apiRequestsLeft   = int.Parse((string)_configs.Value("RequestsPerDay"));
     _requestsPerSecond = int.Parse((string)_configs.Value("RequestsPerSecond"));
     _currentDay        = DateTime.UtcNow;
 }
 public Observer(string configPath, string userID, string location, int responsesPerHour, Consumer consumer, Publisher publisher)
 {
     _userID           = userID;
     _location         = location;
     _configs          = new JsonFileContent(configPath);
     _responsesPerHour = responsesPerHour;
     _updateTime       = Convert.ToInt32(DateTime.UtcNow.Ticks);
     _consumer         = consumer;
     _publisher        = publisher;
 }
Example #5
0
        public WeatherApiController(string configPath, IRepository <ApiResponse> databaseClient)
        {
            JsonFileContent config       = new JsonFileContent(configPath);
            var             rabbitAdress = (string)config.Value("RabbitMQ");

            publisher           = new Publisher(rabbitAdress, "TaskController", "TaskController");
            consumer            = new Consumer(rabbitAdress, "TaskController", "TaskController");
            terminal            = new ApiRequestTerminal(configPath, databaseClient);
            manager             = new TaskManager(terminal, publisher, databaseClient);
            rabbitExchangeValue = (string)config.Value("QueueKey");
        }
 public SubscriptionFacade(string configPath, Consumer consumer, Publisher publisher, MySqlDatabaseClient database)
 {
     _configPath            = configPath;
     _configContent         = new JsonFileContent(configPath);
     _consumer              = consumer;
     _publisher             = publisher;
     _subject               = new Subject();
     _dbClien               = database;
     _subscriptionQueueKey  = Convert.ToString(_configContent.Value("SubscriotionQueueKey"));
     _subscriptionKey       = Convert.ToString(_configContent.Value("SubscriotionKey"));
     _cancelSubscriptionKey = Convert.ToString(_configContent.Value("CanceledSubscriotionKey"));
     _unit = new SubscriptionUnitOfWork(_dbClien);
     Restart();
 }
Example #7
0
        public Intialization()
        {
            var configPath = Path.Join(Directory.GetCurrentDirectory(), "configs.json");

            configContent = new JsonFileContent(configPath);
            consumer      = new Consumer(
                configContent.Value("RabbitUrl").ToString(),
                configContent.Value("RabbitLogin").ToString(),
                configContent.Value("RabbitPassword").ToString()
                );
            publisher = new Publisher(
                configContent.Value("RabbitUrl").ToString(),
                configContent.Value("RabbitLogin").ToString(),
                configContent.Value("RabbitPassword").ToString()
                );
            connection = new MySqlDatabaseConnection(
                configContent.Value("MySqlServer").ToString(),
                configContent.Value("MySqlDatabase").ToString(),
                configContent.Value("MySqlLogin").ToString(),
                configContent.Value("MySqlPassword").ToString()
                );
            databaseClient = new MySqlDatabaseClient(connection);
            facade         = new SubscriptionFacade("configs.json", consumer, publisher, databaseClient);
        }