/// <inheritdoc/> public async Task <PublisherListModel> QueryPublishersAsync( PublisherQueryModel query, bool onlyServerState, int?pageSize, CancellationToken ct) { var result = await _client.QueryPublishersAsync(query.ToApiModel(), onlyServerState, pageSize, ct); return(result.ToServiceModel()); }
/// <inheritdoc/> public async Task <PublisherListModel> QueryPublishersAsync( PublisherQueryModel model, bool onlyServerState, int?pageSize, CancellationToken ct) { var query = "SELECT * FROM devices.modules WHERE " + $"properties.reported.{TwinProperty.Type} = '{IdentityType.Publisher}'"; if (model?.SiteId != null) { // If site id provided, include it in search query += $"AND (properties.reported.{TwinProperty.SiteId} = " + $"'{model.SiteId}' OR properties.desired.{TwinProperty.SiteId} = " + $"'{model.SiteId}')"; } if (model?.Connected != null) { // If flag provided, include it in search if (model.Connected.Value) { query += $"AND connectionState = 'Connected' "; // Do not use connected property as module might have exited before updating. } else { query += $"AND (connectionState = 'Disconnected' " + $"OR properties.reported.{TwinProperty.Connected} != true) "; } } var queryResult = await _iothub.QueryDeviceTwinsAsync(query, null, pageSize, ct); return(new PublisherListModel { ContinuationToken = queryResult.ContinuationToken, Items = queryResult.Items .Select(t => t.ToPublisherRegistration(onlyServerState)) .Select(s => s.ToServiceModel()) .ToList() }); }