private async Task <CommandStatus> ApplyDesiredPropertiesAsync(JToken jAppsToken) { CommandStatus commandStatus = CommandStatus.NotStarted; if (!(jAppsToken is JObject)) { return(commandStatus); } JObject appsNode = (JObject)jAppsToken; // Reset the nodes to report... _stateToReport = new Dictionary <string, AppxManagementDataContract.AppReportedState>(); IDictionary <string, AppInfo> installedApps = await ListAppsAsync(); DumpInstalledApps(installedApps); AppxManagementDataContract.DesiredProperties desiredProperties = AppxManagementDataContract.DesiredProperties.FromJsonObject(appsNode); AppUtils.DumpDesiredProperties(desiredProperties); ReorderAndValidate(desiredProperties.appDesiredStates, installedApps); // Process explicitly defined app blocks... foreach (AppxManagementDataContract.AppDesiredState appDesiredState in desiredProperties.appDesiredStates) { try { commandStatus = await ApplyAppDesiredState(this._connectionString, installedApps, appDesiredState); } catch (Exception) { // Catch everything here so that we may continue processing other appDesiredStates. // No reporting to the IoT Hub is needed here because it has already taken place. } // Should we continue? if (commandStatus == CommandStatus.PendingDMAppRestart) { break; } } // Process the "?" ProcessFullListQuery(installedApps, desiredProperties.appListQuery, _stateToReport); // Reset the apps reported node... await NullifyReported(); // Report all collected values... foreach (var pair in _stateToReport) { await ReportAppStatus(pair.Value); } return(commandStatus); }
public static void DumpDesiredProperties(AppxManagementDataContract.DesiredProperties desiredProperties) { Logger.Log("- Desired Properties ------------------------------------------------", LoggingLevel.Verbose); Logger.Log("appListQuery.store = " + desiredProperties.appListQuery.store, LoggingLevel.Verbose); Logger.Log("appListQuery.nonStore = " + desiredProperties.appListQuery.nonStore, LoggingLevel.Verbose); foreach (AppxManagementDataContract.AppDesiredState appDesiredState in desiredProperties.appDesiredStates) { DumpAppDesiredState(appDesiredState); } }