diff --git a/Borepin/Borepin/PageModel/AddServerProcess/AuthPlainPageModel.cs b/Borepin/Borepin/PageModel/AddServerProcess/AuthPlainPageModel.cs index 56c367f..656c023 100644 --- a/Borepin/Borepin/PageModel/AddServerProcess/AuthPlainPageModel.cs +++ b/Borepin/Borepin/PageModel/AddServerProcess/AuthPlainPageModel.cs @@ -5,6 +5,7 @@ using Borepin.Base; using Borepin.Model; using Borepin.Service.BFFH; using Borepin.Service.BFFH.Exceptions; +using FabAccessAPI.Exceptions; using Prism.Commands; using Prism.Navigation; using Prism.Services; @@ -85,13 +86,20 @@ namespace Borepin.PageModel.AddServerProcess IsBusy = false; return; } - catch (AuthenticatingFailedException) + catch (AuthenticationFailedException) { await _PageDialogService.DisplayAlertAsync("Connection failed", "Unable to authenticate to server.", "Ok").ConfigureAwait(false); IsBusy = false; return; } + catch(Exception) + { + await _PageDialogService.DisplayAlertAsync("Connection failed", "Unexpected Error.", "Ok").ConfigureAwait(false); + + IsBusy = false; + return; + } await _NavigationService.NavigateAsync("/MainPage/NavigationPage/MachineListPage").ConfigureAwait(false); } diff --git a/Borepin/Borepin/PageModel/ScanURNPageModel.cs b/Borepin/Borepin/PageModel/ScanURNPageModel.cs index b7484a0..52bdeae 100644 --- a/Borepin/Borepin/PageModel/ScanURNPageModel.cs +++ b/Borepin/Borepin/PageModel/ScanURNPageModel.cs @@ -1,5 +1,6 @@ using Borepin.Base; using Borepin.Service.BFFH; +using Borepin.Service.BFFH.Exceptions; using FabAccessAPI.Schema; using Prism.Commands; using Prism.Navigation; @@ -97,8 +98,21 @@ namespace Borepin.PageModel return; } // END HACK + string id = null; + try + { + id = await QRToID(ScanResult.Text).ConfigureAwait(false); + } + catch(ReconnectingFailedException) + { + Device.BeginInvokeOnMainThread(async () => + { + await _PageDialogService.DisplayAlertAsync("Connection failed", "Please reconnect to the server.", "OK").ConfigureAwait(false); + IsScanning = true; + }); - string id = await QRToID(ScanResult.Text).ConfigureAwait(false); + return; + } if (id != null) { @@ -119,13 +133,18 @@ namespace Borepin.PageModel await _PageDialogService.DisplayAlertAsync("Alert", "QR Code is invalid", "OK").ConfigureAwait(false); IsScanning = true; }); + return; } + + IsScanning = true; } public async Task QRToID(string value) { if (!_BFFHService.IsConnected) { + await _BFFHService.Reconnect().ConfigureAwait(false); + IsConnected = false; return null; }