Added: Reconnect in UI

This commit is contained in:
TheJoKlLa 2023-01-28 01:15:43 +01:00
parent b2cce15464
commit 492ed2e3ce
23 changed files with 504 additions and 240 deletions

View File

@ -53,5 +53,7 @@
<Capabilities>
<Capability Name="internetClient" />
<Capability Name="privateNetworkClientServer"/>
<Capability Name="allJoyn"/>
</Capabilities>
</Package>

View File

@ -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<ILoginStorageService, LoginStorageService>();
containerRegistry.RegisterSingleton<IErrorMessageService, ErrorMessageService>();
// NEED PLATFORM SPECIFIC SERVICE
// IPreferenceStorageService

View File

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

View File

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Borepin.Base
{
public static class ErrorMessages
{
}
}

View File

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

View File

@ -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}">
<ContentPage.Resources>
<ResourceDictionary>
<converters:AllTrueBoolConverter x:Key="AllTrueBoolConverter"/>
<converters:InvertBoolConverter x:Key="InvertBoolConverter"/>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<StackLayout Padding="20">
<StackLayout IsVisible="{Binding IsBusy}">
<ActivityIndicator IsRunning="{Binding IsBusy}"></ActivityIndicator>
</StackLayout>
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
<StackLayout IsVisible="{Binding IsConnected}">
<Label Text="{x:Static resource_text:TextResource.USERNAME}" Style="{StaticResource Style_Label_Property_Title}"></Label>
<views:ConnectionStateView/>
<StackLayout>
<StackLayout.IsVisible>
<MultiBinding Converter="{StaticResource AllTrueBoolConverter}">
<Binding Path="IsBusy" Converter="{StaticResource InvertBoolConverter}"/>
<Binding Path="IsConnected" />
</MultiBinding>
</StackLayout.IsVisible>
<Label Text="{x:Static resource_text:TextResource.USERNAME}" Style="{StaticResource Style_Label_Property_Title}"></Label>
<Entry Text="{Binding Username}" Keyboard="Url" IsSpellCheckEnabled="false"/>
<Label Text="{x:Static resource_text:TextResource.PASSWORD}" Style="{StaticResource Style_Label_Property_Title}"></Label>
<Entry Text="{Binding Password}" Keyboard="Url" IsSpellCheckEnabled="false"/>
<Button Text="{x:Static resource_text:TextResource.AddUserPage_AddUser}" Command="{Binding AddUserCommand}" Style="{StaticResource Style_Button_Primary}"/>
</StackLayout>
<StackLayout IsVisible="{Binding IsConnected, Converter={StaticResource InvertBoolConverter}}">
<Label Text="{x:Static resource_text:TextResource.PLEASECONNECTTOSERVER}"/>
</StackLayout>
<Button Text="{x:Static resource_text:TextResource.AddUserPage_AddUser}" Command="{Binding AddUserCommand}" Style="{StaticResource Style_Button_Primary}"/>
</StackLayout>
</StackLayout>
</ContentPage.Content>

View File

