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);
            }
        }
Esempio n. 2
0
        private void UpdateDocumentBookmarkRibbons()
        {
            List <Bookmark> bookmarkList = BooksOnDeviceAccessor.GetBookmarks(book.ID);

            if (bookmarkList != null)
            {
                // Clear all the bookmarks first
                NSError error;
                this.Document.BookmarkParser.ClearAllBookmarks(out error);

                // Add bookmarks
                foreach (Bookmark bookmark in bookmarkList)
                {
                    Page page = BooksOnDeviceAccessor.GetPage(bookmark.BookID, bookmark.PageID);
                    AddBookmarkToBookmarkParser((UInt32)page.PageNumber - 1);
                }
            }
        }
Esempio n. 3
0
        private void ShowBookmarkCollections()
        {
            try
            {
                List <Page> pageList = new List <Page>();

                List <Bookmark> bookmarkList = BooksOnDeviceAccessor.GetBookmarks(book.ID);
                if (bookmarkList != null)
                {
                    foreach (Bookmark bookmark in bookmarkList)
                    {
                        Page page = BooksOnDeviceAccessor.GetPage(bookmark.BookID, bookmark.PageID);
                        pageList.Add(page);
                    }
                }

                ShowCollectionView(new NSString("BookmarkCell"), pageList);
            }
            catch (Exception ex)
            {
                Logger.WriteLineDebugging("PageViewController - ShowBookmarkCollections: {0}", ex.ToString());
            }
        }
Esempio n. 4
0
        static void HandleGetMyBookmarksEvent(String bookID, List <Bookmark> sBookmarks, bool lastItem)
        {
            try
            {
                List <Bookmark> dBookmarks = BooksOnDeviceAccessor.GetBookmarks(bookID);
                if (dBookmarks != null && dBookmarks.Count > 0)
                {
                    foreach (Bookmark dBookmark in dBookmarks)
                    {
                        if (sBookmarks != null && sBookmarks.Count > 0)
                        {
                            foreach (Bookmark sBookmark in sBookmarks)
                            {
                                if (dBookmark.PageID == sBookmark.PageID)
                                {
                                    if (dBookmark.ModifiedUtc < sBookmark.ModifiedUtc)
                                    {
                                        if (sBookmark.Removed)
                                        {
                                            // Remove bookmark if bookmark on the cloud has 'Removed' checked
                                            BooksOnDeviceAccessor.RemoveBookmark(dBookmark.BookID, dBookmark.PageID);
                                        }
                                        else
                                        {
                                            // Update bookmark if bookmark on the cloud has the latest ModifiedUtc
                                            dBookmark.BookVersion = sBookmark.BookVersion;
                                            dBookmark.Title       = sBookmark.Title;
                                            dBookmark.ModifiedUtc = sBookmark.ModifiedUtc;

                                            BooksOnDeviceAccessor.UpdateBookmark(dBookmark);
                                        }
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }

                // Add bookmark if the bookmark is not on the device
                if (sBookmarks != null && sBookmarks.Count > 0)
                {
                    foreach (Bookmark sBookmark in sBookmarks)
                    {
                        if (!sBookmark.Removed)
                        {
                            if (BooksOnDeviceAccessor.GetBookmark(sBookmark.BookID, sBookmark.PageID) == null)
                            {
                                BooksOnDeviceAccessor.AddBookmark(sBookmark);
                            }
                        }
                    }
                }

                // Check if syncing is done
                if (cancelled)
                {
                    SetReceive(true);

                    CheckReceiveDone();
                }
                else
                {
                    if (lastItem)
                    {
                        SaveMyStuff.GetMyBookmarksEvent -= HandleGetMyBookmarksEvent;
                        receiveBookmarks = true;

                        CheckReceiveDone();
                    }
                }
            }
            catch (Exception ex)
            {
                SetReceive(true);

                CheckReceiveDone();

                Logger.WriteLineDebugging("CloudSync - HandleGetMyBookmarksEvent: {0}", ex.ToString());
            }
        }
Esempio 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());
            }
        }