Esempio n. 1
0
        public async Task Execute(FavContext context, CancellationToken ct)
        {
            foreach (var request in from favLink in context.Links
                     where !string.IsNullOrWhiteSpace(favLink)
                     select new FavLinkRequest(context.User.Cookies, favLink))
            {
                await Gate.SendAsync(request);

                await Task.Delay(TimeSpan.FromSeconds(context.Settings.WaitingBetweenFav), ct);
            }
        }
Esempio n. 2
0
        public async Task Execute(FavContext context, CancellationToken ct)
        {
            var request = new GalleryPageRequest(context.User.Cookies);
            var parser  = new GalleryPageResponseParser();

            try
            {
                var response =
                    await Gate.SendAsync <GalleryPageRequest, HashSet <string>, GalleryPageResponseParser>(request, parser);

                await Task.Delay(TimeSpan.FromSeconds(2), ct); // to simulate user behavior

                context.Links = response !;
            }
            catch (FuraffinityApiException)
            {
                //don't cate about a couple of bad links
            }
        }
Esempio n. 3
0
        public async Task Execute(UserEntity user, SettingEntity setting, CancellationToken ct)
        {
            try
            {
                var context = new FavContext()
                {
                    User = user, Settings = setting
                };
                foreach (var page in _favPages.OrderBy(action => action.Order))
                {
                    await page.Execute(context, ct);
                }

                OnFavExecuted.Invoke(context.Links.Count);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex);
            }
        }
Esempio n. 4
0
        public async Task Execute(FavContext context, CancellationToken ct)
        {
            var result = new HashSet <string>();
            var parser = new FavResponseParser(FavAction.Fav);

            foreach (var request in from contextLink in context.Links
                     where !string.IsNullOrWhiteSpace(contextLink)
                     select new FavLinkRequest(context.User.Cookies, contextLink))
            {
                try
                {
                    var response = await Gate.SendAsync <FavLinkRequest, string, FavResponseParser>(request, parser);

                    await Task.Delay(TimeSpan.FromSeconds(2), ct); // to simulate user behavior

                    result.Add(response !);
                    context.Links = result !;
                }
                catch (FuraffinityApiException)
                {
                    //don't cate about a couple of bad links
                }
            }
        }