示例#1
0
        private async Task ProcessNewerValues(OctopusTariffEntry? latest, CancellationToken ct)
        {
            Instant requestTime;
            if (latest == null)
            {
                requestTime = Instant.FromDateTimeOffset(new DateTimeOffset(2020, 1, 1, 0, 0, 0, TimeSpan.Zero));
            }
            else
            {
                requestTime = latest.Time.Plus(Duration.FromMinutes(30));
            }

            var entries = new List<OctopusTariffEntry>();
            await foreach (var tariff in OctopusService.ReadTariff(requestTime, ct))
            {
                entries.Add(tariff);
            }

            if (entries.Count > 0)
            {
                var ordered = entries.OrderBy(e => e.Time).ToList();
                Logger.LogInformation("Got {Count} new tariff entries from {Start} to {End}", ordered.Count, ordered[0].Time, ordered[^1].Time);
示例#2
0
 public OctopusTariffService(ILogger<OctopusTariffService> logger, OctopusService octopusService, OctopusStoreService octopusStoreService)
 {
     Logger = logger;
     OctopusService = octopusService;
     OctopusStoreService = octopusStoreService;
 }
 public OctopusConsumptionService(ILogger <OctopusConsumptionService> logger, OctopusService octopusService, OctopusStoreService octopusStoreService)
 {
     Logger              = logger;
     OctopusService      = octopusService;
     OctopusStoreService = octopusStoreService;
 }