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));
        }
Exemple #2
0
        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));
        }