Пример #1
0
        public void SetBookList(string html)
        {
            if (!string.IsNullOrEmpty(html))
            {
                var list = AnalysisSoduService.GetBookShelftListFromHtml(html);
                if (list == null)
                {
                    this.IsShow = true;
                }
                else
                {
                    this.ShelfBookList?.Clear();
                    this.IsShow = false;

                    if (list.Count > 0)
                    {
                        var temp = list.OrderByDescending(p => DateTime.Parse(p.UpdateTime)).ToList();
                        foreach (var item in temp)
                        {
                            var entity = DBBookShelf.GetBook(AppDataPath.GetBookShelfDBPath(), item);
                            if (!string.IsNullOrEmpty(entity?.LastReadChapterName))
                            {
                                item.LastReadChapterName = entity.LastReadChapterName;
                                var sim = LevenshteinDistancePercent(item.LastReadChapterName, item.NewestChapterName);
                                if (sim)
                                {
                                    item.UnReadCountData = "";
                                }
                                else
                                {
                                    item.UnReadCountData = "(有更新)";
                                }
                            }
                            else
                            {
                                item.UnReadCountData     = "(有更新)";
                                item.LastReadChapterName = item.NewestChapterName;
                            }
                            ShelfBookList.Add(item);
                        }
                        DBBookShelf.ClearBooks(AppDataPath.GetBookShelfDBPath());
                        DBBookShelf.InsertOrUpdateBooks(AppDataPath.GetBookShelfDBPath(), ShelfBookList.ToList());
                    }
                }
                ToastHeplper.ShowMessage("个人书架已更新");
            }
        }