public async Task <IEnumerable <福利> > GetPagedItemsAsync(int pageIndex, int pageSize, CancellationToken cancellationToken = default(CancellationToken))
        {
            var res = await GankService.GetRandomCategoryItemsAsync <福利>(pageSize);

            if (res == null || !res.Any())
            {
                throw new NoMoreItemsException();
            }
            return(res);
        }
Example #2
0
        public static async Task UpdateTileByPhotos(IEnumerable <福利> fulis = null)
        {
            try
            {
                fulis = fulis ?? await GankService.GetRandomCategoryItemsAsync <福利>(5);

                var updater = getTileUpdater(fulis.Count() >= 5);
                foreach (var f in fulis.Sample(5))
                {
                    string xml;
                    xml = getFuliTileXML(f);
                    var doc = loadXml(xml);
                    updater.Update(new TileNotification(doc));
                }
                Setting.LastUpdateTime = DateTime.Now;
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
        }
        public async Task <IEnumerable <T> > GetPagedItemsAsync(int pageIndex, int pageSize, CancellationToken cancellationToken = default(CancellationToken))
        {
            //Views.Busy.SetBusy(true,$"加载第{pageIndex + 1}页数据。");
            //try
            //{
            var res = await GankService.GetRandomCategoryItemsAsync <T>(pageSize);

            if (res == null || !res.Any())
            {
                throw new NoMoreItemsException();
            }
            return(res);
            //}
            //catch (Exception e)
            //{
            //    Debug.WriteLine($"获取{typeof(T)}数据失败:" + e.Message);
            //    return new T[0];
            //}
            //finally
            //{
            //    //Views.Busy.SetBusy(false);
            //}
        }