@ -1,16 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:Borepin.View"
x:Class="Borepin.Page.MachineListPage"
xmlns:converters="clr-namespace:Borepin.Converter"
xmlns:resource_text="clr-namespace:Borepin.Resources.Text"
Title="{x:Static resource_text:TextResource.TITLE_Machines}">
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:Borepin.View"
x:Class="Borepin.Page.MachineListPage"
xmlns:converters="clr-namespace:Borepin.Converter"
xmlns:resource_text="clr-namespace:Borepin.Resources.Text"
Title="{x:Static resource_text:TextResource.TITLE_Machines}"
>
<NavigationPage.TitleView>
<Button Text="Refresh" HorizontalOptions="End" BackgroundColor="{StaticResource SecondColor}" TextColor="{StaticResource FirstColor}" Command="{Binding RefreshCommand}"/>
</NavigationPage.TitleView>
<ContentPage.Resources>
<ResourceDictionary>
<converters:AllTrueBoolConverter x:Key="AllTrueBoolConverter"/>
<converters:InvertBoolConverter x:Key="InvertBoolConverter"/>
<converters:ListNotEmptyConverter x:Key="ListNotEmptyConverter"/>
</ResourceDictionary>
@ -18,34 +21,38 @@
<ContentPage.Content>
<StackLayout Padding="20">
<views:ConnectionStateView/>
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
<StackLayout IsVisible="{Binding IsConnected}">
<Button Text="{x:Static resource_text:TextResource.SCANQR}" Command="{Binding ScanCodeCommand}" Style="{StaticResource Style_Button_Primary}">
<StackLayout>
<StackLayout.IsVisible>
<MultiBinding Converter="{StaticResource AllTrueBoolConverter}">
<Binding Path="IsBusy" Converter="{StaticResource InvertBoolConverter}"/>
<Binding Path="IsConnected"/>
</MultiBinding>
</StackLayout.IsVisible>
<Button Text="{x:Static resource_text:TextResource.SCANQR}" Command="{Binding ScanCodeCommand}" Style="{StaticResource Style_Button_Primary}">
<Button.IsVisible>
<OnPlatform x:TypeArguments="x:Boolean"
iOS="True"
Android="True"/>
</Button.IsVisible>
</Button>
<ListView ItemsSource="{Binding MachineListItemViewModel_List}" SelectionMode="None" SeparatorColor="Transparent" IsGroupingEnabled="True" GroupDisplayBinding="{Binding Category}">
<ListView.GroupHeaderTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Margin="0, 10, 0, 0">
<Label Text="{Binding Category}"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.GroupHeaderTemplate>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<views:MachineListItemView />
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
<ListView ItemsSource="{Binding MachineListItemViewModel_List}" SelectionMode="None" SeparatorColor="Transparent" IsGroupingEnabled="True" GroupDisplayBinding="{Binding Category}">
<ListView.GroupHeaderTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Margin="0, 10, 0, 0">
<Label Text="{Binding Category}"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.GroupHeaderTemplate>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<views:MachineListItemView />
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</StackLayout>
</ContentPage.Content>

View File

