Implementato sdk honeywell e metodi per lo scanner barcode
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
@page "/login"
|
||||
@using SteUp.Shared.Components.Layout.Spinner
|
||||
@using SteUp.Shared.Core.BarcodeReader.Contracts
|
||||
@using SteUp.Shared.Core.Interface.System
|
||||
@using SteUp.Shared.Core.Services
|
||||
@inject IUserAccountService UserAccountService
|
||||
@inject AppAuthenticationStateProvider AuthenticationStateProvider
|
||||
@inject IGenericSystemService GenericSystemService
|
||||
@inject IBarcodeManager BarcodeManager
|
||||
|
||||
@if (Spinner)
|
||||
{
|
||||
@@ -90,6 +92,7 @@ else
|
||||
await UserAccountService.Login(UserData.Username, UserData.Password, UserData.CodHash);
|
||||
AuthenticationStateProvider.NotifyAuthenticationState(); //Chiamato per forzare il refresh
|
||||
await SteupDataService.Init();
|
||||
BarcodeManager.Init();
|
||||
|
||||
LocalStorage.SetString("codHash", UserData.CodHash);
|
||||
NavigationManager.NavigateTo("/");
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
@using SteUp.Shared.Components.SingleElements.Modal.ExceptionModal
|
||||
@using SteUp.Shared.Core.BarcodeReader.Contracts
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject IBarcodeManager BarcodeManager
|
||||
|
||||
<ErrorBoundary @ref="ErrorBoundary">
|
||||
<ChildContent>
|
||||
@@ -43,5 +45,6 @@
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await SteupDataService.Init();
|
||||
BarcodeManager.Init();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
.card-form-modal {
|
||||
background: var(--mud-palette-table-striped);
|
||||
border-radius: 1em;
|
||||
border-radius: 20px;
|
||||
padding: .5rem 1rem;
|
||||
width: -webkit-fill-available;
|
||||
}
|
||||
|
||||
@@ -8,11 +8,13 @@
|
||||
@using SteUp.Shared.Core.Interface.LocalDb
|
||||
@using SteUp.Shared.Core.Interface.System
|
||||
@using SteUp.Shared.Core.Interface.System.Network
|
||||
@using SteUp.Shared.Core.Messages.Scanner
|
||||
@inject INetworkService NetworkService
|
||||
@inject IDialogService Dialog
|
||||
@inject IIntegryApiService IntegryApiService
|
||||
@inject IAttachedService AttachedService
|
||||
@inject IIspezioniService IspezioniService
|
||||
@inject OnScannerService OnScannerService
|
||||
|
||||
<MudDialog Class="customDialog-form">
|
||||
<DialogContent>
|
||||
@@ -159,6 +161,9 @@
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
OnScannerService.OnNewScanSuccessful += OnNewScanSuccessful;
|
||||
OnScannerService.OnErrorScan += OnErrorScan;
|
||||
|
||||
_originalScheda = Scheda.Clone();
|
||||
Snackbar.Configuration.PositionClass = Defaults.Classes.Position.TopCenter;
|
||||
|
||||
@@ -351,7 +356,7 @@
|
||||
AttachedList.Add(new AttachedDto { Name = a.Name, MimeType = a.MimeType, FileBytes = a.FileBytes });
|
||||
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
|
||||
RecalcDirty(true);
|
||||
|
||||
// Processa in background e aggiorna UI man mano (o a blocchi)
|
||||
@@ -419,4 +424,19 @@
|
||||
await InvokeAsync(StateHasChanged);
|
||||
});
|
||||
}
|
||||
|
||||
#region Scanner
|
||||
|
||||
public static void OnNewScanSuccessful(string? value)
|
||||
{
|
||||
//To be implemented
|
||||
}
|
||||
|
||||
private static void OnErrorScan(string? value)
|
||||
{
|
||||
//To be implemented
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
32
SteUp.Shared/Core/BarcodeReader/BarcodeManager.cs
Normal file
32
SteUp.Shared/Core/BarcodeReader/BarcodeManager.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using SteUp.Shared.Core.BarcodeReader.Contracts;
|
||||
using SteUp.Shared.Core.Messages.Scanner;
|
||||
|
||||
namespace SteUp.Shared.Core.BarcodeReader;
|
||||
|
||||
public class BarcodeManager(
|
||||
IBarcodeReaderService scanner,
|
||||
IMessenger messenger) : IBarcodeManager
|
||||
{
|
||||
public void Init()
|
||||
{
|
||||
if (!scanner.IsRightAdapter())
|
||||
{
|
||||
Console.WriteLine("Dispositivo non compatibile con lo scanner Honeywell.");
|
||||
return;
|
||||
}
|
||||
|
||||
scanner.Register(
|
||||
onScanSuccessful: dto =>
|
||||
{
|
||||
messenger.Send(new NewScannerMessage(dto.StringValue));
|
||||
},
|
||||
onScanFailed: ex =>
|
||||
{
|
||||
messenger.Send(new ErrorScannerMessage(ex.Message));
|
||||
}
|
||||
);
|
||||
|
||||
scanner.Init(() => { scanner.ChangeSettings([("TRIGGER_SCAN_MODE", "ONE_SHOT")]); });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace SteUp.Shared.Core.BarcodeReader.Contracts;
|
||||
|
||||
public interface IBarcodeManager
|
||||
{
|
||||
void Init();
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using SteUp.Shared.Core.BarcodeReader.Dto;
|
||||
|
||||
namespace SteUp.Shared.Core.BarcodeReader.Contracts;
|
||||
|
||||
public interface IBarcodeReaderService
|
||||
{
|
||||
bool IsRightAdapter();
|
||||
void Init(Action onDeviceReady);
|
||||
void Deinit();
|
||||
void Register(Action<BarcodeScanDto> onScanSuccessful, Action<Exception> onScanFailed);
|
||||
string GetAdapterName();
|
||||
void OnKeyEvent(object keyEvent);
|
||||
void ChangeSettings(List<(string Key, object Value)> settings);
|
||||
}
|
||||
8
SteUp.Shared/Core/BarcodeReader/Dto/BarcodeScanDto.cs
Normal file
8
SteUp.Shared/Core/BarcodeReader/Dto/BarcodeScanDto.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace SteUp.Shared.Core.BarcodeReader.Dto;
|
||||
|
||||
public class BarcodeScanDto
|
||||
{
|
||||
public string? StringValue { get; set; }
|
||||
public string? Type { get; set; }
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using IntegryApiClient.Core.Domain.Abstraction.Contracts.Account;
|
||||
using IntegryApiClient.Core.Domain.Abstraction.Contracts.Device;
|
||||
using SteUp.Shared.Core.BarcodeReader.Contracts;
|
||||
using SteUp.Shared.Core.Data.Contracts;
|
||||
using SteUp.Shared.Core.Dto;
|
||||
using SteUp.Shared.Core.Dto.PageState;
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
using CommunityToolkit.Mvvm.Messaging.Messages;
|
||||
|
||||
namespace SteUp.Shared.Core.Messages.Scanner;
|
||||
|
||||
public class ErrorScannerMessage(string? value = null) : ValueChangedMessage<string?>(value);
|
||||
5
SteUp.Shared/Core/Messages/Scanner/NewScannerMessage.cs
Normal file
5
SteUp.Shared/Core/Messages/Scanner/NewScannerMessage.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
using CommunityToolkit.Mvvm.Messaging.Messages;
|
||||
|
||||
namespace SteUp.Shared.Core.Messages.Scanner;
|
||||
|
||||
public class NewScannerMessage(string? value = null) : ValueChangedMessage<string?>(value);
|
||||
15
SteUp.Shared/Core/Messages/Scanner/OnScannerService.cs
Normal file
15
SteUp.Shared/Core/Messages/Scanner/OnScannerService.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
|
||||
namespace SteUp.Shared.Core.Messages.Scanner;
|
||||
|
||||
public class OnScannerService
|
||||
{
|
||||
public event Action<string?>? OnNewScanSuccessful;
|
||||
public event Action<string?>? OnErrorScan;
|
||||
|
||||
public OnScannerService(IMessenger messenger)
|
||||
{
|
||||
messenger.Register<NewScannerMessage>(this, (_, x) => { OnNewScanSuccessful?.Invoke(x.Value); });
|
||||
messenger.Register<ErrorScannerMessage>(this, (_, x) => { OnErrorScan?.Invoke(x.Value); });
|
||||
}
|
||||
}
|
||||
@@ -197,7 +197,7 @@ h1:focus {
|
||||
aspect-ratio: 1;
|
||||
border-radius: 50%;
|
||||
border: 8px solid #0000;
|
||||
border-right-color: var(--mud-palette-secondary);
|
||||
border-right-color: var(--mud-palette-primary);
|
||||
position: relative;
|
||||
animation: l24 1s infinite linear;
|
||||
}
|
||||
|
||||
@@ -26,14 +26,8 @@ function monitorBottomSheetClass(mutations) {
|
||||
});
|
||||
}
|
||||
|
||||
// Esegui la funzione tabindex inizialmente
|
||||
addTabindexToButtons();
|
||||
|
||||
// Observer combinato per tutte le funzionalità
|
||||
const observer = new MutationObserver((mutations) => {
|
||||
// Aggiungi tabindex ai nuovi bottoni
|
||||
addTabindexToButtons();
|
||||
|
||||
// Monitora bottom-sheet-container
|
||||
monitorBottomSheetClass(mutations);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user