public async Task <JobServiceModel> ScheduleTwinUpdateAsync( string jobId, string queryCondition, DeviceTwinServiceModel twin, DateTimeOffset startTimeUtc, long maxExecutionTimeInSeconds) { var result = await this.jobClient.ScheduleTwinUpdateAsync( jobId, queryCondition, twin.ToAzureModel(), startTimeUtc.DateTime, maxExecutionTimeInSeconds); // Update the deviceProperties cache, no need to wait var model = new DevicePropertyServiceModel(); var tagRoot = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(twin.Tags)) as JToken; if (tagRoot != null) { model.Tags = new HashSet <string>(tagRoot.GetAllLeavesPath()); } var reportedRoot = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(twin.ReportedProperties)) as JToken; if (reportedRoot != null) { model.Reported = new HashSet <string>(reportedRoot.GetAllLeavesPath()); } var unused = deviceProperties.UpdateListAsync(model); return(new JobServiceModel(result)); }
public DeviceServiceModel ToServiceModel() { var twinModel = new DeviceTwinServiceModel ( etag: this.TwinEtag, deviceId: this.Id, desiredProperties: this.Properties?.Desired, reportedProperties: this.Properties?.Reported, tags: this.Tags, isSimulated: this.IsSimulated ); return(new DeviceServiceModel ( etag: this.DeviceRegistryEtag, id: this.Id, c2DMessageCount: this.C2DMessageCount, lastActivity: this.LastActivity, connected: this.Connected, enabled: this.Enabled, lastStatusUpdated: this.LastStatusUpdated, twin: twinModel, ioTHubHostName: this.IoTHubHostName, authentication: this.Authentication == null ? null : this.Authentication.ToServiceModel() )); }
public JobUpdateTwinApiModel(string deviceId, DeviceTwinServiceModel deviceTwin) { if (deviceTwin != null) { this.Etag = deviceTwin.Etag; this.DeviceId = deviceId; this.Properties = new TwinPropertiesApiModel(deviceTwin.DesiredProperties, deviceTwin.ReportedProperties); this.Tags = deviceTwin.Tags; this.IsSimulated = deviceTwin.IsSimulated; } }
public async Task <JobServiceModel> ScheduleTwinUpdateAsync( string jobId, string queryCondition, DeviceTwinServiceModel twin, DateTimeOffset startTimeUtc, long maxExecutionTimeInSeconds) { var result = await this.jobClient.ScheduleTwinUpdateAsync( jobId, queryCondition, twin.ToAzureModel(), startTimeUtc.DateTime, maxExecutionTimeInSeconds); // Update the deviceGroupFilter cache, no need to wait var unused = this.configService.UpdateDeviceGroupFiltersAsync(twin); return(new JobServiceModel(result)); }
public async Task UpdateDeviceGroupFiltersAsync(DeviceTwinServiceModel twin) { var model = new DeviceGroupFiltersApiModel(); var tagRoot = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(twin.Tags)) as JToken; if (tagRoot != null) { model.Tags = new HashSet <string>(tagRoot.GetAllLeavesPath()); } var reportedRoot = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(twin.ReportedProperties)) as JToken; if (reportedRoot != null) { model.Reported = new HashSet <string>(reportedRoot.GetAllLeavesPath()); } await this.httpClient.PostAsync(this.url, "DeviceGroupFilters", model); }