private static async Task DeleteDevicesAsync(IEnumerator <string> deviceIds, RegistryManager registryManager, DeviceProvisionStats stats) { while (deviceIds.MoveNext()) { var deviceId = deviceIds.Current; try { await registryManager.RemoveDeviceAsync(deviceId); stats.IncrementDeleted(1); } catch { stats.IncrementErrors(1); } } }
private static async Task BulkCreateDevicesAsync(List <Device> devices, RegistryManager registryManager, DeviceProvisionStats stats) { try { var bulkResult = await registryManager.AddDevices2Async(devices); var totalErrors = bulkResult?.Errors?.Length ?? 0; var totalCreated = devices.Count - totalErrors; if (totalCreated > 0) { stats.IncrementCreated(totalCreated); } if (totalErrors > 0) { stats.IncrementErrors(totalErrors); } } catch (Exception ex) { Console.Error.WriteLine(ex); } }