handleBodyClick()">
+
HandleBodyClick()">
-
+
@if (userIsOk || NavMan.Uri.Contains("reg-new-device"))
{
@@ -24,5 +24,5 @@
-
+
diff --git a/MP-TAB3/Shared/MainLayout.razor.cs b/MP-TAB3/Shared/MainLayout.razor.cs
index 672d10ec..eb50caa6 100644
--- a/MP-TAB3/Shared/MainLayout.razor.cs
+++ b/MP-TAB3/Shared/MainLayout.razor.cs
@@ -3,7 +3,6 @@ using Microsoft.AspNetCore.Components.Routing;
using Microsoft.JSInterop;
using MP.Data.DatabaseModels;
using MP.Data.Services;
-using MP_TAB3.Components;
using NLog;
namespace MP_TAB3.Shared
@@ -94,23 +93,25 @@ namespace MP_TAB3.Shared
protected async Task checkDtDiff2Logout()
{
- TimeSpan tsDeltaAct = DateTime.Now.Subtract(MsgServ.dtLastAction);
- TimeSpan tsDeltaSave = DateTime.Now.Subtract(MsgServ.dtLastSave);
+ DateTime adesso = DateTime.Now;
+ TimeSpan tsDeltaAct = adesso.Subtract(MsgServ.dtLastAction);
+ TimeSpan tsDeltaSave = adesso.Subtract(MsgServ.dtLastSave);
+ string userTkn = "";
switch (typeScadLogin)
{
case 1:
if (tsDeltaAct.TotalMinutes >= dtScadLogin)
{
- var userTkn = await TDataService.OperatoreGetRedis(MatrOpr, currDevGuid);
- if (!string.IsNullOrEmpty(userTkn))
+ userTkn = await TDataService.OperatoreGetRedis(MatrOpr, currDevGuid);
+ if (string.IsNullOrEmpty(userTkn))
{
- await MsgServ.DoLogIn(userTkn, true);
- MsgServ.dtLastAction = DateTime.Now;
- MsgServ.dtLastSave = DateTime.Now;
+ NavMan.NavigateTo("logout");
}
else
{
- NavMan.NavigateTo("logout");
+ await MsgServ.DoLogIn(userTkn, true);
+ MsgServ.dtLastAction = adesso;
+ MsgServ.dtLastSave = adesso;
}
}
else
@@ -118,21 +119,35 @@ namespace MP_TAB3.Shared
// se fosse oltre 1 minuto da ultimo save --> salvo!
if (tsDeltaSave.TotalMinutes > 1)
{
- var userTkn = await TDataService.OperatoreGetRedis(MatrOpr, currDevGuid);
+ userTkn = await TDataService.OperatoreGetRedis(MatrOpr, currDevGuid);
if (!string.IsNullOrEmpty(userTkn))
{
await MsgServ.DoLogIn(userTkn, true);
- MsgServ.dtLastAction = DateTime.Now;
- MsgServ.dtLastSave = DateTime.Now;
+ MsgServ.dtLastAction = adesso;
+ MsgServ.dtLastSave = adesso;
}
}
}
break;
case 2:
- if (tsDeltaAct.TotalMinutes >= dtScadLogin)
+ // se fosse oltre 1 minuto da ultimo save --> salvo!
+ if (tsDeltaSave.TotalMinutes > 1)
{
- NavMan.NavigateTo("logout");
+ // mitigazione controlli: solo ogni 1 minuto...
+ if (tsDeltaSave.TotalMinutes > 1)
+ {
+ MsgServ.dtLastSave = adesso;
+ userTkn = await TDataService.OperatoreGetRedis(MatrOpr, currDevGuid);
+ if (string.IsNullOrEmpty(userTkn))
+ {
+ NavMan.NavigateTo("logout");
+ }
+ if (tsDeltaAct.TotalMinutes >= dtScadLogin)
+ {
+ NavMan.NavigateTo("logout");
+ }
+ }
}
break;
@@ -145,13 +160,12 @@ namespace MP_TAB3.Shared
}
}
- protected async Task checkIfUserOk(bool isOk)
+ protected async Task ForceReloadMStor(bool isOk)
{
- await Task.Delay(1);
- userIsOk = isOk;
+ await ReloadMemStor();
}
- protected async Task handleBodyClick()
+ protected async Task HandleBodyClick()
{
await Task.Delay(1);
if (!pageOk)
@@ -160,6 +174,15 @@ namespace MP_TAB3.Shared
}
}
+ protected override async Task OnAfterRenderAsync(bool firstRender)
+ {
+ currDevGuid = await MsgServ.GetCurrDevGuidLSAsync();
+ // rileggo scadenza ultima...
+ DateTime adesso = DateTime.Now;
+ TimeSpan tsScadenza = TDataService.OperatoreGetGuidTTL(MatrOpr, currDevGuid);
+ MsgServ.dtLastSave = adesso.Subtract(TimeSpan.FromMinutes(dtScadLogin)).Add(tsScadenza);
+ }
+
///
/// Init struttura dati
///
@@ -184,11 +207,6 @@ namespace MP_TAB3.Shared
}
}
- protected override async Task OnAfterRenderAsync(bool firstRender)
- {
- currDevGuid = await MsgServ.GetCurrDevGuidLSAsync();
- }
-
protected async Task ReloadMemStor()
{
// in primis svuoto...
@@ -223,6 +241,12 @@ namespace MP_TAB3.Shared
TDataService.SetupConfig();
}
+ protected async Task SetUserOk(bool isOk)
+ {
+ await Task.Delay(1);
+ userIsOk = isOk;
+ }
+
#endregion Protected Methods
#region Private Fields
diff --git a/MP.Data/Services/MessageService.cs b/MP.Data/Services/MessageService.cs
index 6d818038..0466f32f 100644
--- a/MP.Data/Services/MessageService.cs
+++ b/MP.Data/Services/MessageService.cs
@@ -53,30 +53,6 @@ namespace MP.Data.Services
#endregion Public Events
-#if false
- protected bool _tReset { get; set; } = false;
- protected bool tReset
- {
- get => _tReset;
- set
- {
- if (_tReset != value)
- {
- _tReset = value;
- resetTimer();
- }
- }
- }
-
- protected void resetTimer()
- {
- if (EA_ResetFooterTimer != null)
- {
- EA_ResetFooterTimer?.Invoke();
- }
- }
-#endif
-
#region Public Properties
public string CognomeNome
@@ -251,8 +227,6 @@ namespace MP.Data.Services
public async Task
DoLogIn(string decodValue, bool saveOpr)
{
bool answ = false;
- //expDays = SMService.GetConfInt("cookieDayExpire");
- //var expDT = DateTime.Now.AddDays(expDays);
var devGuid = await GetCurrDevGuidLSAsync();
// decifro i valori..
var decrVal = DecryptData(decodValue);
@@ -306,6 +280,7 @@ namespace MP.Data.Services
}
return answ;
}
+
///
/// Restituisce il record OperatoreDTO da localstorage
///
@@ -351,6 +326,20 @@ namespace MP.Data.Services
return answ;
}
+ public TimeSpan GetKeyTTL(string redKey)
+ {
+ TimeSpan answ = new TimeSpan();
+ try
+ {
+ answ = redisDb.KeyTimeToLive(redKey) ?? new TimeSpan();
+ }
+ catch (Exception exc)
+ {
+ Log.Info($"Errore GetKeyTTL | currKey: {redKey}{Environment.NewLine}{exc}");
+ }
+ return answ;
+ }
+
///
/// Restituisce ultima matrOpr registrata da localstorage
///
@@ -440,17 +429,6 @@ namespace MP.Data.Services
return hasKey;
}
- ///
- /// scrive il record OperatoreDTO nel localstorage
- ///
- ///
- public async Task SetCurrOperDtoLSAsync(string currTkn)
- {
- bool answ = false;
- await localStorage.SetItemAsync("currTkn", currTkn);
- answ = true;
- return answ;
- }
///
/// scrive il record Device GUID nel localstorage
///
@@ -463,6 +441,18 @@ namespace MP.Data.Services
return answ;
}
+ ///
+ /// scrive il record OperatoreDTO nel localstorage
+ ///
+ ///
+ public async Task SetCurrOperDtoLSAsync(string currTkn)
+ {
+ bool answ = false;
+ await localStorage.SetItemAsync("currTkn", currTkn);
+ answ = true;
+ return answ;
+ }
+
///
/// Scrive il valore di IPV4 del device nel localstoragee
///
@@ -515,7 +505,6 @@ namespace MP.Data.Services
return answ;
}
-
///
/// Recupero singola preferenza utente
///
diff --git a/MP.Data/Services/TabDataService.cs b/MP.Data/Services/TabDataService.cs
index 67f96f8d..cb4db236 100644
--- a/MP.Data/Services/TabDataService.cs
+++ b/MP.Data/Services/TabDataService.cs
@@ -1617,6 +1617,36 @@ namespace MP.Data.Services
return answ;
}
+ public TimeSpan GetKeyTTL(string redKey)
+ {
+ TimeSpan answ = TimeSpan.FromMinutes(-1);
+ try
+ {
+ answ = redisDb.KeyTimeToLive(redKey) ?? new TimeSpan();
+ }
+ catch (Exception exc)
+ {
+ Log.Info($"Errore GetKeyTTL | currKey: {redKey}{Environment.NewLine}{exc}");
+ }
+ return answ;
+ }
+
+
+ ///
+ /// Legge l'oggetto operatore+device loggato e restituisce la sua TTL
+ ///
+ ///
+ ///
+ ///
+ public TimeSpan OperatoreGetGuidTTL(int matrOpr, Guid currDevGuid)
+ {
+ TimeSpan answ = new TimeSpan();
+ // cerco in redis...
+ string currKey = $"{redisUserDataKey}:CurrOpr:{matrOpr}:CurrDevGuid:{currDevGuid}";
+ answ = GetKeyTTL(currKey);
+ return answ;
+ }
+
///
/// Legge l'oggetto operatore loggato
///
@@ -1633,8 +1663,6 @@ namespace MP.Data.Services
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
{
- //var encrData = SteamCrypto.DecryptString(rawData, passPhrase);
- //answ = JsonConvert.DeserializeObject(rawData);
answ = rawData;
}
if (answ == null)
diff --git a/MP.Stats/MP.Stats.csproj b/MP.Stats/MP.Stats.csproj
index c653bf46..c6ca10bf 100644
--- a/MP.Stats/MP.Stats.csproj
+++ b/MP.Stats/MP.Stats.csproj
@@ -4,8 +4,8 @@
net6.0
MP.Stats
826e877c-ba70-4253-84cb-d0b1cafd4440
- 6.16.2311.1009
- 6.16.2311.1009
+ 6.16.2401.0914
+ 6.16.2401.0914
@@ -186,7 +186,7 @@
-
+
diff --git a/MP.Stats/Pages/Energy.razor b/MP.Stats/Pages/Energy.razor
new file mode 100644
index 00000000..0e5554c5
--- /dev/null
+++ b/MP.Stats/Pages/Energy.razor
@@ -0,0 +1,88 @@
+@page "/Energy"
+
+@using MP.Stats.Components
+
+
+
+
+ @if (ListRecords == null)
+ {
+
+ }
+ else if (totalCount == 0)
+ {
+
Nessun record trovato
+ }
+ else
+ {
+
+
+
+
+
+ | Macchina |
+ Commessa/ODL |
+ Articolo |
+ Inizio |
+ Fine |
+ Unit |
+ Energy |
+ Gas |
+ P1 |
+ P2 |
+ P3 |
+
+
+
+ @foreach (var record in ListRecords)
+ {
+
+ | @record.IdxMacchina |
+
+ @record.KeyRichiesta
+ @record.IdxOdl
+ |
+
+ @record.CodArticolo
+ @record.DescArticolo
+ |
+ @record.DataInizio |
+ @record.DataFine |
+ @(record.NumPezziEv + 200) m |
+
+ @{
+ double currSim = simVal(record.NumPezzi, record.NumPezziEv + 200);
+ double currSimGas = simVal(record.NumPezzi, record.NumPezziEv + 200);
+ }
+
+ @currSim.ToString("N2") kWh
+
+
+ @righDiv(currSim, record.NumPezziEv + 200).ToString("N1") kWh/m
+
+ |
+
+
+ @currSim.ToString("N2") m3
+
+
+ @righDiv(currSim, record.NumPezziEv + 200).ToString("N1") m3/m
+
+ |
+ @($"{currSim:N1}") |
+ @($"{currSimGas:N1}") |
+ @($"{currSim + currSimGas:N1}") |
+
+ }
+
+
+
+
+ }
+
+
+
\ No newline at end of file
diff --git a/MP.Stats/Pages/Energy.razor.cs b/MP.Stats/Pages/Energy.razor.cs
new file mode 100644
index 00000000..c367b36d
--- /dev/null
+++ b/MP.Stats/Pages/Energy.razor.cs
@@ -0,0 +1,214 @@
+using Microsoft.AspNetCore.Components;
+using Microsoft.JSInterop;
+using MP.Stats.Data;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace MP.Stats.Pages
+{
+ public partial class Energy : ComponentBase, IDisposable
+ {
+ #region Private Fields
+
+ private MP.Data.DatabaseModels.StatsODL currRecord = null;
+
+ private List ListRecords;
+ private List SearchRecords;
+
+ #endregion Private Fields
+
+ #region Protected Fields
+
+ protected string fileName = "ODL.csv";
+
+ #endregion Protected Fields
+
+ #region Private Properties
+
+ private SelectData currFilter
+ {
+ get
+ {
+ return MessageService.ODL_Filter;
+ }
+ set
+ {
+ MessageService.ODL_Filter = value;
+ }
+ }
+
+ private int currPage { get; set; } = 1;
+
+ private string fullPath
+ {
+ get => $"{Directory.GetCurrentDirectory()}\\temp\\{fileName}";
+ }
+
+ private bool isLoading { get; set; } = false;
+ private int numRecord { get; set; } = 10;
+
+ #endregion Private Properties
+
+ #region Protected Properties
+
+ [Inject]
+ protected IJSRuntime JSRuntime { get; set; }
+
+ [Inject]
+ protected MessageService MessageService { get; set; }
+
+ [Inject]
+ protected NavigationManager NavManager { get; set; }
+
+ [Inject]
+ protected MpStatsService StatService { get; set; }
+
+ protected int totalCount
+ {
+ get
+ {
+ int answ = 0;
+ if (SearchRecords != null)
+ {
+ answ = SearchRecords.Count;
+ }
+ return answ;
+ }
+ }
+
+ #endregion Protected Properties
+
+ #region Private Methods
+
+ private async void clearFile()
+ {
+ await Task.Run(() => File.Delete(fullPath));
+ }
+
+ private async Task ExportCsv()
+ {
+ isLoading = true;
+ // salvo davvero!
+ await MP.Data.Utils.SaveToCsv(SearchRecords, fullPath, ';');
+ isLoading = false;
+ }
+
+ private async Task ReloadData()
+ {
+ SearchRecords = await StatService.StatOdlGetAll(currFilter, MessageService.SearchVal);
+ ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
+ }
+
+ #endregion Private Methods
+
+ #region Protected Methods
+
+ protected async Task DoFilter(SelectData newFilter)
+ {
+ clearFile();
+ SearchRecords = null;
+ ListRecords = null;
+ currFilter = newFilter;
+ await ReloadData();
+ }
+
+ protected async Task ForceReload(int newNum)
+ {
+ numRecord = newNum;
+ await ReloadData();
+ }
+
+ protected async Task ForceReloadPage(int newNum)
+ {
+ currPage = newNum;
+ await ReloadData();
+ }
+
+ protected override async Task OnInitializedAsync()
+ {
+ clearFile();
+ numRecord = 10;
+ MessageService.ShowSearch = false;
+ MessageService.PageName = "Report ODL/Comm.";
+ MessageService.PageIcon = "oi oi-book";
+ MessageService.EA_SearchUpdated += OnSeachUpdated;
+ await ReloadData();
+ }
+
+ protected void ResetData()
+ {
+ clearFile();
+ StatService.rollBackEdit(currRecord);
+ currRecord = null;
+ }
+
+ protected async Task ResetFilter(SelectData newFilter)
+ {
+ clearFile();
+ currRecord = null;
+ SearchRecords = null;
+ ListRecords = null;
+ currFilter = SelectData.Init(5, 7);
+ await ReloadData();
+ }
+
+ protected async Task UpdateData()
+ {
+ currRecord = null;
+ await ReloadData();
+ }
+
+ #endregion Protected Methods
+
+ #region Public Methods
+
+ public string checkSelect(int IdxODL)
+ {
+ string answ = "";
+ if (currRecord != null)
+ {
+ try
+ {
+ answ = (currRecord.IdxOdl == IdxODL) ? "table-info" : "";
+ }
+ catch
+ { }
+ }
+ return answ;
+ }
+
+ public void Dispose()
+ {
+ MessageService.EA_SearchUpdated -= OnSeachUpdated;
+ }
+
+ public async void OnSeachUpdated()
+ {
+ await InvokeAsync(() =>
+ {
+ Task task = UpdateData();
+ StateHasChanged();
+ });
+ }
+
+ #endregion Public Methods
+
+ protected double righDiv(double num, double den)
+ {
+ if (den == 0)
+ {
+ den = 1;
+ }
+ double answ = num / den;
+ return answ;
+ }
+ protected double simVal(double minVal, double maxVal)
+ {
+ Random rnd = new Random();
+ return rnd.NextDouble() * (maxVal - minVal) + minVal;
+ }
+ }
+}
\ No newline at end of file
diff --git a/MP.Stats/Resources/ChangeLog.html b/MP.Stats/Resources/ChangeLog.html
index fc337935..0e6160b8 100644
--- a/MP.Stats/Resources/ChangeLog.html
+++ b/MP.Stats/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
Modulo statistiche MAPO
- Versione: 6.16.2311.1009
+ Versione: 6.16.2401.0914
Note di rilascio:
diff --git a/MP.Stats/Resources/VersNum.txt b/MP.Stats/Resources/VersNum.txt
index cf39a0ed..c318ff4f 100644
--- a/MP.Stats/Resources/VersNum.txt
+++ b/MP.Stats/Resources/VersNum.txt
@@ -1 +1 @@
-6.16.2311.1009
+6.16.2401.0914
diff --git a/MP.Stats/Resources/manifest.xml b/MP.Stats/Resources/manifest.xml
index 39ed393f..8bc8e35a 100644
--- a/MP.Stats/Resources/manifest.xml
+++ b/MP.Stats/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 6.16.2311.1009
+ 6.16.2401.0914
https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/MP.Stats.zip
https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/ChangeLog.html
false
diff --git a/MP.Stats/Shared/NavMenu.razor b/MP.Stats/Shared/NavMenu.razor
index 39754f97..1c6487c0 100644
--- a/MP.Stats/Shared/NavMenu.razor
+++ b/MP.Stats/Shared/NavMenu.razor
@@ -17,6 +17,11 @@
TRS/OEE %
+
-
+
+ ENERGY
+
+
-
Report ODL/Comm.