コード例 #1
0
        public async void GetData()
        {
            if (!CookieHelper.CheckLogin() || IsLoading)
            {
                return;
            }
            try
            {
                IsLoading = true;

                var html = await GetHtmlData2(SoduPageValue.BookShelfPage, false, true);

                var list = ListPageDataHelper.GetBookShelftListFromHtml(html);
                if (list == null || list.Count == 0)
                {
                    if (html != null && html.Contains(SoduPageValue.BookShelfPage))
                    {
                        Books = null;
                        ToastHelper.ShowMessage("您的在线书架为空");
                    }
                    else
                    {
                        ToastHelper.ShowMessage("获取在线书架数据失败");
                    }
                }
                else
                {
                    var result = await CompareWithLocalCache(list.ToList());

                    Books?.Clear();
                    foreach (var book in list)
                    {
                        Books?.Add(book);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message + "\n" + ex.StackTrace);
            }
            finally
            {
                IsLoading = false;
            }
        }
コード例 #2
0
        public async Task <List <Book> > GetOnlineData()
        {
            try
            {
                var html = await GetHtmlData(SoduPageValue.BookShelfPage, true);

                var list = ListPageDataHelper.GetBookShelftListFromHtml(html)?.ToList();
                if (list == null || list.Count == 0)
                {
                    return(null);
                }
                return(list);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message + "\n" + ex.StackTrace);
                return(null);
            }
        }