Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
@@ -114,10 +114,10 @@ else
|
||||
</div>
|
||||
<div class="d-flex justify-content-between">
|
||||
<div>
|
||||
<CircleGauge Titolo="9:00" Testo="Caricate" maxVal="480" currVal="540" strokeColorVal="#F1C40F" StyleTesto="font-size: 1em; fill: #fff;"></CircleGauge>
|
||||
<CircleGauge Titolo="@LeftGaugeTitle" Testo="@LeftGaugeText" maxVal="480" currVal="540" strokeColorVal="#F1C40F" StyleTesto="font-size: 1em; fill: #fff;"></CircleGauge>
|
||||
</div>
|
||||
<div>
|
||||
<CircleGauge Titolo="4:00" Testo="Lavorate" maxVal="480" currVal="240" strokeColorVal="#00FF00" StyleTesto="font-size: 1em; fill: #fff;"></CircleGauge>
|
||||
<CircleGauge Titolo="@RightGaugeTitle" Testo="@RightGaugeText" maxVal="480" currVal="240" strokeColorVal="#00FF00" StyleTesto="font-size: 1em; fill: #fff;"></CircleGauge>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row p-2 pt-3">
|
||||
|
||||
@@ -80,6 +80,28 @@ namespace GPW.CORE.Comp
|
||||
[Parameter]
|
||||
public string WeekEndCss { get; set; } = "bg-secondary text-light bg-opacity-75";
|
||||
|
||||
/// <summary>
|
||||
/// titolo che verrà inserito in gauge
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public string RightGaugeTitle { get; set; } = "--:--";
|
||||
/// <summary>
|
||||
/// testo che verrà inserito in gauge
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public string RightGaugeText { get; set; } = "-----";
|
||||
|
||||
/// <summary>
|
||||
/// titolo che verrà inserito in gauge
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public string LeftGaugeTitle { get; set; } = "--:--";
|
||||
/// <summary>
|
||||
/// testo che verrà inserito in gauge
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public string LeftGaugeText { get; set; } = "-----";
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
@@ -41,4 +41,8 @@
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.11" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GPW.CORE.Data\GPW.CORE.Data.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
<div class="col">
|
||||
<CalendarMonth DtRif="@dtCurr" MainCss="table table-dark table-borderless" DateSelected="DisplayDate" DateCheck="@DateCheck" SingleWeek="@singleWeek" SelDayCss="selDate rounded-top p-2" HeadCss="color: #E67E22"></CalendarMonth>
|
||||
</div>
|
||||
@if (timbratureOggi != null)
|
||||
{
|
||||
|
||||
<div class="col">
|
||||
<CalendarMonth RightGaugeTitle="@oreLavorate" LeftGaugeText="@oreCaricate" RightGaugeText="Lavorate" LeftGaugeTitle="Caricate" DtRif="@dtCurr" MainCss="table table-dark table-borderless" DateSelected="DisplayDate" DateCheck="@DateCheck" SingleWeek="@singleWeek" SelDayCss="selDate rounded-top p-2" HeadCss="color: #E67E22"></CalendarMonth>
|
||||
</div>
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -12,19 +12,33 @@ using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.AspNetCore.Components.Web.Virtualization;
|
||||
using Microsoft.JSInterop;
|
||||
using GPW.CORE.Smart;
|
||||
using GPW.CORE.Data;
|
||||
using GPW.CORE.Smart.Shared;
|
||||
using GPW.CORE.Comp;
|
||||
using GPW.CORE.Data.DTO;
|
||||
using GPW.CORE.Data.Controllers;
|
||||
|
||||
namespace GPW.CORE.Smart.Components
|
||||
{
|
||||
public partial class Calendario
|
||||
{
|
||||
[Inject]
|
||||
protected GPWController GPWContr { get; set; } = null!;
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
dtCurr = DateTime.Today;
|
||||
await Task.Delay(1);
|
||||
|
||||
listRecords = GPWContr.DailyDetails(56, DateTime.Now.AddDays(-3), DateTime.Now);
|
||||
|
||||
timbratureOggi = listRecords.Where(x=> x.DtInizio == DateTime.Now.Date).FirstOrDefault();
|
||||
|
||||
oreCaricate = timbratureOggi.OreComm.ToString();
|
||||
oreLavorate = timbratureOggi.OreLav.ToString();
|
||||
|
||||
DateCheck = new Dictionary<DateTime, string>();
|
||||
Random rnd = new Random();
|
||||
// random colorate...
|
||||
@@ -42,6 +56,12 @@ namespace GPW.CORE.Smart.Components
|
||||
}
|
||||
}
|
||||
|
||||
protected string oreCaricate = "";
|
||||
protected string oreLavorate = "";
|
||||
|
||||
protected List<DailyDataDTO>? listRecords = null;
|
||||
protected DailyDataDTO? timbratureOggi = null;
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
using GPW.CORE.Data.DTO;
|
||||
using GPW.CORE.Data.DbModels;
|
||||
using GPW.CORE.Data.DTO;
|
||||
using Microsoft.AspNetCore.Identity.UI.Services;
|
||||
using Microsoft.Extensions.Caching.Distributed;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.VisualBasic;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using StackExchange.Redis;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection.PortableExecutable;
|
||||
using System.Text;
|
||||
|
||||
namespace GPW.CORE.Smart.Data
|
||||
{
|
||||
@@ -62,6 +66,54 @@ namespace GPW.CORE.Smart.Data
|
||||
|
||||
#region Public Methods
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database controller
|
||||
dbController.Dispose();
|
||||
}
|
||||
private readonly IDistributedCache distributedCache;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Recupera l'elenco dei dettagli giornalieri attività di un dipendente, dato periodo riferimento
|
||||
/// </summary>
|
||||
/// <param name="idxDipendente">Dipendente interessato</param>
|
||||
/// <param name="dtInizio">Data di riferimento (ultima/corrente)</param>
|
||||
/// <param name="dtFine">NUm settimane precedenti da recuperare</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<CORE.Data.DTO.DailyDataDTO>> DailyDetails(int idxDipendente, DateTime dtInizio, DateTime dtFine)
|
||||
{
|
||||
List<CORE.Data.DTO.DailyDataDTO>? dbResult = new List<CORE.Data.DTO.DailyDataDTO>();
|
||||
string currKey = $"{rKeyDailyData}:{idxDipendente}:{dtInizio.ToString("yyyy-MM-dd")}:{dtFine.ToString("yyyy-MM-dd")}";
|
||||
trackCache(currKey);
|
||||
string rawData;
|
||||
var redisDataList = await distributedCache.GetAsync(currKey);
|
||||
if (redisDataList != null)
|
||||
{
|
||||
rawData = Encoding.UTF8.GetString(redisDataList);
|
||||
dbResult = JsonConvert.DeserializeObject<List<CORE.Data.DTO.DailyDataDTO>>(rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbController.DailyDetails(idxDipendente, dtInizio, dtFine);
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
redisDataList = Encoding.UTF8.GetBytes(rawData);
|
||||
await distributedCache.SetAsync(currKey, redisDataList, cacheOpt(true));
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB + caching per DailyDetails: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
if (dbResult == null)
|
||||
{
|
||||
dbResult = new List<CORE.Data.DTO.DailyDataDTO>();
|
||||
}
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Recupera l'elenco dei dettagli giornalieri attività di un dipendente, dato periodo riferimento
|
||||
/// </summary>
|
||||
@@ -104,79 +156,6 @@ namespace GPW.CORE.Smart.Data
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database controller
|
||||
dbController.Dispose();
|
||||
}
|
||||
|
||||
public async Task<bool> FlushRedisCache()
|
||||
{
|
||||
await Task.Delay(1);
|
||||
RedisValue pattern = new RedisValue($"{redisBaseAddr}:*");
|
||||
bool answ = await ExecFlushRedisPattern(pattern);
|
||||
return answ;
|
||||
}
|
||||
|
||||
public void rollBackEdit(object item)
|
||||
{
|
||||
dbController.rollBackEntity(item);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected const string redisBaseAddr = "GPW:Smart";
|
||||
|
||||
protected const string rKeyAKV = $"{redisBaseAddr}:Cache:AKV";
|
||||
|
||||
protected const string rKeyAnOrDip = $"{redisBaseAddr}:Cache:AnOrariDip";
|
||||
|
||||
protected const string rKeyCalcOreFase = $"{redisBaseAddr}:Cache:CalcOreFase";
|
||||
|
||||
protected const string rKeyCalcOreProj = $"{redisBaseAddr}:Cache:CalcOreProj";
|
||||
|
||||
protected const string rKeyCalendari = $"{redisBaseAddr}:Cache:Calendari";
|
||||
|
||||
protected const string rKeyCliAll = $"{redisBaseAddr}:Cache:CliAll";
|
||||
|
||||
protected const string rKeyConfig = $"{redisBaseAddr}:Cache:Config";
|
||||
|
||||
protected const string rKeyDailyData = $"{redisBaseAddr}:Cache:DailyData";
|
||||
|
||||
protected const string rKeyDipendenti = $"{redisBaseAddr}:Cache:Dipendenti";
|
||||
|
||||
protected const string rKeyFasiAll = $"{redisBaseAddr}:Cache:FasiAll";
|
||||
|
||||
protected const string rKeyFasiByProj = $"{redisBaseAddr}:Cache:FasiByProj";
|
||||
|
||||
protected const string rKeyFasiSearch = $"{redisBaseAddr}:Cache:FasiSearch";
|
||||
|
||||
protected const string rKeyGiust = $"{redisBaseAddr}:Cache:Giustif";
|
||||
|
||||
protected const string rKeyGrpAll = $"{redisBaseAddr}:Cache:GrpAll";
|
||||
|
||||
protected const string rKeyGrpUser = $"{redisBaseAddr}:Cache:GrpUser";
|
||||
|
||||
protected const string rKeyParetoRegAtt = $"{redisBaseAddr}:Cache:ParetoRegAtt";
|
||||
|
||||
protected const string rKeyProjAll = $"{redisBaseAddr}:Cache:ProjAll";
|
||||
|
||||
protected const string rKeyRilTemp = $"{redisBaseAddr}:Cache:RilTemp";
|
||||
|
||||
protected const string rKeyVC19 = $"{redisBaseAddr}:Cache:VC19";
|
||||
|
||||
protected const string rKeyVetoIns = $"{redisBaseAddr}:Cache:VetoInsert";
|
||||
|
||||
protected const string rKeyWeekStats = $"{redisBaseAddr}:Cache:WeekStats";
|
||||
|
||||
protected static string connStringBBM = "";
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Invio email tramite libreria
|
||||
/// </summary>
|
||||
@@ -854,6 +833,7 @@ namespace GPW.CORE.Smart.Data
|
||||
return await Task.FromResult(keyResult);
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<DipendentiModel>> DipendentiGetAll()
|
||||
{
|
||||
List<DipendentiModel>? dbResult = new List<DipendentiModel>();
|
||||
@@ -883,6 +863,7 @@ namespace GPW.CORE.Smart.Data
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// invalida tutta la cache in caso di update
|
||||
/// </summary>
|
||||
@@ -1370,8 +1351,14 @@ namespace GPW.CORE.Smart.Data
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public void rollBackEdit(object item)
|
||||
{
|
||||
dbController.rollBackEntity(item);
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Elenco timbrature di un giorno
|
||||
@@ -1419,7 +1406,133 @@ namespace GPW.CORE.Smart.Data
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected const string rKeyAKV = "Cache:AKV";
|
||||
protected const string rKeyAnOrDip = "Cache:AnOrariDip";
|
||||
protected const string rKeyCalcOreFase = "Cache:CalcOreFase";
|
||||
protected const string rKeyCalcOreProj = "Cache:CalcOreProj";
|
||||
protected const string rKeyCalendari = "Cache:Calendari";
|
||||
protected const string rKeyCliAll = "Cache:CliAll";
|
||||
protected const string rKeyConfig = "Cache:Config";
|
||||
protected const string rKeyDailyData = "Cache:DailyData";
|
||||
protected const string rKeyDipendenti = "Cache:Dipendenti";
|
||||
protected const string rKeyFasiAll = "Cache:FasiAll";
|
||||
protected const string rKeyFasiByProj = "Cache:FasiByProj";
|
||||
protected const string rKeyFasiSearch = "Cache:FasiSearch";
|
||||
protected const string rKeyGiust = "Cache:Giustif";
|
||||
protected const string rKeyGrpAll = "Cache:GrpAll";
|
||||
protected const string rKeyGrpUser = "Cache:GrpUser";
|
||||
protected const string rKeyParetoRegAtt = "Cache:ParetoRegAtt";
|
||||
protected const string rKeyProjAll = "Cache:ProjAll";
|
||||
protected const string rKeyRilTemp = "Cache:RilTemp";
|
||||
protected const string rKeyVC19 = "Cache:VC19";
|
||||
protected const string rKeyVetoIns = "Cache:VetoInsert";
|
||||
protected const string rKeyWeekStats = "Cache:WeekStats";
|
||||
protected static string connStringBBM = "";
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Invio email tramite libreria
|
||||
/// </summary>
|
||||
/// <param name="destList"></param>
|
||||
/// <param name="subject"></param>
|
||||
/// <param name="message"></param>
|
||||
/// <returns></returns>
|
||||
protected async Task sendEmail(string destList, string subject, string message)
|
||||
{
|
||||
List<string> emailDestList = destList.Split(",").ToList();
|
||||
foreach (var dest in emailDestList)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _emailSender.SendEmailAsync(dest, subject, message);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante invio email:{Environment.NewLine}dest: {dest} | subject {subject}{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registra in cache chiave se non fosse già in elenco
|
||||
/// </summary>
|
||||
/// <param name="newKey"></param>
|
||||
protected void trackCache(string newKey)
|
||||
{
|
||||
if (!cachedDataList.Contains(newKey))
|
||||
{
|
||||
cachedDataList.Add(newKey);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration = null!;
|
||||
private static ILogger<CoreSmartDataService> _logger = null!;
|
||||
private static JsonSerializerSettings? JSSettings;
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private readonly IEmailSender _emailSender;
|
||||
|
||||
//private readonly IEmailSender _emailSender;
|
||||
//private readonly UserManager<IdentityUser> _userManager;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto per connessione a REDIS
|
||||
/// </summary>
|
||||
private IConnectionMultiplexer redisConn;
|
||||
//private ConnectionMultiplexer redisConnMult = null!;
|
||||
|
||||
//ISubscriber sub = redis.GetSubscriber();
|
||||
/// <summary>
|
||||
/// Oggetto DB redis da impiegare x chiamate R/W
|
||||
/// </summary>
|
||||
private IDatabase redisDb = null!;
|
||||
|
||||
private readonly IMemoryCache memoryCache;
|
||||
private List<string> cachedDataList = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Durata assoluta massima della cache IN SECONDI
|
||||
/// </summary>
|
||||
private int chAbsExp = 60 * 5;
|
||||
|
||||
/// <summary>
|
||||
/// Durata della cache IN SECONDI in modalità inattiva (non acceduta) prima di venire
|
||||
/// rimossa NON estende oltre il tempo massimo di validità della cache (chAbsExp)
|
||||
/// </summary>
|
||||
private int chSliExp = 60 * 1;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private DistributedCacheEntryOptions cacheOpt(bool fastCache)
|
||||
{
|
||||
var numSecAbsExp = fastCache ? chAbsExp : chAbsExp * 10;
|
||||
var numSecSliExp = fastCache ? chSliExp : chSliExp * 10;
|
||||
return new DistributedCacheEntryOptions().SetAbsoluteExpiration(DateTime.Now.AddSeconds(numSecAbsExp)).SetSlidingExpiration(TimeSpan.FromSeconds(numSecSliExp));
|
||||
}
|
||||
|
||||
private DistributedCacheEntryOptions cacheOpt(int multFact)
|
||||
{
|
||||
var numSecAbsExp = chAbsExp * multFact;
|
||||
var numSecSliExp = chSliExp * multFact;
|
||||
return new DistributedCacheEntryOptions().SetAbsoluteExpiration(DateTime.Now.AddSeconds(numSecAbsExp)).SetSlidingExpiration(TimeSpan.FromSeconds(numSecSliExp));
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user