private async Task CompleteUpdate()
        {
            var currentDeviceModel = deviceSetupService.CurrentDeviceModel;

            if (currentDeviceModel == null)
            {
                return;
            }

            var updateTagsModel = new DevicesUpdateTagsModel
            {
                DeviceIds = new List <Guid> {
                    currentDeviceModel.DeviceId
                },
                Name        = currentDeviceModel.Name,
                Enabled     = currentDeviceModel.Enabled,
                Geolocation = currentDeviceModel.Geolocation,
                Location1   = currentDeviceModel.Location1,
                Location2   = currentDeviceModel.Location2,
                Location3   = currentDeviceModel.Location3,
                SSID        = deviceSetupService.CurrentDeviceModel.SSID
            };

            var success = await deviceRestService.UpdateDevice(updateTagsModel);

            deviceSetupService.IsNew = false;

            OnDeviceUpdated?.Invoke(this, success);
        }
        public async Task <bool> UpdateDevice(DevicesUpdateTagsModel updateTagsModel)
        {
            var request = PrepareRequest("/IoTHub/Tags", Method.PUT, updateTagsModel);
            var result  = await client.ExecuteTaskAsync <bool>(request);

            if (result.IsSuccessful)
            {
                return(result.Data);
            }

            logger.Log($"Error updating device: {result.ErrorMessage}");

            return(false);
        }
        /// <summary>
        /// Update a set of devices tags
        /// </summary>
        /// <param name="devices">List of device ids</param>
        /// <returns>True if the masstransit publish command has succeeded</returns>
        public async Task <bool> UpdateDevicesTags(DevicesUpdateTagsModel devices)
        {
            var tags = new
            {
                devices.Geolocation,
                devices.Name,
                devices.Location1,
                devices.Location2,
                devices.Location3,
                devices.Custom,
                devices.Enabled
            };

            await _serviceBus.BusAccess.Publish(new IoTDevicesUpdateRequestedEvent()
            {
                DeviceIds   = devices.DeviceIds,
                JsonDesired = "",
                JsonTags    = JsonConvert.SerializeObject(tags)
            });

            return(true);
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> UpdateDevicesTags(DevicesUpdateTagsModel devices)
        {
            var result = await _iotHubControllerDataManager.UpdateDevicesTags(devices);

            return(Ok(result));
        }
Ejemplo n.º 5
0
 public Task <bool> UpdateDevice(DevicesUpdateTagsModel updateTagsModel)
 {
     return(Task.FromResult(true));
 }