b1afa82a91
- GpwDataSrvice - MessageService - ogni dipendenza (aggiunti using, in _import non basta...)
160 lines
4.7 KiB
C#
160 lines
4.7 KiB
C#
using GPW.CORE.Data.DbModels;
|
|
using GPW.CORE.Data.Services;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
|
|
namespace GPW.CORE.WRKLOG.Components.Compo
|
|
{
|
|
public partial class RecFaseStart
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public int idxFase { get; set; } = 0;
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> RecStarted { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#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 OnParametersSetAsync()
|
|
{
|
|
await ReloadData();
|
|
}
|
|
|
|
protected async Task ReloadData()
|
|
{
|
|
// recupero dati fase completi...
|
|
currFase = await GDataServ.AnagFasiByKey(idxFase);
|
|
if (currFase != null)
|
|
{
|
|
if (currFase.IdxProgetto != null)
|
|
{
|
|
currProj = await GDataServ.AnagProjSearch((int)currFase.IdxProgetto);
|
|
}
|
|
|
|
ancestFase = await GDataServ.AnagFasiByKey(currFase.IdxFaseAncest);
|
|
int idxFaseTgt = currFase.IdxFaseAncest == 0 ? currFase.IdxFase : currFase.IdxFaseAncest;
|
|
CalcOreFasi = await GDataServ.CalcOreFase(idxFaseTgt);
|
|
cssCheckOre = "text-success";
|
|
if (CalcOreFasi.percUsed > 1)
|
|
{
|
|
cssCheckOre = "text-danger";
|
|
}
|
|
else if (CalcOreFasi.percUsed * 100 > 80)
|
|
{
|
|
cssCheckOre = "text-warning";
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private string cssCheckOre = "";
|
|
private string descrizione = "";
|
|
private bool doClose = true;
|
|
private int minDur = 30;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private AnagFasiModel? ancestFase { get; set; } = null;
|
|
|
|
private bool buttonEnabled
|
|
{
|
|
get
|
|
{
|
|
bool answ = !VetoProj;
|
|
if (CalcOreFasi != null)
|
|
{
|
|
if (CalcOreFasi.Attivo != null && !(bool)CalcOreFasi.Attivo)
|
|
{
|
|
if (VetoInsert)
|
|
{
|
|
answ = false;
|
|
}
|
|
else
|
|
{
|
|
answ = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
private CalcOreFasiModel? CalcOreFasi { get; set; } = null;
|
|
private AnagFasiModel? currFase { get; set; } = null;
|
|
private AnagProgettiModel? currProj { get; set; } = null;
|
|
private bool VetoInsert { get => GDataServ.VetoInsert; }
|
|
|
|
private bool VetoProj
|
|
{
|
|
get
|
|
{
|
|
bool answ = false;
|
|
if (currProj != null)
|
|
{
|
|
var projAttivo = true;
|
|
_ = bool.TryParse($"{currProj.Attivo}", out projAttivo);
|
|
answ = !projAttivo;
|
|
}
|
|
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private async Task ClosePage()
|
|
{
|
|
await RecStarted.InvokeAsync(false);
|
|
}
|
|
|
|
private async Task StartRecord()
|
|
{
|
|
// calcolo dataora chiusura...
|
|
DateTime newInizio = CORE.Data.Utils.DateRounded(DateTime.Now, 5, true);
|
|
// chiudo attivit� precedente (se c'�) odierna
|
|
if (doClose)
|
|
{
|
|
var lastRA = await GDataServ.RegAttLastByDip(AppMServ.IdxDipendente, false);
|
|
if (lastRA != null && lastRA.Inizio.Date == DateTime.Today)
|
|
{
|
|
lastRA.Fine = newInizio;
|
|
await GDataServ.RegAttUpdate(lastRA);
|
|
}
|
|
}
|
|
|
|
// registro nuova attivit�
|
|
RegAttivitaModel newItem = new RegAttivitaModel()
|
|
{ IdxDipendente = AppMServ.IdxDipendente, Inizio = newInizio, Fine = newInizio.AddMinutes(minDur), IdxFase = idxFase, Descrizione = descrizione };
|
|
await GDataServ.RegAttUpdate(newItem);
|
|
// segnalo fatto
|
|
await RecStarted.InvokeAsync(false);
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |