Browse Source

PRS MOBILE - pin login page more intelligent error message and options

Nick-PRSDigital@bitbucket.org 2 years ago
parent
commit
1a70b2bea9
1 changed files with 26 additions and 11 deletions
  1. 26 11
      prs.mobile/comal.timesheets/Main/PINLoginPage.xaml.cs

+ 26 - 11
prs.mobile/comal.timesheets/Main/PINLoginPage.xaml.cs

@@ -32,7 +32,7 @@ namespace comal.timesheets
                 loadFromIOSLink = logindetails;
         }
 
-    
+
 
         protected override void OnAppearing()
         {
@@ -78,14 +78,14 @@ namespace comal.timesheets
                     Thread.Sleep(250);
                     Device.BeginInvokeOnMainThread(() =>
                     {
-                    if (App.IsUserLoggedIn && GlobalVariables.ChangeUser == false)
-                    {
-                        LaunchMainPage();
-                        return;
-                    }
-                    else
-                    {
-                        if (String.IsNullOrWhiteSpace(App.Settings.UserID) || String.IsNullOrWhiteSpace(App.Settings.Password))
+                        if (App.IsUserLoggedIn && GlobalVariables.ChangeUser == false)
+                        {
+                            LaunchMainPage();
+                            return;
+                        }
+                        else
+                        {
+                            if (String.IsNullOrWhiteSpace(App.Settings.UserID) || String.IsNullOrWhiteSpace(App.Settings.Password))
                             {
                                 DisplayAlert("Unable to log in", "User ID or password is blank", "OK");
                                 ShowPINPad();
@@ -158,7 +158,22 @@ namespace comal.timesheets
             }
             catch (Exception ex)
             {
-                DisplayAlert("Connection Error", ex.Message, "OK");
+                string chosenOption = await DisplayActionSheet("Connection error - please check your connection. Try again?", "Cancel", null, "Yes");
+                switch (chosenOption)
+                {
+                    case "Yes":
+                        Task.Run(() =>
+                        {
+                            Thread.Sleep(1000);
+                            Device.BeginInvokeOnMainThread(() =>
+                            {
+                                RunValidate();  
+                            });
+                        });
+                        break;
+                    default:
+                        break;
+                }
             }
         }
 
@@ -168,7 +183,7 @@ namespace comal.timesheets
                 App.Current.Properties.Add("SessionID", ClientFactory.SessionID);
             else
                 App.Current.Properties["SessionID"] = ClientFactory.SessionID;
-            if(timerRunning)
+            if (timerRunning)
                 timer.Dispose();
             App.Data.Refresh(true);
             Device.BeginInvokeOnMainThread(async () => { await Navigation.PushAsync(new MainPage()); });