示例#1
0
        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);
            }
        }
示例#2
0
        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();
        }