Merge branch 'feature/opendoor' into feature/NFC

This commit is contained in:
TheJoKlLa 2023-02-27 01:21:30 +01:00
commit f42bcfd3a1
6 changed files with 96 additions and 0 deletions

View File

@ -80,6 +80,7 @@ namespace Borepin.Model
CanManage = !((ManageInterface_Proxy)_Machine.Manage).IsNull;
CanAdmin = !((AdminInterface_Proxy)_Machine.Admin).IsNull;
CanNotUseByPermission = State == MachineState.free && !CanUse;
IsLock = !((ProdInterface_Proxy)_Machine.Prodable).IsNull;
}
#endregion
@ -202,6 +203,13 @@ namespace Borepin.Model
get => _CanNotUseByPermission;
set => SetProperty(ref _CanNotUseByPermission, value);
}
private bool _IsLock;
public bool IsLock
{
get => _IsLock;
set => SetProperty(ref _IsLock, value);
}
#endregion
}
}

View File

@ -46,6 +46,25 @@
<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}" TextColor="{StaticResource FourthColor}"/>
<Button Text="{x:Static resource_text:TextResource.MachinePage_GiveBack}" IsVisible="{Binding MachineItem.CanInUse}" Command="{Binding GiveBackMachineCommand}" Style="{StaticResource Style_Button_Primary}"/>
<Button Text="{x:Static resource_text:TextResource.MachinePage_Unlock}" Command="{Binding UnlockLockCommand}" Style="{StaticResource Style_Button_Primary}">
<Button.IsVisible>
<MultiBinding Converter="{StaticResource AllTrueBoolConverter}">
<Binding Path="MachineItem.CanInUse" Converter="{StaticResource InvertBoolConverter}"/>
<Binding Path="MachineItem.IsLock" />
</MultiBinding>
</Button.IsVisible>
</Button>
<Button Text="{x:Static resource_text:TextResource.MachinePage_Identify}" Command="{Binding IdentifyLockCommand}" Style="{StaticResource Style_Button_Primary}">
<Button.IsVisible>
<MultiBinding Converter="{StaticResource AllTrueBoolConverter}">
<Binding Path="MachineItem.CanInUse" Converter="{StaticResource InvertBoolConverter}"/>
<Binding Path="MachineItem.IsLock" />
</MultiBinding>
</Button.IsVisible>
</Button>
<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}" Margin="0,50,0,0">
<Label Text="{x:Static resource_text:TextResource.MachinePage_ManageMachine}" Style="{StaticResource Style_Label_Property_Title}"/>

View File

@ -11,6 +11,7 @@ using Borepin.Base.Exceptions;
using Capnp.Rpc;
using System;
using Borepin.Service.Browser;
using System.Text;
namespace Borepin.PageModel
{
@ -236,6 +237,60 @@ namespace Borepin.PageModel
}
}
}
private ICommand _UnlockLockCommand;
public ICommand UnlockLockCommand
{
get => _UnlockLockCommand;
set => SetProperty(ref _UnlockLockCommand, value);
}
public async void UnlockLockCommandExecute()
{
IsBusy = true;
if (_API.IsConnected)
{
try
{
Machine.IProdInterface prodInterface = _Machine.Prodable;
await prodInterface.ProdWithData(Encoding.ASCII.GetBytes("action: unlock")).ConfigureAwait(false);
}
catch (RpcException exception) when (string.Equals(exception.Message, "RPC connection is broken. Task would never return.", StringComparison.Ordinal))
{
Log.Debug("RPC Connection Loss");
}
}
IsBusy = false;
}
private ICommand _IdentifyLockCommand;
public ICommand IdentifyLockCommand
{
get => _IdentifyLockCommand;
set => SetProperty(ref _IdentifyLockCommand, value);
}
public async void IdentifyLockCommandExecute()
{
IsBusy = true;
if (_API.IsConnected)
{
try
{
Machine.IProdInterface prodInterface = _Machine.Prodable;
await prodInterface.ProdWithData(Encoding.ASCII.GetBytes("action: identify")).ConfigureAwait(false);
}
catch (RpcException exception) when (string.Equals(exception.Message, "RPC connection is broken. Task would never return.", StringComparison.Ordinal))
{
Log.Debug("RPC Connection Loss");
}
}
IsBusy = false;
}
#endregion
}
}

View File

@ -531,6 +531,15 @@ namespace Borepin.Resources.Text {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Identify ähnelt.
/// </summary>
internal static string MachinePage_Identify {
get {
return ResourceManager.GetString("MachinePage_Identify", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Last User: ähnelt.
/// </summary>

View File

@ -293,6 +293,9 @@ Please speak with the staff at the Space to receive the necessary training and a
<data name="MachinePage_GiveBack" xml:space="preserve">
<value>GiveBack</value>
</data>
<data name="MachinePage_Identify" xml:space="preserve">
<value>Identify</value>
</data>
<data name="MachinePage_LastUser" xml:space="preserve">
<value>Last User:</value>
</data>

View File

@ -1,4 +1,5 @@
using FabAccessAPI;
using NUnit.Framework;
using System;
using System.Collections.Generic;
@ -11,6 +12,7 @@ namespace FabAccessAPI_Test
public const int TESTSERVER_PORT = 59661;
public const string PASSWORD = "secret";
[TestCase("Testuser")]
public static ConnectionData CreateConnetionData(string username)
{
ConnectionData connectionData = new ConnectionData()