// IClientPropertyHandler
        public async Task <CommandStatus> OnDesiredPropertyChange(JToken desiredValue)
        {
            Logger.Log("WindowsUpdatesHandler.OnDesiredPropertyChange()", LoggingLevel.Verbose);

            if (!(desiredValue is JObject))
            {
                throw new Error(ErrorCodes.INVALID_DESIRED_JSON_VALUE, "Invalid json value type for the " + PropertySectionName + " node.");
            }

            WindowsUpdatesDataContract.DesiredProperties desiredProperties = WindowsUpdatesDataContract.DesiredProperties.FromJsonObject((JObject)desiredValue);

            SetWindowsUpdatesConfiguration configuration = new SetWindowsUpdatesConfiguration();

            configuration.approved = desiredProperties.approved;

            var request = new SetWindowsUpdatesRequest(configuration);

            await this._systemConfiguratorProxy.SendCommandAsync(request);

            JObject reportedProperties = await GetReportedPropertyAsync();

            Debug.WriteLine("-- Reporting Windows Updates -------------------------------------");
            Debug.WriteLine(reportedProperties.ToString());
            Debug.WriteLine("-- Reporting Windows Updates Done --------------------------------");

            // Report the updated list...
            await _deviceManagementClient.ReportPropertiesAsync(PropertySectionName, reportedProperties);

            return(CommandStatus.Committed);
        }
Example #2
0
 /// <summary>
 /// Set Windows Updates via device twin.
 /// </summary>
 private async void SetWindowsUpdateButton_ClickAsync(object sender, RoutedEventArgs e)
 {
     WindowsUpdatesDataContract.DesiredProperties desiredProperties = new WindowsUpdatesDataContract.DesiredProperties();
     desiredProperties.approved = WindowsUpdateInput.Text;
     string refreshingValue = "\"refreshing\"";
     string finalValue      = "{" + desiredProperties.ToJsonString() + "}";
     await _mainPage.UpdateTwinData(refreshingValue, finalValue);
 }
 private WindowsUpdatesDataContract.DesiredProperties UIToWindowsUpdatesConfiguration()
 {
     WindowsUpdatesDataContract.DesiredProperties desiredProperties = new WindowsUpdatesDataContract.DesiredProperties();
     desiredProperties.approved = DesiredApproved.Text;
     return(desiredProperties);
 }