Example #1
0
 partial void UpdatePublication(NSObject sender)
 {
     if (UpdateButton.Title == "Update")
     {
         UpdateButton.Title              = "Cancel";
         ProgressView.Hidden             = false;
         ProgressBar.MinValue            = 0;
         ProgressBar.MaxValue            = 1.0;
         ProgressStatusLabel.StringValue = "Downloading";
         StartDownloadWithoutLimitation(BookInfo, true);
     }
     else if (UpdateButton.Title == "Open")
     {
         IsOpenContentPanel = true;
         Window.PerformClose(sender);
     }
     else
     {
         string title  = "Cancel Updates";
         string errMsg = "Are you sure you want to cancel the updates?";
         nint   result = AlertSheet.RunConfirmAlert(title, errMsg);
         if (result == 1)
         {
             UpdateButton.Title = "Update";
             CancelUpdate(UpdateButton);
         }
     }
 }
        partial void logoutButtonClick(NSObject sender)
        {
            string title  = "Sign Out";
            string info   = "Thank you for using LexisNexis Red application.Are you sure you want to exit ?";
            nint   result = AlertSheet.RunConfirmAlert(title, info);

            if (result == (int)NSAlertType.DefaultReturn)
            {
                ConfirmLogout();
            }
            else
            {
                WindowStopModal();
            }
        }
        public override void MouseUp(NSEvent theEvent)
        {
            //base.MouseUp (theEvent);
            string title  = "Cancel Download";
            string errMsg = "Are you sure you want to cancel the download of this LexisNexis Red publication?";
            nint   result = AlertSheet.RunConfirmAlert(title, errMsg);

            if (result == 1)
            {
                if (superViewObj != null)
                {
                    ResetProgress();
                    superViewObj.CancelDownload();
                }
            }
        }
Example #4
0
        public void RefreshDownloadStatus(DownloadResult downloadResult, bool isUpdate)
        {
            string status = String.Empty;

            switch (downloadResult.DownloadStatus)
            {
            case DownLoadEnum.Canceled:
                status = "Update failed";
                SetProgressViewStatus(status);
                break;

            case DownLoadEnum.Failure:
                status = "Update failed";
                SetProgressViewStatus(status);

                break;

            case DownLoadEnum.NetDisconnected:
                status = "Missing connection";
                SetProgressViewStatus(status);

                break;

            case DownLoadEnum.Success:
                BookInfo = downloadResult.Publication;
                PublicationsDataManager.SharedInstance.ReplacePublicationByBookID(BookInfo);                  //update Publication data
                PublicationsDataManager.SharedInstance.CurrentPublication = BookInfo;

                SetProgressViewStatus(status);
                UpdateStatus = 2;

                RefreshInfoView();

                NSNotificationCenter.DefaultCenter.PostNotificationName(LNRConstants.LNPublicationDidFinishedDownload,
                                                                        NSObject.FromObject(BookInfo.BookId));

                break;
            }

            AlertSheet.DestroyConfirmAlert();
        }
Example #5
0
        async void StartDownloadWithoutLimitation(Publication publication, bool isUpdate)
        {
            ProgressStatusLabel.StringValue = "Uploading...";
            tokenSource = new CancellationTokenSource();

            DownloadResult downloadResult = await PublicationUtil.Instance.DownloadPublicationByBookId(publication.BookId, tokenSource.Token, UpdateDownloadProgress);

            string status = String.Empty;

            switch (downloadResult.DownloadStatus)
            {
            case DownLoadEnum.Canceled:
                status = "Update failed";
                SetProgressViewStatus(status);
                break;

            case DownLoadEnum.Failure:
                status = "Update failed";
                SetProgressViewStatus(status);

                break;

            case DownLoadEnum.NetDisconnected:
                status = "Missing connection";
                SetProgressViewStatus(status);

                break;

            case DownLoadEnum.Success:
                BookInfo = downloadResult.Publication;
                PublicationsDataManager.SharedInstance.ReplacePublicationByBookID(BookInfo);                  //update Publication data
                PublicationsDataManager.SharedInstance.CurrentPubliction = BookInfo;
                //Console.WriteLine ("DownLoadEnum.Success CurrentPubliction:update{0}", BookInfo.UpdateCount);
                SetProgressViewStatus(status);

                RefreshInfoView();
                break;
            }

            AlertSheet.DestroyConfirmAlert();
        }
