diff --git a/Borepin/Borepin.UWP/Package.appxmanifest b/Borepin/Borepin.UWP/Package.appxmanifest
index 837242f..f509582 100644
--- a/Borepin/Borepin.UWP/Package.appxmanifest
+++ b/Borepin/Borepin.UWP/Package.appxmanifest
@@ -53,5 +53,7 @@
+
+
\ No newline at end of file
diff --git a/Borepin/Borepin/App.xaml.cs b/Borepin/Borepin/App.xaml.cs
index 400aa87..0ef9f00 100644
--- a/Borepin/Borepin/App.xaml.cs
+++ b/Borepin/Borepin/App.xaml.cs
@@ -12,6 +12,7 @@ using Borepin.PageModel.AddServerProcess;
using System;
using Borepin.Service.Storage;
using NLog;
+using Borepin.Service.ErrorMessage;
namespace Borepin
{
@@ -69,6 +70,7 @@ namespace Borepin
#region Register Service
containerRegistry.RegisterSingleton();
+ containerRegistry.RegisterSingleton();
// NEED PLATFORM SPECIFIC SERVICE
// IPreferenceStorageService
diff --git a/Borepin/Borepin/Base/ConnectionModelBase.cs b/Borepin/Borepin/Base/ConnectionModelBase.cs
index aed8945..de1759a 100644
--- a/Borepin/Borepin/Base/ConnectionModelBase.cs
+++ b/Borepin/Borepin/Base/ConnectionModelBase.cs
@@ -42,11 +42,9 @@ namespace Borepin.Base
{
await LoadAPIData().ConfigureAwait(false);
}
- catch
+ catch(Exception exception)
{
- IsConnected = false;
- await _API.Disconnect().ConfigureAwait(false);
- _API.UnbindEventHandler();
+ Log.Warn("Load API Data failed", exception);
}
break;
case ConnectionStatusChanged.ConnectionLoss:
@@ -101,10 +99,7 @@ namespace Borepin.Base
}
catch(Exception exception)
{
- IsConnected = false;
- await _API.Disconnect().ConfigureAwait(false);
- _API.UnbindEventHandler();
- Log.Error("LoadAPIData failed", exception);
+ Log.Warn("Load API Data failed", exception);
}
}
}
diff --git a/Borepin/Borepin/Base/ErrorMessages.cs b/Borepin/Borepin/Base/ErrorMessages.cs
new file mode 100644
index 0000000..c53a915
--- /dev/null
+++ b/Borepin/Borepin/Base/ErrorMessages.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Borepin.Base
+{
+ public static class ErrorMessages
+ {
+
+ }
+}
diff --git a/Borepin/Borepin/Converter/AllTrueBoolConverter.cs b/Borepin/Borepin/Converter/AllTrueBoolConverter.cs
new file mode 100644
index 0000000..0cfaae5
--- /dev/null
+++ b/Borepin/Borepin/Converter/AllTrueBoolConverter.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Globalization;
+using Xamarin.Forms;
+
+namespace Borepin.Converter
+{
+ public class AllTrueBoolConverter : IMultiValueConverter
+ {
+ public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (values == null || !targetType.IsAssignableFrom(typeof(bool)))
+ {
+ return false;
+ }
+
+ foreach (var value in values)
+ {
+ if (!(value is bool b))
+ {
+ return false;
+ }
+ else if (!b)
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
+ {
+ throw new NotSupportedException();
+ }
+ }
+}
diff --git a/Borepin/Borepin/Page/AddUserPage.xaml b/Borepin/Borepin/Page/AddUserPage.xaml
index 9cdceb5..3ec8089 100644
--- a/Borepin/Borepin/Page/AddUserPage.xaml
+++ b/Borepin/Borepin/Page/AddUserPage.xaml
@@ -3,29 +3,30 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Borepin.Page.AddUserPage"
xmlns:converters="clr-namespace:Borepin.Converter"
- xmlns:resource_text="clr-namespace:Borepin.Resources.Text"
+ xmlns:resource_text="clr-namespace:Borepin.Resources.Text"
+ xmlns:views="clr-namespace:Borepin.View"
Title="{x:Static resource_text:TextResource.TITLE_AddUser}">
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
diff --git a/Borepin/Borepin/Page/MachineListPage.xaml b/Borepin/Borepin/Page/MachineListPage.xaml
index 08fcd0a..2201d09 100644
--- a/Borepin/Borepin/Page/MachineListPage.xaml
+++ b/Borepin/Borepin/Page/MachineListPage.xaml
@@ -1,16 +1,19 @@
-
+
+
@@ -18,34 +21,38 @@
-
-
-
diff --git a/Borepin/Borepin/Page/MachinePage.xaml b/Borepin/Borepin/Page/MachinePage.xaml
index 3a0576f..99ebf23 100644
--- a/Borepin/Borepin/Page/MachinePage.xaml
+++ b/Borepin/Borepin/Page/MachinePage.xaml
@@ -3,51 +3,61 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Borepin.Page.MachinePage"
xmlns:converters="clr-namespace:Borepin.Converter"
- xmlns:resource_text="clr-namespace:Borepin.Resources.Text"
+ xmlns:resource_text="clr-namespace:Borepin.Resources.Text"
+ xmlns:views="clr-namespace:Borepin.View"
Title="{x:Static resource_text:TextResource.TITLE_Machine}">
-
-
-
+
+
-
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
diff --git a/Borepin/Borepin/Page/ProfilePage.xaml b/Borepin/Borepin/Page/ProfilePage.xaml
index 2a1d6fb..6f21c73 100644
--- a/Borepin/Borepin/Page/ProfilePage.xaml
+++ b/Borepin/Borepin/Page/ProfilePage.xaml
@@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Borepin.Page.ProfilePage"
xmlns:converters="clr-namespace:Borepin.Converter"
- xmlns:resource_text="clr-namespace:Borepin.Resources.Text"
+ xmlns:resource_text="clr-namespace:Borepin.Resources.Text" xmlns:views="clr-namespace:Borepin.View"
Title="{x:Static resource_text:TextResource.TITLE_Profile}">
@@ -12,21 +12,20 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Borepin/Borepin/Page/UserListPage.xaml b/Borepin/Borepin/Page/UserListPage.xaml
index 47f1c44..4b990d5 100644
--- a/Borepin/Borepin/Page/UserListPage.xaml
+++ b/Borepin/Borepin/Page/UserListPage.xaml
@@ -11,36 +11,36 @@
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Borepin/Borepin/Page/UserPage.xaml b/Borepin/Borepin/Page/UserPage.xaml
index 4ae7dc4..da07ab6 100644
--- a/Borepin/Borepin/Page/UserPage.xaml
+++ b/Borepin/Borepin/Page/UserPage.xaml
@@ -8,39 +8,39 @@
Title="{x:Static resource_text:TextResource.TITLE_User}">
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Borepin/Borepin/PageModel/AddServerProcess/SelectServerPageModel.cs b/Borepin/Borepin/PageModel/AddServerProcess/SelectServerPageModel.cs
index 62b6e15..859465b 100644
--- a/Borepin/Borepin/PageModel/AddServerProcess/SelectServerPageModel.cs
+++ b/Borepin/Borepin/PageModel/AddServerProcess/SelectServerPageModel.cs
@@ -1,4 +1,5 @@
using Borepin.Base;
+using Borepin.Service.ErrorMessage;
using FabAccessAPI;
using FabAccessAPI.Exceptions;
using Prism.Commands;
@@ -16,11 +17,14 @@ namespace Borepin.PageModel.AddServerProcess
{
#region Private Fields
private ConnectionData _ConnectionData;
+ private IErrorMessageService _ErrorMessageService;
#endregion
#region Constructors
- public SelectServerPageModel(INavigationService navigationService, IPageDialogService pageDialogService) : base(navigationService, pageDialogService)
+ public SelectServerPageModel(INavigationService navigationService, IPageDialogService pageDialogService, IErrorMessageService errorMessageService) : base(navigationService, pageDialogService)
{
+ _ErrorMessageService = errorMessageService;
+
ConnectToServerCommand = new DelegateCommand(async () => await ConnectToServerExecute().ConfigureAwait(false));
DetectLocalServerCommand = new DelegateCommand(DetectHostCommandExecute);
ScanCodeCommand = new DelegateCommand(ScanCodeCommandExecute);
@@ -120,15 +124,10 @@ namespace Borepin.PageModel.AddServerProcess
API api = new API();
await api.TryToConnect(_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;
}
diff --git a/Borepin/Borepin/PageModel/MachineListPageModel.cs b/Borepin/Borepin/PageModel/MachineListPageModel.cs
index d85d9fa..6e05381 100644
--- a/Borepin/Borepin/PageModel/MachineListPageModel.cs
+++ b/Borepin/Borepin/PageModel/MachineListPageModel.cs
@@ -145,7 +145,15 @@ namespace Borepin.PageModel
{
if(_API.IsConnected)
{
- await LoadAPIData().ConfigureAwait(true);
+ try
+ {
+ await LoadAPIData().ConfigureAwait(true);
+ }
+ catch
+ {
+ // TODO
+ }
+
}
IsRefreshing = false;
diff --git a/Borepin/Borepin/PageModel/ServerListPageModel.cs b/Borepin/Borepin/PageModel/ServerListPageModel.cs
index 26dff07..7b49db4 100644
--- a/Borepin/Borepin/PageModel/ServerListPageModel.cs
+++ b/Borepin/Borepin/PageModel/ServerListPageModel.cs
@@ -36,7 +36,7 @@ namespace Borepin.PageModel
List tasks = new List();
IList list = await _LoginStorageService.GetList().ConfigureAwait(false);
- if (_API.IsConnected)
+ if (_API.IsConnected || _API.IsConnecting)
{
ActiveConnection = new ServerListItemViewModel(_NavigationService, _PageDialogService);
await ActiveConnection.LoadInstance(_API.ConnectionData).ConfigureAwait(false);
diff --git a/Borepin/Borepin/PageModel/ServerPageModel.cs b/Borepin/Borepin/PageModel/ServerPageModel.cs
index 2212e3c..cce4a94 100644
--- a/Borepin/Borepin/PageModel/ServerPageModel.cs
+++ b/Borepin/Borepin/PageModel/ServerPageModel.cs
@@ -1,6 +1,7 @@
using Borepin.Base;
using Borepin.Base.Exceptions;
using Borepin.Service;
+using Borepin.Service.ErrorMessage;
using Borepin.Service.Storage;
using FabAccessAPI;
using FabAccessAPI.Exceptions;
@@ -22,14 +23,16 @@ namespace Borepin.PageModel
#region Private Fields
private readonly IDialogService _DialogService;
private readonly ILoginStorageService _LoginStorageService;
+ private readonly IErrorMessageService _ErrorMessageService;
private bool IsDialog = false;
#endregion
#region Constructors
- public ServerPageModel(INavigationService navigationService, IPageDialogService pageDialogService, IAPIService apiService, IDialogService dialogService, ILoginStorageService loginStorageService) : base(navigationService, pageDialogService, apiService)
+ public ServerPageModel(INavigationService navigationService, IPageDialogService pageDialogService, IAPIService apiService, IDialogService dialogService, ILoginStorageService loginStorageService, IErrorMessageService errorMessageService) : base(navigationService, pageDialogService, apiService)
{
_DialogService = dialogService;
_LoginStorageService = loginStorageService;
+ _ErrorMessageService = errorMessageService;
ConnectCommand = new DelegateCommand(async () => await ConnectCommandExecute().ConfigureAwait(false));
DisconnectCommand = new DelegateCommand(async () => await DisonnectCommandExecute().ConfigureAwait(false));
@@ -52,7 +55,7 @@ namespace Borepin.PageModel
throw new InstanceIncorrectException();
}
- if(_API.IsConnected && Connection_Item != null)
+ if((_API.IsConnected || _API.IsConnecting) && Connection_Item != null)
{
InstanceIsActiveConnection = Connection_Item.Equals(_API.ConnectionData);
}
@@ -125,31 +128,16 @@ namespace Borepin.PageModel
if(_API.IsConnected)
{
await _API.Disconnect().ConfigureAwait(true);
- _API.UnbindEventHandler();
}
try
{
await _API.Connect(Connection_Item).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;
- });
- 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;
- });
+ _ErrorMessageService.DisplayConnectFailedMessage(exception);
+ IsBusy = false;
return;
}
diff --git a/Borepin/Borepin/PageModel/StartPageModel.cs b/Borepin/Borepin/PageModel/StartPageModel.cs
index 59bdec5..34636b7 100644
--- a/Borepin/Borepin/PageModel/StartPageModel.cs
+++ b/Borepin/Borepin/PageModel/StartPageModel.cs
@@ -1,5 +1,6 @@
using Borepin.Base;
using Borepin.Service;
+using Borepin.Service.ErrorMessage;
using Borepin.Service.Storage;
using FabAccessAPI;
using FabAccessAPI.Exceptions;
@@ -19,12 +20,14 @@ namespace Borepin.PageModel
{
#region Private Fields
private readonly ILoginStorageService _LoginStorageService;
+ private readonly IErrorMessageService _ErrorMessageService;
#endregion
#region Constructors
- public StartPageModel(INavigationService navigationService, IPageDialogService pageDialogService, IAPIService apiService, ILoginStorageService loginStorageService) : base(navigationService, pageDialogService, apiService)
+ public StartPageModel(INavigationService navigationService, IPageDialogService pageDialogService, IAPIService apiService, ILoginStorageService loginStorageService, IErrorMessageService errorMessageService) : base(navigationService, pageDialogService, apiService)
{
_LoginStorageService = loginStorageService;
+ _ErrorMessageService = errorMessageService;
}
#endregion
@@ -70,33 +73,9 @@ namespace Borepin.PageModel
}
});
}
- 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);
- });
- }
- catch (AuthenticationFailedException)
- {
- Device.BeginInvokeOnMainThread(async () =>
- {
- await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_ConnectionFailed, Resources.Text.TextResource.ALERT_AuthServer, Resources.Text.TextResource.OK).ConfigureAwait(false);
- });
- }
- catch (InvalidCredentialsException)
- {
- Device.BeginInvokeOnMainThread(async () =>
- {
- await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_ConnectionFailed, Resources.Text.TextResource.ALERT_CredentialsInvalid, Resources.Text.TextResource.OK).ConfigureAwait(false);
- });
- }
- catch (Exception)
- {
- Device.BeginInvokeOnMainThread(async () =>
- {
- await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_UnexpectedError, Resources.Text.TextResource.ALERT_UnableServer, Resources.Text.TextResource.OK).ConfigureAwait(false);
- });
+ _ErrorMessageService.DisplayConnectFailedMessage(exception);
}
if (_API.IsConnected == false)
diff --git a/Borepin/Borepin/PageModel/UserListPageModel.cs b/Borepin/Borepin/PageModel/UserListPageModel.cs
index 220d479..937ad9e 100644
--- a/Borepin/Borepin/PageModel/UserListPageModel.cs
+++ b/Borepin/Borepin/PageModel/UserListPageModel.cs
@@ -90,7 +90,14 @@ namespace Borepin.PageModel
{
if(_API.IsConnected)
{
- await LoadAPIData().ConfigureAwait(true);
+ try
+ {
+ await LoadAPIData().ConfigureAwait(true);
+ }
+ catch (Exception)
+ {
+ // TODO
+ }
}
IsRefreshing = false;
diff --git a/Borepin/Borepin/Resources/Text/TextResource.Designer.cs b/Borepin/Borepin/Resources/Text/TextResource.Designer.cs
index 3b7573e..60a9afa 100644
--- a/Borepin/Borepin/Resources/Text/TextResource.Designer.cs
+++ b/Borepin/Borepin/Resources/Text/TextResource.Designer.cs
@@ -170,6 +170,15 @@ namespace Borepin.Resources.Text {
}
}
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die Authentication failed ähnelt.
+ ///
+ internal static string ALERT_AuthFailed {
+ get {
+ return ResourceManager.GetString("ALERT_AuthFailed", resourceCulture);
+ }
+ }
+
///
/// Sucht eine lokalisierte Zeichenfolge, die Unable to authenticate to server. ähnelt.
///
@@ -179,6 +188,15 @@ namespace Borepin.Resources.Text {
}
}
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die SASL Mechanism is not supported- ähnelt.
+ ///
+ internal static string ALERT_BadMechanism {
+ get {
+ return ResourceManager.GetString("ALERT_BadMechanism", resourceCulture);
+ }
+ }
+
///
/// Sucht eine lokalisierte Zeichenfolge, die Connection failed ähnelt.
///
@@ -188,6 +206,15 @@ namespace Borepin.Resources.Text {
}
}
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die Connection time exceeded. ähnelt.
+ ///
+ internal static string ALERT_ConnectionTimeout {
+ get {
+ return ResourceManager.GetString("ALERT_ConnectionTimeout", resourceCulture);
+ }
+ }
+
///
/// Sucht eine lokalisierte Zeichenfolge, die Credentials are invalid. ähnelt.
///
@@ -224,6 +251,24 @@ namespace Borepin.Resources.Text {
}
}
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die SASL Authenticaiton failed ähnelt.
+ ///
+ internal static string ALERT_SASLAuth {
+ get {
+ return ResourceManager.GetString("ALERT_SASLAuth", resourceCulture);
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die TLS certificate is invalid. ähnelt.
+ ///
+ internal static string ALERT_TLSInvalid {
+ get {
+ return ResourceManager.GetString("ALERT_TLSInvalid", resourceCulture);
+ }
+ }
+
///
/// Sucht eine lokalisierte Zeichenfolge, die Unable to connect to server. ähnelt.
///
@@ -296,6 +341,33 @@ namespace Borepin.Resources.Text {
}
}
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die Connecting to Server ... ähnelt.
+ ///
+ internal static string ConnectionStatus_Connecting {
+ get {
+ return ResourceManager.GetString("ConnectionStatus_Connecting", resourceCulture);
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die No Connection to Server ähnelt.
+ ///
+ internal static string ConnectionStatus_NoConnection {
+ get {
+ return ResourceManager.GetString("ConnectionStatus_NoConnection", resourceCulture);
+ }
+ }
+
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die Please select a Server. ähnelt.
+ ///
+ internal static string ConnectionStatus_NotConnected {
+ get {
+ return ResourceManager.GetString("ConnectionStatus_NotConnected", resourceCulture);
+ }
+ }
+
///
/// Sucht eine lokalisierte Zeichenfolge, die Delete ähnelt.
///
@@ -558,15 +630,6 @@ namespace Borepin.Resources.Text {
}
}
- ///
- /// Sucht eine lokalisierte Zeichenfolge, die Please connect to Server ähnelt.
- ///
- internal static string PLEASECONNECTTOSERVER {
- get {
- return ResourceManager.GetString("PLEASECONNECTTOSERVER", resourceCulture);
- }
- }
-
///
/// Sucht eine lokalisierte Zeichenfolge, die Change Password ähnelt.
///
diff --git a/Borepin/Borepin/Resources/Text/TextResource.resx b/Borepin/Borepin/Resources/Text/TextResource.resx
index faa73d3..1b7a9cf 100644
--- a/Borepin/Borepin/Resources/Text/TextResource.resx
+++ b/Borepin/Borepin/Resources/Text/TextResource.resx
@@ -151,39 +151,71 @@ You can also put down several servers and then connect to the desired server.
Server address is invaild.
+ Message Content
Add User failed
+ Message Content
+
+
+ Authentication failed
+ Message Title
Unable to authenticate to server.
+ Message Content
+
+
+ SASL Mechanism is not supported-
+ Message Content
Connection failed
+ Message Title
+
+
+ Connection time exceeded.
+ Message Content
Credentials are invalid.
+ Message Content
Connection already exist. Please delete old Connection before adding the new Connection.
+ Message Content
Password is invalid.
+ Message Content
QR Code is invalid
+ Message Content
+
+
+ SASL Authenticaiton failed
+ Message Content
+
+
+ TLS certificate is invalid.
+ Message Content
Unable to connect to server.
+ Message Content
Unexpected Error.
+ Message Content
User allready exist.
+ Message Content
Username is invalid.
+ Message Content
It's Bionade
@@ -197,6 +229,15 @@ You can also put down several servers and then connect to the desired server.
Confirm
+
+ Connecting to Server ...
+
+
+ No Connection to Server
+
+
+ Please select a Server.
+
Delete
@@ -285,9 +326,6 @@ Ask in your Space if you can be trained on the machine to be unlocked for the ma
Password
-
- Please connect to Server
-
Change Password
diff --git a/Borepin/Borepin/Service/ErrorMessage/ErrorMessageService.cs b/Borepin/Borepin/Service/ErrorMessage/ErrorMessageService.cs
new file mode 100644
index 0000000..40e3ff6
--- /dev/null
+++ b/Borepin/Borepin/Service/ErrorMessage/ErrorMessageService.cs
@@ -0,0 +1,108 @@
+using Capnp.Rpc;
+using FabAccessAPI.Exceptions;
+using FabAccessAPI.Exceptions.SASL;
+using Prism.Services;
+using Xamarin.Forms;
+
+namespace Borepin.Service.ErrorMessage
+{
+ public class ErrorMessageService : IErrorMessageService
+ {
+ #region Private Members
+ private IPageDialogService _PageDialogService;
+ #endregion
+
+ #region Constructor
+ public ErrorMessageService(IPageDialogService pageDialogService)
+ {
+ _PageDialogService = pageDialogService;
+ }
+ #endregion
+
+ #region Methods to Display Connection Error
+
+ public void DisplayConnectFailedMessage(System.Exception exception)
+ {
+ if(exception is ConnectionException)
+ {
+ DisplayConnectionMessage(exception as ConnectionException);
+ }
+ else if(exception is AuthenticationException)
+ {
+ DisplayAuthenticationMessage(exception as AuthenticationException);
+ }
+ else
+ {
+ Device.BeginInvokeOnMainThread(async () =>
+ {
+ await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_ConnectionFailed, Resources.Text.TextResource.ALERT_UnexpectedError, Resources.Text.TextResource.OK).ConfigureAwait(false);
+ });
+ }
+ }
+
+ public void DisplayAuthenticationMessage(AuthenticationException exception)
+ {
+ if (exception.InnerException is BadMechanismException)
+ {
+ Device.BeginInvokeOnMainThread(async () =>
+ {
+ await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_AuthFailed, Resources.Text.TextResource.ALERT_BadMechanism, Resources.Text.TextResource.OK).ConfigureAwait(false);
+ });
+ }
+ else if (exception.InnerException is InvalidCredentialsException)
+ {
+ Device.BeginInvokeOnMainThread(async () =>
+ {
+ await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_AuthFailed, Resources.Text.TextResource.ALERT_CredentialsInvalid, Resources.Text.TextResource.OK).ConfigureAwait(false);
+ });
+ }
+ else if (exception.InnerException is AuthenticationFailedException)
+ {
+ Device.BeginInvokeOnMainThread(async () =>
+ {
+ await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_AuthFailed, Resources.Text.TextResource.ALERT_SASLAuth, Resources.Text.TextResource.OK).ConfigureAwait(false);
+ });
+ }
+ else
+ {
+ Device.BeginInvokeOnMainThread(async () =>
+ {
+ await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_AuthFailed, Resources.Text.TextResource.ALERT_UnexpectedError, Resources.Text.TextResource.OK).ConfigureAwait(false);
+ });
+ }
+ }
+
+ public void DisplayConnectionMessage(ConnectionException exception)
+ {
+ if(exception.InnerException is System.Security.Authentication.AuthenticationException)
+ {
+ Device.BeginInvokeOnMainThread(async () =>
+ {
+ await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_ConnectionFailed, Resources.Text.TextResource.ALERT_TLSInvalid, Resources.Text.TextResource.OK).ConfigureAwait(false);
+ });
+ }
+ else if(exception.InnerException is FabAccessAPI.Exceptions.TimeoutException)
+ {
+ Device.BeginInvokeOnMainThread(async () =>
+ {
+ await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_ConnectionFailed, Resources.Text.TextResource.ALERT_ConnectionTimeout, Resources.Text.TextResource.OK).ConfigureAwait(false);
+ });
+ }
+ else if(exception.InnerException is RpcException)
+ {
+ Device.BeginInvokeOnMainThread(async () =>
+ {
+ await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_ConnectionFailed, Resources.Text.TextResource.ALERT_UnableServer, Resources.Text.TextResource.OK).ConfigureAwait(false);
+ });
+ }
+ else
+ {
+ Device.BeginInvokeOnMainThread(async () =>
+ {
+ await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_ConnectionFailed, Resources.Text.TextResource.ALERT_UnexpectedError, Resources.Text.TextResource.OK).ConfigureAwait(false);
+ });
+ }
+ }
+ #endregion
+ }
+}
diff --git a/Borepin/Borepin/Service/ErrorMessage/IErrorMessageService.cs b/Borepin/Borepin/Service/ErrorMessage/IErrorMessageService.cs
new file mode 100644
index 0000000..01f60a8
--- /dev/null
+++ b/Borepin/Borepin/Service/ErrorMessage/IErrorMessageService.cs
@@ -0,0 +1,14 @@
+using FabAccessAPI.Exceptions;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Borepin.Service.ErrorMessage
+{
+ public interface IErrorMessageService
+ {
+ void DisplayConnectFailedMessage(Exception exception);
+ void DisplayConnectionMessage(ConnectionException exception);
+ void DisplayAuthenticationMessage(AuthenticationException exception);
+ }
+}
diff --git a/Borepin/Borepin/View/ConnectionStateView.xaml b/Borepin/Borepin/View/ConnectionStateView.xaml
index 4e78667..600b0f7 100644
--- a/Borepin/Borepin/View/ConnectionStateView.xaml
+++ b/Borepin/Borepin/View/ConnectionStateView.xaml
@@ -6,8 +6,8 @@
xmlns:resource_text="clr-namespace:Borepin.Resources.Text">
+
-
@@ -15,12 +15,17 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FabAccessAPI/API.cs b/FabAccessAPI/API.cs
index 3bf0bbf..3c81f40 100644
--- a/FabAccessAPI/API.cs
+++ b/FabAccessAPI/API.cs
@@ -291,26 +291,19 @@ namespace FabAccessAPI
/// When API-Service can not connect to a server
public async Task TryToConnect(ConnectionData connectionData, TcpRpcClient tcpRpcClient = null)
{
- try
+ if (tcpRpcClient == null)
{
- if (tcpRpcClient == null)
- {
- tcpRpcClient = new TcpRpcClient();
- }
-
- await _ConnectAsync(tcpRpcClient, connectionData).ConfigureAwait(false);
- IBootstrap bootstrap = tcpRpcClient.GetMain();
-
- ServerData serverData = await _GetServerData(bootstrap).ConfigureAwait(false);
-
- tcpRpcClient.Dispose();
-
- return serverData;
- }
- catch(System.Exception ex)
- {
- throw new ConnectionException("Test Connection Failed", ex);
+ tcpRpcClient = new TcpRpcClient();
}
+
+ await _ConnectAsync(tcpRpcClient, connectionData).ConfigureAwait(false);
+ IBootstrap bootstrap = tcpRpcClient.GetMain();
+
+ ServerData serverData = await _GetServerData(bootstrap).ConfigureAwait(false);
+
+ tcpRpcClient.Dispose();
+
+ return serverData;
}
///
@@ -357,7 +350,7 @@ namespace FabAccessAPI
sslStream.AuthenticateAsClient("bffhd");
return sslStream;
}
- catch (AuthenticationException exception)
+ catch (System.Security.Authentication.AuthenticationException exception)
{
sslStream.Close();
Log.Warn(exception);