Aggiunta cache metodi:
- elenco operatori - elenco sessioni in corso
This commit is contained in:
@@ -28,17 +28,31 @@ namespace MP.Data.Controllers
|
||||
/// Elenco Inventari CORRENTI (=aperti, senza data fine)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<InventorySessionModel> InventSessCurrList()
|
||||
public List<InventorySessionModel> InventSessCurrList(DateTime dtStart, DateTime? dtEnd)
|
||||
{
|
||||
List<InventorySessionModel> dbResult = new List<InventorySessionModel>();
|
||||
using (var dbCtx = new MoonPro_InveContext(_configuration))
|
||||
{
|
||||
if(dtEnd == null)
|
||||
{
|
||||
|
||||
|
||||
dbResult = dbCtx
|
||||
.DbInveSess
|
||||
.Where(x => x.DtEnd == null)
|
||||
.AsNoTracking()
|
||||
.OrderByDescending(x => x.DtStart)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbInveSess
|
||||
.Where(x => (x.DtEnd == dtEnd) && (x.DtStart == dtStart))
|
||||
.AsNoTracking()
|
||||
.OrderByDescending(x => x.DtStart)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using Egw.Core;
|
||||
using MP.Data.Conf;
|
||||
using MP.Data.DatabaseModels;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using StackExchange.Redis;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace MP.INVE.Data
|
||||
{
|
||||
@@ -66,8 +68,43 @@ namespace MP.INVE.Data
|
||||
|
||||
public List<AnagOperatoriModel> ElencoOperatori(int matrOpr, string authkey)
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
List<AnagOperatoriModel>? result = new List<AnagOperatoriModel>();
|
||||
result = dbController.ElencoOperatori(matrOpr, authkey);
|
||||
// cerco in redis...
|
||||
RedisValue rawData = redisDb.StringGet(redisElencoOperatori);
|
||||
if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
{
|
||||
var dese = JsonConvert.DeserializeObject<List<AnagOperatoriModel>>($"{rawData}");
|
||||
if (dese != null)
|
||||
{
|
||||
if ((matrOpr != 0) && (authkey != ""))
|
||||
{
|
||||
result = dese.Where(x => (x.MatrOpr == matrOpr) && (x.authKey == authkey)).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dese;
|
||||
}
|
||||
}
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Debug($"ElencoOperatori Read from REDIS: {ts.TotalMilliseconds}ms");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.ElencoOperatori(matrOpr, authkey);
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSetAsync(redisElencoOperatori, rawData, getRandTOut(redisLongTimeCache));
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Debug($"ElencoOperatori Read from DB: {ts.TotalMilliseconds}ms");
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<AnagOperatoriModel>();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -76,10 +113,43 @@ namespace MP.INVE.Data
|
||||
return SteamCrypto.EncryptString(rawData, passPhrase);
|
||||
}
|
||||
|
||||
public List<InventorySessionModel> InventSessCurrList()
|
||||
public List<InventorySessionModel> InventSessCurrList(DateTime dtStart, DateTime? dtEnd)
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
List<InventorySessionModel> result = new List<InventorySessionModel>();
|
||||
result = dbController.InventSessCurrList();
|
||||
// cerco in redis...
|
||||
RedisValue rawData = redisDb.StringGet(redisSessionList);
|
||||
if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
{
|
||||
var dese = JsonConvert.DeserializeObject<List<InventorySessionModel>>($"{rawData}");
|
||||
if ((dtEnd != null) && (dese != null))
|
||||
{
|
||||
result = dese.Where(x => (x.DtStart == dtStart) && (x.DtEnd == dtEnd)).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dese;
|
||||
}
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Debug($"InventSessCurrList Read from REDIS: {ts.TotalMilliseconds}ms");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.InventSessCurrList(dtStart, dtEnd);
|
||||
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSetAsync(redisSessionList, rawData, getRandTOut(redisLongTimeCache));
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Debug($"InventSessCurrList Read from DB: {ts.TotalMilliseconds}ms");
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<InventorySessionModel>();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -116,6 +186,11 @@ namespace MP.INVE.Data
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private const string redisBaseAddr = "MP:INVE";
|
||||
|
||||
private const string redisElencoOperatori = redisBaseAddr + ":eleOperatori";
|
||||
private const string redisSessionList = redisBaseAddr + ":sessionList";
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto vocabolario x uso continuo traduzione
|
||||
/// </summary>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>MP.INVE</RootNamespace>
|
||||
<Version>6.16.2211.1618</Version>
|
||||
<Version>6.16.2211.1711</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
+78
-47
@@ -1,57 +1,87 @@
|
||||
@page "/Session"
|
||||
|
||||
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3>Sessione</h3>
|
||||
<div class="card-header d-flex justify-content-between">
|
||||
<div class="col-6">
|
||||
<h3>Sessione</h3>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="input-group input-group-sm">
|
||||
<div class="input-group-text">
|
||||
<span class="me-1">In corso</span>
|
||||
<div class="form-check form-check-sm form-switch py-1" title="Parameter View Mode (RealTime / LogData)">
|
||||
<input class="form-check-input" type="checkbox" id="mySwitch" name="setupAlarms" @onclick="() => toggle()">
|
||||
</div>
|
||||
<span class="">Concluse</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
@if (isLoading)
|
||||
{
|
||||
<LoadingData></LoadingData>
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Id</th>
|
||||
<th scope="col">Description</th>
|
||||
<th scope="col">Operatore</th>
|
||||
<th scope="col">Data inizio</th>
|
||||
<th scope="col">Data fine</th>
|
||||
<th scope="col">Trasferita</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@if (elencoSessioni != null)
|
||||
{
|
||||
@foreach (var item in elencoSessioni)
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">QR</th>
|
||||
<th scope="col">Description</th>
|
||||
<th scope="col">Operatore</th>
|
||||
<th scope="col">Data inizio</th>
|
||||
<th scope="col">Data fine</th>
|
||||
<th scope="col">Trasferita</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@if (elencoSessioni != null)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@item.InveSessID
|
||||
<!-- Button trigger modal -->
|
||||
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal" @onclick="()=> getCurrSess(item.InveSessID)">
|
||||
APRI QR
|
||||
</button>
|
||||
</td>
|
||||
<td>
|
||||
@item.Description
|
||||
</td>
|
||||
<td>
|
||||
@item.UserCrea
|
||||
</td>
|
||||
<td>
|
||||
@item.DtStart
|
||||
</td>
|
||||
<td>
|
||||
@item.DtEnd
|
||||
</td>
|
||||
<td>
|
||||
@item.Transferred
|
||||
</td>
|
||||
</tr>
|
||||
@foreach (var item in elencoSessioni)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<!-- Button trigger modal -->
|
||||
<button type="button" class="btn btn-dark" data-bs-toggle="modal" data-bs-target="#exampleModal" @onclick="()=> getCurrSess(item.InveSessID)" title="Apri qr per connettersi alla sessione">
|
||||
<i class="fa-solid fa-qrcode"></i>
|
||||
</button>
|
||||
</td>
|
||||
<td>
|
||||
@item.Description
|
||||
</td>
|
||||
<td>
|
||||
@item.UserCrea
|
||||
</td>
|
||||
<td>
|
||||
@item.DtStart
|
||||
</td>
|
||||
@if (item.DtEnd != null)
|
||||
{
|
||||
<td>
|
||||
@item.DtEnd
|
||||
</td>
|
||||
}
|
||||
else
|
||||
{
|
||||
<td>
|
||||
In corso...
|
||||
</td>
|
||||
}
|
||||
<td>
|
||||
@item.Transferred
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
|
||||
</div>
|
||||
<div class="card-footer py-1">
|
||||
@@ -65,7 +95,7 @@
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
|
||||
<h5 class="modal-title" id="exampleModalLabel">CONNETTERSI ALLA SESSIONE: <b>@currIdSess</b></h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
@@ -74,8 +104,9 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
<button type="button" class="btn btn-primary">Save changes</button>
|
||||
<span>
|
||||
Matricola Operatore: <b>@idOperatore</b>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -33,21 +33,32 @@ namespace MP.INVE.Pages
|
||||
//await FilterChanged.InvokeAsync(actFilter);
|
||||
await getId();
|
||||
await Task.Delay(1);
|
||||
elencoSessioni = MIDataservice.InventSessCurrList();
|
||||
await reloadData();
|
||||
}
|
||||
|
||||
#if false
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
await JSRuntime.InvokeVoidAsync("clearContent", $"qrCodeImg_{101}");
|
||||
await JSRuntime.InvokeVoidAsync("displayQr", $"qrCodeImg_{101}", rawCode);
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private bool inCorso { get; set; } = true;
|
||||
protected async Task toggle()
|
||||
{
|
||||
inCorso = !inCorso;
|
||||
await reloadData();
|
||||
}
|
||||
|
||||
protected string BaseUrlTab { get => $"{Configuration["ServerConf:BaseUrlJumper"]}"; }
|
||||
private int idOperatore { get; set; } = 0;
|
||||
private int currIdSess { get; set; } = 0;
|
||||
private string authKey { get; set; } = "";
|
||||
private DateTime dtStart { get; set; } = DateTime.Now.AddMonths(-1);
|
||||
private DateTime dtEnd { get; set; } = DateTime.Now;
|
||||
|
||||
protected string rawCode
|
||||
{
|
||||
@@ -59,10 +70,27 @@ namespace MP.INVE.Pages
|
||||
}
|
||||
}
|
||||
|
||||
private bool isLoading { get; set; } = false;
|
||||
|
||||
protected void getCurrSess(int idSess)
|
||||
private async Task reloadData()
|
||||
{
|
||||
await Task.Delay(1);
|
||||
isLoading = true;
|
||||
if (inCorso)
|
||||
{
|
||||
elencoSessioni = MIDataservice.InventSessCurrList(dtStart, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
elencoSessioni = MIDataservice.InventSessCurrList(dtStart, dtEnd);
|
||||
}
|
||||
isLoading = false;
|
||||
}
|
||||
protected async Task getCurrSess(int idSess)
|
||||
{
|
||||
currIdSess = idSess;
|
||||
await JSRuntime.InvokeVoidAsync("clearContent", $"qrCodeImg_{101}");
|
||||
await JSRuntime.InvokeVoidAsync("displayQr", $"qrCodeImg_{101}", rawCode);
|
||||
}
|
||||
|
||||
[Inject]
|
||||
@@ -83,6 +111,7 @@ namespace MP.INVE.Pages
|
||||
{
|
||||
idOperatore = local.MatrOpr;
|
||||
authKey = local.hashAuthKey;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ builder.Services.AddHttpContextAccessor();
|
||||
builder.Services.AddSingleton<IConnectionMultiplexer>(redisMultiplexer);
|
||||
builder.Services.AddSingleton<MiDataService>();
|
||||
builder.Services.AddScoped<MessageService>();
|
||||
builder.Services.AddScoped<LoginService>();
|
||||
// aggiungere servizio da usare come DI x gestione session, aggiungere anche local storage
|
||||
|
||||
builder.Services.AddBlazoredSessionStorage();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MAPOINVE </i>
|
||||
<h4>Versione: 6.16.2211.1618</h4>
|
||||
<h4>Versione: 6.16.2211.1711</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.16.2211.1618
|
||||
6.16.2211.1711
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>6.16.2211.1618</version>
|
||||
<version>6.16.2211.1711</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-INVE/stable/LAST/MP.INVE.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-INVE/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"cacheCheckArtUsato": "2",
|
||||
"redisLongTimeCache": "15",
|
||||
"MpIoBaseUrl": "http://localhost:20967/",
|
||||
"BaseUrl": "https://iis02.egalware.com/MP/MAG/SMART/PLScanner?"
|
||||
"BaseUrl": "https://iis02.egalware.com/MP/MAG/SMART/PLScanner?",
|
||||
"BaseUrlJumper": "https://iis02.egalware.com/MP/jumper?"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user