public async void LoadDeploymentDevicesAsync(string targetQuery) { DevicesQuery allDevicesQuery = new DevicesQuery(targetQuery); await allDevicesQuery.Refresh(_connectionString); _devices = allDevicesQuery.Devices; RebuildDeviceList(); }
private async Task LoadDeploymentsAsync() { if (String.IsNullOrEmpty(_connectionString) || _connectionString == "<connection string>") { return; } int maxDeploymentCount = 20; RegistryManager registryManager; try { registryManager = RegistryManager.CreateFromConnectionString(_connectionString); } catch (Exception e) { MessageBox.Show("Failed to connect to IoTHub.\n\nMake sure you are using the iothubowner connection string (not a device connection string).\n\nIoT Hub Error: " + e.Message, "Connection Error", MessageBoxButton.OK); return; } try { _deploymentSummaries = new List <DeploymentSummary>(); DevicesQuery allDevicesQuery = new DevicesQuery(""); await allDevicesQuery.Refresh(_connectionString); DeploymentSummary cs = new DeploymentSummary(); cs.Name = DMConstants.AllDevicesConfigName; cs.AzureConfiguration = new Configuration(DMConstants.AllDevicesConfigName); cs.AzureConfiguration.Priority = 1; cs.AppliedCount = "-"; cs.FailedCount = allDevicesQuery.FailedDeviceCount.ToString(); cs.SuccessCount = allDevicesQuery.SuccessDeviceCount.ToString(); cs.TargetedCount = allDevicesQuery.DeviceCount.ToString(); cs.PendingCount = allDevicesQuery.PendingDeviceCount.ToString(); _deploymentSummaries.Add(cs); IEnumerable <Configuration> configurations = await registryManager.GetConfigurationsAsync(maxDeploymentCount); foreach (var configuration in configurations) { _deploymentSummaries.Add(SummarizeConfiguration(configuration)); } } catch (Exception) { MessageBox.Show("Failed to enumerate existing deployments.", "Enumeration Error", MessageBoxButton.OK); return; } }
private async void ConditionRunAsync(string condition) { DevicesQuery allDevicesQuery = new DevicesQuery(condition); await allDevicesQuery.Refresh(_connectionString); StringBuilder sb = new StringBuilder(); foreach (var pair in allDevicesQuery.Devices) { sb.Append(pair.Key); sb.Append("\n"); } if (sb.Length != 0) { MessageBox.Show(sb.ToString()); } else { MessageBox.Show("No devices found!"); } }