public static void Show(UIView view, CloudSync.SyncType syncType) { if (Reachability.IsDefaultNetworkAvailable()) { LoadingView.CancelEvent += HandleCancelEvent; LoadingView.Show("Syncing", "Please wait while" + '\n' + "eBriefing is syncing." + '\n' + "This may take a few minutes..."); // Pull sync if (syncType == CloudSync.SyncType.PULL) { CloudSync.ReceiveDoneEvent += HandleReceiveDoneEvent; CloudSync.Pull(); } // Push and Pull sync else if (syncType == CloudSync.SyncType.PUSH_AND_PULL) { PushNPullInProgress = true; CloudSync.SyncDoneEvent += HandleSyncDoneEvent; CloudSync.PushAndPull(); } } else { StartTimer(); } }
async public static void Push() { if (!CloudSync.SyncingInProgress) { await eBriefingService.Run(() => CloudSync.Push()); } }
static void HandleCancelEvent() { LoadingView.CancelEvent -= HandleCancelEvent; LoadingView.Hide(); CloudSync.CancelSync(); }
async private Task OpenSyncView() { LoadingView.Show("Syncing", "Please wait while" + '\n' + "eBriefing is syncing." + '\n' + "This may take a few minutes...", false); // Start Push and Pull if (!CloudSync.SyncingInProgress) { CloudSync.SyncingInProgress = true; await eBriefingService.Run(() => CloudSync.PushAndPull()); CloudSync.SyncingInProgress = false; } LoadingView.Hide(); // Once syncing is finished, check books to download BookUpdater.CheckBooks2Download(); }
async private Task OpenSyncView(bool bfromSyncButton = false) { LoadingView.Show("Syncing", "Please wait while" + '\n' + "eBriefing is syncing." + '\n' + "This may take a few minutes...", false); // Start Push and Pull if (!CloudSync.SyncingInProgress) { CloudSync.SyncingInProgress = true; await eBriefingService.Run(() => CloudSync.PushAndPull()); CloudSync.SyncingInProgress = false; } LoadingView.Hide(); // Once syncing is finished, check books to download BookUpdater.CheckBooks2Download(); // Refresh HandleRefreshEvent1(this, EventArgs.Empty); if (tabBarController.SelectedIndex == 1) { HandleRefreshEvent2(this, EventArgs.Empty); } else if (tabBarController.SelectedIndex == 2) { HandleRefreshEvent3(this, EventArgs.Empty); } else if (tabBarController.SelectedIndex == 3) { vc4.LoadBooks(); } if (!bfromSyncButton) { // Start the PUSH timer in the background SyncPushTimer.Start(); } }
private static void Sync() { CloudSync.Push(); }
async private void DeleteMyStuff() { await eBriefingService.Run(() => CloudSync.DeleteMyStuff()); }
public static void Start() { if (Books2Download != null && Books2Download.Count > 0) { try { // Check to see if there is any book that was downloading or updating in progress. // If there is, then resume downloading and do not sort bool sortRequired = true; foreach (Book book in Books2Download) { if (book.Status == Book.BookStatus.DOWNLOADING || book.Status == Book.BookStatus.UPDATING) { sortRequired = false; } } if (sortRequired) { SortBooks(); } InProgress = true; CurrentBook = Books2Download[0]; if (CurrentBook.Status == Book.BookStatus.PENDING2UPDATE) { CurrentBook.Status = Book.BookStatus.UPDATING; } else if (CurrentBook.Status == Book.BookStatus.PENDING2DOWNLOAD) { CurrentBook.Status = Book.BookStatus.DOWNLOADING; } BackgroundWorker downloadWorker = new BackgroundWorker(); downloadWorker.WorkerSupportsCancellation = true; downloadWorker.DoWork += async delegate { // Get my stuff for this book if (CurrentBook.Status == Book.BookStatus.DOWNLOADING) { if (!CloudSync.SyncingInProgress) { await eBriefingService.Run(() => CloudSync.PullMyStuffs(CurrentBook)); } } List <String> fileUrlsToDownload = new List <String>(); // Notify UI the start of the downloading ParentViewController.InvokeOnMainThread(delegate { if (DownloadStartEvent != null) { DownloadStartEvent(CurrentBook.ID); } }); // Queue up cover images for the book only if the image version is different if (CurrentBook.Status == Book.BookStatus.UPDATING) { Book deviceBook = BooksOnDeviceAccessor.GetBook(CurrentBook.ID); if (deviceBook != null && (deviceBook.ImageVersion != CurrentBook.ImageVersion)) { DownloadedFilesCache.RemoveFile(deviceBook.LargeImageURL); DownloadedFilesCache.RemoveFile(deviceBook.SmallImageURL); fileUrlsToDownload.Add(CurrentBook.LargeImageURL); fileUrlsToDownload.Add(CurrentBook.SmallImageURL); } } // Download chapters await eBriefingService.Run(() => DownloadChaptersWork(CurrentBook.ID, fileUrlsToDownload)); // Download pages List <Page> pageList = await eBriefingService.Run(() => DownloadPagesWork(CurrentBook.ID)); if (pageList != null) { List <Page> differentPageList = Pages2Download(CurrentBook.ID, pageList); foreach (Page page in differentPageList) { fileUrlsToDownload.Add(page.URL); } } // Filter out those files that are already downloaded (Only if the status is DOWNLOADING, not UPDATING) // CoreServices 2.0 will check for updates too since we can check for version number for each file fileUrlsToDownload = RemoveAlreadyDownloadedFiles(fileUrlsToDownload); // Download Start if (fileUrlsToDownload.Count == 0) { QueueDidFinish(null); } else { DownloadPDFsWork(CurrentBook.ID, fileUrlsToDownload); } }; downloadWorker.RunWorkerAsync(); } catch (Exception ex) { Logger.WriteLineDebugging("BookUpdater - Start: {0}", ex.ToString()); } } }