public DbFillerService(AppDbContext context, IRSSService rssService, ITextractService textractService, ILogger <DbFillerService> logger) { this.context = context; this.rssService = rssService; this.textractService = textractService; this.logger = logger; }
public MainPageViewModel(IWeatherService weatherService, ITrafficService trafficService, IRSSService rSSService, ISettingsService settingsService, IComplimentService commonService) { // Constructor injection _weatherService = weatherService; _trafficService = trafficService; _rssService = rSSService; _settingsService = settingsService; _commonService = commonService; App.UserSettings = _settingsService.LoadSettings(); InitializeTimers(); RefreshAllData(); SetRefreshTimers(); GoToSettingsCommand = new CustomCommand(NavigateToSettings, CanNavigateToSettings); }
private void ShowChannels() { var context = new RSSContext(); _service = new RSSService( new RSSPageParser(), new RSSReader(), new UnitOfWrok(context, new Repository <RSSChannel>(context), new Repository <RSSItem>(context)), "http://www.rss.lostsite.pl//index.php?rss=32"); foreach (var item in _service.GetAllRSS()) { listOfChannels.Items.Add(item); } }
public RssFeedsController(IDataService dataService, IRSSService rssService) : base(dataService, null) { _rss = rssService; }
public FeedsController(IRSSService rssService) { this._rssService = rssService; }
public HomeController(IRSSService rssService) { _rssService = rssService; }
protected async override Task ExecuteAsync(CancellationToken cancellationToken) { _logger.LogInformation("Renew Background Service is starting."); var counter = 0; using (var scope = _scopeFactory.CreateScope()) { _data = scope.ServiceProvider.GetRequiredService <IVolatileDataService>(); _rss = scope.ServiceProvider.GetRequiredService <IRSSService>(); while (!cancellationToken.IsCancellationRequested) { try { counter++; _logger.LogInformation("Checking state of items."); _data.CheckItemState(); if (counter >= CheckRSSRenewCount) { _logger.LogInformation("Renewing RSSFeed items and weather forecast."); var renewed = _rss.RenewActiveRssFeeds().Result; using (var client = new HttpClient()) { try { client.BaseAddress = new Uri("https://api.openweathermap.org"); var city = _data.GetSettingByName("WeatherLocation"); var response = await client.GetAsync($"/data/2.5/forecast?q={city}&appid=e9e81d9533487c8075cd2f47af1ef9ae&units=metric&lang=nl"); response.EnsureSuccessStatusCode(); var stringResult = await response.Content.ReadAsStringAsync(); WeatherItem weather = _data.GetSingle <WeatherItem>(); weather.Forecast = stringResult; _data.Edit(weather); _data.Commit(); } catch (HttpRequestException httpRequestException) { _logger.LogInformation($"Error getting weather from OpenWeather: {httpRequestException.Message}"); } } counter = 0; } await Task.Delay(TimeSpan.FromSeconds(CheckItemStateInterval)); } catch (Exception ex) { _logger.LogError(ex, $"An unexpected error occurred in RenewBackgroundController."); } } } _logger.LogInformation("Renew Background Service is stopping."); }