Most működik egy tesztelhető verzió.

This commit is contained in:
2025-04-22 14:17:11 +02:00
parent cba9181a2d
commit 3c394f632d
12 changed files with 124 additions and 28 deletions
@@ -7,6 +7,7 @@ using System.Threading.Tasks;
using System.Windows.Input;
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.Common.Enums;
using WorkFlowCheck.MAUI.Helper;
using WorkFlowCheck.MAUI.Pages.NFC;
using WorkFlowCheck.MAUI.Services.Interfaces;
@@ -26,7 +27,7 @@ public partial class CheckListPage : ContentPage
public ICommand UnblockCommand { get; set; }
public ICommand BlockCommand { get; set; }
public ICommand AcceptCommand { get; set; }
public bool IsLoading
{
get => _isLoading;
@@ -57,8 +58,8 @@ public partial class CheckListPage : ContentPage
UnblockCommand = new Command<CheckListHeaderDTO>(OnUnblockItem);
BlockCommand = new Command<CheckListHeaderDTO>(OnBlockItem);
AcceptCommand = new Command<CheckListHeaderDTO>(OnAcceptItem);
}
private void SetInfo()
{
@@ -132,15 +133,36 @@ public partial class CheckListPage : ContentPage
}
private async void OnContinueItem(CheckListHeaderDTO checkListHeaderDTO)
{
var checkPointCode = await NFCWaiter.ShowModalAsync();
if (!string.IsNullOrEmpty(checkPointCode))
if (CrossNFC.IsSupported && CrossNFC.Current.IsAvailable)
{
if (Navigation.ModalStack.Count > 0)
var checkPointCode = await NFCWaiter.ShowModalAsync();
if (!string.IsNullOrEmpty(checkPointCode))
{
await Navigation.PopModalAsync();
if (Navigation.ModalStack.Count > 0)
{
await Navigation.PopModalAsync();
}
await Navigation.PushAsync(new CheckListWorkPage(checkListHeaderDTO.Id, checkPointCode));
}
}
else
{
// Ha nincs NFC, akkor az utoljára beküldött és a sorrendben lévõ checkpointra ugrik
var nextCheckPoint = await _checkListService.GetNextCheckpointNotSend(checkListHeaderDTO);
if (nextCheckPoint != null && nextCheckPoint.Id > 0)
{
if (!string.IsNullOrEmpty(nextCheckPoint.Code))
{
if (Navigation.ModalStack.Count > 0)
{
await Navigation.PopModalAsync();
}
await Navigation.PushAsync(new CheckListWorkPage(checkListHeaderDTO.Id, nextCheckPoint.Code));
}
}
await Navigation.PushAsync(new CheckListWorkPage(checkListHeaderDTO.Id, checkPointCode));
}
}
private async void OnUnblockItem(CheckListHeaderDTO checkListHeaderDTO)
@@ -211,7 +233,16 @@ public class BlockedConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is CheckStatus status)
var canEnableBlocked = false;
foreach (var roleDTO in SystemHelper.SystemUserDTO.RoleDTO)
{
if (roleDTO.CanEnableBlocked)
{
canEnableBlocked = true;
break;
}
}
if (value is CheckStatus status && canEnableBlocked)
{
return status == CheckStatus.InProgress;
}
@@ -227,9 +258,18 @@ public class UnBlockedConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var canEnableBlocked = false;
foreach (var roleDTO in SystemHelper.SystemUserDTO.RoleDTO)
{
if (roleDTO.CanEnableBlocked)
{
canEnableBlocked = true;
break;
}
}
if (value is CheckStatus status)
{
if (status == CheckStatus.Blocked)
if (status == CheckStatus.Blocked && canEnableBlocked)
{
return true;
}
@@ -247,7 +287,7 @@ public class ContinueConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is CheckStatus status && CrossNFC.IsSupported && CrossNFC.Current.IsAvailable)
if (value is CheckStatus status)
{
if (status == CheckStatus.InProgress || status == CheckStatus.Open)
{
@@ -267,7 +307,16 @@ public class AcceptConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is CheckStatus status)
var canEnableBlocked = false;
foreach (var roleDTO in SystemHelper.SystemUserDTO.RoleDTO)
{
if (roleDTO.CanEnableBlocked)
{
canEnableBlocked = true;
break;
}
}
if (value is CheckStatus status && canEnableBlocked)
{
if (status == CheckStatus.Sent)
{
@@ -8,7 +8,7 @@
Title="">
<Shell.TitleView>
<Grid Padding="2" VerticalOptions="Center">
<Label Text=""
<Label x:Name="HeaderLabel" Text=""
FontSize="22"
FontAttributes="Bold"
VerticalOptions="Center"
@@ -12,10 +12,11 @@ public partial class CheckListWorkPage : ContentPage
{
private readonly ICheckListService _checkListService;
private readonly ISyncService _syncService;
private readonly IUserService _userService;
private string _checkPointCode;
private int _checkListHeaderId;
private UserDTO _userDTO;
private UserDTO _currentUser;
private bool _isLoading;
@@ -40,12 +41,25 @@ public partial class CheckListWorkPage : ContentPage
_checkListHeaderId = checkListHeaderId;
_checkListService = MauiProgram.ServiceProvider.GetRequiredService<ICheckListService>();
_syncService = MauiProgram.ServiceProvider.GetRequiredService<ISyncService>();
_userDTO = MauiProgram.ServiceProvider.GetRequiredService<IUserService>().GetCurrentUser();
_userService = MauiProgram.ServiceProvider.GetRequiredService<IUserService>();
SaveCommand = new Command(OnSave);
SendCommand = new Command(OnSend);
}
private async Task SetInfo()
{
_currentUser = _userService.GetCurrentUser();
DeviceId.Text = _userService.DeviceId;
UserInfo.Text = $"{_currentUser?.LastName} {_currentUser?.FirstName}";
var checkPoint = await _checkListService.GetCheckPoint(_checkPointCode);
if (checkPoint != null && checkPoint.IsSuccess)
{
HeaderLabel.Text = checkPoint.Data.ShortName;
}
}
private async void OnSend()
{
IsLoading = true;
@@ -55,8 +69,6 @@ public partial class CheckListWorkPage : ContentPage
{
OnSave();
await Task.Run(async () =>
{
var result = await _syncService.SyncCheckListHeader_Up(_checkListHeaderId, (percentage, infostring) =>
@@ -72,8 +84,7 @@ public partial class CheckListWorkPage : ContentPage
{
if (Navigation.ModalStack.Count > 0)
{
//await Navigation.PopModalAsync();
await Shell.Current.GoToAsync("//CheckListPage");
await Navigation.PopModalAsync();
}
}
else
@@ -83,7 +94,8 @@ public partial class CheckListWorkPage : ContentPage
});
progressLabel.Text = "Szinkronizálás befejezve!";
await Shell.Current.GoToAsync("//CheckListPage");
}
catch (Exception ex)
{
@@ -132,9 +144,11 @@ public partial class CheckListWorkPage : ContentPage
protected override async void OnAppearing()
{
base.OnAppearing();
BindingContext = this;
await SetInfo();
CreatePhoto = new Command<CheckListRowDTO>(OnTakePhoto);
await LoadCheckPointCheckListRows();
BindingContext = this;
}
private async void OnTakePhoto(CheckListRowDTO checkListRowDTO)
{
@@ -188,7 +202,7 @@ public partial class CheckListWorkPage : ContentPage
IsLoading = true;
CheckListRows.Clear();
var checkListRowDTOs = await _checkListService.GetCheckListRowsByCheckPointCode(_userDTO.Id, _checkListHeaderId, _checkPointCode);
var checkListRowDTOs = await _checkListService.GetCheckListRowsByCheckPointCode(_currentUser.Id, _checkListHeaderId, _checkPointCode);
foreach (var item in checkListRowDTOs)
{
if (item.Answer == "Igen")