diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs index 6527775b..8c27cd57 100644 --- a/MP.Data/Controllers/MpSpecController.cs +++ b/MP.Data/Controllers/MpSpecController.cs @@ -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 diff --git a/MP.Data/DTO/DossierFluxLogDTO.cs b/MP.Data/DTO/DossierFluxLogDTO.cs new file mode 100644 index 00000000..37cc8819 --- /dev/null +++ b/MP.Data/DTO/DossierFluxLogDTO.cs @@ -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 ODL { get; set; } = new List(); + } +} diff --git a/MP.Data/DatabaseModels/Dossiers.cs b/MP.Data/DatabaseModels/Dossiers.cs index 9289bd6e..23edff12 100644 --- a/MP.Data/DatabaseModels/Dossiers.cs +++ b/MP.Data/DatabaseModels/Dossiers.cs @@ -23,7 +23,6 @@ namespace MP.Data.DatabaseModels public string Valore { get; set; } - #endregion Public Properties } } \ No newline at end of file diff --git a/MP.SPEC/Components/DossiersFilter.razor b/MP.SPEC/Components/DossiersFilter.razor index 4efc679a..5aae30d9 100644 --- a/MP.SPEC/Components/DossiersFilter.razor +++ b/MP.SPEC/Components/DossiersFilter.razor @@ -1,24 +1,11 @@ - -
+
- @if (!liveUpdate) - { - - } - else - { - - } +
-
-
- @if (showEditPar) +
+
+ @*@if (showEditPar) {
@@ -64,7 +51,7 @@
- } + }*@
@@ -78,17 +65,8 @@ } } - - + +
diff --git a/MP.SPEC/Components/DossiersFilter.razor.cs b/MP.SPEC/Components/DossiersFilter.razor.cs index 37e8430e..12a155a5 100644 --- a/MP.SPEC/Components/DossiersFilter.razor.cs +++ b/MP.SPEC/Components/DossiersFilter.razor.cs @@ -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 FilterChanged { get; set; } + public EventCallback 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? ListFlux = null; + private List? ListDossier = null; private List? 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 diff --git a/MP.SPEC/Components/ListDossiers.razor b/MP.SPEC/Components/ListDossiers.razor index 0745d5cb..6c04d24c 100644 --- a/MP.SPEC/Components/ListDossiers.razor +++ b/MP.SPEC/Components/ListDossiers.razor @@ -1,9 +1,103 @@ -

ListDossiers

+@using MP.SPEC.Components +@using MP.SPEC.Data + +@if (ListRecords == null) +{ + +} +else if (totalCount == 0) +{ +
Nessun record trovato
+} +else +{ +
+
+ + + + + + + + + + + + + @foreach (var record in ListRecords) + { + + + + + + + + } + +
+ @**@ + Macchina Data ODL DATA TYPE
+ + + @record.IdxMacchina + + @record.DtRif + + @record.IdxODL + + @record.DataType +
+ + @if (!visualizzaFlux) + { + if(listaFlux == null) + { +
Nessun record trovato
+ } + else + { + + + + + + + + + + + + @foreach (var record in listaFlux) + { + + + + + + + + } + +
Macchina Data ODL Valore
+ @record.IdxMacchina + + @record.dtEvento + + @record.CodFlux + + @record.Valore + + +
+ } + + } +
+
+} + -
    -
  • copiare da ListParameters
  • -
  • metodo dati: DossiersGetLastFilt
  • -
  • metodo dati x ora non fa cache redis (se vuoi provare...)
  • -
diff --git a/MP.SPEC/Components/ListDossiers.razor.cs b/MP.SPEC/Components/ListDossiers.razor.cs index 872595ff..6ef78953 100644 --- a/MP.SPEC/Components/ListDossiers.razor.cs +++ b/MP.SPEC/Components/ListDossiers.razor.cs @@ -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 TotRecordChanged { get; set; } + [Parameter] + public EventCallback 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? ListRecords; + private List? SearchRecords; + private List? 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 } } \ No newline at end of file diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index 470a72b2..3bdc25be 100644 --- a/MP.SPEC/Data/MpDataService.cs +++ b/MP.SPEC/Data/MpDataService.cs @@ -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 /// public async Task> DossiersGetLastFilt(string IdxMacchina, DateTime DtRef, int MaxRec) { -#if false - List? result = new List(); + List? result = new List(); 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>($"{rawData}"); + result = JsonConvert.DeserializeObject>($"{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(); + result = new List(); } 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 convertToFluxLog(string Valore) + { + //string valStriped = Valore.Substring(7, Valore.Length - 8); + //var result = JsonConvert.DeserializeObject>(valStriped); + var result = JsonConvert.DeserializeObject(Valore); + return result.ODL; } /// diff --git a/MP.SPEC/Data/SelectDossierParams.cs b/MP.SPEC/Data/SelectDossierParams.cs new file mode 100644 index 00000000..01ba368b --- /dev/null +++ b/MP.SPEC/Data/SelectDossierParams.cs @@ -0,0 +1,68 @@ +namespace MP.SPEC.Data +{ + public class SelectDossierParams + { + #region Public Constructors + + public SelectDossierParams() + { } + + #endregion Public Constructors + + #region Public Properties + + /// +        /// Inizializzazione con periodo e arrotondamento +        /// +        /// +        /// +        /// +        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 + } +} \ No newline at end of file diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj index a2e1a3e7..3ab99e74 100644 --- a/MP.SPEC/MP.SPEC.csproj +++ b/MP.SPEC/MP.SPEC.csproj @@ -5,7 +5,7 @@ enable enable MP.SPEC - 6.15.2209.2009 + 6.15.2209.2108 diff --git a/MP.SPEC/Pages/DOSS.razor b/MP.SPEC/Pages/DOSS.razor index 0bdba786..29766f5f 100644 --- a/MP.SPEC/Pages/DOSS.razor +++ b/MP.SPEC/Pages/DOSS.razor @@ -14,7 +14,7 @@ } else { - + }
@@ -27,11 +27,11 @@ else { @**@ - + }
diff --git a/MP.SPEC/Pages/DOSS.razor.cs b/MP.SPEC/Pages/DOSS.razor.cs index 3c38b08b..2038917f 100644 --- a/MP.SPEC/Pages/DOSS.razor.cs +++ b/MP.SPEC/Pages/DOSS.razor.cs @@ -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; diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html index d198161f..a3441d96 100644 --- a/MP.SPEC/Resources/ChangeLog.html +++ b/MP.SPEC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 6.15.2209.2009

+

Versione: 6.15.2209.2108


Note di rilascio:
  • diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt index 5047ec82..39734096 100644 --- a/MP.SPEC/Resources/VersNum.txt +++ b/MP.SPEC/Resources/VersNum.txt @@ -1 +1 @@ -6.15.2209.2009 +6.15.2209.2108 diff --git a/MP.SPEC/Resources/manifest.xml b/MP.SPEC/Resources/manifest.xml index 3c5aa0b3..8d602ec9 100644 --- a/MP.SPEC/Resources/manifest.xml +++ b/MP.SPEC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.15.2209.2009 + 6.15.2209.2108 https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html false