示例#1
0
        /// <summary>
        /// Remove a book from the library
        /// </summary>
        /// <param name="bookFile">Path to the folder which contains the book files</param>
        public static void Discard(string bookFile) //Permanently remove a book from the library
        {
            if (!File.Exists(bookFile))
            {
                return;
            }

            const string sqlDeleteBook       = "DELETE FROM books WHERE Path = @Path";
            const string sqlDeleteCategories = "DELETE FROM categories WHERE Path = @Path";

            var bookFileRelativePath = GetRelativeBookFilePath(bookFile);

            try
            {
                File.Delete(bookFile);

                Db.NonQuery(sqlDeleteBook, new[] { new SQLiteParameter("Path", bookFileRelativePath) });
                Db.NonQuery(sqlDeleteCategories, new[] { new SQLiteParameter("Path", bookFileRelativePath) });

                LibraryStructure.GenerateFileTree();
                MainWindow.MW.BookGridReload();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                MainWindow.Info(String.Format(UiLang.Get("DiscardingBookFailed"), bookFile));
                DebugConsole.WriteLine("Book keeper: I was unable to delete " + bookFile + ": " + e);
            }
        }
示例#2
0
        private static void AddBooksFromList(IEnumerable <string> list)
        {
            Busy(true);

            Task.Factory.StartNew(() =>
            {
                foreach (var file in list)
                {
                    BookKeeper.Add(file);
                }

                MW.Dispatcher.Invoke(() =>
                {
                    LibraryStructure.GenerateFileTree();
                    MW.BookGridReload();
                });

                Busy(false);
            });
        }