Exemplo n.º 1
0
        private void ShowTOCCollections()
        {
            try
            {
                List <Page> pageList = new List <Page>();

                List <Chapter> chapterList = BooksOnDeviceAccessor.GetChapters(book.ID);
                if (chapterList != null)
                {
                    pageList = new List <Page>();

                    foreach (Chapter chapter in chapterList)
                    {
                        Page page = BooksOnDeviceAccessor.GetPage(book.ID, chapter.FirstPageID);
                        if (page != null)
                        {
                            pageList.Add(page);
                        }
                    }
                }

                ShowCollectionView(new NSString("TOCCell"), pageList);
            }
            catch (Exception ex)
            {
                Logger.WriteLineDebugging("PageViewController - ShowTOCCollections: {0}", ex.ToString());
            }
        }
Exemplo n.º 2
0
        public static void RemoveBookInCache(Book book)
        {
            // Remove page images from the file system
            List <Page> pageList = BooksOnDeviceAccessor.GetPages(book.ID);

            if (pageList != null)
            {
                foreach (Page page in pageList)
                {
                    DownloadedFilesCache.RemoveFile(page.URL);
                }
            }

            // Remove chapter images from the file system
            List <Chapter> chapterList = BooksOnDeviceAccessor.GetChapters(book.ID);

            if (chapterList != null)
            {
                foreach (Chapter chapter in chapterList)
                {
                    DownloadedFilesCache.RemoveFile(chapter.SmallImageURL);
                    DownloadedFilesCache.RemoveFile(chapter.LargeImageURL);
                }
            }

            // Remove book images from the file system
            DownloadedFilesCache.RemoveFile(book.SmallImageURL);
            DownloadedFilesCache.RemoveFile(book.LargeImageURL);
        }
        private void RetrieveData()
        {
            chapterList  = BooksOnDeviceAccessor.GetChapters(book.ID);
            bookmarkList = BooksOnDeviceAccessor.GetBookmarks(book.ID);
            noteList     = BooksOnDeviceAccessor.GetNotes(book.ID);
            annList      = BooksOnDeviceAccessor.GetAnnotations(book.ID);

            // Update chapter number for backward compatibililty
            if (chapterList != null && chapterList.Count > 0)
            {
                for (int i = 0; i < chapterList.Count; i++)
                {
                    chapterList[i].ChapterNumber = i + 1;
                }

                BooksOnDeviceAccessor.UpdateChapters(book.ID, chapterList);
            }
        }
Exemplo n.º 4
0
        public static void RemoveBook(Book book)
        {
            // Remove page images from the file system
            List <Page> pageList = BooksOnDeviceAccessor.GetPages(book.ID);

            if (pageList != null)
            {
                foreach (Page page in pageList)
                {
                    BooksOnDeviceAccessor.RemoveBookmark(book.ID, page.ID);
                    BooksOnDeviceAccessor.RemoveAllNotesForThisPage(book.ID, page.ID);
                    BooksOnDeviceAccessor.RemoveAnnotation(book.ID, page.ID);

                    DownloadedFilesCache.RemoveFile(page.URL);
                }
            }
            BooksOnServerAccessor.RemovePages(book.ID);
            BooksOnDeviceAccessor.RemovePages(book.ID);

            // Remove chapter images from the file system
            List <Chapter> chapterList = BooksOnDeviceAccessor.GetChapters(book.ID);

            if (chapterList != null)
            {
                foreach (Chapter chapter in chapterList)
                {
                    DownloadedFilesCache.RemoveFile(chapter.SmallImageURL);
                    DownloadedFilesCache.RemoveFile(chapter.LargeImageURL);
                }
            }
            BooksOnServerAccessor.RemoveChapters(book.ID);
            BooksOnDeviceAccessor.RemoveChapters(book.ID);

            // Remove book images from the file system
            DownloadedFilesCache.RemoveFile(book.SmallImageURL);
            DownloadedFilesCache.RemoveFile(book.LargeImageURL);

            BooksOnDeviceAccessor.RemoveBook(book.ID);
        }
Exemplo n.º 5
0
        private static void UpdateDatabase(Book book)
        {
            try
            {
                List <Chapter> chapterList = BooksOnServerAccessor.GetChapters(book.ID);
                List <Page>    pageList    = BooksOnServerAccessor.GetPages(book.ID);

                // Update notes
                if (BooksOnDeviceAccessor.GetNotes(book.ID) != null)
                {
                    // Remove orphans
                    BooksOnDeviceAccessor.RemoveOrphanNotes(book.ID, pageList);
                }

                // Update bookmarks
                if (BooksOnDeviceAccessor.GetBookmarks(book.ID) != null)
                {
                    // Remove orphans
                    BooksOnDeviceAccessor.RemoveOrphanBookmarks(book.ID, pageList);
                }

                // Update new chapters
                if (BooksOnDeviceAccessor.GetChapters(book.ID) == null)
                {
                    BooksOnDeviceAccessor.AddChapters(book.ID, chapterList);
                }
                else
                {
                    BooksOnDeviceAccessor.UpdateChapters(book.ID, chapterList);
                }

                BooksOnDeviceAccessor.MapPagesToChapter(chapterList, pageList); // ML: 4/9/2013 We need to map them after each update

                // Update new pages
                if (BooksOnDeviceAccessor.GetPages(book.ID) == null)
                {
                    BooksOnDeviceAccessor.AddPages(book.ID, pageList);
                }
                else
                {
                    BooksOnDeviceAccessor.UpdatePages(book.ID, pageList);
                }

                // Remove chapters and pages list from BooksOnServer because they now exist on the device
                BooksOnServerAccessor.RemoveChapters(book.ID);
                BooksOnServerAccessor.RemovePages(book.ID);

                // Update new book
                book.New           = true;
                book.Status        = Book.BookStatus.DOWNLOADED;
                book.UserAddedDate = DateTime.UtcNow;

                if (BooksOnDeviceAccessor.GetBook(book.ID) == null)
                {
                    BooksOnDeviceAccessor.AddBook(book);
                }
                else
                {
                    if (BooksDataAccessor.IsFavorite(book.ID))
                    {
                        book.IsFavorite = true;
                    }
                    BooksOnDeviceAccessor.UpdateBook(book);
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLineDebugging("BookUpdater - UpdateDatabase: {0}", ex.ToString());
            }
        }