FÉLKÉSZ

This commit is contained in:
2025-04-05 18:11:42 +02:00
parent 4951fc0c7a
commit 33232bae75
15 changed files with 404 additions and 72 deletions
@@ -0,0 +1,99 @@
using System.Windows.Input;
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.MAUI.Services.Interfaces;
using WorkFlowCheck.MAUI.Pages.NFC;
namespace WorkFlowCheck.MAUI.Pages.Security;
public partial class UsersPage : ContentPage
{
private readonly IUserService _userService;
public UsersPage()
{
InitializeComponent();
_userService = MauiProgram.ServiceProvider.GetRequiredService<IUserService>();
}
public ICommand RefreshCommand { get; set; }
public ICommand PairCommand { get; set; }
public bool IsRefreshing { get; set; }
protected override async void OnAppearing()
{
base.OnAppearing();
RefreshCommand = new Command(async () => await LoadUsers());
PairCommand = new Command<UserDTO>(OnPairItem);
BindingContext = this;
await LoadUsers();
}
private async Task LoadUsers()
{
IsRefreshing = true;
//await _syncService.SyncDatas();
UsersList.ItemsSource = await _userService.GetAllUsers();
IsRefreshing = false;
OnPropertyChanged(nameof(IsRefreshing));
}
private async void OnPairItem(UserDTO UserDTO)
{
var UserCode = await NFCWaiter.ShowModalAsync();
if (!string.IsNullOrEmpty(UserCode))
{
if (Navigation.ModalStack.Count > 0)
{
await Navigation.PopModalAsync();
}
if (UserDTO != null)
{
UserDTO.Code = UserCode;
await _baseStockService.UpdateUser(UserDTO);
await LoadUsers();
}
}
}
protected override bool OnBackButtonPressed()
{
Shell.Current.GoToAsync("//BaseStockPage");
return true;
}
private async void OnButtonSync(object sender, EventArgs e)
{
IsRefreshing = true;
ButtonSync.IsEnabled = false;
progressLabel.Text = "Szinkronizálás indítása...";
progressBar.Progress = 0;
try
{
await Task.Run(async () =>
{
await _userService.SyncUsers_Up((percentage, infostring) =>
{
MainThread.BeginInvokeOnMainThread(() =>
{
progressBar.Progress = percentage / 100;
progressLabel.Text = $"{infostring}: {percentage:0.00}%";
});
});
});
progressLabel.Text = "Szinkronizálás befejezve!";
}
catch (Exception ex)
{
progressLabel.Text = $"Hiba történt: {ex.Message}";
}
finally
{
ButtonSync.IsEnabled = true;
IsRefreshing = false;
}
}
}