CheckListInfoPage implementálása
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
using Android.DeviceLock;
|
||||
using Firebase.Auth;
|
||||
using System.Globalization;
|
||||
using System.Threading.Tasks;
|
||||
using WorkFlowCheck.Common.DTO;
|
||||
using WorkFlowCheck.MAUI.Services.Interfaces;
|
||||
|
||||
namespace WorkFlowCheck.MAUI.Pages.CheckList;
|
||||
|
||||
public partial class CheckListInfoPage : ContentPage
|
||||
{
|
||||
private readonly ICheckListService _checkListService;
|
||||
private readonly IUserService _userService;
|
||||
private UserDTO _currentUser;
|
||||
private CheckListHeaderDTO _checkListHeaderDTO;
|
||||
private CheckListHeaderInfoDTO _checkListHeaderInfoDTO;
|
||||
public CheckListInfoPage(CheckListHeaderDTO checkListHeaderDTO)
|
||||
{
|
||||
InitializeComponent();
|
||||
_userService = MauiProgram.ServiceProvider.GetRequiredService<IUserService>();
|
||||
_checkListService = MauiProgram.ServiceProvider.GetRequiredService<ICheckListService>();
|
||||
_checkListHeaderDTO = checkListHeaderDTO;
|
||||
}
|
||||
private async Task SetInfo()
|
||||
{
|
||||
_currentUser = _userService.GetCurrentUser();
|
||||
DeviceId.Text = _userService.DeviceId;
|
||||
UserInfo.Text = $"{_currentUser?.LastName} {_currentUser?.FirstName}";
|
||||
HeaderLabel.Text = _checkListHeaderDTO.DocumentNumber;
|
||||
}
|
||||
protected override async void OnAppearing()
|
||||
{
|
||||
base.OnAppearing();
|
||||
BindingContext = this;
|
||||
await SetInfo();
|
||||
BuildCheckListHeaderInfo();
|
||||
}
|
||||
private async Task BuildCheckListHeaderInfo()
|
||||
{
|
||||
_checkListHeaderInfoDTO = new CheckListHeaderInfoDTO();
|
||||
|
||||
var result = _checkListHeaderDTO.CheckListRowDTO
|
||||
.GroupBy(r => 1)
|
||||
.Select(g => new
|
||||
{
|
||||
TotalRowCount = g.Count(),
|
||||
EmptyAnswerCount = g.Count(r => string.IsNullOrEmpty(r.Answer)),
|
||||
CheckPointCount = g.Select(r => r.CheckListTemplateRowDTO.CheckPointId).Distinct().Count()
|
||||
})
|
||||
.FirstOrDefault();
|
||||
if (result != null)
|
||||
{
|
||||
_checkListHeaderInfoDTO.TotalRowCount = result.TotalRowCount;
|
||||
_checkListHeaderInfoDTO.CheckPointCount = result.CheckPointCount;
|
||||
_checkListHeaderInfoDTO.EmptyAnswerCount = result.EmptyAnswerCount;
|
||||
if (_checkListHeaderInfoDTO.TotalRowCount > 0)
|
||||
{
|
||||
_checkListHeaderInfoDTO.ReadyPercent = ((double)(_checkListHeaderInfoDTO.TotalRowCount - _checkListHeaderInfoDTO.EmptyAnswerCount) / _checkListHeaderInfoDTO.TotalRowCount * 100)
|
||||
.ToString("0.00", new CultureInfo("hu-HU")) + " %";
|
||||
}
|
||||
}
|
||||
|
||||
var checkPointDTO = await _checkListService.GetNextCheckpointNotSend(_checkListHeaderDTO);
|
||||
|
||||
row1.Text = $"Összes ellenõrizendõ lépés: {_checkListHeaderInfoDTO.TotalRowCount} db";
|
||||
row2.Text = $"Összes még nem ellenõrzött lépés: {_checkListHeaderInfoDTO.EmptyAnswerCount} db";
|
||||
row3.Text = $"Ellenõrzési pontok száma: {_checkListHeaderInfoDTO.CheckPointCount} db";
|
||||
row4.Text = $"Készültség: {_checkListHeaderInfoDTO.ReadyPercent}";
|
||||
row5.Text = $"Következõ ellenõrzési pont : {checkPointDTO.ShortName}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user