Updated API Connect

This commit is contained in:
TheJoKlLa 2023-01-31 15:13:19 +01:00
parent 1d0abbcff7
commit e396e82fbc
6 changed files with 15 additions and 49 deletions

View File

@ -65,7 +65,6 @@ namespace Borepin
#region Register Dialog
containerRegistry.RegisterDialog<ConfirmDialog, ConfirmDialogModel>();
containerRegistry.RegisterDialog<ScanDialog, ScanDialogModel>();
#endregion
#region Register Service

View File

@ -99,9 +99,6 @@
<EmbeddedResource Update="Dialog\ConfirmDialog.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Dialog\ScanDialog.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Update="Page\AddServerProcess\SelectServerPage.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>

View File

@ -10,9 +10,9 @@
<ActivityIndicator IsRunning="{Binding IsBusy}"/>
</StackLayout>
<ActivityIndicator IsRunning="{Binding IsBusy}"/>
<StackLayout IsVisible="{Binding IsConnecting}" VerticalOptions="CenterAndExpand">
<StackLayout IsVisible="{Binding RunConnecting}" VerticalOptions="CenterAndExpand">
<Label Text="{x:Static resource_text:TextResource.StartPage_Connecting}" Style="{StaticResource Style_Label_Text_Center}"/>
<ActivityIndicator IsRunning="{Binding IsConnecting}"/>
<ActivityIndicator IsRunning="{Binding RunConnecting}"/>
</StackLayout>
</StackLayout>
</ContentPage.Content>

View File

@ -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);

View File

@ -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);

@ -1 +1 @@
Subproject commit a70eecd99112b16902128b8b4b2c95b2721fdf0e
Subproject commit 1be9ffbf8acbc9770f2d5b67c961fb60e49e5ec5