Exemple #1
0
        private static void PullStart()
        {
            if (cancelled)
            {
                SetReceive(true);

                CheckReceiveDone();
            }
            else
            {
                if (Reachability.IsDefaultNetworkAvailable())
                {
                    SaveMyStuff.GetMyBooksEvent += HandleGetMyBooksEvent;
                    SaveMyStuff.GetMyBooks();
                }
                else
                {
                    if (currentSyncType == SyncType.PUSH_AND_PULL)
                    {
                        if (SyncDoneEvent != null)
                        {
                            SyncDoneEvent();
                        }
                    }
                }
            }
        }
Exemple #2
0
        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());
            }
        }