BEMUTATÓRA kész.

This commit is contained in:
2025-03-24 23:26:25 +01:00
parent ab1de236be
commit 2341b186ef
6 changed files with 83 additions and 33 deletions
@@ -14,8 +14,8 @@ namespace WorkFlowCheck.Common.DTO
public CheckListTemplateRowDTO CheckListTemplateRowDTO { get; set; } public CheckListTemplateRowDTO CheckListTemplateRowDTO { get; set; }
public string GroupName => $"AnswerGroup_{CheckListTemplateRowDTO.RowIndex}"; public string GroupName => $"AnswerGroup_{CheckListTemplateRowDTO.RowIndex}";
public string Answer { get; set; } = null!; public string Answer { get; set; } = null!;
public string AnswerYes { get; set; } = null!; public bool? AnswerYes { get; set; } = null!;
public string AnswerNo { get; set; } = null!; public bool? AnswerNo { get; set; } = null!;
public byte[] Photo { get; set; } = null!; public byte[] Photo { get; set; } = null!;
public Guid GuidNumber { get; set; } public Guid GuidNumber { get; set; }
} }
@@ -31,6 +31,8 @@ public partial class CheckListPage : ContentPage
InitializeComponent(); InitializeComponent();
_checkListService = MauiProgram.ServiceProvider.GetRequiredService<ICheckListService>(); _checkListService = MauiProgram.ServiceProvider.GetRequiredService<ICheckListService>();
_userService = MauiProgram.ServiceProvider.GetRequiredService<IUserService>(); _userService = MauiProgram.ServiceProvider.GetRequiredService<IUserService>();
NewCommand = new Command<CheckListTemplateHeaderDTO>(OnNewItem);
ContinueCommand = new Command<CheckListHeaderDTO>(OnContinueItem);
} }
protected override bool OnBackButtonPressed() protected override bool OnBackButtonPressed()
@@ -41,8 +43,7 @@ public partial class CheckListPage : ContentPage
protected override async void OnAppearing() protected override async void OnAppearing()
{ {
base.OnAppearing(); base.OnAppearing();
NewCommand = new Command<CheckListTemplateHeaderDTO>(OnNewItem);
ContinueCommand = new Command<CheckListHeaderDTO>(OnContinueItem);
BindingContext = this; BindingContext = this;
await LoadCheckListTemplate(); await LoadCheckListTemplate();
await LoadCheckList(); await LoadCheckList();
@@ -55,11 +56,11 @@ public partial class CheckListPage : ContentPage
private async void OnContinueItem(CheckListHeaderDTO checkListHeaderDTO) private async void OnContinueItem(CheckListHeaderDTO checkListHeaderDTO)
{ {
var taskCompletionSource = new TaskCompletionSource<string>(); var taskCompletionSource = new TaskCompletionSource<string>();
await Navigation.PushAsync(new NFCWaiter(taskCompletionSource)); await Navigation.PushModalAsync(new NFCWaiter(taskCompletionSource));
var checkPintCode = await taskCompletionSource.Task; var checkPintCode = await taskCompletionSource.Task;
if (!string.IsNullOrEmpty(checkPintCode)) if (!string.IsNullOrEmpty(checkPintCode))
{ {
await Navigation.PopAsync(); await Navigation.PopModalAsync();
await Navigation.PushAsync(new CheckListWorkPage(checkListHeaderDTO.Id, checkPintCode)); await Navigation.PushAsync(new CheckListWorkPage(checkListHeaderDTO.Id, checkPintCode));
} }
@@ -68,14 +68,14 @@
Content="Igen" Content="Igen"
Value="Igen" Value="Igen"
BindableGroupName="{Binding GroupName}" BindableGroupName="{Binding GroupName}"
IsChecked="{Binding AnswerYes, Converter={StaticResource RBConverter}, ConverterParameter=Igen}" IsChecked="{Binding AnswerYes}"
HorizontalOptions="Center" VerticalOptions="Center"/> HorizontalOptions="Center" VerticalOptions="Center"/>
<local:BindableRadioButton <local:BindableRadioButton
Grid.Row="1" Grid.Row="1"
Content="Nem" Content="Nem"
Value="Nem" Value="Nem"
BindableGroupName="{Binding GroupName}" BindableGroupName="{Binding GroupName}"
IsChecked="{Binding AnswerNo, Converter={StaticResource RBConverter}, ConverterParameter=Nem}" IsChecked="{Binding AnswerNo}"
HorizontalOptions="Center" VerticalOptions="Center"/> HorizontalOptions="Center" VerticalOptions="Center"/>
</Grid> </Grid>
</Grid> </Grid>
@@ -149,14 +149,14 @@
Content="Igen" Content="Igen"
Value="Igen" Value="Igen"
BindableGroupName="{Binding GroupName}" BindableGroupName="{Binding GroupName}"
IsChecked="{Binding AnswerYes, Converter={StaticResource RBConverter}, ConverterParameter=Igen}" IsChecked="{Binding AnswerYes}"
HorizontalOptions="Center" VerticalOptions="Center"/> HorizontalOptions="Center" VerticalOptions="Center"/>
<local:BindableRadioButton <local:BindableRadioButton
Grid.Row="1" Grid.Row="1"
Content="Nem" Content="Nem"
Value="Nem" Value="Nem"
BindableGroupName="{Binding GroupName}" BindableGroupName="{Binding GroupName}"
IsChecked="{Binding AnswerNo, Converter={StaticResource RBConverter}, ConverterParameter=Nem}" IsChecked="{Binding AnswerNo}"
HorizontalOptions="Center" VerticalOptions="Center"/> HorizontalOptions="Center" VerticalOptions="Center"/>
</Grid> </Grid>
</Grid> </Grid>
@@ -183,14 +183,14 @@
Content="Igen" Content="Igen"
Value="Igen" Value="Igen"
BindableGroupName="{Binding GroupName}" BindableGroupName="{Binding GroupName}"
IsChecked="{Binding AnswerYes, Converter={StaticResource RBConverter}, ConverterParameter=Igen}" IsChecked="{Binding AnswerYes}"
HorizontalOptions="Center" VerticalOptions="Center"/> HorizontalOptions="Center" VerticalOptions="Center"/>
<local:BindableRadioButton <local:BindableRadioButton
Grid.Row="1" Grid.Row="1"
Content="Nem" Content="Nem"
Value="Nem" Value="Nem"
BindableGroupName="{Binding GroupName}" BindableGroupName="{Binding GroupName}"
IsChecked="{Binding AnswerNo, Converter={StaticResource RBConverter}, ConverterParameter=Nem}" IsChecked="{Binding AnswerNo}"
HorizontalOptions="Center" VerticalOptions="Center"/> HorizontalOptions="Center" VerticalOptions="Center"/>
</Grid> </Grid>
</Grid> </Grid>
@@ -217,14 +217,14 @@
Content="Igen" Content="Igen"
Value="Igen" Value="Igen"
BindableGroupName="{Binding GroupName}" BindableGroupName="{Binding GroupName}"
IsChecked="{Binding AnswerYes, Converter={StaticResource RBConverter}, ConverterParameter=Igen}" IsChecked="{Binding AnswerYes}"
HorizontalOptions="Center" VerticalOptions="Center"/> HorizontalOptions="Center" VerticalOptions="Center"/>
<local:BindableRadioButton <local:BindableRadioButton
Grid.Row="1" Grid.Row="1"
Content="Nem" Content="Nem"
Value="Nem" Value="Nem"
BindableGroupName="{Binding GroupName}" BindableGroupName="{Binding GroupName}"
IsChecked="{Binding AnswerNo, Converter={StaticResource RBConverter}, ConverterParameter=Nem}" IsChecked="{Binding AnswerNo}"
HorizontalOptions="Center" VerticalOptions="Center"/> HorizontalOptions="Center" VerticalOptions="Center"/>
</Grid> </Grid>
</Grid> </Grid>
@@ -251,14 +251,14 @@
Content="Igen" Content="Igen"
Value="Igen" Value="Igen"
BindableGroupName="{Binding GroupName}" BindableGroupName="{Binding GroupName}"
IsChecked="{Binding AnswerYes, Converter={StaticResource RBConverter}, ConverterParameter=Igen}" IsChecked="{Binding AnswerYes}"
HorizontalOptions="Center" VerticalOptions="Center"/> HorizontalOptions="Center" VerticalOptions="Center"/>
<local:BindableRadioButton <local:BindableRadioButton
Grid.Row="1" Grid.Row="1"
Content="Nem" Content="Nem"
Value="Nem" Value="Nem"
BindableGroupName="{Binding GroupName}" BindableGroupName="{Binding GroupName}"
IsChecked="{Binding AnswerNo, Converter={StaticResource RBConverter}, ConverterParameter=Nem}" IsChecked="{Binding AnswerNo}"
HorizontalOptions="Center" VerticalOptions="Center"/> HorizontalOptions="Center" VerticalOptions="Center"/>
</Grid> </Grid>
</Grid> </Grid>
@@ -1,12 +1,10 @@
using WorkFlowCheck.Common.DTO; using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.MAUI.Services.Interfaces; using WorkFlowCheck.MAUI.Services.Interfaces;
using Microsoft.Maui.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Globalization; using System.Globalization;
using DevExpress.Data.Helpers;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Runtime.CompilerServices;
using Android.Provider;
namespace WorkFlowCheck.MAUI.Pages.CheckList; namespace WorkFlowCheck.MAUI.Pages.CheckList;
@@ -43,14 +41,39 @@ public partial class CheckListWorkPage : ContentPage
SendCommand = new Command(OnSend); SendCommand = new Command(OnSend);
} }
private void OnSend(object obj) private async void OnSend()
{ {
int i = 0;
} }
private void OnSave(object obj) private async void OnSave()
{ {
int i = 0; IsLoading = true;
try
{
foreach (var checkListRow in CheckListRows)
{
if (checkListRow.AnswerYes == true)
{
checkListRow.Answer = "Igen";
}
if (checkListRow.AnswerNo == true)
{
checkListRow.Answer = "Nem";
}
await _checkListService.UpdateCheckListRow(checkListRow);
}
await LoadCheckPointCheckListRows();
}
catch (Exception)
{
}
finally
{
IsLoading = false;
}
} }
protected override async void OnAppearing() protected override async void OnAppearing()
{ {
@@ -96,6 +119,16 @@ public partial class CheckListWorkPage : ContentPage
var checkListRowDTOs = await _checkListService.GetCheckListRowsByCheckPointCode(_userDTO.Id, _checkListHeaderId, _checkPointCode); var checkListRowDTOs = await _checkListService.GetCheckListRowsByCheckPointCode(_userDTO.Id, _checkListHeaderId, _checkPointCode);
foreach (var item in checkListRowDTOs) foreach (var item in checkListRowDTOs)
{ {
if (item.Answer == "Igen")
{
item.AnswerYes = true;
item.AnswerNo = false;
}
else if (item.Answer == "Nem")
{
item.AnswerYes = false;
item.AnswerNo = true;
}
CheckListRows.Add(item); CheckListRows.Add(item);
} }
@@ -36,6 +36,11 @@ public partial class NFCWaiter : ContentPage
} }
} }
protected override void OnDisappearing()
{
base.OnDisappearing();
}
async Task AutoStartAsync() async Task AutoStartAsync()
{ {
// Some delay to prevent Java.Lang.IllegalStateException "Foreground dispatch can only be enabled when your activity is resumed" on Android // Some delay to prevent Java.Lang.IllegalStateException "Foreground dispatch can only be enabled when your activity is resumed" on Android
@@ -47,6 +52,7 @@ public partial class NFCWaiter : ContentPage
await BeginListening(); await BeginListening();
} }
async Task BeginListening() async Task BeginListening()
{ {
try try
@@ -62,16 +68,14 @@ public partial class NFCWaiter : ContentPage
//await ShowAlert(ex.Message); //await ShowAlert(ex.Message);
} }
} }
async Task EndListening() async Task StopListening()
{ {
try try
{ {
MainThread.BeginInvokeOnMainThread(() => MainThread.BeginInvokeOnMainThread(() =>
{ {
UnsubscribeEvents();
CrossNFC.Current.StopPublishing();
CrossNFC.Current.StopListening(); CrossNFC.Current.StopListening();
UnsubscribeEvents();
}); });
} }
catch (Exception ex) catch (Exception ex)
@@ -79,6 +83,7 @@ public partial class NFCWaiter : ContentPage
//await ShowAlert(ex.Message); //await ShowAlert(ex.Message);
} }
} }
void SubscribeEvents() void SubscribeEvents()
{ {
if (_eventsAlreadySubscribed) if (_eventsAlreadySubscribed)
@@ -86,18 +91,21 @@ public partial class NFCWaiter : ContentPage
_eventsAlreadySubscribed = true; _eventsAlreadySubscribed = true;
CrossNFC.Current.OnMessageReceived += Current_OnMessageReceived_NFCData; CrossNFC.Current.OnMessageReceived += OnMessageReceived_NFCData;
} }
void UnsubscribeEvents() void UnsubscribeEvents()
{ {
CrossNFC.Current.OnMessageReceived -= Current_OnMessageReceived_NFCData; CrossNFC.Current.OnMessageReceived -= OnMessageReceived_NFCData;
_eventsAlreadySubscribed = false; _eventsAlreadySubscribed = false;
} }
async void Current_OnMessageReceived_NFCData(ITagInfo tagInfo) async void OnMessageReceived_NFCData(ITagInfo tagInfo)
{ {
_onReceiveing = true; _onReceiveing = true;
if (tagInfo == null) if (tagInfo == null)
{ {
await ShowAlert("No tag found"); await ShowAlert("No tag found");
@@ -109,9 +117,16 @@ public partial class NFCWaiter : ContentPage
var identifier = tagInfo.Identifier; var identifier = tagInfo.Identifier;
var serialNumber = NFCUtils.ByteArrayToHexString(identifier, ":"); var serialNumber = NFCUtils.ByteArrayToHexString(identifier, ":");
_taskCompletionSource.TrySetResult(serialNumber); _taskCompletionSource.TrySetResult(serialNumber);
await EndListening();
await Navigation.PopAsync();
_onReceiveing = false; _onReceiveing = false;
await Task.Delay(500);
await StopListening();
await MainThread.InvokeOnMainThreadAsync(async () =>
{
await Navigation.PopModalAsync();
//await Navigation.PopModalAsync();
});
} }
Task ShowAlert(string message, string title = null) => DisplayAlert(string.IsNullOrWhiteSpace(title) ? "NFC olvasás" : title, message, "OK"); Task ShowAlert(string message, string title = null) => DisplayAlert(string.IsNullOrWhiteSpace(title) ? "NFC olvasás" : title, message, "OK");
} }
@@ -162,6 +162,7 @@ namespace WorkFlowCheck.MAUI.Services
var checkListRow = await _dbContext.CheckListRows.Where(w => w.Id == checkListRowDTO.Id).FirstOrDefaultAsync(); var checkListRow = await _dbContext.CheckListRows.Where(w => w.Id == checkListRowDTO.Id).FirstOrDefaultAsync();
if (checkListRow != null) if (checkListRow != null)
{ {
checkListRow.Answer = checkListRowDTO.Answer;
checkListRow.Photo = checkListRowDTO.Photo; checkListRow.Photo = checkListRowDTO.Photo;
await _dbContext.SaveChangesAsync(); await _dbContext.SaveChangesAsync();
} }