Update display allarme
This commit is contained in:
@@ -1,5 +1,72 @@
|
||||
<h3>AlarmsMan</h3>
|
||||
|
||||
@code {
|
||||
<EgwCoreLib.Razor.PeriodoSel CurrPeriodo=CurrPeriodo E_PeriodoSel="SetPeriodo"></EgwCoreLib.Razor.PeriodoSel>
|
||||
|
||||
@if (isProcessing)
|
||||
{
|
||||
<EgwCoreLib.Razor.LoadingData></EgwCoreLib.Razor.LoadingData>
|
||||
}
|
||||
else
|
||||
{
|
||||
<table class="table table-dark table-sm table-striped">
|
||||
<thead>
|
||||
<tr class="text-start1">
|
||||
<th>
|
||||
Elenco Allarmi
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in ListPaged)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<div class="row">
|
||||
<div class="col-6 col-md-8 small">
|
||||
<div>
|
||||
Mem: <b>@($"{item.MemAddress}.{@item.MemIndex}")</b>
|
||||
</div>
|
||||
<div class="text-danger">
|
||||
<b>@item.ValDecoded</b>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 col-md-4 text-end small">
|
||||
<div class="d-flex flex-row-reverse">
|
||||
<div class="px-1">
|
||||
<div class="text-truncate">
|
||||
@($"{item.DtRif:ddd dd.MM.yy HH:mm:ss}") <i class="fa fa-clock-o" aria-hidden="true"></i>
|
||||
</div>
|
||||
<div class="text-truncate">
|
||||
@($"{item.Duration:N2} min") <i class="fa fa-hourglass-end" aria-hidden="true"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-1">
|
||||
@if (!string.IsNullOrEmpty(item.UserAck))
|
||||
{
|
||||
<b>@item.UserAck</b> <i class="fa fa-user" aria-hidden="true"></i>
|
||||
}
|
||||
</div>
|
||||
<div class="px-1">
|
||||
@if (item.ReqNotify != 0)
|
||||
{
|
||||
<button class="btn btn-sm btn-primary py-0" @onclick="() => SendNotify(item)">Invia <i class="fa fa-envelope" aria-hidden="true"></i></button>
|
||||
}
|
||||
@if (item.ReqAck != 0)
|
||||
{
|
||||
<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>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<EgwCoreLib.Razor.DataPager currPage="@PageNum" PageSize="@NumRecPage" totalCount="@TotalCount" numPageChanged="SavePage" numRecordChanged="SaveNumRec"></EgwCoreLib.Razor.DataPager>
|
||||
}
|
||||
@@ -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
|
||||
|
||||
/// <summary>
|
||||
/// Aggiorno valori produzione alla data richiesta...
|
||||
/// </summary>
|
||||
/// <param name="newDate"></param>
|
||||
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<AlarmLogModel> ListComplete { get; set; } = new List<AlarmLogModel>();
|
||||
|
||||
protected List<AlarmLogModel> ListPaged { get; set; } = new List<AlarmLogModel>();
|
||||
|
||||
[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<bool>("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<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!;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>6.16.2310.1116</Version>
|
||||
<Version>6.16.2310.1119</Version>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>MP_TAB_SERV</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<div>
|
||||
<MachineBlock RecMSE="CurrMSE" FullMode="false"></MachineBlock>
|
||||
</div>
|
||||
<AlarmsMan></AlarmsMan>
|
||||
<MachineBlock RecMSE="CurrMSE" FullMode="false"></MachineBlock>
|
||||
<AlarmsMan RecMSE="CurrMSE"></AlarmsMan>
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MAPOSPEC </i>
|
||||
<h4>Versione: 6.16.2310.1116</h4>
|
||||
<h4>Versione: 6.16.2310.1119</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.16.2310.1116
|
||||
6.16.2310.1119
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>6.16.2310.1116</version>
|
||||
<version>6.16.2310.1119</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>
|
||||
|
||||
@@ -25,6 +25,33 @@ namespace MP.Data.Controllers
|
||||
|
||||
#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 List<AlarmLogModel> AlarmLogListFilt(string idxMacchina, DateTime dtFrom, DateTime dtTo, bool showMulti)
|
||||
{
|
||||
List<AlarmLogModel> dbResult = new List<AlarmLogModel>();
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce l'anagrafica EVENTI per intero
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
#nullable disable
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,8 @@ namespace MP.Data
|
||||
|
||||
#region Public Properties
|
||||
|
||||
|
||||
public virtual DbSet<AlarmLogModel> DbSetAlarmLog { get; set; }
|
||||
public virtual DbSet<StatsAnagArticoli> DbSetStatArticoli { get; set; }
|
||||
public virtual DbSet<AnagArticoli> DbSetArticoli { get; set; }
|
||||
public virtual DbSet<AnagEventiModel> DbSetAnagEventi { get; set; }
|
||||
|
||||
@@ -890,6 +890,44 @@ 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>
|
||||
|
||||
Reference in New Issue
Block a user