@ -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}">
<NavigationPage.TitleView>
<Label Text="{Binding MachineItem.State, Converter={StaticResource MachineStateStringConverter}}" FontAttributes="Bold" HorizontalOptions="End" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" WidthRequest="150" Margin="7.5" VerticalOptions="FillAndExpand" FontSize="Small" BackgroundColor="{Binding MachineItem.State, Converter={StaticResource MachineStateColorConverter}}"/>
</NavigationPage.TitleView>
<ContentPage.Resources>
<ResourceDictionary>
<converters:AllTrueBoolConverter x:Key="AllTrueBoolConverter"/>
<converters:InvertBoolConverter x:Key="InvertBoolConverter"/>
<converters:MachineStateColorConverter x:Key="MachineStateColorConverter"/>
<converters:MachineStateStringConverter x:Key="MachineStateStringConverter"/>
<converters:IsNotNullBoolConverter x:Key="IsNotNullBoolConverter"/>
<converters:InvertBoolConverter x:Key="InvertBoolConverter"/>
</ResourceDictionary>
</ContentPage.Resources>
<NavigationPage.TitleView>
<Label Text="{Binding MachineItem.State, Converter={StaticResource MachineStateStringConverter}}" FontAttributes="Bold" HorizontalOptions="End" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" WidthRequest="150" Margin="7.5" VerticalOptions="FillAndExpand" FontSize="Small" BackgroundColor="{Binding MachineItem.State, Converter={StaticResource MachineStateColorConverter}}">
<Label.IsVisible>
<MultiBinding Converter="{StaticResource AllTrueBoolConverter}">
<Binding Path="IsBusy" Converter="{StaticResource InvertBoolConverter}"/>
<Binding Path="IsConnected" />
</MultiBinding>
</Label.IsVisible>
</Label>
</NavigationPage.TitleView>
<ContentPage.Content>
<ScrollView>
<StackLayout Padding="20">
<StackLayout IsVisible="{Binding IsConnected}">
<StackLayout IsVisible="{Binding IsBusy}">
<ActivityIndicator IsRunning="{Binding IsBusy}"></ActivityIndicator>
<views:ConnectionStateView/>
<StackLayout>
<StackLayout.IsVisible>
<MultiBinding Converter="{StaticResource AllTrueBoolConverter}">
<Binding Path="IsBusy" Converter="{StaticResource InvertBoolConverter}"/>
<Binding Path="IsConnected" />
</MultiBinding>
</StackLayout.IsVisible>
<Label Text="{Binding MachineItem.Name}" Style="{StaticResource LabelStyle_Title}"/>
<Label Text="{Binding MachineItem.Description}" Style="{StaticResource Style_Label_Text_Center}"/>
<StackLayout Orientation="Horizontal" IsVisible="{Binding MachineItem.CurrentUser, Converter={StaticResource IsNotNullBoolConverter}}">
<Label Text="{x:Static resource_text:TextResource.MachinePage_CurrentUser}" Style="{StaticResource Style_Label_Property_Title}"/>
<Label Text="{Binding MachineItem.CurrentUser.Username}" Style="{StaticResource Style_Label_Property_Text}"/>
</StackLayout>
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
<Label Text="{Binding MachineItem.Name}" Style="{StaticResource LabelStyle_Title}"/>
<Label Text="{Binding MachineItem.Description}" Style="{StaticResource Style_Label_Text_Center}"/>
<StackLayout Orientation="Horizontal" IsVisible="{Binding MachineItem.CurrentUser, Converter={StaticResource IsNotNullBoolConverter}}">
<Label Text="{x:Static resource_text:TextResource.MachinePage_CurrentUser}" Style="{StaticResource Style_Label_Property_Title}"/>
<Label Text="{Binding MachineItem.CurrentUser.Username}" Style="{StaticResource Style_Label_Property_Text}"/>
</StackLayout>
<Button Text="{x:Static resource_text:TextResource.MachinePage_Use}" IsVisible="{Binding MachineItem.CanUse}" Command="{Binding UseMachineCommand}" Style="{StaticResource Style_Button_Primary}"/>
<Label Text="{x:Static resource_text:TextResource.MachinePage_CanNotUseByPermission}" IsVisible="{Binding MachineItem.CanNotUseByPermission}" Style="{StaticResource Style_Label_Text_Center}"/>
<Button Text="{x:Static resource_text:TextResource.MachinePage_GiveBack}" IsVisible="{Binding MachineItem.CanInUse}" Command="{Binding GiveBackMachineCommand}" Style="{StaticResource Style_Button_Primary}"/>
<Button VerticalOptions="End" Text="{x:Static resource_text:TextResource.MachinePage_OpenWiki}" IsVisible="{Binding MachineItem.Wiki, Converter={StaticResource IsNotNullBoolConverter}}" Command="{Binding OpenWikiCommand}" Style="{StaticResource Style_Button_Primary}"/>
<StackLayout Grid.Row="2" VerticalOptions="End" IsVisible="{Binding MachineItem.CanManage}">
<Label Text="{x:Static resource_text:TextResource.MachinePage_ManageMachine}" Style="{StaticResource Style_Label_Property_Title}"/>
<StackLayout Margin="10, 0, 0, 20" Orientation="Horizontal" IsVisible="{Binding MachineItem.LastUser, Converter={StaticResource IsNotNullBoolConverter}}">
<Label Text="{x:Static resource_text:TextResource.MachinePage_LastUser}" Style="{StaticResource Style_Label_Property_Title}"/>
<Label Text="{Binding MachineItem.LastUser.Username}" Style="{StaticResource Style_Label_Property_Text}" Margin="10, 0, 0, 0"/>
</StackLayout>
<Button Text="{x:Static resource_text:TextResource.MachinePage_ForceFree}" Command="{Binding ForceFreeMachineCommand}" Style="{StaticResource Style_Button_Primary}"/>
<Button Text="{x:Static resource_text:TextResource.MachinePage_ForceBlock}" Command="{Binding ForceBlockMachineCommand}" Style="{StaticResource Style_Button_Admin}"/>
<Button Text="{x:Static resource_text:TextResource.MachinePage_ForceDisable}" Command="{Binding ForceDisableMachineCommand}" Style="{StaticResource Style_Button_Admin}"/>
<Button Text="{x:Static resource_text:TextResource.MachinePage_Use}" IsVisible="{Binding MachineItem.CanUse}" Command="{Binding UseMachineCommand}" Style="{StaticResource Style_Button_Primary}"/>
<Label Text="{x:Static resource_text:TextResource.MachinePage_CanNotUseByPermission}" IsVisible="{Binding MachineItem.CanNotUseByPermission}" Style="{StaticResource Style_Label_Text_Center}"/>
<Button Text="{x:Static resource_text:TextResource.MachinePage_GiveBack}" IsVisible="{Binding MachineItem.CanInUse}" Command="{Binding GiveBackMachineCommand}" Style="{StaticResource Style_Button_Primary}"/>
<Button VerticalOptions="End" Text="{x:Static resource_text:TextResource.MachinePage_OpenWiki}" IsVisible="{Binding MachineItem.Wiki, Converter={StaticResource IsNotNullBoolConverter}}" Command="{Binding OpenWikiCommand}" Style="{StaticResource Style_Button_Primary}"/>
<StackLayout Grid.Row="2" VerticalOptions="End" IsVisible="{Binding MachineItem.CanManage}">
<Label Text="{x:Static resource_text:TextResource.MachinePage_ManageMachine}" Style="{StaticResource Style_Label_Property_Title}"/>
<StackLayout Margin="10, 0, 0, 20" Orientation="Horizontal" IsVisible="{Binding MachineItem.LastUser, Converter={StaticResource IsNotNullBoolConverter}}">
<Label Text="{x:Static resource_text:TextResource.MachinePage_LastUser}" Style="{StaticResource Style_Label_Property_Title}"/>
<Label Text="{Binding MachineItem.LastUser.Username}" Style="{StaticResource Style_Label_Property_Text}" Margin="10, 0, 0, 0"/>
</StackLayout>
<Button Text="{x:Static resource_text:TextResource.MachinePage_ForceFree}" Command="{Binding ForceFreeMachineCommand}" Style="{StaticResource Style_Button_Primary}"/>
<Button Text="{x:Static resource_text:TextResource.MachinePage_ForceBlock}" Command="{Binding ForceBlockMachineCommand}" Style="{StaticResource Style_Button_Admin}"/>
<Button Text="{x:Static resource_text:TextResource.MachinePage_ForceDisable}" Command="{Binding ForceDisableMachineCommand}" Style="{StaticResource Style_Button_Admin}"/>
</StackLayout>
</StackLayout>
<Label Text="{x:Static resource_text:TextResource.PLEASECONNECTTOSERVER}" IsVisible="{Binding IsConnected, Converter={StaticResource InvertBoolConverter}}"></Label>
</StackLayout>
</ScrollView>
</ContentPage.Content>

