Ensure non-device-owned properties are not overwritten by the device.
This commit is contained in:
Родитель
60528dd8c4
Коммит
7b755b0bf0
|
@ -33,6 +33,11 @@
|
|||
public const string UPDATED_TIME = "UpdatedTime";
|
||||
public const string HOST_NAME = "HostName";
|
||||
public const string ICCID = "ICCID";
|
||||
|
||||
/// <summary>
|
||||
/// The list of properties not owned by the device.
|
||||
/// </summary>
|
||||
public static readonly string[] External = { ICCID };
|
||||
}
|
||||
|
||||
public static class CommandModelConstants
|
||||
|
|
|
@ -235,10 +235,17 @@ namespace Microsoft.Azure.Devices.Applications.RemoteMonitoring.DeviceAdmin.Infr
|
|||
dynamic existingDevice = await GetDeviceAsync(DeviceSchemaHelper.GetDeviceID(device));
|
||||
|
||||
// Save the command history and the original created date of the existing device
|
||||
if (DeviceSchemaHelper.GetDeviceProperties(existingDevice) != null)
|
||||
dynamic existingDeviceProperties = DeviceSchemaHelper.GetDeviceProperties(existingDevice);
|
||||
if (existingDeviceProperties != null)
|
||||
{
|
||||
dynamic deviceProperties = DeviceSchemaHelper.GetDeviceProperties(device);
|
||||
deviceProperties.CreatedTime = DeviceSchemaHelper.GetCreatedTime(existingDevice);
|
||||
|
||||
// Save existing external properties to the updated device
|
||||
foreach (string ext in DevicePropertiesConstants.External)
|
||||
{
|
||||
D.Dynamic.InvokeSet(deviceProperties, ext, D.Dynamic.InvokeGet(existingDeviceProperties, ext));
|
||||
}
|
||||
}
|
||||
|
||||
device.CommandHistory = existingDevice.CommandHistory;
|
||||
|
|
Загрузка…
Ссылка в новой задаче