コード例 #1
0
ファイル: SyncView.cs プロジェクト: MetroStar/eBriefingiOS
        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();
            }
        }
コード例 #2
0
ファイル: SyncView.cs プロジェクト: MetroStar/eBriefingiOS
        static void HandleCancelEvent()
        {
            LoadingView.CancelEvent -= HandleCancelEvent;

            LoadingView.Hide();

            CloudSync.CancelSync();
        }
コード例 #3
0
        private void Dismiss(bool cancelled)
        {
            LoadingView.Hide();

            if (DismissEvent != null)
            {
                DismissEvent(cancelled);
            }
        }
コード例 #4
0
        async private void Connect()
        {
            if (!Reachability.IsDefaultNetworkAvailable())
            {
                AlertView.Show(StringRef.connectionFailure, StringRef.connectionRequired, StringRef.ok);
            }
            else
            {
                try
                {
                    bool notCompatible             = false;
                    WebExceptionStatus errorStatus = WebExceptionStatus.ConnectFailure;
                    cts = new CancellationTokenSource();

                    Settings.WriteUseFormsAuth(false);

                    LoadingView.Show("Connecting", "Please wait while we're connecting to Demo Library...");
                    await eBriefingService.Run(() => StartAuthenticate(out errorStatus, out notCompatible), cts.Token);

                    LoadingView.Hide();
                    cts.Token.ThrowIfCancellationRequested();

                    if (errorStatus == WebExceptionStatus.Success)
                    {
                        Settings.Authenticated      = true;
                        Settings.AvailableCheckTime = DateTime.MinValue;
                        Settings.WriteSyncOn(false);

                        CancelAllDownloads();

                        // Success
                        Dismiss(false);
                    }
                    else
                    {
                        Settings.Authenticated = false;

                        if (notCompatible)
                        {
                            AlertView.Show(StringRef.alert, StringRef.notCompatible, StringRef.ok);
                        }
                        else
                        {
                            WebExceptionAlertView.ShowAlert(errorStatus);
                        }
                    }
                }
                catch (OperationCanceledException)
                {
                    KeychainAccessor.ClearCredential();
                }
            }
        }
コード例 #5
0
ファイル: SyncView.cs プロジェクト: MetroStar/eBriefingiOS
        static void HandleReceiveDoneEvent()
        {
            StartTimer();

            CloudSync.ReceiveDoneEvent -= HandleReceiveDoneEvent;

            LoadingView.Hide();

            if (ReceiveDoneEvent != null)
            {
                ReceiveDoneEvent();
            }
        }
コード例 #6
0
        async private void LoadPageViewController(String pageID)
        {
            try
            {
                LoadingView.Show("Loading", "Please wait while we're loading " + book.Title + "...", false);

                int           pageNumber = BooksOnDeviceAccessor.GetPage(book.ID, pageID).PageNumber;
                PSPDFDocument document   = await eBriefingService.Run(() => GenerateDocument());

                if (document == null)
                {
                    LoadingView.Hide();

                    AlertView.Show(StringRef.alert, "We're sorry, but we could not open the document.", StringRef.ok);
                }
                else
                {
                    PSPDFConfiguration configuration = PSPDFConfiguration.FromConfigurationBuilder(delegate(PSPDFConfigurationBuilder builder)
                    {
                        builder.CreateAnnotationMenuEnabled = builder.ShouldHideStatusBar = builder.ShouldCacheThumbnails = false;
                        builder.ShouldHideStatusBarWithHUD  = builder.AlwaysBouncePages = builder.SmartZoomEnabled = builder.DoublePageModeOnFirstPage
                                                                                                                         = builder.ShouldHideHUDOnPageChange = builder.ShouldHideNavigationBarWithHUD = true;
                        builder.HUDViewMode      = PSPDFHUDViewMode.Automatic;
                        builder.HUDViewAnimation = PSPDFHUDViewAnimation.Fade;
                        builder.ThumbnailBarMode = PSPDFThumbnailBarMode.None;
                        builder.RenderingMode    = PSPDFPageRenderingMode.Render;
                        builder.PageTransition   = PSPDFPageTransition.Curl;
                        builder.ShouldAskForAnnotationUsername = false;
                        builder.AllowBackgroundSaving          = false;
                        builder.OverrideClass(new Class(typeof(PSPDFHUDView)), new Class(typeof(CustomPSPDFHUDView)));
                        builder.OverrideClass(new Class(typeof(PSPDFViewControllerDelegate)), new Class(typeof(CustomPSPDFViewControllerDelegate)));
                        builder.OverrideClass(new Class(typeof(PSPDFBarButtonItem)), new Class(typeof(CustomPSPDFBarButtonItem)));
                    });

                    PageViewController pvc = new PageViewController(book, document, configuration);
                    pvc.Delegate = new CustomPSPDFViewControllerDelegate();
                    pvc.Page     = (nuint)pageNumber - 1;

                    pvc.AddAnnotations();

                    LoadingView.Hide();
                    this.NavigationController.PushViewController(pvc, true);
                }
            }
            catch (Exception ex)
            {
                LoadingView.Hide();

                Logger.WriteLineDebugging("DashboardViewController - LoadPageViewController: {0}", ex.ToString());
            }
        }
