Esempio n. 1
0
        public static void RequestDidFinish(NSObject sender)
        {
            try
            {
                ASIHTTPRequest request = sender as ASIHTTPRequest;
                if (request != null)
                {
                    // THIS IS REQUIRED TO SKIP iCLOUD BACKUP
                    SkipBackup2iCloud.SetAttribute(request.DownloadDestinationPath);

                    // Removed from the list if succeeded re-downloading
                    if (CurrentBook.FailedURLs != null)
                    {
                        if (CurrentBook.FailedURLs.Contains(request.Url.AbsoluteString))
                        {
                            CurrentBook.FailedURLs.Remove(request.Url.AbsoluteString);
                        }
                    }

                    CurrentBook.DownloadCount += 1;

                    DownloadReporter.UpdateProgress();
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLineDebugging("BookUpdater - RequestDidFinish: {0}", ex.ToString());
            }
        }
Esempio n. 2
0
        public static void QueueDidFinish(NSObject sender)
        {
            try
            {
                if (CurrentBook != null)
                {
                    if (CurrentBook.Cancelled)
                    {
                        // Dequeue
                        Dequeue(CurrentBook.ID);

                        // If all the update has been completed, do followings
                        if (Books2Download != null && Books2Download.Count == 0)
                        {
                            DownloadFinished();
                        }
                        else
                        {
                            // Start downloading next book
                            Start();
                        }
                    }
                    else
                    {
                        if (CurrentBook.FailedURLs != null && CurrentBook.FailedURLs.Count > 0)
                        {
                            DownloadReporter.ShowAlertView();
                        }
                        else
                        {
                            // Initialize FailedURLs
                            if (CurrentBook.FailedURLs != null)
                            {
                                InitializeFailedURLs();
                            }

                            bool updated = false;
                            if (CurrentBook.Status == Book.BookStatus.UPDATING)
                            {
                                updated = true;

                                RemoveBookFromBooks2Update(CurrentBook.ID);
                            }

                            UpdateDatabase(CurrentBook);

                            DownloadReporter.DownloadFinished(updated);

                            // Dequeue
                            Dequeue(CurrentBook.ID);

                            // Start downloading next book
                            Start();

                            // If all the update has been completed, do followings
                            if (Books2Download != null && Books2Download.Count == 0)
                            {
                                DownloadFinished();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLineDebugging("BookUpdater - QueueDidFinish: {0}", ex.ToString());
            }
        }