protected override CachedTask <EventPoolResponse> GetData(bool force, CancellationToken token)
        {
            if (force ||
                Pool == null ||
                (Pool != null && Pool.AlwaysRefresh == true) ||
                (_previousSettings.Item1 != _settings.SearchPeriod || _previousSettings.Item2 != _settings.SearchInPast))
            {
                if (!_settings.ExcludedCategoriesByPool.ContainsKey(_poolId))
                {
                    _settings.ExcludedCategoriesByPool.Add(_poolId, new int[0]);
                }
                if (!_settings.ExcludedTagsByPool.ContainsKey(_poolId))
                {
                    _settings.ExcludedTagsByPool.Add(_poolId, new string[0]);
                }

                var request = new EventPoolRequest
                {
                    PoolId           = _poolId,
                    HoursCount       = (int)_settings.SearchPeriod,
                    IsInPast         = _settings.SearchInPast,
                    UserTickets      = _settings.UserTickets.ToArray(),
                    FavoriteEventIds = _settings.FavoriteItemIds.ToArray(),
                    Language         = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName
                };
                return(CachedTask.Create(() => _eventsService.GetEventPoolAsync(request, token), _poolId, DateTime.Now.Add(CacheDuration)));
            }
            return(CachedTask.NoNewData <EventPoolResponse>());
        }
示例#2
0
 public Task <EventPoolResponse> GetEventPoolAsync(EventPoolRequest request, CancellationToken cancellationToken)
 {
     return(CallAsync <EventPoolRequest, CancellationToken, EventPoolResponse>(x => x.GetEventPoolAsync, request, cancellationToken));
 }