/// <summary> /// Set schedule reboot info via device twin. /// </summary> private async void SetScheduleRebootButton_ClickAsync(object sender, RoutedEventArgs e) { string dailyReboot = string.Empty; string singleReboot = string.Empty; if (RebootInfoDailyChkbx.IsChecked == true) { var pickedRebootDate = RebootInfoDailyRebootDateInput.Date; var pickedRebootTime = RebootInfoDailyRebootTimeInput.Time; DateTime resultDailyDateTime = new DateTime(pickedRebootDate.Year, pickedRebootDate.Month, pickedRebootDate.Day, pickedRebootTime.Hours, pickedRebootTime.Minutes, 0, DateTimeKind.Utc); dailyReboot = (resultDailyDateTime.ToString("yyyy-MM-ddTHH:mm:ssZ")); } if (RebootInfoSingleChkbx.IsChecked == true) { var pickedRebootDate = RebootInfoSingleRebootDateInput.Date; var pickedRebootTime = RebootInfoSingleRebootTimeInput.Time; DateTime resulSingleDateTime = new DateTime(pickedRebootDate.Year, pickedRebootDate.Month, pickedRebootDate.Day, pickedRebootTime.Hours, pickedRebootTime.Minutes, 0, DateTimeKind.Utc); singleReboot = (resulSingleDateTime.ToString("yyyy-MM-ddTHH:mm:ssZ")); } RebootInfoDataContract.DesiredProperties desiredProperties = new RebootInfoDataContract.DesiredProperties(); desiredProperties.singleRebootTime = singleReboot; desiredProperties.dailyRebootTime = dailyReboot; string refreshingValue = "\"refreshing\""; string finalValue = "{" + desiredProperties.ToJsonString() + "}"; await _mainPage.UpdateTwinData(refreshingValue, finalValue); }
public string ToJsonString() { RebootInfoDataContract.DesiredProperties desiredProperties = new RebootInfoDataContract.DesiredProperties(); desiredProperties.singleRebootTime = SingleRebootTime.Text; desiredProperties.dailyRebootTime = DailyRebootTime.Text; return(desiredProperties.ToJsonString()); }