View File

@ -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}">
<ContentPage.Resources>
<ResourceDictionary>
@ -12,21 +12,20 @@
</ContentPage.Resources>
<ContentPage.Content>
<StackLayout Padding="20">
<StackLayout IsVisible="{Binding IsBusy}">
<ActivityIndicator IsRunning="{Binding IsBusy}"></ActivityIndicator>
</StackLayout>
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
<StackLayout IsVisible="{Binding IsConnected}">
<Label Text="{Binding Username}" Style="{StaticResource LabelStyle_Title}"/>
<StackLayout IsVisible="{Binding CanManage}">
<Label Text="{x:Static resource_text:TextResource.ProfilePage_ChangePassword}" Style="{StaticResource Style_Label_Property_Title}"/>
<Entry Placeholder="{x:Static resource_text:TextResource.ProfilePage_OldPassword}" Text="{Binding OldPassword}"/>
<Entry Placeholder="{x:Static resource_text:TextResource.ProfilePage_NewPassword}" Text="{Binding NewPassword}"/>
<Button Text="{x:Static resource_text:TextResource.ProfilePage_UpdatePassword}" Command="{Binding UpdatePasswordCommand}" Style="{StaticResource Style_Button_Primary}"/>
</StackLayout>
</StackLayout>
<StackLayout IsVisible="{Binding IsConnected, Converter={StaticResource InvertBoolConverter}}">
<Label Text="{x:Static resource_text:TextResource.PLEASECONNECTTOSERVER}"/>
<views:ConnectionStateView/>
<StackLayout>
<StackLayout.IsVisible>
<MultiBinding Converter="{StaticResource AllTrueBoolConverter}">
<Binding Path="IsBusy" Converter="{StaticResource InvertBoolConverter}"/>
<Binding Path="IsConnected" />
</MultiBinding>
</StackLayout.IsVisible>
<Label Text="{Binding Username}" Style="{StaticResource LabelStyle_Title}"/>
<StackLayout IsVisible="{Binding CanManage}">
<Label Text="{x:Static resource_text:TextResource.ProfilePage_ChangePassword}" Style="{StaticResource Style_Label_Property_Title}"/>
<Entry Placeholder="{x:Static resource_text:TextResource.ProfilePage_OldPassword}" Text="{Binding OldPassword}"/>
<Entry Placeholder="{x:Static resource_text:TextResource.ProfilePage_NewPassword}" Text="{Binding NewPassword}"/>
<Button Text="{x:Static resource_text:TextResource.ProfilePage_UpdatePassword}" Command="{Binding UpdatePasswordCommand}" Style="{StaticResource Style_Button_Primary}"/>
</StackLayout>
</StackLayout>
</StackLayout>

