Merge remote-tracking branch 'origin/Feature/ParameterDataMethods' into develop

This commit is contained in:
Samuele Locatelli
2022-09-14 16:56:57 +02:00
12 changed files with 511 additions and 44 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>6.15.2207.2109</Version>
<Version>6.15.2209.1411</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MON MAPO</i>
<h4>Versione: 6.15.2207.2109</h4>
<h4>Versione: 6.15.2209.1411</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
6.15.2207.2109
6.15.2209.1411
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.15.2207.2109</version>
<version>6.15.2209.1411</version>
<url>https://nexus.steamware.net/repository/SWS/MP-MON/stable/LAST/MP.Mon.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-MON/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
-7
View File
@@ -38,13 +38,6 @@ namespace MP.SPEC.Components
#region Protected Methods
protected override void OnInitialized()
{
var currAssembly = typeof(Program).Assembly.GetName();
version = currAssembly.Version != null ? currAssembly.Version : new Version();
StartTimer();
}
#endregion Protected Methods
#region Private Fields
+62
View File
@@ -0,0 +1,62 @@
@using MP.SPEC.Components
@using MP.SPEC.Data
@if (ListRecords == null)
{
<LoadingData></LoadingData>
}
else if (totalCount == 0)
{
<div class="alert alert-warning text-center display-4">Nessun record trovato</div>
}
else
{
<div class="row">
<div class="col-12">
<table class="table table-sm table-striped small">
<thead>
<tr>
<th>
@*<button @onclick="() => resetSel()" class="btn btn-primary btn-sm"><i class="bi bi-arrow-counterclockwise"></i></button>*@
</th>
<th>Data</th>
<th>Macchina</th>
<th>Flusso</th>
<th style="text-align: right">Valore</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var record in ListRecords)
{
<tr class="@checkSelect(@record.IdxMacchina)">
<td>
@*<button @onclick="() => selRecord(record)" class="btn btn-primary btn-sm"><i class="bi bi-pencil-square"></i></button>*@
</td>
<td>
@record.dtEvento
</td>
<td>
@record.IdxMacchina
</td>
<td>
@record.CodFlux
</td>
<td style="text-align: right">
<b>@record.Valore</b>
</td>
<td>
@*@if (ArticoloDelEnabled(record.CodArticolo))
{
<button @onclick="() => deleteRecord(record)" class="btn btn-danger btn-sm"><i class="bi bi-trash-fill"></i></button>
}*@
</td>
</tr>
}
</tbody>
</table>
</div>
</div>
}
+158
View File
@@ -0,0 +1,158 @@
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using MP.Data.DatabaseModels;
using MP.SPEC.Data;
namespace MP.SPEC.Components
{
public partial class ListPARAMS
{
#region Public Properties
[Parameter]
public EventCallback<bool> PagerResetReq { get; set; }
[Parameter]
public string SelMacchina
{
get => _statoMacchina;
set
{
if (_statoMacchina != value)
{
_statoMacchina = value;
var pUpd = Task.Run(async () => await reloadData());
pUpd.Wait();
}
}
}
#endregion Public Properties
#region Public Methods
public string checkSelect(string IdxMacchina)
{
string answ = "";
if (currRecord != null)
{
try
{
answ = (currRecord.IdxMacchina == IdxMacchina) ? "table-info" : "";
}
catch
{ }
}
return answ;
}
#endregion Public Methods
#region Protected Properties
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
[Inject]
protected MpDataService MDService { get; set; } = null!;
[Inject]
protected MessageService MessageService { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected override async Task OnInitializedAsync()
{
MessageService.EA_PageUpdated += MessageService_EA_PageUpdated;
MessageService.EA_SearchUpdated += OnSeachUpdated;
await reloadData();
}
protected async void OnSeachUpdated()
{
await InvokeAsync(() =>
{
PagerResetReq.InvokeAsync(true);
//currPage = 1;
Task task = UpdateData();
StateHasChanged();
});
}
protected async Task UpdateData()
{
currRecord = null;
await reloadData();
}
#endregion Protected Methods
#region Private Fields
private string _statoMacchina = "*";
private FluxLog? currRecord = null;
private List<FluxLog>? ListRecords;
private List<FluxLog>? SearchRecords;
#endregion Private Fields
#region Private Properties
private int currPage
{
get => MessageService.currPage;
set => MessageService.currPage = value;
}
private bool isLoading { get; set; } = false;
private int numRecord
{
get => MessageService.numRecord;
set => MessageService.numRecord = value;
}
private string SearchVal
{
get => string.IsNullOrEmpty(MessageService.SearchVal) ? "*" : MessageService.SearchVal;
}
private int totalCount
{
get => MessageService.totalCount;
set => MessageService.totalCount = value;
}
#endregion Private Properties
#region Private Methods
private async void MessageService_EA_PageUpdated()
{
await reloadData();
}
public async Task reloadData()
{
isLoading = true;
SearchRecords = await MDService.FluxLogGetLastFilt(SelMacchina, "*", 300);
totalCount = SearchRecords.Count;
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
await Task.Delay(1);
await InvokeAsync(() => StateHasChanged());
isLoading = false;
}
#endregion Private Methods
}
}
+1 -1
View File
@@ -3,7 +3,7 @@
@inject MessageService AppMService
<div class="input-group input-group-sm">
<div class="input-group input-group-sm" hidden>
<input @bind-value="@searchVal" @bind-value:event="oninput" type="text" class="form-control" title="Campo Ricerca" placeholder="Ricerca [ALT-R]" accesskey="R" />
<button @onclick="reset" class="btn btn-success input-group-text"><i class="fa-solid fa-rotate"></i></button>
</div>
+16
View File
@@ -8,6 +8,8 @@
public event Action EA_SearchUpdated;
public event Action EA_MacchUpdated;
public event Action EA_ShowSearch;
public event Action EA_StatoSearch;
@@ -64,6 +66,20 @@
//}
}
}
private string _selMacchina { get; set; } = "*";
public string SelMacchina
{
get => _selMacchina;
set
{
_selMacchina = value;
if (EA_MacchUpdated != null)
{
EA_MacchUpdated?.Invoke();
}
}
}
public bool ShowSearch
{
+59 -27
View File
@@ -1,31 +1,63 @@
@page "/PARAMS"
<div class="card">
<div class="card-header table-primary">
<div class="row">
<div class="col-5">
<div class="d-flex justify-content-around">
<div class="px-2">
<h3><b>PARAMETERS</b></h3>
</div>
<button class="btn btn-primary" type="button" >
<span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span>
Valori live
</button>
<div class="px-2">
</div><div class="px-2">
</div>
</div>
</div>
<div class="col-2">
</div>
<div class="col-5">
<div class="d-flex justify-content-between">
<div class="px-2">
</div>
<div class="px-2">
<select @bind="@selMacchina" class="form-select">
<option value="*">--- Tutti ---</option>
@if (ListMacchine != null)
{
foreach (var item in ListMacchine)
{
<option value="@item.IdxMacchina">@item.IdxMacchina</option>
}
}
</select>
</div>
<div class="px-2">
<select @bind="@selFlux" class="form-select">
<option value="*">--- Tutti ---</option>
@if (ListFlux != null)
{
foreach (var item in ListFlux)
{
<option value="@item">@item</option>
}
}
</select>
</div>
</div>
</div>
</div>
</div>*@
</div>
<div class="card-body">
<ListPARAMS SelMacchina="@selMacchina"></ListPARAMS>
</div>
<div class="card-footer py-1">
<DataPager @ref="pagerODL" PageSize="numRecord" currPage="currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" totalCount="totalCount" showLoading="isLoading" />
</div>
</div>
<h3>PARAMS</h3>
<p>Appunti (eliminabili)</p>
<ul>
<li>
I parametri sono nella tabella FluxLog (in preparazione modello dati + metodi...) --> FluxLogGetLastFilt
</li>
<li>
scopo della apgina è mostrare in "quasi tempo reale" (near realtime) i parametri che si aggiornano
</li>
<li>
la pagina deve avere un card come PODL nel cui header siano mostrate elenco amchcine ed elenco parametri x mostrare tutti / solo uno (filtro)
</li>
<li>
MpDataService --> metodi per elenchi: MacchineGetAll e ParametriGetAll
</li>
<li>
il metodo principale recupera gli ultimi n record (configurabile? mostrare in alto un selettore x indicare quanti "last values" recuperare?)
</li>
<li>
il refgresh idealmente è ogni 2-5 sec (configurabile come sopra?)
</li>
</ul>
@code {
}
+206
View File
@@ -0,0 +1,206 @@
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using MP.Data.DatabaseModels;
using MP.SPEC.Components;
using MP.SPEC.Data;
namespace MP.SPEC.Pages
{
public partial class PARAMS
{
#region Protected Properties
public void Dispose()
{
//aTimer.Elapsed -= ElapsedTimer;
aTimer.Stop();
aTimer.Dispose();
}
public void ElapsedTimer(object? source, System.Timers.ElapsedEventArgs e)
{
if (!isLoading)
{
var pUpd = Task.Run(async () =>
{
await Task.Delay(1);
await InvokeAsync(() => reloadData());
});
pUpd.Wait();
}
}
public void StartTimer()
{
int tOutPeriod = 2000;
//int.TryParse(Configuration["ReloadStatusTimer"], out tOutPeriod);
aTimer = new System.Timers.Timer(tOutPeriod);
aTimer.Elapsed += ElapsedTimer;
aTimer.Enabled = true;
aTimer.Start();
}
private static System.Timers.Timer aTimer = null!;
[Inject]
protected IJSRuntime JSRuntime { get; set; }
[Inject]
protected MpDataService MDService { get; set; }
[Inject]
protected MessageService MsgService { get; set; }
[Inject]
protected NavigationManager NavManager { get; set; }
#endregion Protected Properties
#region Protected Methods
protected void ForceReload(int newNum)
{
numRecord = newNum;
}
protected void ForceReloadPage(int newNum)
{
currPage = newNum;
}
protected async Task pgResetReq(bool doReset)
{
if (doReset)
{
await pagerODL.resetCurrPage();
}
}
protected DataPager pagerODL;
protected bool reqNew = false;
/// <summary>
/// Crea nuovo record e va in editing...
/// </summary>
/// <returns></returns>
protected async Task reqNewPODL()
{
reqNew = !reqNew;
await Task.Delay(1);
}
protected override async Task OnInitializedAsync()
{
// abilito ricerca...
MsgService.ShowSearch = true;
// resetto search
MsgService.SearchVal = "";
MsgService.EA_MacchUpdated += MsgService_EA_MacchUpdated;
//ListAziende = await MDService.ElencoAziende();
//ListStati = await MDService.AnagStatiComm();
ListMacchine = await MDService.MacchineGetAll();
StartTimer();
// carico dati
await reloadData();
}
private async void MsgService_EA_MacchUpdated()
{
await reloadData();
}
private string currAziend { get; set; } = "*";
private List<MP.Data.DatabaseModels.AnagGruppi>? ListAziende;
#endregion Protected Methods
#region Private Fields
private List<MP.Data.DatabaseModels.ListValues>? ListStati;
private List<MP.Data.DatabaseModels.Macchine>? ListMacchine;
private List<string>? ListFlux;
#endregion Private Fields
#region Private Properties
private int currPage
{
get => MsgService.currPage;
set => MsgService.currPage = value;
}
private bool isLoading { get; set; } = false;
private int numRecord
{
get => MsgService.numRecord;
set => MsgService.numRecord = value;
}
private string selMacchina
{
get => MsgService.SelMacchina;
set => MsgService.SelMacchina = value;
}
private string selFlux { get; set; } = "*";
#if false
private string selStato
{
get => _selStato;
set
{
if (!_selStato.Equals(value))
{
_selStato = value;
addEnabled = selStato != "*";
////StateHasChanged();
//var pUpd = Task.Run(async () =>
//{
// //await reloadData();
// await Task.Delay(1);
// await InvokeAsync(() => StateHasChanged());
//});
//pUpd.Wait();
}
}
}
#endif
private bool addEnabled = false;
private int totalCount
{
get => MsgService.totalCount;
set => MsgService.totalCount = value;
}
#endregion Private Properties
#region Private Methods
private async Task reloadData()
{
isLoading = true;
await Task.Delay(1);
ListFlux = await MDService.ParametriGetFilt(selMacchina);
isLoading = false;
await Task.Delay(1);
}
#endregion Private Methods
}
}
+5 -5
View File
@@ -262,11 +262,11 @@ namespace MP.SPEC.Pages
#region Private Methods
private async Task navToODL()
{
await Task.Delay(1);
NavManager.NavigateTo("/ODL");
}
//private async Task navToODL()
//{
// await Task.Delay(1);
// NavManager.NavigateTo("/ODL");
//}
private async Task reloadData()
{