Example #6
0
        async partial void SendButtonClick(NSObject sender)
        {
            SetControlsState(false);
            LoginUser user = new LoginUser();

            user.Email = EmailTF.StringValue;

            List <Country> regions = ConfigurationService.GetAllCountryMap();

            foreach (Country region in regions)
            {
                if (region.CountryName.Equals(CountryCombobox.StringValue))
                {
                    user.CountryCode = region.CountryCode;
                    break;
                }
            }

            PasswordResetEnum resetResponse = await ResetPassword(user);

            if (IsRequestCancel)
            {
                IsRequestCancel = false;
                return;
            }

            SetControlsState(true);

            AlertSheet.RunResetPasswordAlert(Window, resetResponse);

            if (resetResponse == PasswordResetEnum.ResetSuccess)
            {
                IsResetSuccess = true;
                Window.OrderOut(null);
                Window.Close();
            }
            else
            {
                IsResetSuccess = false;
            }
        }
        async partial void DeleteButtonClick(NSObject sender)
        {
            nint index = tableView.SelectedRow;

            if (index < 0)
            {
                return;
            }

            int    selIndex  = Convert.ToInt32(index);
            string bookTitle = publicationArray[selIndex].Name;

            if (bookTitle == BookTitle)
            {
                AlertSheet.RunPromptModal("Error", "This title is open, please select another one.");
                return;
            }

            string title  = String.Format("Are you sure you want to delete \"{0}\"?", bookTitle);
            string errMsg = "You will have to call our Customer Support if you want to re-install it.";

            nint result = AlertSheet.RunDeleteAlert(title, errMsg);

            if (result == 1)
            {
                IsDeletePublication = true;

                Publication book = publicationArray[selIndex];
                BookIDDeleted = book.BookId;

                await PublicationUtil.Instance.DeletePublicationByUser(book.BookId);

                Window.Close();
                Window.OrderOut(null);

                //await DeletePublicationByBookId(book.BookId);
            }
        }
        private void RefreshDownloadStatus(DownloadResult downloadResult, bool isUpdate)
        {
            string status = String.Empty;

            switch (downloadResult.DownloadStatus)
            {
            case DownLoadEnum.Canceled:
                if (isUpdate)
                {
                    status = "Update failed";
                }
                else
                {
                    status = "Download failed";
                }

                ShowProgressView(false);
                AlertSheet.DestroyConfirmAlert();
                break;

            case DownLoadEnum.Failure:
                if (isUpdate)
                {
                    status = "Update failed";
                }
                else
                {
                    status = "Download failed";
                }
                ShowProgressView(false);
                AlertSheet.DestroyConfirmAlert();
                break;

            case DownLoadEnum.NetDisconnected:
                status = "Missing connection";
                ShowProgressView(false);

                if (!Utility.IsKeyWindowLogin())
                {
                    AlertSheet.ShowMissingConnectAlert();
                }
                break;

            case DownLoadEnum.Success:
                BookInfo = downloadResult.Publication;
                PublicationsDataManager.SharedInstance.ReplacePublicationByBookID(BookInfo);
                PublicationsDataManager.SharedInstance.CurrentPublication = BookInfo;

                UpdateTitleStatus();

                AlertSheet.DestroyConfirmAlert();
                break;
            }

            if (status.Length > 0)
            {
                NSAttributedString attributeTitle = Utility.AttributedTitle(status,
                                                                            Utility.ColorWithHexColorValue("#000000", 1.0f), "System", 12.0f, NSTextAlignment.Left);
                titleStatusLabel.AttributedStringValue = attributeTitle;
            }

            if (downloadResult.DownloadStatus == DownLoadEnum.Failure)
            {
                if (!Utility.IsKeyWindowLogin())
                {
                    AlertSheet.RunPromptAlert("Installation Error", "Installation of the book has been interrupted. Please re-install the book.");
                }
            }
        }
 void ShowRenewBookAlert(NSObject sender)
 {
     //Console.WriteLine ("ShowRenewBookAlert");
     AlertSheet.RunPromptAlert("Prompt", "how to renew the title.");
 }
 nint ShowInstallErrorAlert()
 {
     return(AlertSheet.RunPromptAlert("Installation Error", "Installation of the book has been interrupted. Please re-install the book."));
 }
        async partial void RegisterButtonClick(NSObject sender)
        {
            SetControlsState(false);

            //invoke login business logic
            LoginUser user = new LoginUser();

            user.Email    = userMail.StringValue;
            user.Password = userPassword.StringValue;

            regions = ConfigurationService.GetAllCountryMap();

            foreach (Country region in regions)
            {
                if (region.CountryName.Equals(comboBox.Title))
                {
                    user.CountryCode = region.CountryCode;
                    break;
                }
            }

            LoginStatusEnum loginResponse = await SignIn(user);

            if (isRequestCancel)
            {
                isRequestCancel = false;
                return;
            }

            SetControlsState(true);

            if (loginResponse != LoginStatusEnum.LoginSuccess)
            {
                AlertSheet.RunLoginAlert(loginResponse);
            }
            else
            {
                mainWindow.OrderOut(null);
                mainWindow.Close();

                LoginUserDetails userDetail = GlobalAccess.Instance.CurrentUserInfo;

                var appDelegate = (AppDelegate)NSApplication.SharedApplication.Delegate;

                //for test
                //bool isEnter = true;
                //if (isEnter) {

                if (userDetail.NeedChangePassword)
                {
                    CGRect  frameRect = Window.Frame;
                    CGPoint orgPoint  = frameRect.Location;
                    orgPoint.Y = frameRect.Top - (315 - 260);
                    //using (var windowController = new ChangePasswordWindowController(orgPoint)) {
                    var windowController = new ChangePasswordWindowController(orgPoint);
                    var changeWindow     = windowController.Window;
                    windowController.ShowWindow(this);

                    Window.OrderOut(null);

                    changeWindow.WindowShouldClose += t => true;
                    changeWindow.WillClose         += delegate(object obj, EventArgs e){
                        if (windowController.IsChangeSuccess)
                        {
                            appDelegate.SwitchWindowByWindowName("PublicationWindowController");
                            appDelegate.SetLogOutMenuItemFullName();
                        }
                        else
                        {
                            Window.OrderFront(null);
                        }
                    };
                    //}
                }
                else
                {
                    appDelegate.SwitchWindowByWindowName("PublicationWindowController");
                    appDelegate.SetLogOutMenuItemFullName();
                }
            }
        }