View File

@ -11,36 +11,36 @@
</NavigationPage.TitleView>
<ContentPage.Resources>
<ResourceDictionary>
<converters:AllTrueBoolConverter x:Key="AllTrueBoolConverter"/>
<converters:InvertBoolConverter x:Key="InvertBoolConverter"/>
<converters:ListNotEmptyConverter x:Key="ListNotEmptyConverter"/>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<StackLayout Padding="20">
<StackLayout IsVisible="{Binding IsBusy}">
<ActivityIndicator IsRunning="{Binding IsBusy}"></ActivityIndicator>
</StackLayout>
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
<StackLayout IsVisible="{Binding IsConnected}">
<Button Text="{x:Static resource_text:TextResource.UserListPage_AddUser}" Command="{Binding AddUserCommand}" Style="{StaticResource Style_Button_Primary}"/>
<SearchBar Text="{Binding SearchUsername}" SearchCommand="{Binding SearchUserCommand}">
<SearchBar.Behaviors>
<prism:EventToCommandBehavior EventName="TextChanged" Command="{Binding SearchUserCommand}"/>
</SearchBar.Behaviors>
</SearchBar>
<ListView ItemsSource="{Binding FilteredUserListItemViewModel_List}" SelectionMode="None" SeparatorColor="Transparent">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<views:UserListItemView />
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
<StackLayout IsVisible="{Binding IsConnected, Converter={StaticResource InvertBoolConverter}}">
<Label Text="{x:Static resource_text:TextResource.PLEASECONNECTTOSERVER}"/>
</StackLayout>
<views:ConnectionStateView/>
<StackLayout>
<StackLayout.IsVisible>
<MultiBinding Converter="{StaticResource AllTrueBoolConverter}">
<Binding Path="IsBusy" Converter="{StaticResource InvertBoolConverter}"/>
<Binding Path="IsConnected" />
</MultiBinding>
</StackLayout.IsVisible>
<Button Text="{x:Static resource_text:TextResource.UserListPage_AddUser}" Command="{Binding AddUserCommand}" Style="{StaticResource Style_Button_Primary}"/>
<SearchBar Text="{Binding SearchUsername}" SearchCommand="{Binding SearchUserCommand}">
<SearchBar.Behaviors>
<prism:EventToCommandBehavior EventName="TextChanged" Command="{Binding SearchUserCommand}"/>
</SearchBar.Behaviors>
</SearchBar>
<ListView ItemsSource="{Binding FilteredUserListItemViewModel_List}" SelectionMode="None" SeparatorColor="Transparent">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<views:UserListItemView />
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</StackLayout>
</ContentPage.Content>

View File

