public static async Task CollectBackground(string deviceId) { #if DEBUG //Debugger.Launch(); #endif var filePath = System.IO.Path.GetTempFileName(); try { // Launch srumutil which will append live results to a file on disk //collect last hour of data await LaunchPowerCFG(filePath); var logs = ExtractPowerInfoPer15Mins(filePath); var consumptionLog = new ConsumptionLog() { DeviceId = deviceId, Values = logs }; await DeviceConsumption.ReportDeviceConsumptionAsync(consumptionLog); //File.WriteAllText(Path.Combine(ApplicationData.Current.TemporaryFolder.Path, "e3log.json"), fileContent); } finally { File.Delete(filePath); } }
internal static async Task ReportDeviceConsumptionAsync(ConsumptionLog consumptionLog) { var json = JsonConvert.SerializeObject(consumptionLog); if (CoreConfigurationManager.Instance.Configuration == null) { await CoreConfigurationManager.Instance.InitAsync(); } var result = await httpClient.PostAsync(CoreConfigurationManager.Instance.Configuration.ConsumptionReportUrl, new StringContent(json, System.Text.Encoding.UTF8, "application/json")); result.EnsureSuccessStatusCode(); }