コード例 #7
0
        async private void LoadData()
        {
            if (isFirst)
            {
                LoadingView.Show("Loading", "Please wait while we're loading the book information...", false);

                await eBriefingService.Run(() => RetrieveData());
            }
            else
            {
                LoadingView.Show("Loading", "Please wait while we're updating the book information...", false);

                await eBriefingService.Run(() => RetrieveData());
            }

            LoadingView.Hide();

            // Update number of bookmarks
            int count = 0;

            if (bookmarkList != null && bookmarkList.Count > 0)
            {
                count = bookmarkList.Count;
            }
            segmentedControl.SetTitle("Bookmarks (" + count.ToString() + ")", 1);

            // Update number of notes
            count = 0;
            if (noteList != null && noteList.Count > 0)
            {
                count = noteList.Count;
            }
            segmentedControl.SetTitle("Notes (" + count.ToString() + ")", 2);

            // Update number of annotations
            count = 0;
            if (annList != null && annList.Count > 0)
            {
                count = annList.Count;
            }
            segmentedControl.SetTitle("Annotations (" + count.ToString() + ")", 3);

            // Load collectionView
            LoadCollectionView();

            // Update overview pane info
            if (dashboardView != null)
            {
                dashboardView.UpdateBookInfo();
            }
        }
コード例 #8
0
ファイル: SyncView.cs プロジェクト: MetroStar/eBriefingiOS
        static void HandleSyncDoneEvent()
        {
            StartTimer();

            CloudSync.SyncDoneEvent -= HandleSyncDoneEvent;

            PushNPullInProgress = false;

            LoadingView.Hide();

            if (SyncDoneEvent != null)
            {
                SyncDoneEvent();
            }
        }
コード例 #9
0
        private void Dismiss(bool cancelled)
        {
            this.InvokeOnMainThread(delegate
            {
                LoadingView.Hide();

                this.DismissViewController(true, delegate
                {
                    if (DismissEvent != null)
                    {
                        DismissEvent(cancelled);
                    }
                });
            });
        }
コード例 #10
0
        private void LoadCollectionView()
        {
            // Load collectionView
            if (collectionView != null)
            {
                List <Book> bookList = null;

                // Only show those books that are not on the device
                List <Book> sBooks = BooksOnServerAccessor.GetBooks();
                List <Book> dBooks = BooksOnDeviceAccessor.GetBooks();

                if (sBooks != null && dBooks != null)
                {
                    HashSet <String> dIDs = new HashSet <String>(dBooks.Select(d => d.ID));
                    var results           = sBooks.Where(s => !dIDs.Contains(s.ID)).ToList();
                    if (results != null)
                    {
                        bookList = results;
                    }
                }
                else if (sBooks != null)
                {
                    bookList = sBooks;
                }

                LoadingView.Hide();

                if (bookList == null || bookList.Count == 0)
                {
                    UpdateStatusLabel("There are no more available books.");

                    UpdateAvailableBadge();
                }
                else
                {
                    dataSource = new LibraryDataSource(new List <Book>(bookList), this);
                    dataSource.ItemPressedEvent += HandleItemPressedEvent;
                    dataSource.DownloadEvent    += HandleDownloadEvent;
                    collectionView.Source        = dataSource;
                    collectionView.ReloadData();

                    ShowHideStatusLabel(false);
                }
            }
        }
コード例 #11
0
        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();
        }
