/// <summary> /// Retrieve reboot info from device twin. /// </summary> private async void GetRebootInfoButton_ClickAsync(object sender, RoutedEventArgs e) { var twinResult = await _mainPage.GetTwinData(RebootInfoDataContract.SectionName); if (twinResult != null) { RebootInfoDataContract.ReportedProperties reportedProperties = RebootInfoDataContract.ReportedProperties.FromJsonObject((JObject)twinResult); RebootInfoLastRebootTime.Text = reportedProperties.lastBootTime; RebootInfoSingleReboot.Text = reportedProperties.singleRebootTime; RebootInfoDailyReboot.Text = reportedProperties.dailyRebootTime; } }
private async Task <JObject> GetRebootInfoAsync() { var request = new Message.GetRebootInfoRequest(); var response = await _systemConfiguratorProxy.SendCommandAsync(request) as GetRebootInfoResponse; RebootInfoDataContract.ReportedProperties reportedProperties = new RebootInfoDataContract.ReportedProperties(); reportedProperties.lastBootTime = response.lastBootTime; reportedProperties.singleRebootTime = response.singleRebootTime; reportedProperties.dailyRebootTime = response.dailyRebootTime; return(reportedProperties.ToJsonObject()); }
public void FromJsonObject(JToken json) { if (!(json is JObject)) { System.Windows.MessageBox.Show("Incorrect json format for: " + RebootInfoDataContract.SectionName); return; } JObject jsonObj = (JObject)json; RebootInfoDataContract.ReportedProperties reportedProperties = RebootInfoDataContract.ReportedProperties.FromJsonObject(jsonObj); SingleRebootTime.Text = reportedProperties.singleRebootTime; DailyRebootTime.Text = reportedProperties.dailyRebootTime; LastBoot.Text = reportedProperties.lastBootTime; }