Fix progress bar
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<EgwCoreLib.Razor.PeriodoSel CurrPeriodo=CurrPeriodo E_PeriodoSel="SetPeriodo"></EgwCoreLib.Razor.PeriodoSel>
|
||||
<EgwCoreLib.Razor.PeriodoSel CurrPeriodo="CurrPeriodo" E_PeriodoSel="SetPeriodo"></EgwCoreLib.Razor.PeriodoSel>
|
||||
|
||||
<ShowProcessing Message="Invio in corso" IsProcessing="@isSending"></ShowProcessing>
|
||||
@if (isProcessing)
|
||||
{
|
||||
<EgwCoreLib.Razor.LoadingData></EgwCoreLib.Razor.LoadingData>
|
||||
@@ -53,12 +54,6 @@ else
|
||||
{
|
||||
<button class="btn btn-sm btn-warning py-0" @onclick="() => DoAck(item)">Set <i class="fa fa-exclamation-triangle" aria-hidden="true"></i></button>
|
||||
}
|
||||
@* <div class="text-truncate" runat="server" id="divNotify" visible='<%# getBool(Eval("ReqNotify")) %>'>
|
||||
<asp:LinkButton runat="server" ID="lbtSendNotify" CssClass="btn btn-sm btn-primary py-0" ToolTip='<%# traduci("lblSendNotify") %>' OnClick="lbtSendNotify_Click" CommandArgument='<%# Eval("AlarmLogId") %>' OnClientClick='<%# SteamWare.jsUtils.getCBE("confermaSendNotify") %>'>Invia <i class="fa fa-envelope-o" aria-hidden="true"></i></asp:LinkButton>
|
||||
</div> *@
|
||||
@* <div class="text-truncate" runat="server" id="divAck" visible='<%# getBool(Eval("ReqAck")) %>'>
|
||||
<asp:LinkButton runat="server" ID="lbkDoAck" CssClass="btn btn-sm btn-warning py-0" ToolTip='<%# traduci("lblUserAck") %>' OnClick="lbkDoAck_Click" CommandArgument='<%# Eval("AlarmLogId") %>' OnClientClick='<%# SteamWare.jsUtils.getCBE("confermaUserAck") %>'>Set <i class="fa fa-exclamation-triangle" aria-hidden="true"></i></asp:LinkButton>
|
||||
</div> *@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,6 +3,8 @@ using Microsoft.JSInterop;
|
||||
using MP.Data;
|
||||
using MP.Data.DatabaseModels;
|
||||
using MP.Data.Services;
|
||||
using NLog;
|
||||
using System.Text;
|
||||
using static EgwCoreLib.Utils.DtUtils;
|
||||
|
||||
namespace MP_TAB_SERV.Components
|
||||
@@ -42,6 +44,7 @@ namespace MP_TAB_SERV.Components
|
||||
#region Protected Fields
|
||||
|
||||
protected bool isProcessing = false;
|
||||
protected bool isSending = false;
|
||||
protected int NumRecPage = 10;
|
||||
protected int PageNum = 1;
|
||||
|
||||
@@ -51,27 +54,46 @@ namespace MP_TAB_SERV.Components
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
[Inject]
|
||||
protected IJSRuntime JSRuntime { get; set; } = null!;
|
||||
|
||||
protected List<AlarmLogModel> ListComplete { get; set; } = new List<AlarmLogModel>();
|
||||
|
||||
protected List<AlarmLogModel> ListPaged { get; set; } = new List<AlarmLogModel>();
|
||||
|
||||
[Inject]
|
||||
protected TabDataService TabDServ { get; set; } = null!;
|
||||
|
||||
protected MailService MailServ { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected MailService MailServ { get; set; } = null!;
|
||||
protected MessageService MServ { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected TabDataService TabDServ { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected async Task DoAck(AlarmLogModel currAlarm)
|
||||
{
|
||||
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Sicuro di voler registrare ACK dell'allarme?{Environment.NewLine}[{currAlarm.ValDecoded}]"))
|
||||
return;
|
||||
|
||||
isSending = true;
|
||||
await Task.Delay(1);
|
||||
TabDServ.AlarmLogSetAck(currAlarm.AlarmLogId, DateTime.Now, $"{MServ.MatrOpr} - {MServ.CognomeNome}");
|
||||
isSending = false;
|
||||
await Task.Delay(1);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await Task.Delay(1);
|
||||
if (RecMSE != null)
|
||||
{
|
||||
IdxMaccSel = RecMSE.IdxMacchina;
|
||||
CurrPeriodo = new Periodo(PeriodSet.LastWeek);
|
||||
await doUpdate();
|
||||
}
|
||||
}
|
||||
@@ -88,6 +110,47 @@ namespace MP_TAB_SERV.Components
|
||||
UpdateTable();
|
||||
}
|
||||
|
||||
protected async Task SendNotify(AlarmLogModel currAlarm)
|
||||
{
|
||||
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Sicuro di voler inviare notifica allarme?{Environment.NewLine}[{currAlarm.ValDecoded}]"))
|
||||
return;
|
||||
|
||||
isSending = true;
|
||||
await Task.Delay(1);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
List<string> dest = new List<string>();
|
||||
dest.Add("samuele@steamware.net");
|
||||
string oggetto = $"Notifica allarme impianto {currAlarm.MachineId}";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine("Attenzione: allarme presente per un periodo superiore alla soglia di controllo.");
|
||||
sb.AppendLine();
|
||||
sb.AppendLine($"<b>{currAlarm.ValDecoded}</b>");
|
||||
sb.AppendLine();
|
||||
sb.AppendLine($"Info Area: {currAlarm.MemAddress}.{currAlarm.MemIndex} | Status {currAlarm.StatusVal}");
|
||||
sb.AppendLine();
|
||||
string corpo = sb.ToString().Replace($"{Environment.NewLine}", "<br/>");
|
||||
MailKitMailData mData = new MailKitMailData()
|
||||
{
|
||||
To = dest,
|
||||
Subject = oggetto,
|
||||
Body = corpo
|
||||
};
|
||||
bool done = await MailServ.SendAsync(mData);
|
||||
if (done)
|
||||
{
|
||||
// salvo invio Notifica allarme
|
||||
TabDServ.AlarmLogSetNotify(currAlarm.AlarmLogId, DateTime.Now);
|
||||
Log.Info($"Notifica allarme {currAlarm.AlarmLogId} inviato a {string.Join(",", dest)}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"Errore in invio email allarmi attivi per {currAlarm.AlarmLogId}");
|
||||
}
|
||||
isSending = false;
|
||||
await Task.Delay(1);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
protected async Task SetMacc(string selIdxMacc)
|
||||
{
|
||||
isProcessing = true;
|
||||
@@ -119,40 +182,17 @@ namespace MP_TAB_SERV.Components
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private Periodo CurrPeriodo { get; set; } = new Periodo();
|
||||
private string IdxMaccSel { get; set; } = "";
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
protected async Task SendNotify(AlarmLogModel currAlarm)
|
||||
{
|
||||
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Sicuro di voler inviare notifica allarme?{Environment.NewLine}[{currAlarm.ValDecoded}]"))
|
||||
return;
|
||||
|
||||
isProcessing = true;
|
||||
List<string> dest = new List<string>();
|
||||
dest.Add("samuele@steamware.net");
|
||||
string body = $"Registrato allarme {currAlarm.ValDecoded}";
|
||||
MailKitMailData mData = new MailKitMailData()
|
||||
{
|
||||
To = dest,
|
||||
Subject = "MAPO Alarm Notification",
|
||||
Body = body
|
||||
};
|
||||
await MailServ.SendAsync(mData);
|
||||
isProcessing = false;
|
||||
await Task.Delay(1);
|
||||
}
|
||||
protected async Task DoAck(AlarmLogModel currAlarm)
|
||||
{
|
||||
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Sicuro di voler registrare ACK dell'allarme?{Environment.NewLine}[{currAlarm.ValDecoded}]"))
|
||||
return;
|
||||
await Task.Delay(1);
|
||||
}
|
||||
|
||||
[Inject]
|
||||
protected IJSRuntime JSRuntime { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
@@ -101,7 +101,7 @@ namespace MP_TAB_SERV.Components
|
||||
decimal denom = (decimal)CountData.numPzOrd / 100; //CountData.numPzProd > CountData.numPzOrd ? (decimal)CountData.numPzProd / 100 : (decimal)CountData.numPzOrd / 100;
|
||||
denom = denom == 0 ? 1 : denom;
|
||||
// calcolo se sono nel caso prod < ordinati o se sono andato OVER
|
||||
if (CountData.numPzProd < CountData.numPzOrd)
|
||||
if (CountData.numPzProd <= CountData.numPzOrd)
|
||||
{
|
||||
nGreen = (int)Math.Floor((decimal)CountData.numPzConf / denom);
|
||||
nYellow = (int)Math.Floor((decimal)(CountData.numPzProd - CountData.numPzConf) / denom);
|
||||
@@ -111,18 +111,18 @@ namespace MP_TAB_SERV.Components
|
||||
else
|
||||
{
|
||||
// green: confermati verdi
|
||||
// devo verificare SE ne ho confermati meno che ordinati o meno...
|
||||
nGreen = (int)Math.Floor((decimal)CountData.numPzConf / denom);
|
||||
// gialli: extra prodotti fino a 100...
|
||||
if (CountData.numPzConf < CountData.numPzOrd)
|
||||
{
|
||||
nGreen = (int)Math.Floor((decimal)CountData.numPzConf / denom);
|
||||
nYellow = (int)Math.Floor((decimal)(CountData.numPzProd - CountData.numPzConf) / denom);
|
||||
}
|
||||
else
|
||||
{
|
||||
nGreen = (int)Math.Floor((decimal)CountData.numPzOrd / denom);
|
||||
nYellow = 100 - nGreen;
|
||||
}
|
||||
// blu: quanti sono "extra" e da confermare
|
||||
nBlue = (int)Math.Floor((decimal)(CountData.numPzProd) / denom) - nGreen;
|
||||
nYellow = 0;
|
||||
nBlue = (int)Math.Floor((decimal)(CountData.numPzProd - CountData.numPzOrd) / denom);
|
||||
nGray = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<div class="text-center text-warning align-middle">
|
||||
<div class="progress" style="height:2rem;">
|
||||
<div class="progress-bar progress-bar-striped bg-primary progress-bar-animated" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100" style="width: 75%;">
|
||||
<b>ELABORAZIONE IN CORSO</b>
|
||||
<b>@Message</b>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -15,5 +15,6 @@
|
||||
@code {
|
||||
[Parameter]
|
||||
public bool IsProcessing { get; set; } = false;
|
||||
|
||||
[Parameter]
|
||||
public string Message { get; set; } = "ELABORAZIONE IN CORSO";
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>6.16.2310.1208</Version>
|
||||
<Version>6.16.2310.1211</Version>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>MP_TAB_SERV</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MAPOSPEC </i>
|
||||
<h4>Versione: 6.16.2310.1208</h4>
|
||||
<h4>Versione: 6.16.2310.1211</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.16.2310.1208
|
||||
6.16.2310.1211
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>6.16.2310.1208</version>
|
||||
<version>6.16.2310.1211</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-TAB-SERV/stable/LAST/MP-TAB-SERV.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-TAB-SERV/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
@@ -52,6 +52,52 @@ namespace MP.Data.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registrato ACK allarme
|
||||
/// </summary>
|
||||
/// <param name="alarmLogId">Id Allarme</param>
|
||||
/// <param name="dtAck">Data Ack</param>
|
||||
/// <param name="userAck">User Ack</param>
|
||||
/// <returns></returns>
|
||||
public bool AlarmLogSetAck(int alarmLogId, DateTime dtAck, string userAck)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
var AlarmLogId = new SqlParameter("@AlarmLogId", alarmLogId);
|
||||
var DtAck = new SqlParameter("@DtAck", dtAck);
|
||||
var UserAck = new SqlParameter("@UserAck", userAck);
|
||||
|
||||
var result = dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRaw("EXEC stp_AL_setAck @AlarmLogId, @DtAck, @UserAck", AlarmLogId, DtAck, UserAck);
|
||||
fatto = result != 0;
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registrato invio notifica allarme
|
||||
/// </summary>
|
||||
/// <param name="alarmLogId">Id Allarme</param>
|
||||
/// <param name="dtNotify">Data notifica</param>
|
||||
/// <returns></returns>
|
||||
public bool AlarmLogSetNotify(int alarmLogId, DateTime dtNotify)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
var AlarmLogId = new SqlParameter("@AlarmLogId", alarmLogId);
|
||||
var DtNotify = new SqlParameter("@DtNotify", dtNotify);
|
||||
|
||||
var result = dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRaw("EXEC stp_AL_setNotify @AlarmLogId, @DtNotify", AlarmLogId, DtNotify);
|
||||
fatto = result != 0;
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce l'anagrafica EVENTI per intero
|
||||
/// </summary>
|
||||
|
||||
@@ -13,8 +13,7 @@ using System.Threading.Tasks;
|
||||
namespace MP.Data.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementazione MailKit come descritto qui
|
||||
/// https://blog.christian-schou.dk/send-emails-with-asp-net-core-with-mailkit/
|
||||
/// Implementazione MailKit come descritto qui https://blog.christian-schou.dk/send-emails-with-asp-net-core-with-mailkit/
|
||||
/// </summary>
|
||||
public class MailService : IMailService
|
||||
{
|
||||
@@ -131,8 +130,8 @@ namespace MP.Data.Services
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly MailKitMailSettings _settings;
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private readonly MailKitMailSettings _settings;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
|
||||
@@ -100,6 +100,19 @@ namespace MP.Data.Services
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
public string CognomeNome
|
||||
{
|
||||
get
|
||||
{
|
||||
string answ = "";
|
||||
//int answ = -1;
|
||||
if (_rigaOper != null)
|
||||
{
|
||||
answ = $"{_rigaOper.Cognome} {_rigaOper.Nome}";
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
public AnagOperatoriModel? RigaOper
|
||||
{
|
||||
|
||||
@@ -68,6 +68,69 @@ namespace MP.Data.Services
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Elenco allarmi macchina
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina">Macchina</param>
|
||||
/// <param name="dtFrom">Inizio periodo</param>
|
||||
/// <param name="dtTo">Fine periodo</param>
|
||||
/// <param name="showMulti"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<AlarmLogModel>> AlarmLogListFilt(string idxMacchina, DateTime dtFrom, DateTime dtTo, bool showMulti)
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<AlarmLogModel>? result = new List<AlarmLogModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:AlarmLog:{idxMacchina}:{dtFrom:yyyyMMdd-HHmmss}:{dtTo::yyyyMMdd-HHmmss}:{showMulti}";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<AlarmLogModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await Task.FromResult(dbTabController.AlarmLogListFilt(idxMacchina, dtFrom, dtTo, showMulti));
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, UltraFastCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<AlarmLogModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"AlarmLogListFilt | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registrato ACK allarme
|
||||
/// </summary>
|
||||
/// <param name="alarmLogId">Id Allarme</param>
|
||||
/// <param name="dtAck">Data Ack</param>
|
||||
/// <param name="userAck">User Ack</param>
|
||||
/// <returns></returns>
|
||||
public bool AlarmLogSetAck(int alarmLogId, DateTime dtAck, string userAck)
|
||||
{
|
||||
bool answ = dbTabController.AlarmLogSetAck(alarmLogId, dtAck, userAck);
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registrato ACK allarme
|
||||
/// </summary>
|
||||
/// <param name="alarmLogId">Id Allarme</param>
|
||||
/// <param name="dtNotify">Data Ack</param>
|
||||
/// <returns></returns>
|
||||
public bool AlarmLogSetNotify(int alarmLogId, DateTime dtNotify)
|
||||
{
|
||||
bool answ = dbTabController.AlarmLogSetNotify(alarmLogId, dtNotify);
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco completo EVENTI
|
||||
/// </summary>
|
||||
@@ -523,6 +586,39 @@ namespace MP.Data.Services
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Elenco PODL macchina </summary> <param name="idxMacchina">Macchina</param> <param
|
||||
/// name="onlyFree">Solo disponibili (1) o tutte (0)</param> <param
|
||||
/// name="codGruppo">Gruppo</param> <returns></returns>
|
||||
public async Task<List<PODLExpModel>> ListPODLByMacc(string idxMacchina, bool onlyFree, bool onlyDirect)
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<PODLExpModel>? result = new List<PODLExpModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:PODL:{idxMacchina}:{onlyFree}:{onlyDirect}";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<PODLExpModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await Task.FromResult(dbTabController.ListPODLByMacc(idxMacchina, onlyFree, onlyDirect));
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<PODLExpModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"ListPODLByMacc | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua ricalcolo MSE x macchina indicata
|
||||
/// </summary>
|
||||
@@ -890,80 +986,6 @@ namespace MP.Data.Services
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco allarmi macchina
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina">Macchina</param>
|
||||
/// <param name="dtFrom">Inizio periodo</param>
|
||||
/// <param name="dtTo">Fine periodo</param>
|
||||
/// <param name="showMulti"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<AlarmLogModel>> AlarmLogListFilt(string idxMacchina, DateTime dtFrom, DateTime dtTo, bool showMulti)
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<AlarmLogModel>? result = new List<AlarmLogModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:AlarmLog:{idxMacchina}:{dtFrom:yyyyMMdd-HHmmss}:{dtTo::yyyyMMdd-HHmmss}:{showMulti}";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<AlarmLogModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await Task.FromResult(dbTabController.AlarmLogListFilt(idxMacchina, dtFrom, dtTo, showMulti));
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, UltraFastCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<AlarmLogModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"AlarmLogListFilt | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// Elenco PODL macchina
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina">Macchina</param>
|
||||
/// <param name="onlyFree">Solo disponibili (1) o tutte (0)</param>
|
||||
/// <param name="codGruppo">Gruppo</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<PODLExpModel>> ListPODLByMacc(string idxMacchina, bool onlyFree, bool onlyDirect)
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<PODLExpModel>? result = new List<PODLExpModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:PODL:{idxMacchina}:{onlyFree}:{onlyDirect}";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<PODLExpModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await Task.FromResult(dbTabController.ListPODLByMacc(idxMacchina, onlyFree, onlyDirect));
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<PODLExpModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"ListPODLByMacc | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Toggle stato turno
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user