public void InserOrUpdateHistory(Book bookPara)
        {
            if (bookPara == null)
            {
                return;
            }
            var book = bookPara.Clone();

            Task.Run(() =>
            {
                DbHelper.AddDbOperator(new Action(() =>
                {
                    DbHistory.InsertOrUpdatHistory(AppDataPath.GetAppCacheDbPath(), book);
                }));

                var temp = Books.FirstOrDefault(p => p.BookId == book.BookId);
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    if (temp != null)
                    {
                        Books.Remove(temp);
                    }
                    Books.Insert(0, book);
                });
            });
        }
 /// <summary>
 /// 更新历史纪录,更新本地图书记录
 /// </summary>
 private void UpdateDatabase()
 {
     try
     {
         if (CurrentBook.IsLocal || CurrentBook.IsOnline || CurrentBook.IsTxt)
         {
             DbHelper.AddDbOperator(() =>
             {
                 ViewModelInstance.Instance.LocalBookPage.InserOrUpdateBook(CurrentBook);
             });
         }
         else
         {
             DbHelper.AddDbOperator(() =>
             {
                 ViewModelInstance.Instance.History.InserOrUpdateHistory(CurrentBook);
             });
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine($"{e.Message}\n{e.StackTrace}");
     }
 }
        public async void StartUpdate()
        {
            try
            {
                var taskCount  = 3;
                var groups     = NeedUpdateCatalogs.Split <BookCatalog>(taskCount);
                var enumerable = groups as IEnumerable <BookCatalog>[] ?? groups.ToArray();
                if (groups == null || !enumerable.Any())
                {
                    return;
                }
                IsUpdating = true;

                var tasks = new Task[enumerable.Length];
                for (var i = 0; i < enumerable.Length; i++)
                {
                    if (IsDeleted)
                    {
                        break;
                    }
                    tasks[i] = await Task.Factory.StartNew(async() =>
                    {
                        var catalogs = enumerable[i];
                        foreach (var bookCatalog in catalogs)
                        {
                            try
                            {
                                if (IsDeleted)
                                {
                                    break;
                                }

                                bookCatalog.CatalogContent =
                                    await AnalisysSourceHelper.GetCatalogContent(bookCatalog.CatalogUrl);
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e);
                            }
                            finally
                            {
                                lock (_obj)
                                {
                                    DispatcherHelper.CheckBeginInvokeOnUI(() =>
                                    {
                                        NeedUpdateCount = (int.Parse(NeedUpdateCount) - 1).ToString();
                                    });
                                }
                            }
                        }
                    });
                }

                await Task.Factory.ContinueWhenAll(tasks, (obj) =>
                {
                    DbHelper.AddDbOperator(new Action(() =>
                    {
                        var reslut = DbLocalBook.InsertOrUpdateBookCatalogs(AppDataPath.GetLocalBookDbPath(),
                                                                            NeedUpdateCatalogs);
                    }));

                    DispatcherHelper.CheckBeginInvokeOnUI(() =>
                    {
                        NeedUpdateCount = "";
                    });
                });
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            finally
            {
                IsUpdating = false;
            }
        }