Example #1
0
        protected async Task RefreshSubscriptions(CancellationToken cancellationToken)
        {
            var query = new PagedQuery()
            {
                CurrentPage = 1
            };

            var  posIdentifiers = new HashSet <Guid>();
            bool addedAtLeastOne;

            do
            {
                addedAtLeastOne = false;
                var posPage = await _posService.BrowsePointsOfSale(query);

                if (posPage.Items is null)
                {
                    break;
                }

                foreach (var pos in posPage.Items)
                {
                    if (posIdentifiers.Add(pos.Id))
                    {
                        addedAtLeastOne = true;
                    }
                }
            } while (addedAtLeastOne);

            var subscriptions = posIdentifiers.Select(_posTopicClassifier.GetStatsTopic);

            _logger.LogInformation($"Updating subscriptions to {posIdentifiers.Count} points of sale");

            try
            {
                await _client.SubscribeAsync(subscriptions.Select(topic => new TopicFilterBuilder().WithTopic(topic).Build()));
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Could not update subscriptions");
            }
        }
Example #2
0
 public async Task <ActionResult <IPagedResult <PointOfSale> > > BrowsePointsOfSale([FromQuery] BrowsePointsOfSale query) =>
 Collection(await _pointsOfSaleService.BrowsePointsOfSale(query));