Merge pull request #197 from Azure/zhengzh-nationalclouds
Fix device spoofing issue - Fixes Issue #191
This commit is contained in:
Коммит
ea44b31c31
|
@ -319,9 +319,9 @@
|
|||
"Transformation": {
|
||||
"Name": "AllToBlob",
|
||||
"Properties": {
|
||||
"Query": "WITH \r\n [StreamData]\r\nAS (\r\n SELECT\r\n *\r\n FROM \r\n [IoTHubStream] \r\n WHERE\r\n [ObjectType] IS NULL -- Filter out device info and command responses\r\n) \r\n\r\nSELECT\r\n *\r\nINTO\r\n [Telemetry]\r\nFROM\r\n [StreamData]\r\n\r\nSELECT\r\n DeviceId,\r\n AVG (Humidity) AS [AverageHumidity], \r\n MIN(Humidity) AS [MinimumHumidity], \r\n MAX(Humidity) AS [MaxHumidity], \r\n 5.0 AS TimeframeMinutes \r\nINTO\r\n [TelemetrySummary]\r\nFROM\r\n [StreamData]\r\nWHERE\r\n [Humidity] IS NOT NULL\r\nGROUP BY\r\n DeviceId, \r\n SlidingWindow (mi, 5)",
|
||||
"Query": "WITH \r\n [StreamData]\r\nAS (\r\n SELECT\r\n *\r\n FROM [IoTHubStream]\r\n WHERE\r\n [ObjectType] IS NULL -- Filter out device info and command responses\r\n) \r\n\r\nSELECT\r\n IoTHub.ConnectionDeviceId AS DeviceId,\r\n Temperature,\r\n Humidity,\r\n ExternalTemperature,\r\n EventProcessedUtcTime,\r\n PartitionId,\r\n EventEnqueuedUtcTime,\r\n * \r\nINTO\r\n [Telemetry]\r\nFROM\r\n [StreamData]\r\n\r\nSELECT\r\n IoTHub.ConnectionDeviceId AS DeviceId,\r\n AVG (Humidity) AS [AverageHumidity],\r\n MIN(Humidity) AS [MinimumHumidity],\r\n MAX(Humidity) AS [MaxHumidity],\r\n 5.0 AS TimeframeMinutes \r\nINTO\r\n [TelemetrySummary]\r\nFROM [StreamData]\r\nWHERE\r\n [Humidity] IS NOT NULL\r\nGROUP BY\r\n IoTHub.ConnectionDeviceId,\r\n SlidingWindow (mi, 5)",
|
||||
"StreamingUnits": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -525,9 +525,9 @@
|
|||
"Transformation": {
|
||||
"Name": "DeviceRules",
|
||||
"Properties": {
|
||||
"Query": "WITH AlarmsData AS \r\n(\r\nSELECT\r\n Stream.DeviceID,\r\n 'Temperature' as ReadingType,\r\n Stream.Temperature as Reading,\r\n Ref.Temperature as Threshold,\r\n Ref.TemperatureRuleOutput as RuleOutput,\r\n Stream.EventEnqueuedUtcTime AS [Time]\r\nFROM IoTTelemetryStream Stream\r\nJOIN DeviceRulesBlob Ref ON Stream.DeviceID = Ref.DeviceID\r\nWHERE\r\n Ref.Temperature IS NOT null AND Stream.Temperature > Ref.Temperature\r\n\r\nUNION ALL\r\n\r\nSELECT\r\n Stream.DeviceID,\r\n 'Humidity' as ReadingType,\r\n Stream.Humidity as Reading,\r\n Ref.Humidity as Threshold,\r\n Ref.HumidityRuleOutput as RuleOutput,\r\n Stream.EventEnqueuedUtcTime AS [Time]\r\nFROM IoTTelemetryStream Stream\r\nJOIN DeviceRulesBlob Ref ON Stream.DeviceID = Ref.DeviceID\r\nWHERE\r\n Ref.Humidity IS NOT null AND Stream.Humidity > Ref.Humidity\r\n)\r\n\r\nSELECT *\r\nINTO DeviceRulesMonitoring\r\nFROM AlarmsData\r\n\r\nSELECT *\r\nINTO DeviceRulesHub\r\nFROM AlarmsData",
|
||||
"Query": "WITH AlarmsData AS \r\n(\r\nSELECT\r\n Stream.IoTHub.ConnectionDeviceId AS DeviceId,\r\n 'Temperature' as ReadingType,\r\n Stream.Temperature as Reading,\r\n Ref.Temperature as Threshold,\r\n Ref.TemperatureRuleOutput as RuleOutput,\r\n Stream.EventEnqueuedUtcTime AS [Time]\r\nFROM IoTTelemetryStream Stream\r\nJOIN DeviceRulesBlob Ref ON Stream.IoTHub.ConnectionDeviceId = Ref.DeviceID\r\nWHERE\r\n Ref.Temperature IS NOT null AND Stream.Temperature > Ref.Temperature\r\n\r\nUNION ALL\r\n\r\nSELECT\r\n Stream.IoTHub.ConnectionDeviceId AS DeviceId,\r\n 'Humidity' as ReadingType,\r\n Stream.Humidity as Reading,\r\n Ref.Humidity as Threshold,\r\n Ref.HumidityRuleOutput as RuleOutput,\r\n Stream.EventEnqueuedUtcTime AS [Time]\r\nFROM IoTTelemetryStream Stream\r\nJOIN DeviceRulesBlob Ref ON Stream.IoTHub.ConnectionDeviceId = Ref.DeviceID\r\nWHERE\r\n Ref.Humidity IS NOT null AND Stream.Humidity > Ref.Humidity\r\n)\r\n\r\nSELECT *\r\nINTO DeviceRulesMonitoring\r\nFROM AlarmsData\r\n\r\nSELECT *\r\nINTO DeviceRulesHub\r\nFROM AlarmsData",
|
||||
"StreamingUnits": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -412,9 +412,9 @@
|
|||
"Transformation": {
|
||||
"Name": "AllToBlob",
|
||||
"Properties": {
|
||||
"Query": "WITH \r\n [StreamData]\r\nAS (\r\n SELECT\r\n *\r\n FROM \r\n [IoTHubStream] \r\n WHERE\r\n [ObjectType] IS NULL -- Filter out device info and command responses\r\n) \r\n\r\nSELECT\r\n *\r\nINTO\r\n [Telemetry]\r\nFROM\r\n [StreamData]\r\n\r\nSELECT\r\n DeviceId,\r\n AVG (Humidity) AS [AverageHumidity], \r\n MIN(Humidity) AS [MinimumHumidity], \r\n MAX(Humidity) AS [MaxHumidity], \r\n 5.0 AS TimeframeMinutes \r\nINTO\r\n [TelemetrySummary]\r\nFROM\r\n [StreamData]\r\nWHERE\r\n [Humidity] IS NOT NULL\r\nGROUP BY\r\n DeviceId, \r\n SlidingWindow (mi, 5)",
|
||||
"Query": "WITH \r\n [StreamData]\r\nAS (\r\n SELECT\r\n *\r\n FROM [IoTHubStream]\r\n WHERE\r\n [ObjectType] IS NULL -- Filter out device info and command responses\r\n) \r\n\r\nSELECT\r\n IoTHub.ConnectionDeviceId AS DeviceId,\r\n Temperature,\r\n Humidity,\r\n ExternalTemperature,\r\n EventProcessedUtcTime,\r\n PartitionId,\r\n EventEnqueuedUtcTime,\r\n * \r\nINTO\r\n [Telemetry]\r\nFROM\r\n [StreamData]\r\n\r\nSELECT\r\n IoTHub.ConnectionDeviceId AS DeviceId,\r\n AVG (Humidity) AS [AverageHumidity],\r\n MIN(Humidity) AS [MinimumHumidity],\r\n MAX(Humidity) AS [MaxHumidity],\r\n 5.0 AS TimeframeMinutes \r\nINTO\r\n [TelemetrySummary]\r\nFROM [StreamData]\r\nWHERE\r\n [Humidity] IS NOT NULL\r\nGROUP BY\r\n IoTHub.ConnectionDeviceId,\r\n SlidingWindow (mi, 5)",
|
||||
"StreamingUnits": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -618,9 +618,9 @@
|
|||
"Transformation": {
|
||||
"Name": "DeviceRules",
|
||||
"Properties": {
|
||||
"Query": "WITH AlarmsData AS \r\n(\r\nSELECT\r\n Stream.DeviceID,\r\n 'Temperature' as ReadingType,\r\n Stream.Temperature as Reading,\r\n Ref.Temperature as Threshold,\r\n Ref.TemperatureRuleOutput as RuleOutput,\r\n Stream.EventEnqueuedUtcTime AS [Time]\r\nFROM IoTTelemetryStream Stream\r\nJOIN DeviceRulesBlob Ref ON Stream.DeviceID = Ref.DeviceID\r\nWHERE\r\n Ref.Temperature IS NOT null AND Stream.Temperature > Ref.Temperature\r\n\r\nUNION ALL\r\n\r\nSELECT\r\n Stream.DeviceID,\r\n 'Humidity' as ReadingType,\r\n Stream.Humidity as Reading,\r\n Ref.Humidity as Threshold,\r\n Ref.HumidityRuleOutput as RuleOutput,\r\n Stream.EventEnqueuedUtcTime AS [Time]\r\nFROM IoTTelemetryStream Stream\r\nJOIN DeviceRulesBlob Ref ON Stream.DeviceID = Ref.DeviceID\r\nWHERE\r\n Ref.Humidity IS NOT null AND Stream.Humidity > Ref.Humidity\r\n)\r\n\r\nSELECT *\r\nINTO DeviceRulesMonitoring\r\nFROM AlarmsData\r\n\r\nSELECT *\r\nINTO DeviceRulesHub\r\nFROM AlarmsData",
|
||||
"Query": "WITH AlarmsData AS \r\n(\r\nSELECT\r\n Stream.IoTHub.ConnectionDeviceId AS DeviceId,\r\n 'Temperature' as ReadingType,\r\n Stream.Temperature as Reading,\r\n Ref.Temperature as Threshold,\r\n Ref.TemperatureRuleOutput as RuleOutput,\r\n Stream.EventEnqueuedUtcTime AS [Time]\r\nFROM IoTTelemetryStream Stream\r\nJOIN DeviceRulesBlob Ref ON Stream.IoTHub.ConnectionDeviceId = Ref.DeviceID\r\nWHERE\r\n Ref.Temperature IS NOT null AND Stream.Temperature > Ref.Temperature\r\n\r\nUNION ALL\r\n\r\nSELECT\r\n Stream.IoTHub.ConnectionDeviceId AS DeviceId,\r\n 'Humidity' as ReadingType,\r\n Stream.Humidity as Reading,\r\n Ref.Humidity as Threshold,\r\n Ref.HumidityRuleOutput as RuleOutput,\r\n Stream.EventEnqueuedUtcTime AS [Time]\r\nFROM IoTTelemetryStream Stream\r\nJOIN DeviceRulesBlob Ref ON Stream.IoTHub.ConnectionDeviceId = Ref.DeviceID\r\nWHERE\r\n Ref.Humidity IS NOT null AND Stream.Humidity > Ref.Humidity\r\n)\r\n\r\nSELECT *\r\nINTO DeviceRulesMonitoring\r\nFROM AlarmsData\r\n\r\nSELECT *\r\nINTO DeviceRulesHub\r\nFROM AlarmsData",
|
||||
"StreamingUnits": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -401,9 +401,9 @@
|
|||
"Transformation": {
|
||||
"Name": "AllToBlob",
|
||||
"Properties": {
|
||||
"Query": "WITH \r\n [StreamData]\r\nAS (\r\n SELECT\r\n *\r\n FROM \r\n [IoTHubStream] \r\n WHERE\r\n [ObjectType] IS NULL -- Filter out device info and command responses\r\n) \r\n\r\nSELECT\r\n *\r\nINTO\r\n [Telemetry]\r\nFROM\r\n [StreamData]\r\n\r\nSELECT\r\n DeviceId,\r\n AVG (Humidity) AS [AverageHumidity], \r\n MIN(Humidity) AS [MinimumHumidity], \r\n MAX(Humidity) AS [MaxHumidity], \r\n 5.0 AS TimeframeMinutes \r\nINTO\r\n [TelemetrySummary]\r\nFROM\r\n [StreamData]\r\nWHERE\r\n [Humidity] IS NOT NULL\r\nGROUP BY\r\n DeviceId, \r\n SlidingWindow (mi, 5)",
|
||||
"Query": "WITH \r\n [StreamData]\r\nAS (\r\n SELECT\r\n *\r\n FROM [IoTHubStream]\r\n WHERE\r\n [ObjectType] IS NULL -- Filter out device info and command responses\r\n) \r\n\r\nSELECT\r\n IoTHub.ConnectionDeviceId AS DeviceId,\r\n Temperature,\r\n Humidity,\r\n ExternalTemperature,\r\n EventProcessedUtcTime,\r\n PartitionId,\r\n EventEnqueuedUtcTime,\r\n * \r\nINTO\r\n [Telemetry]\r\nFROM\r\n [StreamData]\r\n\r\nSELECT\r\n IoTHub.ConnectionDeviceId AS DeviceId,\r\n AVG (Humidity) AS [AverageHumidity],\r\n MIN(Humidity) AS [MinimumHumidity],\r\n MAX(Humidity) AS [MaxHumidity],\r\n 5.0 AS TimeframeMinutes \r\nINTO\r\n [TelemetrySummary]\r\nFROM [StreamData]\r\nWHERE\r\n [Humidity] IS NOT NULL\r\nGROUP BY\r\n IoTHub.ConnectionDeviceId,\r\n SlidingWindow (mi, 5)",
|
||||
"StreamingUnits": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -607,9 +607,9 @@
|
|||
"Transformation": {
|
||||
"Name": "DeviceRules",
|
||||
"Properties": {
|
||||
"Query": "WITH AlarmsData AS \r\n(\r\nSELECT\r\n Stream.DeviceID,\r\n 'Temperature' as ReadingType,\r\n Stream.Temperature as Reading,\r\n Ref.Temperature as Threshold,\r\n Ref.TemperatureRuleOutput as RuleOutput,\r\n Stream.EventEnqueuedUtcTime AS [Time]\r\nFROM IoTTelemetryStream Stream\r\nJOIN DeviceRulesBlob Ref ON Stream.DeviceID = Ref.DeviceID\r\nWHERE\r\n Ref.Temperature IS NOT null AND Stream.Temperature > Ref.Temperature\r\n\r\nUNION ALL\r\n\r\nSELECT\r\n Stream.DeviceID,\r\n 'Humidity' as ReadingType,\r\n Stream.Humidity as Reading,\r\n Ref.Humidity as Threshold,\r\n Ref.HumidityRuleOutput as RuleOutput,\r\n Stream.EventEnqueuedUtcTime AS [Time]\r\nFROM IoTTelemetryStream Stream\r\nJOIN DeviceRulesBlob Ref ON Stream.DeviceID = Ref.DeviceID\r\nWHERE\r\n Ref.Humidity IS NOT null AND Stream.Humidity > Ref.Humidity\r\n)\r\n\r\nSELECT *\r\nINTO DeviceRulesMonitoring\r\nFROM AlarmsData\r\n\r\nSELECT *\r\nINTO DeviceRulesHub\r\nFROM AlarmsData",
|
||||
"Query": "WITH AlarmsData AS \r\n(\r\nSELECT\r\n Stream.IoTHub.ConnectionDeviceId AS DeviceId,\r\n 'Temperature' as ReadingType,\r\n Stream.Temperature as Reading,\r\n Ref.Temperature as Threshold,\r\n Ref.TemperatureRuleOutput as RuleOutput,\r\n Stream.EventEnqueuedUtcTime AS [Time]\r\nFROM IoTTelemetryStream Stream\r\nJOIN DeviceRulesBlob Ref ON Stream.IoTHub.ConnectionDeviceId = Ref.DeviceID\r\nWHERE\r\n Ref.Temperature IS NOT null AND Stream.Temperature > Ref.Temperature\r\n\r\nUNION ALL\r\n\r\nSELECT\r\n Stream.IoTHub.ConnectionDeviceId AS DeviceId,\r\n 'Humidity' as ReadingType,\r\n Stream.Humidity as Reading,\r\n Ref.Humidity as Threshold,\r\n Ref.HumidityRuleOutput as RuleOutput,\r\n Stream.EventEnqueuedUtcTime AS [Time]\r\nFROM IoTTelemetryStream Stream\r\nJOIN DeviceRulesBlob Ref ON Stream.IoTHub.ConnectionDeviceId = Ref.DeviceID\r\nWHERE\r\n Ref.Humidity IS NOT null AND Stream.Humidity > Ref.Humidity\r\n)\r\n\r\nSELECT *\r\nINTO DeviceRulesMonitoring\r\nFROM AlarmsData\r\n\r\nSELECT *\r\nINTO DeviceRulesHub\r\nFROM AlarmsData",
|
||||
"StreamingUnits": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -41,6 +41,28 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.Common.DeviceSch
|
|||
return props;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a IoTHubProperties instance from a device.
|
||||
/// </summary>
|
||||
/// <param name="device"></param>
|
||||
/// <returns></returns>
|
||||
public static dynamic GetIoTHubProperties(dynamic device)
|
||||
{
|
||||
if (device == null)
|
||||
{
|
||||
throw new ArgumentNullException("device");
|
||||
}
|
||||
|
||||
var props = device.IoTHub;
|
||||
|
||||
if (props == null)
|
||||
{
|
||||
throw new DeviceRequiredPropertyNotFoundException("'IoTHubProperties' property is missing");
|
||||
}
|
||||
|
||||
return props;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a Device instance's Device ID.
|
||||
/// </summary>
|
||||
|
@ -69,6 +91,30 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.Common.DeviceSch
|
|||
return deviceID;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get connection device id
|
||||
/// </summary>
|
||||
/// <param name="device">Device instance from message</param>
|
||||
/// <returns>Connection device id from IoTHub</returns>
|
||||
public static string GetConnectionDeviceId(dynamic device)
|
||||
{
|
||||
if (device == null)
|
||||
{
|
||||
throw new ArgumentNullException("device");
|
||||
}
|
||||
|
||||
var props = GetIoTHubProperties(device);
|
||||
|
||||
string deviceID = props.ConnectionDeviceId;
|
||||
|
||||
if (deviceID == null)
|
||||
{
|
||||
throw new DeviceRequiredPropertyNotFoundException("'DeviceID' property is missing");
|
||||
}
|
||||
|
||||
return deviceID;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract's a Device instance's Created Time value.
|
||||
/// </summary>
|
||||
|
|
|
@ -33,8 +33,8 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
|
|||
private readonly ISecurityKeyGenerator _securityKeyGenerator;
|
||||
private readonly IDeviceRulesLogic _deviceRulesLogic;
|
||||
|
||||
public DeviceLogic(IIotHubRepository iotHubRepository, IDeviceRegistryCrudRepository deviceRegistryCrudRepository,
|
||||
IDeviceRegistryListRepository deviceRegistryListRepository, IVirtualDeviceStorage virtualDeviceStorage,
|
||||
public DeviceLogic(IIotHubRepository iotHubRepository, IDeviceRegistryCrudRepository deviceRegistryCrudRepository,
|
||||
IDeviceRegistryListRepository deviceRegistryListRepository, IVirtualDeviceStorage virtualDeviceStorage,
|
||||
ISecurityKeyGenerator securityKeyGenerator, IConfigurationProvider configProvider, IDeviceRulesLogic deviceRulesLogic)
|
||||
{
|
||||
_iotHubRepository = iotHubRepository;
|
||||
|
@ -115,11 +115,11 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
|
|||
{
|
||||
Trace.TraceError("The IsSimulatedDevice property was in an invalid format. Exception Error Message: {0}", ex.Message);
|
||||
}
|
||||
if (capturedException == null && isSimulatedAsBool)
|
||||
if (capturedException == null && isSimulatedAsBool)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _virtualDeviceStorage.AddOrUpdateDeviceAsync(new InitialDeviceConfig()
|
||||
await _virtualDeviceStorage.AddOrUpdateDeviceAsync(new InitialDeviceConfig()
|
||||
{
|
||||
DeviceId = DeviceSchemaHelper.GetDeviceID(device),
|
||||
HostName = _configProvider.GetConfigurationSettingValue("iotHub.HostName"),
|
||||
|
@ -132,7 +132,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
|
|||
Trace.TraceError("Failed to add simulated device : {0}", ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Since the rollback code runs async and async code cannot run within the catch block it is run here
|
||||
if (capturedException != null)
|
||||
|
@ -178,7 +178,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
|
|||
capturedException = ExceptionDispatchInfo.Capture(ex);
|
||||
}
|
||||
|
||||
if (capturedException == null)
|
||||
if (capturedException == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -234,7 +234,8 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
|
|||
}
|
||||
|
||||
// Get original device document
|
||||
dynamic existingDevice = await GetDeviceAsync(DeviceSchemaHelper.GetDeviceID(device));
|
||||
var connectionDeviceId = DeviceSchemaHelper.GetConnectionDeviceId(device);
|
||||
dynamic existingDevice = await GetDeviceAsync(connectionDeviceId);
|
||||
|
||||
// Save the command history, original created date, and system properties (if any) of the existing device
|
||||
if (DeviceSchemaHelper.GetDeviceProperties(existingDevice) != null)
|
||||
|
@ -621,7 +622,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
|
|||
devicePropertyIndex =
|
||||
GetDevicePropertyConfiguration().ToDictionary(t => t.Name);
|
||||
|
||||
dynamicProperties =
|
||||
dynamicProperties =
|
||||
new HashSet<string>(
|
||||
D.Dynamic.GetMemberNames(deviceProperties, true));
|
||||
|
||||
|
@ -646,8 +647,8 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
|
|||
}
|
||||
|
||||
D.Dynamic.InvokeSet(
|
||||
deviceProperties,
|
||||
propVal.Name,
|
||||
deviceProperties,
|
||||
propVal.Name,
|
||||
propVal.Value);
|
||||
}
|
||||
}
|
||||
|
@ -966,7 +967,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
|
|||
{
|
||||
List<string> validationErrors = new List<string>();
|
||||
|
||||
if (ValidateDeviceId(device, validationErrors))
|
||||
if (ValidateDeviceId(device, validationErrors))
|
||||
{
|
||||
await CheckIfDeviceExists(device, validationErrors);
|
||||
}
|
||||
|
@ -1021,13 +1022,13 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
|
|||
SecurityKeys generatedSecurityKeys = _securityKeyGenerator.CreateRandomKeys();
|
||||
dynamic device = SampleDeviceFactory.GetSampleDevice(randomNumber, generatedSecurityKeys);
|
||||
await AddDeviceToRepositoriesAsync(device, generatedSecurityKeys);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<string>> BootstrapDefaultDevices()
|
||||
{
|
||||
List<string> sampleIds = SampleDeviceFactory.GetDefaultDeviceNames();
|
||||
foreach(string id in sampleIds)
|
||||
foreach (string id in sampleIds)
|
||||
{
|
||||
dynamic device = DeviceSchemaHelper.BuildDeviceStructure(id, true, null);
|
||||
SecurityKeys generatedSecurityKeys = _securityKeyGenerator.CreateRandomKeys();
|
||||
|
@ -1047,7 +1048,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
|
|||
double maxLong = double.MinValue;
|
||||
|
||||
var locationList = new List<DeviceLocationModel>();
|
||||
foreach(dynamic device in devices)
|
||||
foreach (dynamic device in devices)
|
||||
{
|
||||
dynamic props = DeviceSchemaHelper.GetDeviceProperties(device);
|
||||
if (props.Longitude == null || props.Latitude == null)
|
||||
|
@ -1085,8 +1086,8 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
|
|||
maxLong = longitude;
|
||||
}
|
||||
if (latitude < minLat)
|
||||
{
|
||||
minLat = latitude;
|
||||
{
|
||||
minLat = latitude;
|
||||
}
|
||||
if (latitude > maxLat)
|
||||
{
|
||||
|
@ -1124,7 +1125,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
|
|||
// Get Telemetry Fields
|
||||
if (device.Telemetry != null)
|
||||
{
|
||||
var deviceTelemetryFields = new List<DeviceTelemetryFieldModel>();
|
||||
var deviceTelemetryFields = new List<DeviceTelemetryFieldModel>();
|
||||
|
||||
foreach (JObject field in device.Telemetry)
|
||||
{
|
||||
|
|
|
@ -127,7 +127,7 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.EventProcessor.W
|
|||
}
|
||||
|
||||
string objectType = eventData.ObjectType.ToString();
|
||||
|
||||
|
||||
var objectTypePrefix = _configurationProvider.GetConfigurationSettingValue("ObjectTypePrefix");
|
||||
if (string.IsNullOrWhiteSpace(objectTypePrefix))
|
||||
{
|
||||
|
@ -149,19 +149,19 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.EventProcessor.W
|
|||
private async Task ProcessDeviceInfo(dynamic deviceInfo)
|
||||
{
|
||||
string versionAsString = "";
|
||||
if(deviceInfo.Version != null)
|
||||
if (deviceInfo.Version != null)
|
||||
{
|
||||
dynamic version = deviceInfo.Version;
|
||||
versionAsString = version.ToString();
|
||||
}
|
||||
switch(versionAsString)
|
||||
switch (versionAsString)
|
||||
{
|
||||
case SampleDeviceFactory.VERSION_1_0:
|
||||
//Data coming in from the simulator can sometimes turn a boolean into 0 or 1.
|
||||
//Check the HubEnabledState since this is actually displayed and make sure it's in a good format
|
||||
DeviceSchemaHelper.FixDeviceSchema(deviceInfo);
|
||||
|
||||
dynamic id = deviceInfo.DeviceProperties.DeviceID;
|
||||
dynamic id = DeviceSchemaHelper.GetConnectionDeviceId(deviceInfo);
|
||||
string name = id.ToString();
|
||||
Trace.TraceInformation("ProcessEventAsync -- DeviceInfo: {0}", name);
|
||||
await _deviceLogic.UpdateDeviceFromDeviceInfoPacketAsync(deviceInfo);
|
||||
|
|
Загрузка…
Ссылка в новой задаче