From 84a8f731ca75d0eb49f2157f194b8d5b2a5a15c8 Mon Sep 17 00:00:00 2001 From: Xiangzhi Sheng Date: Wed, 22 Feb 2017 11:43:34 +0800 Subject: [PATCH] Enable rule on all of the "built-in" simulated devices One more minor change: set the threshold of temperature to 60 It is desired for the scenario driven out-of-box experience --- .../BusinessLogic/DeviceRulesLogic.cs | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/DeviceAdministration/Infrastructure/BusinessLogic/DeviceRulesLogic.cs b/DeviceAdministration/Infrastructure/BusinessLogic/DeviceRulesLogic.cs index d5f311a7..b910731f 100644 --- a/DeviceAdministration/Infrastructure/BusinessLogic/DeviceRulesLogic.cs +++ b/DeviceAdministration/Infrastructure/BusinessLogic/DeviceRulesLogic.cs @@ -155,17 +155,20 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr public async Task BootstrapDefaultRulesAsync(List existingDeviceIds) { - DeviceRule temperatureRule = await GetNewRuleAsync(existingDeviceIds[0]); - temperatureRule.DataField = DeviceRuleDataFields.Temperature; - temperatureRule.RuleOutput = "AlarmTemp"; - temperatureRule.Threshold = 38.0d; - await SaveDeviceRuleAsync(temperatureRule); + foreach (var deviceId in existingDeviceIds) + { + DeviceRule temperatureRule = await GetNewRuleAsync(deviceId); + temperatureRule.DataField = DeviceRuleDataFields.Temperature; + temperatureRule.RuleOutput = "AlarmTemp"; + temperatureRule.Threshold = 60.0d; + await SaveDeviceRuleAsync(temperatureRule); - DeviceRule humidityRule = await GetNewRuleAsync(existingDeviceIds[0]); - humidityRule.DataField = DeviceRuleDataFields.Humidity; - humidityRule.RuleOutput = "AlarmHumidity"; - humidityRule.Threshold = 48.0d; - await SaveDeviceRuleAsync(humidityRule); + DeviceRule humidityRule = await GetNewRuleAsync(deviceId); + humidityRule.DataField = DeviceRuleDataFields.Humidity; + humidityRule.RuleOutput = "AlarmHumidity"; + humidityRule.Threshold = 48.0d; + await SaveDeviceRuleAsync(humidityRule); + } } public async Task> DeleteDeviceRuleAsync(string deviceId, string ruleId)