public async Task <RebootRequestStatus> IsRebootAllowedBySystem() { var request = new Message.GetWindowsUpdateRebootPolicyRequest(); var response = await this._systemConfiguratorProxy.SendCommandAsync(request) as Message.GetWindowsUpdateRebootPolicyResponse; if (!response.configuration.allow) { return(RebootRequestStatus.Disabled); } Message.GetWindowsUpdatePolicyResponse updatePolicy = await this.GetWindowsUpdatePolicyAsync(); uint nowHour = (uint)DateTime.Now.Hour; if (updatePolicy.configuration.activeHoursStart <= nowHour && nowHour < updatePolicy.configuration.activeHoursEnd) { return(RebootRequestStatus.InActiveHours); } return(RebootRequestStatus.Allowed); }
private async Task ReportAllDeviceProperties() { Debug.WriteLine("ReportAllDeviceProperties"); Debug.WriteLine("Querying start: " + DateTime.Now.ToString()); Message.GetTimeInfoResponse timeInfoResponse = await GetTimeInfoAsync(); Message.GetCertificateConfigurationResponse certificateConfigurationResponse = await GetCertificateConfigurationAsync(); Message.GetRebootInfoResponse rebootInfoResponse = await GetRebootInfoAsync(); Message.GetDeviceInfoResponse deviceInfoResponse = await GetDeviceInfoAsync(); Message.GetWindowsUpdatePolicyResponse windowsUpdatePolicyResponse = await GetWindowsUpdatePolicyAsync(); Message.GetWindowsUpdatesResponse windowsUpdatesResponse = await GetWindowsUpdatesAsync(); Debug.WriteLine("Querying end: " + DateTime.Now.ToString()); Dictionary <string, object> collection = new Dictionary <string, object>(); collection["microsoft"] = new { management = new { timeInfo = timeInfoResponse, certificates = certificateConfigurationResponse, rebootInfo = rebootInfoResponse, deviceInfo = deviceInfoResponse, windowsUpdatePolicy = windowsUpdatePolicyResponse.configuration, windowsUpdates = windowsUpdatesResponse.configuration } }; _deviceTwin.ReportProperties(collection); }
private static WindowsUpdatePolicyDataContract.WUProperties ResponseToReported(Message.GetWindowsUpdatePolicyResponse response) { WindowsUpdatePolicyDataContract.WUProperties reportedProperties = new WindowsUpdatePolicyDataContract.WUProperties(); reportedProperties.activeHoursStart = (int)response.data.activeHoursStart; reportedProperties.activeHoursEnd = (int)response.data.activeHoursEnd; reportedProperties.allowAutoUpdate = (int)response.data.allowAutoUpdate; reportedProperties.allowUpdateService = (int)response.data.allowUpdateService; reportedProperties.branchReadinessLevel = (int)response.data.branchReadinessLevel; reportedProperties.deferFeatureUpdatesPeriod = (int)response.data.deferFeatureUpdatesPeriod; reportedProperties.deferQualityUpdatesPeriod = (int)response.data.deferQualityUpdatesPeriod; reportedProperties.pauseFeatureUpdates = (int)response.data.pauseFeatureUpdates; reportedProperties.pauseQualityUpdates = (int)response.data.pauseQualityUpdates; reportedProperties.scheduledInstallDay = (int)response.data.scheduledInstallDay; reportedProperties.scheduledInstallTime = (int)response.data.scheduledInstallTime; reportedProperties.ring = response.data.ring; reportedProperties.sourcePriority = PolicyHelpers.SourcePriorityFromPolicy(response.data.policy); return(reportedProperties); }