예제 #1
0
        private void _btnOK_Click(object sender, RoutedEventArgs e)
        {
            switch (_action)
            {
            case "NEW": _crawler.AddBook(model); break;

            case "EDIT": _crawler.Save(); break;
            }
            DialogResult = true;
            Close();
        }
예제 #2
0
        /// <summary>
        /// Процедура загрузки из БД
        /// </summary>
        /// <param name="applyFilter"></param>
        private void LoadBooksFromDb(bool applyFilter = false)
        {
            var list = db.LoadBooksFromDb();

            model.LoadHidden();
            int count               = list.RemoveAll(book => model.HiddenIncludes(book));
            int syncNotDownloaded   = 0;
            int downloadedNotSynced = 0;
            int downloaded          = 0;

            list.ForEach(book =>
            {
                if (book.IsDownloaded)
                {
                    book.IsChecked = true;
                    downloaded++;
                    if (book.Sync == 0)     //downloaded but not synced
                    {
                        book.Sync = 1;
                        db.Save();
                        downloadedNotSynced++;
                    }
                }
                else if (book.Sync > 0)
                {
                    book.IsChecked = true;
                    syncNotDownloaded++;
                }
            });
            model.Books = list;

            model.GetSorting("PostId");
            model.ApplyFilterAndLoad("");
            var lastUpdate = (new FileInfo(DB_PATH)).LastWriteTime.ToString("dd.MM.yyyy HH:mm:ss");

            Notify($"Books loaded ok. DB last updated {lastUpdate}. Total {downloaded} books downloaded. {(syncNotDownloaded > 0 ? $"{syncNotDownloaded} books to synchronize." : "")}");
        }