public async Task DoExport() { Log.Information("Starting ExportValuesForCaching.DoExport()"); using (var api = new HouseDBAPI(new Uri(_houseDBSettings.Url))) { var clientModel = new DomoticzValuesForCachingClientModel { DateTime = DateTime.Now, DomoticzValuesForCachingValues = new List <DomoticzValuesForCachingValue>() }; using (var client = new HttpClient()) { // Get the values for P1 (smart home meter) clientModel.P1Values = await GetP1Values(client); // Get the values to cache for every device foreach (var device in _devices) { var value = await GetDataValues(device, client); clientModel.DomoticzValuesForCachingValues.Add(value); } } await api.ExporterInsertValuesForCachingPostAsync(clientModel); } }
/// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='clientModel'> /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task ExporterInsertValuesForCachingPostAsync(this IHouseDBAPI operations, DomoticzValuesForCachingClientModel clientModel = default(DomoticzValuesForCachingClientModel), CancellationToken cancellationToken = default(CancellationToken)) { (await operations.ExporterInsertValuesForCachingPostWithHttpMessagesAsync(clientModel, null, cancellationToken).ConfigureAwait(false)).Dispose(); }
/// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='clientModel'> /// </param> public static void ExporterInsertValuesForCachingPost(this IHouseDBAPI operations, DomoticzValuesForCachingClientModel clientModel = default(DomoticzValuesForCachingClientModel)) { operations.ExporterInsertValuesForCachingPostAsync(clientModel).GetAwaiter().GetResult(); }