Example #12
0
 public static nint ShowMissingConnectAlert()
 {
     return(AlertSheet.RunPromptAlert("Missing Connection", "Sorry, there appears to no Internet connection. A connection is required to complete this task."));
 }
Example #13
0
        private void RefreshDownloadStatus(DownloadResult downloadResult, bool isUpdate)
        {
            UpdateStatus = 0;
            string status = String.Empty;

            switch (downloadResult.DownloadStatus)
            {
            case DownLoadEnum.Canceled:
                if (isUpdate)
                {
                    status = "Update failed";
                }
                else
                {
                    status = "Download failed";
                }
                downloadPreUpdate = isUpdate;
                ShowSashView(false);
                AlertSheet.DestroyConfirmAlert();
                break;

            case DownLoadEnum.Failure:
                if (isUpdate)
                {
                    status = "Update failed";
                }
                else
                {
                    status = "Download failed";
                }
                downloadPreUpdate = isUpdate;
                ShowSashView(false);
                AlertSheet.DestroyConfirmAlert();
                break;

            case DownLoadEnum.NetDisconnected:
                status            = "Missing connection";
                downloadPreUpdate = isUpdate;
                ShowSashView(false);

                if (!Utility.IsKeyWindowLogin())
                {
                    AlertSheet.ShowMissingConnectAlert();
                }
                break;

            case DownLoadEnum.Success:
                BookInfo = downloadResult.Publication;
                PublicationsDataManager.SharedInstance.ReplacePublicationByBookID(BookInfo);
                PublicationsDataManager.SharedInstance.CurrentPublication = BookInfo;

                UpdateTitleStatus();
                var winController = (PublicationsWindowController)Window.WindowController;
                winController.PublicationsVC.RefreshHistoryView();

                AlertSheet.DestroyConfirmAlert();

                NSNotificationCenter.DefaultCenter.PostNotificationName(LNRConstants.LNPublicationDidFinishedDownload,
                                                                        NSObject.FromObject(BookInfo.BookId));

                break;
            }

            if (status.Length > 0)
            {
                NSAttributedString attributeTitle = Utility.AttributedTitle(status,
                                                                            Utility.ColorWithHexColorValue("#000000", 1.0f), "System", 12.0f, NSTextAlignment.Left);
                titleStatusLabel.AttributedStringValue = attributeTitle;
            }

            if (downloadResult.DownloadStatus == DownLoadEnum.Failure)
            {
                if (!Utility.IsKeyWindowLogin())
                {
                    AlertSheet.RunPromptAlert("Installation Error", "Installation of the book has been interrupted. Please re-install the book.");
                }
            }
        }