From e396e82fbc7d870811d4d96d49894fb808d9dfef Mon Sep 17 00:00:00 2001 From: TheJoKlLa Date: Tue, 31 Jan 2023 15:13:19 +0100 Subject: [PATCH] Updated API Connect --- Borepin/Borepin/App.xaml.cs | 1 - Borepin/Borepin/Borepin.csproj | 3 -- Borepin/Borepin/Page/StartPage.xaml | 4 +- .../AddServerProcess/AuthPlainPageModel.cs | 44 +++---------------- Borepin/Borepin/PageModel/StartPageModel.cs | 10 ++--- external/capnproto-dotnetcore | 2 +- 6 files changed, 15 insertions(+), 49 deletions(-) diff --git a/Borepin/Borepin/App.xaml.cs b/Borepin/Borepin/App.xaml.cs index 0ef9f00..0398942 100644 --- a/Borepin/Borepin/App.xaml.cs +++ b/Borepin/Borepin/App.xaml.cs @@ -65,7 +65,6 @@ namespace Borepin #region Register Dialog containerRegistry.RegisterDialog(); - containerRegistry.RegisterDialog(); #endregion #region Register Service diff --git a/Borepin/Borepin/Borepin.csproj b/Borepin/Borepin/Borepin.csproj index a5f7eac..69ae925 100644 --- a/Borepin/Borepin/Borepin.csproj +++ b/Borepin/Borepin/Borepin.csproj @@ -99,9 +99,6 @@ MSBuild:UpdateDesignTimeXaml - - MSBuild:UpdateDesignTimeXaml - MSBuild:UpdateDesignTimeXaml diff --git a/Borepin/Borepin/Page/StartPage.xaml b/Borepin/Borepin/Page/StartPage.xaml index 7ca721c..ca4ec0e 100644 --- a/Borepin/Borepin/Page/StartPage.xaml +++ b/Borepin/Borepin/Page/StartPage.xaml @@ -10,9 +10,9 @@ - + diff --git a/Borepin/Borepin/PageModel/AddServerProcess/AuthPlainPageModel.cs b/Borepin/Borepin/PageModel/AddServerProcess/AuthPlainPageModel.cs index 8cc022b..bd8291f 100644 --- a/Borepin/Borepin/PageModel/AddServerProcess/AuthPlainPageModel.cs +++ b/Borepin/Borepin/PageModel/AddServerProcess/AuthPlainPageModel.cs @@ -5,6 +5,7 @@ using System.Windows.Input; using Borepin.Base; using Borepin.Base.Exceptions; using Borepin.Service; +using Borepin.Service.ErrorMessage; using Borepin.Service.Storage; using FabAccessAPI; using FabAccessAPI.Exceptions; @@ -21,12 +22,14 @@ namespace Borepin.PageModel.AddServerProcess #region Private Fields private ConnectionData _ConnectionData; private readonly ILoginStorageService _LoginStorageService; + private readonly IErrorMessageService _ErrorMessageService; #endregion #region Constructors - public AuthPlainPageModel(INavigationService navigationService, IAPIService apiService, IPageDialogService pageDialogService, ILoginStorageService loginStorageService) : base(navigationService, pageDialogService, apiService) + public AuthPlainPageModel(INavigationService navigationService, IAPIService apiService, IPageDialogService pageDialogService, ILoginStorageService loginStorageService, IErrorMessageService errorMessageService) : base(navigationService, pageDialogService, apiService) { _LoginStorageService = loginStorageService; + _ErrorMessageService = errorMessageService; AuthenticateCommand = new DelegateCommand(async () => await AuthenticateCommandExecute().ConfigureAwait(false)); } @@ -113,46 +116,13 @@ namespace Borepin.PageModel.AddServerProcess { await _API.Connect(_ConnectionData).ConfigureAwait(false); } - catch (ConnectionException) + catch (Exception exception) { - Device.BeginInvokeOnMainThread(async () => - { - await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_ConnectionFailed, Resources.Text.TextResource.ALERT_UnableServer, Resources.Text.TextResource.OK).ConfigureAwait(false); - - IsBusy = false; - }); + _ErrorMessageService.DisplayConnectFailedMessage(exception); + IsBusy = false; return; } - catch (InvalidCredentialsException) - { - Device.BeginInvokeOnMainThread(async () => - { - await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_ConnectionFailed, Resources.Text.TextResource.ALERT_CredentialsInvalid, Resources.Text.TextResource.OK).ConfigureAwait(false); - IsBusy = false; - }); - return; - } - catch (AuthenticationFailedException) - { - Device.BeginInvokeOnMainThread(async () => - { - await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_ConnectionFailed, Resources.Text.TextResource.ALERT_AuthServer, Resources.Text.TextResource.OK).ConfigureAwait(false); - - IsBusy = false; - }); - return; - } - catch(Exception ex) - { - Device.BeginInvokeOnMainThread(async () => - { - await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_ConnectionFailed, Resources.Text.TextResource.ALERT_UnexpectedError, Resources.Text.TextResource.OK).ConfigureAwait(false); - - IsBusy = false; - }); - return; - } await _LoginStorageService.Add(_ConnectionData).ConfigureAwait(false); await _LoginStorageService.UpdateTimestamp(_ConnectionData).ConfigureAwait(false); diff --git a/Borepin/Borepin/PageModel/StartPageModel.cs b/Borepin/Borepin/PageModel/StartPageModel.cs index 34636b7..43611e0 100644 --- a/Borepin/Borepin/PageModel/StartPageModel.cs +++ b/Borepin/Borepin/PageModel/StartPageModel.cs @@ -32,11 +32,11 @@ namespace Borepin.PageModel #endregion #region Fields - private bool _IsConnecting; - public bool IsConnecting + private bool _RunConnecting; + public bool RunConnecting { - get => _IsConnecting; - set => SetProperty(ref _IsConnecting, value); + get => _RunConnecting; + set => SetProperty(ref _RunConnecting, value); } #endregion @@ -60,7 +60,7 @@ namespace Borepin.PageModel else if(connectionData_Default != null) { IsBusy = false; - IsConnecting = true; + RunConnecting = true; try { await _API.Connect(connectionData_Default).ConfigureAwait(false); diff --git a/external/capnproto-dotnetcore b/external/capnproto-dotnetcore index a70eecd..1be9ffb 160000 --- a/external/capnproto-dotnetcore +++ b/external/capnproto-dotnetcore @@ -1 +1 @@ -Subproject commit a70eecd99112b16902128b8b4b2c95b2721fdf0e +Subproject commit 1be9ffbf8acbc9770f2d5b67c961fb60e49e5ec5