b1afa82a91
- GpwDataSrvice - MessageService - ogni dipendenza (aggiunti using, in _import non basta...)
169 lines
5.0 KiB
C#
169 lines
5.0 KiB
C#
using GPW.CORE.Data.DbModels;
|
|
using GPW.CORE.Data.DTO;
|
|
using GPW.CORE.Data.Services;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
|
|
namespace GPW.CORE.WRKLOG.Components.Pages
|
|
{
|
|
public partial class FastRec
|
|
{
|
|
#region Public Properties
|
|
|
|
public int TipoSearch
|
|
{
|
|
get
|
|
{
|
|
return _tipoSearch;
|
|
}
|
|
|
|
set
|
|
{
|
|
if (!_tipoSearch.Equals(value))
|
|
{
|
|
_tipoSearch = value;
|
|
idxFaseSel = 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Fields
|
|
|
|
protected int endHour = 21;
|
|
|
|
protected bool isLoading = false;
|
|
|
|
protected int startHour = 7;
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected MessageService AppMServ { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected GpwDataService GDataServ { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected IJSRuntime JSRuntime { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await ReloadData();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private int _tipoSearch = 0;
|
|
private int idxFaseSel = 0;
|
|
private List<AnagFasiModel> ListFasi = new List<AnagFasiModel>();
|
|
private List<DailyDataDTO> ListRecords = new List<DailyDataDTO>();
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private int idxDipendente { get => AppMServ.IdxDipendente; }
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private void checkHourRange()
|
|
{
|
|
int minHour = 9;
|
|
int maxHour = 18;
|
|
if (ListRecords != null)
|
|
{
|
|
int roundMin = 15;
|
|
// per ogni giornata
|
|
foreach (var giornata in ListRecords)
|
|
{
|
|
if (giornata.ListTimbr != null)
|
|
{
|
|
var minRecTimb = giornata.ListTimbr.Where(x => x.Entrata == true).OrderBy(x => x.DataOra).FirstOrDefault();
|
|
if (minRecTimb != null)
|
|
{
|
|
if (minHour > minRecTimb.DataOra.AddMinutes(-roundMin).Hour)
|
|
{
|
|
minHour = minRecTimb.DataOra.AddMinutes(-roundMin).Hour;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (giornata.ListRA != null)
|
|
{
|
|
var minRecRa = giornata.ListRA.OrderBy(x => x.Inizio).FirstOrDefault();
|
|
if (minRecRa != null)
|
|
{
|
|
if (minHour > minRecRa.Inizio.AddMinutes(-roundMin).Hour)
|
|
{
|
|
minHour = minRecRa.Inizio.AddMinutes(-roundMin).Hour;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (giornata.ListTimbr != null)
|
|
{
|
|
var maxRecTimb = giornata.ListTimbr.Where(x => x.Entrata == false).OrderByDescending(x => x.DataOra).FirstOrDefault();
|
|
if (maxRecTimb != null)
|
|
{
|
|
if (maxHour < maxRecTimb.DataOra.AddMinutes(roundMin).Hour + 1)
|
|
{
|
|
maxHour = maxRecTimb.DataOra.AddMinutes(roundMin).Hour + 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (giornata.ListRA != null)
|
|
{
|
|
var maxRecRa = giornata.ListRA.OrderByDescending(x => x.Fine).FirstOrDefault();
|
|
if (maxRecRa != null)
|
|
{
|
|
if (maxHour < maxRecRa.Fine.AddMinutes(roundMin).Hour + 1)
|
|
{
|
|
maxHour = maxRecRa.Fine.AddMinutes(roundMin).Hour + 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
startHour = minHour;
|
|
endHour = maxHour;
|
|
}
|
|
|
|
private void RecDone(bool fatto)
|
|
{
|
|
idxFaseSel = 0;
|
|
}
|
|
|
|
private async Task ReloadData()
|
|
{
|
|
isLoading = true;
|
|
DateTime oggi = DateTime.Today;
|
|
var rawData = await GDataServ.DailyDetails(idxDipendente, oggi, oggi.AddDays(1));
|
|
ListRecords = rawData.Where(x => x.DtRif == oggi).ToList();
|
|
await Task.Delay(1);
|
|
checkHourRange();
|
|
await Task.Delay(1);
|
|
isLoading = false;
|
|
}
|
|
|
|
private void SelFase(int idxFase)
|
|
{
|
|
idxFaseSel = idxFase;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |