This commit is contained in:
zaccaria.majid
2023-01-16 17:08:51 +01:00
17 changed files with 455 additions and 92 deletions
@@ -1324,6 +1324,32 @@ namespace GPW.CORE.Data.Controllers
return answ;
}
/// <summary>
/// Elenco di tutte le timbrature richieste (= NON approvate)
/// </summary>
/// <returns></returns>
public List<TimbratureModel> TimbratureRichieste()
{
List<TimbratureModel> dbResult = new List<TimbratureModel>();
using (GPWContext localDbCtx = new GPWContext(_configuration))
{
try
{
dbResult = localDbCtx
.DbSetTimbrature
.Where(x => x.Approv == false)
.Include(d => d.DipNav)
.OrderByDescending(x => x.DataOra)
.ToList();
}
catch (Exception exc)
{
Log.Error($"Eccezione in TimbratureRichieste{Environment.NewLine}{exc}");
}
}
return dbResult;
}
public List<TimbratureModel> TimbratureDay(DateTime dateRif, int IdxDip)
{
List<TimbratureModel> dbResult = new List<TimbratureModel>();
@@ -1379,6 +1405,9 @@ namespace GPW.CORE.Data.Controllers
{
// aggiorno solo entrata/uscita
currRec.Entrata = currItem.Entrata;
currRec.Approv = currItem.Approv;
currRec.Ipv4 = currItem.Ipv4;
currRec.DataOra = currItem.DataOra;
localDbCtx
.DbSetTimbrature
@@ -79,34 +79,6 @@ namespace GPW.CORE.Smart.Components
MService.ReportRicTimb();
}
#if false
private async void checkApp(DateTime? dtRif)
{
isApprovedEntr = true;
isApprovedEsc = true;
DateTime dtScelta = dtRif ?? DateTime.Today;
listTimb = await CSDataService.TimbratureDay(dtScelta, IdxDipendente);
if (listTimb != null)
{
if (listTimb.Count != 0)
{
foreach (var item in listTimb)
{
if (item.Approv == false && item.Entrata == true)
{
isApprovedEntr = false;
}
else if (item.Approv == false && item.Entrata == false)
{
isApprovedEsc = false;
}
}
}
}
}
#endif
private string cssChooseEntr(DateTime? dtRif)
{
string answ = "";
@@ -143,9 +143,6 @@ namespace GPW.CORE.Smart.Components
var rigaDip = ListaDip.FirstOrDefault(x => x.IdxDipendente == idxDipendente);
if (rigaDip != null)
{
//string rndTxt01 = SteamCrypto.RandomString(4, true);
//string rndTxt02 = SteamCrypto.RandomString(4, true);
//string newAuthKey = CDService.EncriptData($"{rndTxt01}|{idxDipendente}|{rigaDip.Email}|{rndTxt02}").ToUpper();
Guid newGuid = Guid.NewGuid();
string newAuthKey = $"{newGuid}";
rigaDip.AuthKey = newAuthKey.ToUpper();
+25
View File
@@ -0,0 +1,25 @@
@if (!userIsAdmin)
{
<div class="alert alert-info">
<h3>Attenzione</h3>
Autorizzazione richiesta per accedere alla funzionalità
</div>
}
else
{
@if (ListTimbRich == null)
{
<LoadingData></LoadingData>
}
else if (ListTimbRich.Count == 0)
{
<div class="alert alert-info">
<h3>Timbrature da Approvare</h3>
Nessun record trovato
</div>
}
else
{
<TimbList ListTimb="@ListTimbRich" EnableAdmin="true" EnableEdit="true" ReqUpdate="DoUpdate"></TimbList>
}
}
@@ -0,0 +1,93 @@
using GPW.CORE.Data.DbModels;
using GPW.CORE.Smart.Data;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
namespace GPW.CORE.Smart.Components
{
public partial class TimbAdmin
{
#region Public Properties
[Parameter]
public int IdxDipAdmin { get; set; } = 0;
#endregion Public Properties
#region Protected Methods
/// <summary>
/// Aggiorno e riporto update
/// </summary>
protected async void DoUpdate(bool forceReload)
{
if (forceReload)
{
await ReloadData();
await Task.Delay(1);
await InvokeAsync(StateHasChanged);
}
}
protected override async Task OnParametersSetAsync()
{
// verifico se il dip sia admin...
var listaRuoli = await CDService.Dip2RuoliGetAll();
var rigaDip = listaRuoli.FirstOrDefault(x => x.IdxDipendente == IdxDipAdmin && x.CodRuolo == "AppMancTimb");
userIsAdmin = rigaDip != null;
await ReloadData();
}
#endregion Protected Methods
#region Private Fields
private bool userIsAdmin = false;
#endregion Private Fields
#region Private Properties
[Inject]
private CoreSmartDataService CDService { get; set; } = null!;
private bool isLoading { get; set; } = false;
[Inject]
private IJSRuntime JSRuntime { get; set; } = null!;
private List<TimbratureModel>? ListTimbRich { get; set; } = null;
[Inject]
private NavigationManager navManager { get; set; } = null!;
#endregion Private Properties
#region Private Methods
private async Task ReloadData()
{
isLoading = true;
await Task.Delay(1);
//// verifico se il dip sia admin...
//var listaRuoli = await CDService.Dip2RuoliGetAll();
//var rigaDip = listaRuoli.FirstOrDefault(x => x.IdxDipendente == IdxDipAdmin && x.CodRuolo == "AppMancTimb");
//userIsAdmin = rigaDip != null;
if (userIsAdmin)
{
ListTimbRich = null;
await Task.Delay(50);
ListTimbRich = await CDService.TimbratureRichieste();
}
else
{
ListTimbRich = null;
}
await Task.Delay(1);
isLoading = true;
}
#endregion Private Methods
}
}
+92
View File
@@ -0,0 +1,92 @@
@using GPW.CORE.Data.DbModels
@using GPW.CORE.Smart.Data
<table class="table table-sm table-striped table-responsive-md">
<thead>
<tr>
@if (EnableAdmin)
{
<th>
<i class="fa-solid fa-user-shield"></i>
</th>
}
<th><i class="far fa-clock"></i></th>
<th title="Entrata"><i class="fas fa-sign-in-alt"></i></th>
<th class="text-center">Scambio</th>
<th title="Uscita"><i class="fas fa-sign-out-alt"></i></th>
<th></th>
</tr>
</thead>
<tbody>
@if (@isLoading)
{
<tr>
@if (EnableAdmin)
{
<td colspan="6">
<LoadingDataSmall></LoadingDataSmall>
</td>
}
else
{
<td colspan="5">
<LoadingDataSmall></LoadingDataSmall>
</td>
}
</tr>
}
else
{
@foreach (var item in ListTimb)
{
<tr>
@if (EnableAdmin)
{
<td>
<button class="btn btn-success btn-sm" @onclick="() => ApprovaTimb(item)">
<i class="fa-solid fa-thumbs-up"></i>
</button>
</td>
}
<td class="small">
@if (EnableAdmin)
{
<div>
<small><b>@item.DipNav.Cognome</b> @item.DipNav.Nome</small>
</div>
}
@item.DataOra.ToString("dd/MM - HH:mm")
</td>
<td title="Entrata">
@if (@item.Entrata == true)
{
<i class="fas fa-times"></i>
}
</td>
<td class="text-center">
<button class="btn btn-sm btn-primary" title="Scambio IN/OUT" @onclick="() => ScambioInOut(item)"><i class="fas fa-exchange-alt"></i></button>
</td>
<td title="Uscita">
@if (@item.Entrata == false)
{
<i class="fas fa-times"></i>
}
</td>
<td>
@if (EnableEdit)
{
<button class="btn btn-sm btn-danger" @onclick="() => Delete(item)"><i class="fas fa-trash-alt"></i></button>
}
else
{
<button class="btn btn-sm btn-secondary" disabled><i class="fas fa-trash-alt"></i></button>
}
</td>
</tr>
}
}
</tbody>
</table>
+101
View File
@@ -0,0 +1,101 @@
using GPW.CORE.Data.DbModels;
using GPW.CORE.Smart.Data;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
namespace GPW.CORE.Smart.Components
{
public partial class TimbList
{
#region Public Properties
[Parameter]
public bool EnableAdmin { get; set; } = false;
[Parameter]
public bool EnableEdit { get; set; } = false;
private bool isLoading { get; set; } = false;
[Parameter]
public List<TimbratureModel> ListTimb
{
get
{
return _ListTimb.OrderByDescending(x => x.DataOra).ToList();
}
set
{
_ListTimb = value;
}
}
[Parameter]
public EventCallback<bool> ReqUpdate { get; set; }
#endregion Public Properties
#region Protected Methods
protected async void ApprovaTimb(TimbratureModel currRecord)
{
string message = "Sicuro di voler approvare la richiesta selezionata?";
if (!await JSRuntime.InvokeAsync<bool>("confirm", message))
return;
isLoading = true;
await Task.Delay(1);
await InvokeAsync(StateHasChanged);
currRecord.Approv = true;
// aggiorno
await CDService.TimbratureUpdate(currRecord);
await Task.Delay(1);
isLoading = false;
await ReqUpdate.InvokeAsync(true);
}
protected async void Delete(TimbratureModel currRecord)
{
string message = "Sicuro di voler eliminare/rifiutare la richiesta selezionata?";
if (!await JSRuntime.InvokeAsync<bool>("confirm", message))
return;
isLoading = true;
await Task.Delay(1);
await InvokeAsync(StateHasChanged);
// elimino
await CDService.TimbratureDelete(currRecord);
await Task.Delay(1);
isLoading = false;
await ReqUpdate.InvokeAsync(true);
}
protected async void ScambioInOut(TimbratureModel currRecord)
{
isLoading = true;
await Task.Delay(1);
await InvokeAsync(StateHasChanged);
currRecord.Entrata = !currRecord.Entrata;
// aggiorno
await CDService.TimbratureUpdate(currRecord);
await Task.Delay(1);
isLoading = false;
await ReqUpdate.InvokeAsync(false);
}
#endregion Protected Methods
#region Private Properties
private List<TimbratureModel> _ListTimb { get; set; } = new List<TimbratureModel>();
[Inject]
private CoreSmartDataService CDService { get; set; } = null!;
[Inject]
private IJSRuntime JSRuntime { get; set; } = null!;
#endregion Private Properties
}
}
+3
View File
@@ -0,0 +1,3 @@
<h3>TimbUser</h3>
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using System.Net.Http;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Components.Routing;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.Web.Virtualization;
using Microsoft.JSInterop;
using GPW.CORE.Comp;
using GPW.CORE.Data.DbModels;
using GPW.CORE.Smart;
using GPW.CORE.Smart.Components;
using GPW.CORE.Smart.Shared;
namespace GPW.CORE.Smart.Components
{
public partial class TimbUser
{
}
}
+18 -1
View File
@@ -517,7 +517,24 @@ namespace GPW.CORE.Smart.Data
dbResult = dbController.TimbratureDay(dateRif, IdxDip);
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Trace($"Effettuata lettura da DB + caching per TimbratureDay: {ts.TotalMilliseconds} ms");
Log.Trace($"Effettuata lettura da DB per TimbratureDay: {ts.TotalMilliseconds} ms");
return dbResult;
}
/// <summary>
/// Elenco di tutte le timbrature richieste (= NON approvate)
/// </summary>
/// <returns></returns>
public async Task<List<TimbratureModel>> TimbratureRichieste()
{
await Task.Delay(1);
List<TimbratureModel>? dbResult = new List<TimbratureModel>();
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
dbResult = dbController.TimbratureRichieste();
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Trace($"Effettuata lettura da DB per TimbratureRichieste: {ts.TotalMilliseconds} ms");
return dbResult;
}
+1 -3
View File
@@ -32,9 +32,7 @@
</button>
</h2>
<div id="collapseTwo" class="accordion-collapse collapse" aria-labelledby="headingThree" data-bs-parent="#accordionExample">
<div class="accordion-body">
<strong>This is the third item's accordion body.</strong> It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
</div>
<TimbAdmin IdxDipAdmin="@idxDipendente"></TimbAdmin>
</div>
</div>
<div class="accordion-item">
+2 -53
View File
@@ -1,9 +1,4 @@
@using CORE.Data.DbModels
@using WRKLOG.Data
@inject IJSRuntime JSRuntime
@inject GpwDataService GDataServ
@inject MessageService AppMServ

<table class="table table-sm table-striped table-responsive-md">
<thead>
@@ -27,14 +22,7 @@
}
</td>
<td>
@*@if (EnableEdit)
{*@
<button class="btn btn-sm btn-primary" title="Scambio IN/OUT" @onclick="() => ScambioInOut(item)"><i class="fas fa-exchange-alt"></i></button>
@*}
else
{
<button class="btn btn-sm btn-secondary" title="Scambio IN/OUT" disabled><i class="fas fa-exchange-alt"></i></button>
}*@
<button class="btn btn-sm btn-primary" title="Scambio IN/OUT" @onclick="() => ScambioInOut(item)"><i class="fas fa-exchange-alt"></i></button>
</td>
<td title="Uscita">
@if (@item.Entrata == false)
@@ -57,43 +45,4 @@
</tbody>
</table>
@code {
private List<TimbratureModel> _ListTimb { get; set; } = new List<TimbratureModel>();
[Parameter]
public List<TimbratureModel> ListTimb
{
get
{
return _ListTimb.OrderByDescending(x => x.DataOra).ToList();
}
set
{
_ListTimb = value;
InvokeAsync(() =>
{
StateHasChanged();
});
}
}
[Parameter]
public bool EnableEdit { get; set; } = false;
[Parameter]
public EventCallback<TimbratureModel> ReqDelete { get; set; }
[Parameter]
public EventCallback<TimbratureModel> ReqUpdate { get; set; }
protected async void Delete(TimbratureModel currRecord)
{
await ReqDelete.InvokeAsync(currRecord);
}
protected async void ScambioInOut(TimbratureModel currRecord)
{
await ReqUpdate.InvokeAsync(currRecord);
}
}
@@ -0,0 +1,62 @@
using GPW.CORE.Data.DbModels;
using GPW.CORE.WRKLOG.Data;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
namespace GPW.CORE.WRKLOG.Components
{
public partial class TimbList
{
#region Public Properties
[Parameter]
public bool EnableEdit { get; set; } = false;
[Parameter]
public List<TimbratureModel> ListTimb
{
get
{
return _ListTimb.OrderByDescending(x => x.DataOra).ToList();
}
set
{
_ListTimb = value;
InvokeAsync(() =>
{
StateHasChanged();
});
}
}
[Parameter]
public EventCallback<TimbratureModel> ReqDelete { get; set; }
[Parameter]
public EventCallback<TimbratureModel> ReqUpdate { get; set; }
#endregion Public Properties
#region Protected Methods
protected async void Delete(TimbratureModel currRecord)
{
await ReqDelete.InvokeAsync(currRecord);
}
protected async void ScambioInOut(TimbratureModel currRecord)
{
await ReqUpdate.InvokeAsync(currRecord);
}
#endregion Protected Methods
#region Private Properties
private List<TimbratureModel> _ListTimb { get; set; } = new List<TimbratureModel>();
#endregion Private Properties
}
}
+1 -1
View File
@@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>3.0.2301.1613</Version>
<Version>3.0.2301.1614</Version>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>GPW - Gestione Presenze Web</i>
<h4>Versione: 3.0.2301.1613</h4>
<h4>Versione: 3.0.2301.1614</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
3.0.2301.1613
3.0.2301.1614
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>3.0.2301.1613</version>
<version>3.0.2301.1614</version>
<url>http://nexus.steamware.net/repository/SWS/GWMS/stable/0/GWMS.UI.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/GWMS/stable/0/ChangeLog.html</changelog>
<mandatory>false</mandatory>