@ -8,39 +8,39 @@
Title="{x:Static resource_text:TextResource.TITLE_User}">
<ContentPage.Resources>
<ResourceDictionary>
<converters:AllTrueBoolConverter x:Key="AllTrueBoolConverter"/>
<converters:InvertBoolConverter x:Key="InvertBoolConverter"/>
<converters:MachineStateColorConverter x:Key="MachineStateColorConverter"/>
<converters:MachineStateStringConverter x:Key="MachineStateStringConverter"/>
<converters:IsNotNullBoolConverter x:Key="IsNotNullBoolConverter"/>
<converters:InvertBoolConverter x:Key="InvertBoolConverter"/>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<StackLayout Padding="20">
<StackLayout IsVisible="{Binding IsBusy}">
<ActivityIndicator IsRunning="{Binding IsBusy}"></ActivityIndicator>
</StackLayout>
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
<StackLayout IsVisible="{Binding IsConnected}">
<Label Text="{Binding UserItem.Username}" Style="{StaticResource LabelStyle_Title}"/>
<ListView ItemsSource="{Binding PermissionSelectViewModel_List}" SelectionMode="None" SeparatorColor="Transparent">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<views:PermissionSelectView />
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<StackLayout IsVisible="{Binding CanAdmin}">
<Label Text="{x:Static resource_text:TextResource.UserPage_ChangePassword}" Style="{StaticResource Style_Label_Property_Title}"/>
<Entry Placeholder="{x:Static resource_text:TextResource.UserPage_NewPassword}" Text="{Binding NewPassword}"/>
<Button Text="{x:Static resource_text:TextResource.UserPage_UpdatePassword}" Command="{Binding UpdatePasswordCommand}" Style="{StaticResource Style_Button_Primary}"/>
</StackLayout>
<Button Grid.Row="1" Text="{x:Static resource_text:TextResource.DELETE}" Command="{Binding DeleteCommand}" Style="{StaticResource Style_Button_Admin}" VerticalOptions="End"/>
</StackLayout>
<StackLayout IsVisible="{Binding IsConnected, Converter={StaticResource InvertBoolConverter}}">
<Label Text="{x:Static resource_text:TextResource.PLEASECONNECTTOSERVER}"/>
<views:ConnectionStateView/>
<StackLayout>
<StackLayout.IsVisible>
<MultiBinding Converter="{StaticResource AllTrueBoolConverter}">
<Binding Path="IsBusy" Converter="{StaticResource InvertBoolConverter}"/>
<Binding Path="IsConnected" />
</MultiBinding>
</StackLayout.IsVisible>
<Label Text="{Binding UserItem.Username}" Style="{StaticResource LabelStyle_Title}"/>
<ListView ItemsSource="{Binding PermissionSelectViewModel_List}" SelectionMode="None" SeparatorColor="Transparent">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<views:PermissionSelectView />
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<StackLayout IsVisible="{Binding CanAdmin}">
<Label Text="{x:Static resource_text:TextResource.UserPage_ChangePassword}" Style="{StaticResource Style_Label_Property_Title}"/>
<Entry Placeholder="{x:Static resource_text:TextResource.UserPage_NewPassword}" Text="{Binding NewPassword}"/>
<Button Text="{x:Static resource_text:TextResource.UserPage_UpdatePassword}" Command="{Binding UpdatePasswordCommand}" Style="{StaticResource Style_Button_Primary}"/>
</StackLayout>
<Button Grid.Row="1" Text="{x:Static resource_text:TextResource.DELETE}" Command="{Binding DeleteCommand}" Style="{StaticResource Style_Button_Admin}" VerticalOptions="End"/>
</StackLayout>
</StackLayout>
</ContentPage.Content>

View File

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

View File

@ -145,7 +145,15 @@ namespace Borepin.PageModel
{
if(_API.IsConnected)
{
await LoadAPIData().ConfigureAwait(true);
try
{
await LoadAPIData().ConfigureAwait(true);
}
catch
{
// TODO
}
}
IsRefreshing = false;

View File

@ -36,7 +36,7 @@ namespace Borepin.PageModel
List<Task> tasks = new List<Task>();
IList<ConnectionData> 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);

View File

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

View File

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

View File

