Example #1
0
        public async Task <GetLatestActivitiesResponse> Handle(GetLatestActivitiesQuery message)
        {
            var result = await _activitiesClient.GetLatestActivities(message.AccountId);

            return(new GetLatestActivitiesResponse
            {
                Result = result
            });
        }
Example #2
0
        public async Task WhenIGetLatestActivities(string accountName)
        {
            var account = _context.GetAccount(accountName);

            _context.Set(account);

            await Task.WhenAll(_context.GetAccounts().Select(async a =>
            {
                var result = await Policy
                             .HandleResult <AggregatedActivitiesResult>(r => r.Total != a.MessageCount)
                             .WaitAndRetryAsync(_sleepDurations)
                             .ExecuteAsync(async() => await _activitiesClient.GetLatestActivities(a.Id));

                a.SetResult(result);
            }));
        }
        public async Task DoAsync(CancellationToken cancellationToken)
        {
            var config = _configProvider.Get <AggregateQueryConfig>();

            foreach (var accountId in NumberRange.ToInts(config.AccountIds))
            {
                var results = await _client.GetLatestActivities(accountId);

                var tubeStops = results.Aggregates.Count();
                if (tubeStops == 0 && config.IgnoreNotFound)
                {
                    continue;
                }

                var activitiesCount = results.Aggregates.Sum(a => a.Count);

                Console.WriteLine($"Account id {accountId} found {tubeStops} tube stops covering {activitiesCount} activities");

                await _resultSaver.Save(results);
            }
        }