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

This commit is contained in:
Samuele Locatelli
2022-09-21 09:22:12 +02:00
15 changed files with 471 additions and 151 deletions
+2
View File
@@ -1,10 +1,12 @@
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using MP.Data.DatabaseModels;
using NLog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
namespace MP.Data.Controllers
+14
View File
@@ -0,0 +1,14 @@
using MP.Data.DatabaseModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MP.Data.DTO
{
public class DossierFluxLogDTO
{
public List<FluxLog> ODL { get; set; } = new List<FluxLog>();
}
}
-1
View File
@@ -23,7 +23,6 @@ namespace MP.Data.DatabaseModels
public string Valore { get; set; }
#endregion Public Properties
}
}
+8 -30
View File
@@ -1,24 +1,11 @@
<div class="d-flex justify-content-between">
<div class="d-flex justify-content-between">
<div class="px-0 py-1">
@if (!liveUpdate)
{
<button class="btn btn-secondary" type="button" @onclick="() => toggleUpdate()">
<small>@lastUpdate</small>
</button>
}
else
{
<button class="btn btn-primary" type="button" @onclick="() => toggleUpdate()">
<span class="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span>
Valori live
</button>
}
</div>
<div class="px-0">
<div class="d-flex justify-content-end">
@if (showEditPar)
<div class="px-0 col-6">
<div class="">
@*@if (showEditPar)
{
<div class="px-0 input-group py-1" id="basic-addon1">
<button class="btn btn-primary" @onclick="() => toggleParams()"> <i class="fa-solid fa-arrow-right"></i></button>
@@ -64,7 +51,7 @@
<div class="px-2 py-1">
<button class="btn btn-primary" @onclick="() => toggleParams()"><i class="fa-solid fa-arrow-left"></i></button>
</div>
}
}*@
<div class="px-0 py-1">
<div class="px-2 input-group" id="basic-addon1">
<label class="input-group-text" for="macchina" title="Selezionare la macchina"><i class="fa-solid fa-hard-drive"></i></label>
@@ -78,17 +65,8 @@
}
}
</select>
<label class="input-group-text" for="flusso" title="Selezionare il tipo di flusso"><i class="fa-solid fa-sliders"></i></label>
<select @bind="@selFlux" class="form-select" id="flusso" title="Selezionare il tipo di flusso">
<option value="*">--- Tutti ---</option>
@if (ListFlux != null)
{
foreach (var item in ListFlux)
{
<option value="@item">@item</option>
}
}
</select>
<label class="input-group-text" for="DtRef" title="Selezionare il tipo di flusso"><i class="fa-solid fa-calendar-check"></i></label>
<input @bind="@selDtRef" id="DtRef" class="form-control" type="datetime-local" />
</div>
</div>
</div>
+20 -72
View File
@@ -15,6 +15,7 @@ using MP.SPEC;
using MP.SPEC.Shared;
using MP.SPEC.Components;
using MP.SPEC.Data;
using MP.Data.DatabaseModels;
namespace MP.SPEC.Components
{
@@ -23,78 +24,35 @@ namespace MP.SPEC.Components
#region Public Properties
[Parameter]
public EventCallback<SelectFluxParams> FilterChanged { get; set; }
public EventCallback<SelectDossierParams> FilterChanged { get; set; }
[Parameter]
public SelectFluxParams SelFilter { get; set; } = null!;
public SelectDossierParams SelFilterDossier { get; set; } = null!;
#endregion Public Properties
#region Protected Fields
protected string lastUpdate
{
get => SelFilter.lastUpdate;
set => SelFilter.lastUpdate = value;
}
#endregion Protected Fields
#region Protected Properties
protected bool liveUpdate
{
get => SelFilter.LiveUpdate;
set
{
if (!SelFilter.LiveUpdate.Equals(value))
{
SelFilter.LiveUpdate = value;
if (!value)
{
SelFilter.CurrPage = 0;
}
reportChange();
}
}
}
[Inject]
protected MpDataService MDService { get; set; } = null!;
protected string selFlux
{
get
{
return SelFilter.CodFlux;
}
set
{
if (!SelFilter.CodFlux.Equals(value))
{
SelFilter.CurrPage = 1;
SelFilter.CodFlux = value;
StateHasChanged();
Task.Delay(1);
reportChange();
}
}
}
protected string selMacchina
{
get
{
return SelFilter.IdxMacchina;
return SelFilterDossier.IdxMacchina;
}
set
{
if (!SelFilter.IdxMacchina.Equals(value))
if (!SelFilterDossier.IdxMacchina.Equals(value))
{
SelFilter.CurrPage = 1;
SelFilter.IdxMacchina = value;
SelFilter.CodFlux = "*";
ListFlux = MDService.ParametriGetFilt(selMacchina).Result;
SelFilterDossier.CurrPage = 1;
SelFilterDossier.IdxMacchina = value;
StateHasChanged();
Task.Delay(1);
reportChange();
@@ -102,36 +60,36 @@ namespace MP.SPEC.Components
}
}
protected int selMaxRecord
{
get
{
return SelFilter.MaxRecord;
return SelFilterDossier.MaxRecord;
}
set
{
if (!SelFilter.MaxRecord.Equals(value))
if (!SelFilterDossier.MaxRecord.Equals(value))
{
SelFilter.MaxRecord = value;
SelFilterDossier.MaxRecord = value;
reportChange();
}
}
}
protected int selTempoAgg
protected DateTime selDtRef
{
get
{
return SelFilter.TempoAgg / 1000;
return SelFilterDossier.DtRef;
}
set
{
int tempoMS = value * 1000;
if (!SelFilter.TempoAgg.Equals(tempoMS))
if (!SelFilterDossier.DtRef.Equals(value))
{
SelFilter.TempoAgg = tempoMS;
SelFilterDossier.DtRef = value;
reportChange();
}
}
@@ -143,10 +101,10 @@ namespace MP.SPEC.Components
protected override async Task OnInitializedAsync()
{
SelFilter = new SelectFluxParams();
SelFilterDossier = new SelectDossierParams();
ListMacchine = await MDService.MacchineWithFlux();
ListFlux = await MDService.ParametriGetFilt(selMacchina);
await FilterChanged.InvokeAsync(SelFilter);
ListDossier = await MDService.DossiersGetLastFilt(selMacchina, selDtRef, selMaxRecord);
await FilterChanged.InvokeAsync(SelFilterDossier);
}
protected void toggleParams()
@@ -154,21 +112,11 @@ namespace MP.SPEC.Components
showEditPar = !showEditPar;
}
protected async Task toggleUpdate()
{
liveUpdate = !liveUpdate;
await Task.Delay(1);
if (!liveUpdate)
{
lastUpdate = $"Last Snapshot: {DateTime.Now:yyyy/MM/dd HH:mm:ss}";
}
}
#endregion Protected Methods
#region Private Fields
private List<string>? ListFlux = null;
private List<Dossiers>? ListDossier = null;
private List<string>? ListMacchine = null;
#endregion Private Fields
@@ -183,7 +131,7 @@ namespace MP.SPEC.Components
private void reportChange()
{
FilterChanged.InvokeAsync(SelFilter);
FilterChanged.InvokeAsync(SelFilterDossier);
}
#endregion Private Methods
+100 -6
View File
@@ -1,9 +1,103 @@
<h3>ListDossiers</h3>
@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="d-flex justify justify-content-between">
<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><i class="fa-solid fa-hard-drive"></i> Macchina</th>
<th><i class="fa-regular fa-calendar-days"></i> Data</th>
<th><i class="fa-solid fa-sliders"></i> ODL</th>
<th><i class="fa-solid fa-sliders"></i> DATA TYPE</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var record in ListRecords)
{
<tr class="@checkSelect(@record)">
<td>
<button class="btn btn-primary btn-sm" @onclick="() => selRecord(record)"><i class="fa-solid fa-magnifying-glass"></i></button>
</td>
<td>
@record.IdxMacchina
</td>
<td>
@record.DtRif
</td>
<td>
@record.IdxODL
</td>
<td>
@record.DataType
</td>
</tr>
}
</tbody>
</table>
@if (!visualizzaFlux)
{
if(listaFlux == null)
{
<div class="alert alert-warning text-center display-4">Nessun record trovato</div>
}
else
{
<table class="table table-sm table-striped small" style="border: 1px solid;">
<thead>
<tr>
<th><i class="fa-solid fa-hard-drive"></i> Macchina</th>
<th><i class="fa-regular fa-calendar-days"></i> Data</th>
<th><i class="fa-solid fa-sliders"></i> ODL</th>
<th><i class="fa-solid fa-sliders"></i> Valore</th>
<th class="d-flex justify-content-end"><button class="btn btn-primary btn-sm py-0 " @onclick="() => unToggleTableFlux()"><i class="fa-solid fa-xmark"></i></button></th>
</tr>
</thead>
<tbody>
@foreach (var record in listaFlux)
{
<tr>
<td>
@record.IdxMacchina
</td>
<td>
@record.dtEvento
</td>
<td>
@record.CodFlux
</td>
<td style="text-align: right;">
<b>@record.Valore</b>
</td>
<td>
</td>
</tr>
}
</tbody>
</table>
}
}
</div>
</div>
}
<ul>
<li>copiare da ListParameters</li>
<li>metodo dati: DossiersGetLastFilt</li>
<li>metodo dati x ora non fa cache redis (se vuoi provare...)</li>
</ul>
+237
View File
@@ -14,10 +14,247 @@ using Microsoft.JSInterop;
using MP.SPEC;
using MP.SPEC.Shared;
using MP.SPEC.Components;
using MP.Data.DatabaseModels;
using MP.SPEC.Data;
using System.Diagnostics;
namespace MP.SPEC.Components
{
public partial class ListDossiers
{
#region Public Properties
[Parameter]
public SelectDossierParams SelFilter { get; set; } = null!;
[Parameter]
public EventCallback<int> TotRecordChanged { get; set; }
[Parameter]
public EventCallback<Dossiers> RecordSel { get; set; }
#endregion Public Properties
#region Public Methods
public string checkSelect(Dossiers recordSel)
{
string answ = "";
if (currRecord != null)
{
try
{
answ = (currRecord.IdxMacchina == recordSel.IdxMacchina && currRecord.DtRif == recordSel.DtRif) ? "table-info" : "";
}
catch
{ }
}
return answ;
}
#if false
public void Dispose()
{
aTimer.Elapsed -= ElapsedTimer;
MessageService.EA_PageUpdated -= MessageService_EA_PageUpdated;
MessageService.EA_SearchUpdated -= OnSeachUpdated;
aTimer.Stop();
aTimer.Dispose();
}
#endif
//public void ElapsedTimer(object? source, System.Timers.ElapsedEventArgs e)
//{
// if (!isLoading && LiveUpdate)
// {
// aTimer.Stop();
// // inizio misura esecuzione
// Stopwatch stopWatch = new Stopwatch();
// stopWatch.Start();
// var pUpd = Task.Run(async () =>
// {
// await Task.Delay(1);
// await InvokeAsync(() => reloadData(true));
// });
// pUpd.Wait();
// // misuro tempo esecuzione
// stopWatch.Stop();
// TimeSpan ts = stopWatch.Elapsed;
// int deltaTime = RefreshPeriod - (int)ts.TotalMilliseconds;
// aTimer.Interval = deltaTime > 100 ? deltaTime : 100;
// aTimer.Start();
// }
//}
public async Task reloadData(bool setChanged)
{
isLoading = true;
SearchRecords = await MDService.DossiersGetLastFilt(SelMacchina, SelDtRef, MaxRecord);
totalCount = SearchRecords.Count;
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
await Task.Delay(1);
if (setChanged)
{
await InvokeAsync(() => StateHasChanged());
}
isLoading = false;
}
//public void StartTimer()
//{
// //int.TryParse(Configuration["ReloadStatusTimer"], out tOutPeriod);
// aTimer = new System.Timers.Timer(RefreshPeriod);
// aTimer.Elapsed += ElapsedTimer;
// aTimer.Enabled = true;
// //aTimer.AutoReset = true;
// aTimer.Start();
//}
#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!;
//protected int RefreshPeriod
//{
// get => SelFilter.TempoAgg;
//}
//protected int RefreshPeriod { get; set; } = 5000;
#endregion Protected Properties
#region Protected Methods
protected override async Task OnInitializedAsync()
{
MessageService.EA_PageUpdated += MessageService_EA_PageUpdated;
MessageService.EA_SearchUpdated += OnSeachUpdated;
ListRecords = await MDService.DossiersGetLastFilt(SelMacchina, SelDtRef, MaxRecord);
await reloadData();
}
protected async Task selRecord(Dossiers selRec)
{
currRecord = selRec;
await RecordSel.InvokeAsync(selRec);
listaFlux = MDService.convertToFluxLog(selRec.Valore);
toggleTableFlux();
}
protected async void OnSeachUpdated()
{
await InvokeAsync(() =>
{
//currPage = 1;
StateHasChanged();
});
}
protected async Task UpdateData()
{
currRecord = null;
await reloadData(true);
}
#endregion Protected Methods
#region Private Fields
//private static System.Timers.Timer aTimer = null!;
private int _totalCount = 0;
private Dossiers? currRecord = null;
private List<Dossiers>? ListRecords;
private List<Dossiers>? SearchRecords;
private List<FluxLog>? listaFlux { get; set; } = null;
#endregion Private Fields
#region Private Properties
private int currPage
{
get => MessageService.currPage;
set => MessageService.currPage = value;
}
private bool visualizzaFlux { get; set; } = true;
private bool isLoading { get; set; } = false;
private int MaxRecord
{
get => SelFilter.MaxRecord;
}
private int numRecord
{
get => MessageService.numRecord;
set => MessageService.numRecord = value;
}
private string SelMacchina
{
get => SelFilter.IdxMacchina;
}
private DateTime SelDtRef
{
get => SelFilter.DtRef;
}
private int totalCount
{
get => _totalCount;
set
{
if (_totalCount != value)
{
_totalCount = value;
TotRecordChanged.InvokeAsync(value);
}
}
}
#endregion Private Properties
#region Private Methods
private async void MessageService_EA_PageUpdated()
{
await reloadData();
}
private async Task reloadData()
{
isLoading = true;
SearchRecords = await MDService.DossiersGetLastFilt(SelMacchina, SelDtRef, MaxRecord);
totalCount = SearchRecords.Count;
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
await Task.Delay(1);
await InvokeAsync(() => StateHasChanged());
isLoading = false;
}
private async Task toggleTableFlux()
{
visualizzaFlux = false;
await Task.Delay(1);
}
private async Task unToggleTableFlux()
{
visualizzaFlux = true;
await Task.Delay(1);
}
#endregion Private Methods
}
}
+13 -7
View File
@@ -1,6 +1,7 @@
using MP.Data;
using MP.Data.Conf;
using MP.Data.DatabaseModels;
using MP.Data.DTO;
using Newtonsoft.Json;
using NLog;
using StackExchange.Redis;
@@ -290,8 +291,7 @@ namespace MP.SPEC.Data
/// <returns></returns>
public async Task<List<Dossiers>> DossiersGetLastFilt(string IdxMacchina, DateTime DtRef, int MaxRec)
{
#if false
List<string>? result = new List<string>();
List<Dossiers>? result = new List<Dossiers>();
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string readType = "DB";
@@ -300,27 +300,33 @@ namespace MP.SPEC.Data
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
{
result = JsonConvert.DeserializeObject<List<string>>($"{rawData}");
result = JsonConvert.DeserializeObject<List<Dossiers>>($"{rawData}");
readType = "REDIS";
}
else
{
result = await Task.FromResult(dbController.ParametriGetFilt(IdxMacchina));
result = await Task.FromResult(dbController.DossiersGetLastFilt(IdxMacchina, DtRef, MaxRec));
// serializzp e salvo...
rawData = JsonConvert.SerializeObject(result);
redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
}
if (result == null)
{
result = new List<string>();
result = new List<Dossiers>();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"ParametriGetFilt | Read from {readType}: {ts.TotalMilliseconds}ms");
return result;
#endif
return await Task.FromResult(dbController.DossiersGetLastFilt(IdxMacchina, DtRef, MaxRec));
//return await Task.FromResult(dbController.DossiersGetLastFilt(IdxMacchina, DtRef, MaxRec));
}
public List<FluxLog> convertToFluxLog(string Valore)
{
//string valStriped = Valore.Substring(7, Valore.Length - 8);
//var result = JsonConvert.DeserializeObject<List<FluxLog>>(valStriped);
var result = JsonConvert.DeserializeObject<DossierFluxLogDTO>(Valore);
return result.ODL;
}
/// <summary>
+68
View File
@@ -0,0 +1,68 @@
namespace MP.SPEC.Data
{
public class SelectDossierParams
{
#region Public Constructors
public SelectDossierParams()
{ }
#endregion Public Constructors
#region Public Properties
/// <summary>
        /// Inizializzazione con periodo e arrotondamento
        /// </summary>
        /// <param name="minRound"></param>
        /// <param name="numDayPrev"></param>
        /// <returns></returns>
        public static DateTime Init(int minRound)
{
TimeSpan DayElapsed = DateTime.Now.Subtract(DateTime.Today);
int minDay = (int)(DayElapsed.TotalMinutes / minRound) * minRound;
DateTime endRounded = DateTime.Today.AddMinutes(minDay);
return endRounded;
}
public string IdxMacchina { get; set; } = "*";
public int MaxRecord { get; set; } = 100;
public DateTime DtRef { get; set; } = Init(3);
public int CurrPage { get; set; } = 1;
#endregion Public Properties
#region Public Methods
public override bool Equals(object obj)
{
if (!(obj is SelectDossierParams item))
return false;
if (IdxMacchina != item.IdxMacchina)
return false;
if (MaxRecord != item.MaxRecord)
return false;
if (DtRef != item.DtRef)
return false;
if (CurrPage != item.CurrPage)
return false;
//if (lastUpdate != item.lastUpdate)
// return false;
return true;
}
public override int GetHashCode()
{
return base.GetHashCode();
}
#endregion Public Methods
}
}
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP.SPEC</RootNamespace>
<Version>6.15.2209.2009</Version>
<Version>6.15.2209.2108</Version>
</PropertyGroup>
<ItemGroup>
+3 -3
View File
@@ -14,7 +14,7 @@
}
else
{
<ParamsFilter FilterChanged="updateFilter"></ParamsFilter>
<DossiersFilter FilterChanged="updateFilter"></DossiersFilter>
}
</div>
</div>
@@ -27,11 +27,11 @@
else
{
@*<ListPARAMS SelFilter="@currFilter" TotRecordChanged="@updateTotal"></ListPARAMS>*@
<ListDossiers></ListDossiers>
<ListDossiers SelFilter="@currFilter" TotRecordChanged="updateTotal"></ListDossiers>
}
</div>
<div class="card-footer py-1">
<DataPager @ref="pagerODL" PageSize="numRecord" currPage="currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" totalCount="totalCount" showLoading="isLoading" />
<DataPager @ref="pagerODL" PageSize="numRecord" currPage="currPage" numRecordChanged="ForceReload" totalCount="totalCount" showLoading="isLoading" />
</div>
</div>
+2 -28
View File
@@ -26,14 +26,6 @@ namespace MP.SPEC.Pages
numRecord = newNum;
}
protected void ForceReloadPage(int newNum)
{
currPage = newNum;
currFilter.lastUpdate = $"Last Snapshot: {DateTime.Now:yyyy/MM/dd HH:mm:ss}";
currFilter.LiveUpdate = (currPage == 1);
StateHasChanged();
}
protected override async Task OnInitializedAsync()
{
isLoading = true;
@@ -45,20 +37,11 @@ namespace MP.SPEC.Pages
await Task.Delay(1);
var modFilter = currFilter;
modFilter.CurrPage = 1;
modFilter.LiveUpdate = (currPage == 1);
currFilter = modFilter;
await Task.Delay(1);
isFiltering = false;
}
protected async Task pgResetReq(bool doReset)
{
if (doReset)
{
await pagerODL.resetCurrPage();
}
}
protected void updateTotal(int newTotCount)
{
totalCount = newTotCount;
@@ -68,7 +51,7 @@ namespace MP.SPEC.Pages
#region Private Properties
private SelectFluxParams currFilter { get; set; } = new SelectFluxParams();
private SelectDossierParams currFilter { get; set; } = new SelectDossierParams();
private int currPage
{
@@ -91,21 +74,12 @@ namespace MP.SPEC.Pages
#region Private Methods
private async Task updateFilter(SelectFluxParams newParams)
private async Task updateFilter(SelectDossierParams newParams)
{
isFiltering = false;
isLoading = true;
await Task.Delay(1);
currPage = 1;
if (newParams.CurrPage == 0)
{
newParams.CurrPage = 1;
newParams.LiveUpdate = false;
}
else
{
newParams.LiveUpdate = (currPage == 1);
}
await Task.Delay(1);
await InvokeAsync(() => StateHasChanged());
currFilter = newParams;
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 6.15.2209.2009</h4>
<h4>Versione: 6.15.2209.2108</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
6.15.2209.2009
6.15.2209.2108
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.15.2209.2009</version>
<version>6.15.2209.2108</version>
<url>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>