コード例 #12
0
        private void Failed2RetrieveBooks()
        {
            LoadingView.Hide();

            UIAlertView alert = new UIAlertView(StringRef.alert, StringRef.failed2Retrieve + "books.", null, StringRef.ok);

            alert.Dismissed += (object sender, UIButtonEventArgs e) =>
            {
                if (!BooksOnServerAccessor.HasBooks())
                {
                    if (String.IsNullOrEmpty(URL.ServerURL))
                    {
                        OpenBookshelf();
                    }
                }
            };
            alert.Show();
        }
コード例 #13
0
        async public void LoadBooks()
        {
            TimeSpan diff = DateTime.UtcNow.Subtract(Settings.AvailableCheckTime);

            if (TimeSettings.LibraryRefreshRequired(diff))
            {
                if (Reachability.IsDefaultNetworkAvailable())
                {
                    LoadingView.Show("Loading", "Please wait while we're checking Available Books...", false);

                    List <Book> bookList = await eBriefingService.Run(() => eBriefingService.StartDownloadBooks());

                    if (bookList != null)
                    {
                        Settings.AvailableCheckTime = DateTime.UtcNow;

                        // Save in the cache
                        BooksOnServerAccessor.SaveBooks(bookList);

                        // Load books
                        RetrieveBooks();

                        // Update available badge
                        UpdateAvailableBadge();
                    }
                    else
                    {
                        LoadingView.Hide();
                    }
                }
                else
                {
                    UpdateStatusLabel(StringRef.connectionRequired);
                }
            }
            else
            {
                RetrieveBooks();
            }
        }
コード例 #14
0
        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();
            }
        }
コード例 #15
0
        async private void PrintSetup(bool bGeneratePdfFile)
        {
            List <Page> pageList = new List <Page>();

            if (Range == PrintHelper.RANGE.ALL)
            {
                pageList = BooksOnDeviceAccessor.GetPages(bookID);
            }
            else if (Range == PrintHelper.RANGE.CURRENT)
            {
                pageList.Add(BooksOnDeviceAccessor.GetPage(bookID, pageID));
            }
            else
            {
                if (StartPage == 0 && EndPage == 0)
                {
                    new UIAlertView(StringRef.alert, "Please enter Start page number & End page number.", null, StringRef.ok, null).Show();
                    return;
                }
                else if (StartPage > EndPage)
                {
                    new UIAlertView(StringRef.alert, "Start page number must be less than the End page number.", null, StringRef.ok, null).Show();
                    return;
                }
                else
                {
                    for (int i = (int)StartPage; i <= (int)EndPage; i++)
                    {
                        Page page = BooksOnDeviceAccessor.GetPage(bookID, i);
                        if (page == null)
                        {
                            new UIAlertView(StringRef.alert, "Page number " + i.ToString() + " is not available. Please check page range. Print operation aborted.", null, StringRef.ok, null).Show();

                            return;
                        }
                        else
                        {
                            pageList.Add(BooksOnDeviceAccessor.GetPage(bookID, i));
                        }
                    }
                }
            }

            printHelper             = new PrintHelper(bookID, pageList);
            printHelper.Orientation = Orientation;
            printHelper.Range       = Range;
            printHelper.Annotation  = Annotation;
            printHelper.Note        = Note;

            LoadingView.Show("Loading", "Getting ready to print...", false);

            string data = null;

            // Generate pdf images
            var isSuccessful = await eBriefingService.Run(() => printHelper.Generate());

            if (isSuccessful)
            {
                this.InvokeOnMainThread(delegate
                {
                    data = printHelper.GeneratePageRender(bGeneratePdfFile);

                    if (data != null)
                    {
                        if (EmailEvent != null)
                        {
                            EmailEvent(data);
                        }
                    }
                });

                LoadingView.Hide();

                // Close panel
                ClosePanel();

                if (data == null)
                {
                    printHelper.Print(barButton);
                }
            }
            else
            {
                LoadingView.Hide();

                MessageBox alert = new MessageBox();
                if (printHelper.PagesNum != null && printHelper.PagesNum > 0)
                {
                    alert.ShowAlert("Error", string.Format("eBriefing is reaching its memory limit. At this level, you can print {0} number of pages. Please reduce your print range.", printHelper.PagesNum), "Ok");
                }
                else
                {
                    alert.ShowAlert("Error", "Please try again", "Ok");

                    // Close panel
                    ClosePanel();
                }
            }
        }
コード例 #16
0
        void HandleCancelEvent()
        {
            cts.Cancel();

            LoadingView.Hide();
        }