private static void PullNotesWork(Book book) { List <Note> sNotes = null; if (String.IsNullOrEmpty(URL.MultipleNoteURL)) { sNotes = SaveMyStuff.GetMyNotes(book.ID); } else { sNotes = SaveMyStuff.GetMyNotes(book.ID, book.LastSyncedDate); } if (sNotes != null && sNotes.Count > 0) { foreach (var sNote in sNotes) { Note dNote = null; if (String.IsNullOrEmpty(URL.MultipleNoteURL)) { dNote = BooksOnDeviceAccessor.GetNote(book.ID, sNote.PageID); } else { dNote = BooksOnDeviceAccessor.GetNote(book.ID, sNote.NoteID); } if (dNote == null) { // This is a new note from the server BooksOnDeviceAccessor.AddNote(sNote); } else { if (dNote.ModifiedUtc <= sNote.ModifiedUtc) { if (sNote.Removed) { // Remove note if the note on the cloud has 'Removed' checked if (String.IsNullOrEmpty(URL.MultipleNoteURL)) { BooksOnDeviceAccessor.RemoveNote(dNote.BookID, dNote.PageID); } else { BooksOnDeviceAccessor.RemoveNote(dNote.BookID, dNote.NoteID); } } else { BooksOnDeviceAccessor.UpdateNote(sNote); } } } } } // Update the last time synced for this book book.LastSyncedDate = DateTime.UtcNow; BooksOnDeviceAccessor.UpdateBook(book); }
private static void PullMyBooksWork() { try { List <Book> sBooks = SaveMyStuff.GetMyBooks(); if (sBooks != null && sBooks.Count > 0) { foreach (var sBook in sBooks) { Book dBook = BooksOnDeviceAccessor.GetBook(sBook.ID); if (dBook == null) { // This is a new book from the server BooksOnDeviceAccessor.AddBook(sBook); } else { if (dBook.ServerModifiedDate <= sBook.ServerModifiedDate) { if (sBook.Removed) { // Remove bookmark if the bookmark on the cloud has 'Removed' checked BookRemover.RemoveBook(sBook); } else { sBook.UserAddedDate = DateTime.UtcNow; sBook.New = true; BooksOnDeviceAccessor.UpdateBook(sBook); } } } } } // Download detail information about these books List <Book> bookList = eBriefingService.StartDownloadBooks(); if (bookList != null && bookList.Count > 0) { List <Book> dBooks = BooksOnDeviceAccessor.GetBooks(); if (dBooks != null && dBooks.Count > 0) { foreach (var book in bookList) { var item = dBooks.Where(i => i.ID == book.ID && i.Status == Book.BookStatus.NONE).FirstOrDefault(); if (item != null) { book.Status = Book.BookStatus.PENDING2DOWNLOAD; book.New = true; BooksOnDeviceAccessor.UpdateBook(book); } } } } } catch (Exception ex) { Logger.WriteLineDebugging("CloudSync - PullMyBooksWork: {0}", ex.ToString()); } }