@ -90,7 +90,14 @@ namespace Borepin.PageModel
{
if(_API.IsConnected)
{
await LoadAPIData().ConfigureAwait(true);
try
{
await LoadAPIData().ConfigureAwait(true);
}
catch (Exception)
{
// TODO
}
}
IsRefreshing = false;

View File

@ -170,6 +170,15 @@ namespace Borepin.Resources.Text {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Authentication failed ähnelt.
/// </summary>
internal static string ALERT_AuthFailed {
get {
return ResourceManager.GetString("ALERT_AuthFailed", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Unable to authenticate to server. ähnelt.
/// </summary>
@ -179,6 +188,15 @@ namespace Borepin.Resources.Text {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die SASL Mechanism is not supported- ähnelt.
/// </summary>
internal static string ALERT_BadMechanism {
get {
return ResourceManager.GetString("ALERT_BadMechanism", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Connection failed ähnelt.
/// </summary>
@ -188,6 +206,15 @@ namespace Borepin.Resources.Text {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Connection time exceeded. ähnelt.
/// </summary>
internal static string ALERT_ConnectionTimeout {
get {
return ResourceManager.GetString("ALERT_ConnectionTimeout", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Credentials are invalid. ähnelt.
/// </summary>
@ -224,6 +251,24 @@ namespace Borepin.Resources.Text {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die SASL Authenticaiton failed ähnelt.
/// </summary>
internal static string ALERT_SASLAuth {
get {
return ResourceManager.GetString("ALERT_SASLAuth", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die TLS certificate is invalid. ähnelt.
/// </summary>
internal static string ALERT_TLSInvalid {
get {
return ResourceManager.GetString("ALERT_TLSInvalid", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Unable to connect to server. ähnelt.
/// </summary>
@ -296,6 +341,33 @@ namespace Borepin.Resources.Text {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Connecting to Server ... ähnelt.
/// </summary>
internal static string ConnectionStatus_Connecting {
get {
return ResourceManager.GetString("ConnectionStatus_Connecting", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die No Connection to Server ähnelt.
/// </summary>
internal static string ConnectionStatus_NoConnection {
get {
return ResourceManager.GetString("ConnectionStatus_NoConnection", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Please select a Server. ähnelt.
/// </summary>
internal static string ConnectionStatus_NotConnected {
get {
return ResourceManager.GetString("ConnectionStatus_NotConnected", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Delete ähnelt.
/// </summary>
@ -558,15 +630,6 @@ namespace Borepin.Resources.Text {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Please connect to Server ähnelt.
/// </summary>
internal static string PLEASECONNECTTOSERVER {
get {
return ResourceManager.GetString("PLEASECONNECTTOSERVER", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Change Password ähnelt.
/// </summary>

View File

@ -151,39 +151,71 @@ You can also put down several servers and then connect to the desired server.</v
</data>
<data name="ALERT_AddressInvalid" xml:space="preserve">
<value>Server address is invaild.</value>
<comment>Message Content</comment>
</data>
<data name="ALERT_AddUserFailed" xml:space="preserve">
<value>Add User failed</value>
<comment>Message Content</comment>
</data>
<data name="ALERT_AuthFailed" xml:space="preserve">
<value>Authentication failed</value>
<comment>Message Title</comment>
</data>
<data name="ALERT_AuthServer" xml:space="preserve">
<value>Unable to authenticate to server.</value>
<comment>Message Content</comment>
</data>
<data name="ALERT_BadMechanism" xml:space="preserve">
<value>SASL Mechanism is not supported-</value>
<comment>Message Content</comment>
</data>
<data name="ALERT_ConnectionFailed" xml:space="preserve">
<value>Connection failed</value>
<comment>Message Title</comment>
</data>
<data name="ALERT_ConnectionTimeout" xml:space="preserve">
<value>Connection time exceeded.</value>
<comment>Message Content</comment>
</data>
<data name="ALERT_CredentialsInvalid" xml:space="preserve">
<value>Credentials are invalid.</value>
<comment>Message Content</comment>
</data>
<data name="ALERT_DuplicateConnection" xml:space="preserve">
<value>Connection already exist. Please delete old Connection before adding the new Connection.</value>
<comment>Message Content</comment>
</data>
<data name="ALERT_PasswordInvalid" xml:space="preserve">
<value>Password is invalid.</value>
<comment>Message Content</comment>
</data>
<data name="ALERT_QRInvalid" xml:space="preserve">
<value>QR Code is invalid</value>
<comment>Message Content</comment>
</data>
<data name="ALERT_SASLAuth" xml:space="preserve">
<value>SASL Authenticaiton failed</value>
<comment>Message Content</comment>
</data>
<data name="ALERT_TLSInvalid" xml:space="preserve">
<value>TLS certificate is invalid.</value>
<comment>Message Content</comment>
</data>
<data name="ALERT_UnableServer" xml:space="preserve">
<value>Unable to connect to server.</value>
<comment>Message Content</comment>
</data>
<data name="ALERT_UnexpectedError" xml:space="preserve">
<value>Unexpected Error.</value>
<comment>Message Content</comment>
</data>
<data name="ALERT_UserExist" xml:space="preserve">
<value>User allready exist.</value>
<comment>Message Content</comment>
</data>
<data name="ALERT_UsernameInvalid" xml:space="preserve">
<value>Username is invalid.</value>
<comment>Message Content</comment>
</data>
<data name="Bionade" xml:space="preserve">
<value>It's Bionade</value>
@ -197,6 +229,15 @@ You can also put down several servers and then connect to the desired server.</v
<data name="CONFIRM" xml:space="preserve">
<value>Confirm</value>
</data>
<data name="ConnectionStatus_Connecting" xml:space="preserve">
<value>Connecting to Server ...</value>
</data>
<data name="ConnectionStatus_NoConnection" xml:space="preserve">
<value>No Connection to Server</value>
</data>
<data name="ConnectionStatus_NotConnected" xml:space="preserve">
<value>Please select a Server.</value>
</data>
<data name="DELETE" xml:space="preserve">
<value>Delete</value>
</data>
@ -285,9 +326,6 @@ Ask in your Space if you can be trained on the machine to be unlocked for the ma
<data name="PASSWORD" xml:space="preserve">
<value>Password</value>
</data>
<data name="PLEASECONNECTTOSERVER" xml:space="preserve">
<value>Please connect to Server</value>
</data>
<data name="ProfilePage_ChangePassword" xml:space="preserve">
<value>Change Password</value>
</data>

View File

@ -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
}
}

View File

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

View File

@ -6,8 +6,8 @@
xmlns:resource_text="clr-namespace:Borepin.Resources.Text">
<ContentView.Resources>
<ResourceDictionary>
<converters:AllTrueBoolConverter x:Key="AllTrueBoolConverter"/>
<converters:InvertBoolConverter x:Key="InvertBoolConverter"/>
<converters:ListNotEmptyConverter x:Key="ListNotEmptyConverter"/>
</ResourceDictionary>
</ContentView.Resources>
<ContentView.Content>
@ -15,12 +15,17 @@
<StackLayout IsVisible="{Binding IsBusy}">
<ActivityIndicator IsRunning="{Binding IsBusy}"></ActivityIndicator>
</StackLayout>
<StackLayout IsVisible="{Binding IsBusy, Converter={StaticResource InvertBoolConverter}}">
<StackLayout IsVisible="{Binding IsConnected, Converter={StaticResource InvertBoolConverter}}">
<Label Text="No Connection to Server"/>
<Label Text="Connecting to Server ..." IsVisible="{Binding IsConnecting}"/>
<Label Text="Please select a Server." IsVisible="{Binding IsConnecting, Converter={StaticResource InvertBoolConverter}}"/>
</StackLayout>
<StackLayout>
<StackLayout.IsVisible>
<MultiBinding Converter="{StaticResource AllTrueBoolConverter}">
<Binding Path="IsBusy" Converter="{StaticResource InvertBoolConverter}"/>
<Binding Path="IsConnected" Converter="{StaticResource InvertBoolConverter}"/>
</MultiBinding>
</StackLayout.IsVisible>
<Label Text="{x:Static resource_text:TextResource.ConnectionStatus_NoConnection}"/>
<Label Text="{x:Static resource_text:TextResource.ConnectionStatus_Connecting}" IsVisible="{Binding IsConnecting}"/>
<Label Text="{x:Static resource_text:TextResource.ConnectionStatus_NotConnected}" IsVisible="{Binding IsConnecting, Converter={StaticResource InvertBoolConverter}}"/>
</StackLayout>
</StackLayout>
</ContentView.Content>

View File

@ -291,26 +291,19 @@ namespace FabAccessAPI
/// <exception cref="ConnectionException"> When API-Service can not connect to a server </exception>
public async Task<ServerData> 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<IBootstrap>();
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<IBootstrap>();
ServerData serverData = await _GetServerData(bootstrap).ConfigureAwait(false);
tcpRpcClient.Dispose();
return serverData;
}
/// <summary>
@ -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);