diff --git a/MP-TAB-SERV/Components/AlarmsMan.razor b/MP-TAB-SERV/Components/AlarmsMan.razor index f88c457c..60caf372 100644 --- a/MP-TAB-SERV/Components/AlarmsMan.razor +++ b/MP-TAB-SERV/Components/AlarmsMan.razor @@ -1,5 +1,72 @@ -

AlarmsMan

- -@code { + +@if (isProcessing) +{ + } +else +{ + + + + + + + + @foreach (var item in ListPaged) + { + + + + } + +
+ Elenco Allarmi +
+
+
+
+ Mem: @($"{item.MemAddress}.{@item.MemIndex}") +
+
+ @item.ValDecoded +
+
+
+
+
+
+ @($"{item.DtRif:ddd dd.MM.yy HH:mm:ss}") +
+
+ @($"{item.Duration:N2} min") +
+
+
+ @if (!string.IsNullOrEmpty(item.UserAck)) + { + @item.UserAck + } +
+
+ @if (item.ReqNotify != 0) + { + + } + @if (item.ReqAck != 0) + { + + } + @*
+ Invia +
*@ + @*
+ Set +
*@ +
+
+
+
+
+ +} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/AlarmsMan.razor.cs b/MP-TAB-SERV/Components/AlarmsMan.razor.cs new file mode 100644 index 00000000..6afa0fef --- /dev/null +++ b/MP-TAB-SERV/Components/AlarmsMan.razor.cs @@ -0,0 +1,140 @@ +using global::Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using MP.Data.DatabaseModels; +using MP.Data.Services; +using static EgwCoreLib.Utils.DtUtils; + +namespace MP_TAB_SERV.Components +{ + public partial class AlarmsMan + { + #region Public Properties + + [Parameter] + public MappaStatoExpl? RecMSE { get; set; } = null; + + #endregion Public Properties + + #region Public Methods + + /// + /// Aggiorno valori produzione alla data richiesta... + /// + /// + public async Task doUpdate() + { + isProcessing = true; + await Task.Delay(1); + if (!string.IsNullOrEmpty(IdxMaccSel)) + { + ListComplete = await TabDServ.AlarmLogListFilt(IdxMaccSel, CurrPeriodo.Inizio, CurrPeriodo.Fine, false); + TotalCount = ListComplete.Count; + // esegue paginazione + UpdateTable(); + } + isProcessing = false; + await Task.Delay(1); + } + + #endregion Public Methods + + #region Protected Fields + + protected bool isProcessing = false; + protected int NumRecPage = 10; + protected int PageNum = 1; + + protected int TotalCount = 0; + + #endregion Protected Fields + + #region Protected Properties + + protected List ListComplete { get; set; } = new List(); + + protected List ListPaged { get; set; } = new List(); + + [Inject] + protected TabDataService TabDServ { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected override async Task OnInitializedAsync() + { + await Task.Delay(1); + if (RecMSE != null) + { + IdxMaccSel = RecMSE.IdxMacchina; + await doUpdate(); + } + } + + protected void SaveNumRec(int newNum) + { + NumRecPage = newNum; + UpdateTable(); + } + + protected void SavePage(int newNum) + { + PageNum = newNum; + UpdateTable(); + } + + protected async Task SetMacc(string selIdxMacc) + { + isProcessing = true; + await Task.Delay(10); + IdxMaccSel = selIdxMacc; + await doUpdate(); + isProcessing = false; + await Task.Delay(10); + } + + protected async Task SetPeriodo(Periodo newPeriodo) + { + CurrPeriodo = newPeriodo; + await doUpdate(); + } + + protected void UpdateTable() + { + // esegue paginazione + if (TotalCount > NumRecPage) + { + ListPaged = ListComplete.Skip((PageNum - 1) * NumRecPage).Take(NumRecPage).ToList(); + } + else + { + ListPaged = ListComplete; + } + } + + #endregion Protected Methods + + #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("confirm", $"Sicuro di voler inviare notifica allarme?{Environment.NewLine}[{currAlarm.ValDecoded}]")) + return; + await Task.Delay(1); + } + protected async Task DoAck(AlarmLogModel currAlarm) + { + if (!await JSRuntime.InvokeAsync("confirm", $"Sicuro di voler registrare ACK dell'allarme?{Environment.NewLine}[{currAlarm.ValDecoded}]")) + return; + await Task.Delay(1); + } + + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + } +} \ No newline at end of file diff --git a/MP-TAB-SERV/MP-TAB-SERV.csproj b/MP-TAB-SERV/MP-TAB-SERV.csproj index fecadb13..395916f9 100644 --- a/MP-TAB-SERV/MP-TAB-SERV.csproj +++ b/MP-TAB-SERV/MP-TAB-SERV.csproj @@ -3,7 +3,7 @@ net6.0 enable - 6.16.2310.1116 + 6.16.2310.1119 enable MP_TAB_SERV diff --git a/MP-TAB-SERV/Pages/Alarms.razor b/MP-TAB-SERV/Pages/Alarms.razor index 2c43a4e6..f57a87a9 100644 --- a/MP-TAB-SERV/Pages/Alarms.razor +++ b/MP-TAB-SERV/Pages/Alarms.razor @@ -6,8 +6,6 @@ } else { -
- -
- + + } diff --git a/MP-TAB-SERV/Resources/ChangeLog.html b/MP-TAB-SERV/Resources/ChangeLog.html index 37e378e4..16749810 100644 --- a/MP-TAB-SERV/Resources/ChangeLog.html +++ b/MP-TAB-SERV/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 6.16.2310.1116

+

Versione: 6.16.2310.1119


Note di rilascio:
  • diff --git a/MP-TAB-SERV/Resources/VersNum.txt b/MP-TAB-SERV/Resources/VersNum.txt index 20a2dac4..c2c230f3 100644 --- a/MP-TAB-SERV/Resources/VersNum.txt +++ b/MP-TAB-SERV/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2310.1116 +6.16.2310.1119 diff --git a/MP-TAB-SERV/Resources/manifest.xml b/MP-TAB-SERV/Resources/manifest.xml index 9ea4ae96..0c40560b 100644 --- a/MP-TAB-SERV/Resources/manifest.xml +++ b/MP-TAB-SERV/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2310.1116 + 6.16.2310.1119 https://nexus.steamware.net/repository/SWS/MP-TAB-SERV/stable/LAST/MP-TAB-SERV.zip https://nexus.steamware.net/repository/SWS/MP-TAB-SERV/stable/LAST/ChangeLog.html false diff --git a/MP.Data/Controllers/MpTabController.cs b/MP.Data/Controllers/MpTabController.cs index 42a71178..75aed825 100644 --- a/MP.Data/Controllers/MpTabController.cs +++ b/MP.Data/Controllers/MpTabController.cs @@ -25,6 +25,33 @@ namespace MP.Data.Controllers #region Public Methods + /// + /// Elenco allarmi macchina + /// + /// Macchina + /// Inizio periodo + /// Fine periodo + /// + /// + public List AlarmLogListFilt(string idxMacchina, DateTime dtFrom, DateTime dtTo, bool showMulti) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina); + var DtFrom = new SqlParameter("@dtFrom", dtFrom); + var DtTo = new SqlParameter("@dtTo", dtTo); + var ShowMulti = new SqlParameter("@showMulti", showMulti); + + dbResult = dbCtx + .DbSetAlarmLog + .FromSqlRaw("EXEC stp_AL_getFilt @IdxMacchina, @dtFrom, @DtTo, @showMulti", IdxMacc, DtFrom, DtTo, ShowMulti) + .AsNoTracking() + .ToList(); + } + return dbResult; + } + /// /// Restituisce l'anagrafica EVENTI per intero /// diff --git a/MP.Data/DatabaseModels/AlarmLogModel.cs b/MP.Data/DatabaseModels/AlarmLogModel.cs new file mode 100644 index 00000000..71bd0c1b --- /dev/null +++ b/MP.Data/DatabaseModels/AlarmLogModel.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +#nullable disable +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace MP.Data.DatabaseModels +{ + [Table("AlarmLog")] + public partial class AlarmLogModel + { + #region Public Properties + + [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int AlarmLogId { get; set; } = 0; + public DateTime DtRif { get; set; } = DateTime.Now; + public decimal Duration { get; set; } = 0; + public string MachineId { get; set; } = ""; + public string MemAddress { get; set; } = ""; + public int MemIndex { get; set; } = 0; + public int StatusVal { get; set; } = 0; + public string ValDecoded { get; set; } = ""; + public DateTime DtNotify { get; set; } = DateTime.Now; + public string UserAck { get; set; } = ""; + public DateTime DtAck { get; set; } = DateTime.Now; + + [NotMapped] + public int ReqNotify + { + get => Duration > 1 && DtNotify < DtRif ? 1 : 0; + } + [NotMapped] + public int ReqAck + { + get => DtNotify > DtRif && DtAck < DtRif ? 1 : 0; + } + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP.Data/MoonProContext.cs b/MP.Data/MoonProContext.cs index 237e0da4..8b59ca5c 100644 --- a/MP.Data/MoonProContext.cs +++ b/MP.Data/MoonProContext.cs @@ -37,6 +37,8 @@ namespace MP.Data #region Public Properties + + public virtual DbSet DbSetAlarmLog { get; set; } public virtual DbSet DbSetStatArticoli { get; set; } public virtual DbSet DbSetArticoli { get; set; } public virtual DbSet DbSetAnagEventi { get; set; } diff --git a/MP.Data/Services/TabDataService.cs b/MP.Data/Services/TabDataService.cs index 4a5b154b..b1cedb4c 100644 --- a/MP.Data/Services/TabDataService.cs +++ b/MP.Data/Services/TabDataService.cs @@ -890,6 +890,44 @@ namespace MP.Data.Services return result; } + /// + /// Elenco allarmi macchina + /// + /// Macchina + /// Inizio periodo + /// Fine periodo + /// + /// + public async Task> AlarmLogListFilt(string idxMacchina, DateTime dtFrom, DateTime dtTo, bool showMulti) + { + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List? result = new List(); + // 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>($"{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(); + } + sw.Stop(); + Log.Debug($"AlarmLogListFilt | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + /// Elenco PODL macchina /// /// Macchina