|
|
@ -8,6 +8,7 @@ using InfoferScraper; |
|
|
|
using InfoferScraper.Models.Station; |
|
|
|
using InfoferScraper.Models.Station; |
|
|
|
using InfoferScraper.Models.Train; |
|
|
|
using InfoferScraper.Models.Train; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
|
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
using scraper.Models.Itinerary; |
|
|
|
using scraper.Models.Itinerary; |
|
|
|
using Server.Models; |
|
|
|
using Server.Models; |
|
|
|
using Server.Services.Interfaces; |
|
|
|
using Server.Services.Interfaces; |
|
|
@ -21,15 +22,15 @@ namespace Server.Services.Implementations { |
|
|
|
private NodaTime.IDateTimeZoneProvider TzProvider { get; } |
|
|
|
private NodaTime.IDateTimeZoneProvider TzProvider { get; } |
|
|
|
private NodaTime.DateTimeZone CfrTimeZone => TzProvider["Europe/Bucharest"]; |
|
|
|
private NodaTime.DateTimeZone CfrTimeZone => TzProvider["Europe/Bucharest"]; |
|
|
|
|
|
|
|
|
|
|
|
public DataManager(NodaTime.IDateTimeZoneProvider tzProvider, IDatabase database, ILogger<DataManager> logger, ProxySettings? proxySettings) { |
|
|
|
public DataManager(NodaTime.IDateTimeZoneProvider tzProvider, IDatabase database, ILogger<DataManager> logger, IOptions<ProxySettings> proxySettings) { |
|
|
|
this.TzProvider = tzProvider; |
|
|
|
this.TzProvider = tzProvider; |
|
|
|
this.Database = database; |
|
|
|
this.Database = database; |
|
|
|
this.Logger = logger; |
|
|
|
this.Logger = logger; |
|
|
|
|
|
|
|
|
|
|
|
HttpClientHandler httpClientHandler = new() { |
|
|
|
HttpClientHandler httpClientHandler = new() { |
|
|
|
UseProxy = proxySettings != null, |
|
|
|
UseProxy = proxySettings.Value.UseProxy, |
|
|
|
Proxy = proxySettings == null ? null : new WebProxy(proxySettings.Url), |
|
|
|
Proxy = proxySettings.Value.UseProxy ? new WebProxy(proxySettings.Value.Url) : null, |
|
|
|
DefaultProxyCredentials = proxySettings?.Credentials == null ? null : new NetworkCredential(proxySettings.Credentials.Username, proxySettings.Credentials.Password), |
|
|
|
DefaultProxyCredentials = string.IsNullOrEmpty(proxySettings.Value.Credentials?.Username) ? null : new NetworkCredential(proxySettings.Value.Credentials.Username, proxySettings.Value.Credentials.Password), |
|
|
|
}; |
|
|
|
}; |
|
|
|
InfoferScraper.Scrapers.StationScraper stationScraper = new(httpClientHandler); |
|
|
|
InfoferScraper.Scrapers.StationScraper stationScraper = new(httpClientHandler); |
|
|
|
InfoferScraper.Scrapers.TrainScraper trainScraper = new(httpClientHandler); |
|
|
|
InfoferScraper.Scrapers.TrainScraper trainScraper = new(httpClientHandler); |
|
|
|