Exemplo n.º 1
0
        public static async Task <List <Item> > GetAllItemsAsync(Rule rule, ProgressCache cache)
        {
            var gatherUrls = GetGatherUrlList(rule);
            var allItems   = new List <Item>();

            foreach (var gatherUrl in gatherUrls)
            {
                cache.IsSuccess = true;
                cache.Message   = "获取链接:" + gatherUrl;

                try
                {
                    var items = await GetItemsAsync(gatherUrl, rule);

                    allItems.AddRange(items);
                }
                catch (Exception ex)
                {
                    cache.IsSuccess = false;
                    cache.Message   = ex.Message;
                    cache.FailureMessages.Add(ex.Message);
                }
            }

            if (rule.IsOrderByDesc)
            {
                allItems.Reverse();
            }
            return(allItems);
        }
Exemplo n.º 2
0
        private ProgressCache InitCache(string guid, string message)
        {
            if (string.IsNullOrEmpty(guid))
            {
                return(null);
            }

            var cache = new ProgressCache
            {
                Status          = StatusProgress,
                IsSuccess       = true,
                Message         = message,
                FailureMessages = new List <string>()
            };

            _cacheManager.AddOrUpdateSliding(guid, cache, 60);
            return(cache);
        }