diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs index a3ad818b..4172154b 100644 --- a/MP.Data/Controllers/MpSpecController.cs +++ b/MP.Data/Controllers/MpSpecController.cs @@ -277,6 +277,46 @@ namespace MP.Data.Controllers { } + /// + /// Elenco ultimi n record DOssiers (che contengono ad esempio "salvataggi" di FLuxLog) dato + /// macchina (ordinato x data registrazione) + /// + /// * = tutte, altrimenti solo x una data macchina + /// Data di riferimento (Massima) per estrazioen records + /// numero massimo record da restituire + /// + public List DossiersGetLastFilt(string IdxMacchina, DateTime DtRef, int MaxRec) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetDossiers + .AsNoTracking() + .Where(x => (IdxMacchina == "*" || x.IdxMacchina == IdxMacchina) && x.DtRif <= DtRef) + .OrderByDescending(x => x.DtRif) + .Take(MaxRec) + .ToList(); + } + return dbResult; + } + + public bool DossiersTakeParamsSnapshot(string idxMacchina, int maxSec) + { + bool answ = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + var pIdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina); + var pMaxSec = new SqlParameter("@MaxSec", maxSec); + + var dbResult = dbCtx + .Database + .ExecuteSqlRaw("EXEC stp_FL_TakeSnapshot @IdxMacchina,@MaxSec", pIdxMacchina, pMaxSec); + answ = true; + } + return answ; + } + /// /// Elenco valori link (x home e navMenu laterale) /// 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 new file mode 100644 index 00000000..23edff12 --- /dev/null +++ b/MP.Data/DatabaseModels/Dossiers.cs @@ -0,0 +1,28 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +#nullable disable + +namespace MP.Data.DatabaseModels +{ + [Table("Dossiers")] + public partial class Dossiers + { + #region Public Properties + + [MaxLength(50)] + public string IdxMacchina { get; set; } + + public DateTime DtRif { get; set; } + + public int IdxODL { get; set; } + + [MaxLength(50)] + public string DataType { get; set; } + + public string Valore { get; set; } + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP.Data/MoonProContext.cs b/MP.Data/MoonProContext.cs index d1b3f033..168c3c66 100644 --- a/MP.Data/MoonProContext.cs +++ b/MP.Data/MoonProContext.cs @@ -45,6 +45,7 @@ namespace MP.Data public virtual DbSet DbSetODL { get; set; } public virtual DbSet DbSetPODL { get; set; } public virtual DbSet DbSetFluxLog { get; set; } + public virtual DbSet DbSetDossiers { get; set; } #endregion Public Properties @@ -291,7 +292,12 @@ namespace MP.Data }); modelBuilder.Entity(entity => { - entity.HasKey(e => new { e.IdxMacchina, e.dtEvento, e.CodFlux}); + entity.HasKey(e => new { e.IdxMacchina, e.dtEvento, e.CodFlux }); + + }); + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.IdxMacchina, e.DtRif }); }); diff --git a/MP.Prog/MP.Prog.csproj b/MP.Prog/MP.Prog.csproj index d4b235a7..e45a5e87 100644 --- a/MP.Prog/MP.Prog.csproj +++ b/MP.Prog/MP.Prog.csproj @@ -3,7 +3,7 @@ net6.0 MP.Prog - 6.15.2202.2715 + 6.15.2209.1609 diff --git a/MP.Prog/Resources/ChangeLog.html b/MP.Prog/Resources/ChangeLog.html index d2421896..c1de604a 100644 --- a/MP.Prog/Resources/ChangeLog.html +++ b/MP.Prog/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo gestione Programmi MAPO -

Versione: 6.15.2202.2715

+

Versione: 6.15.2209.1609


Note di rilascio:
    diff --git a/MP.Prog/Resources/VersNum.txt b/MP.Prog/Resources/VersNum.txt index 4a27e4c5..8c84d3e7 100644 --- a/MP.Prog/Resources/VersNum.txt +++ b/MP.Prog/Resources/VersNum.txt @@ -1 +1 @@ -6.15.2202.2715 +6.15.2209.1609 diff --git a/MP.Prog/Resources/manifest.xml b/MP.Prog/Resources/manifest.xml index 2d2ac344..dd01ff37 100644 --- a/MP.Prog/Resources/manifest.xml +++ b/MP.Prog/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.15.2202.2715 + 6.15.2209.1609 https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/MP.Prog.zip https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/ChangeLog.html false diff --git a/MP.SPEC/Components/CmpFooter.razor.cs b/MP.SPEC/Components/CmpFooter.razor.cs index 56efcd29..acdc906d 100644 --- a/MP.SPEC/Components/CmpFooter.razor.cs +++ b/MP.SPEC/Components/CmpFooter.razor.cs @@ -8,7 +8,7 @@ namespace MP.SPEC.Components public void Dispose() { - //aTimer.Elapsed -= ElapsedTimer; + aTimer.Elapsed -= ElapsedTimer; aTimer.Stop(); aTimer.Dispose(); } @@ -21,7 +21,6 @@ namespace MP.SPEC.Components await InvokeAsync(() => StateHasChanged()); }); pUpd.Wait(); - //Log.Trace($"Elapsed Timer Footer"); } public void StartTimer() @@ -34,6 +33,11 @@ namespace MP.SPEC.Components aTimer.Start(); } + protected override void OnInitialized() + { + version = typeof(Program).Assembly.GetName().Version; + } + #endregion Public Methods #region Protected Methods diff --git a/MP.SPEC/Components/CmpTop.razor b/MP.SPEC/Components/CmpTop.razor index 994fd8da..8061e546 100644 --- a/MP.SPEC/Components/CmpTop.razor +++ b/MP.SPEC/Components/CmpTop.razor @@ -43,7 +43,6 @@ } private async void MService_EA_ShowSearch() { - //await forceReload(); await Task.Delay(1); await InvokeAsync(() => StateHasChanged()); } @@ -54,7 +53,7 @@ var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); var user = authState.User; - if (user.Identity.IsAuthenticated) + if (user.Identity != null&& user.Identity.IsAuthenticated) { userName = $"{user.Identity.Name}"; } diff --git a/MP.SPEC/Components/DossiersFilter.razor b/MP.SPEC/Components/DossiersFilter.razor new file mode 100644 index 00000000..5aae30d9 --- /dev/null +++ b/MP.SPEC/Components/DossiersFilter.razor @@ -0,0 +1,77 @@ +
    +
    + +
    + +
    +
    + @*@if (showEditPar) + { +
    + + + + + +
    + } + else + { +
    + +
    + }*@ +
    +
    + + + + +
    +
    +
    +
    +
    + + + diff --git a/MP.SPEC/Components/DossiersFilter.razor.cs b/MP.SPEC/Components/DossiersFilter.razor.cs new file mode 100644 index 00000000..12a155a5 --- /dev/null +++ b/MP.SPEC/Components/DossiersFilter.razor.cs @@ -0,0 +1,139 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components; +using System.Net.Http; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Components.Authorization; +using Microsoft.AspNetCore.Components.Forms; +using Microsoft.AspNetCore.Components.Routing; +using Microsoft.AspNetCore.Components.Web; +using Microsoft.AspNetCore.Components.Web.Virtualization; +using Microsoft.JSInterop; +using MP.SPEC; +using MP.SPEC.Shared; +using MP.SPEC.Components; +using MP.SPEC.Data; +using MP.Data.DatabaseModels; + +namespace MP.SPEC.Components +{ + public partial class DossiersFilter + { + #region Public Properties + + [Parameter] + public EventCallback FilterChanged { get; set; } + + [Parameter] + public SelectDossierParams SelFilterDossier { get; set; } = null!; + + #endregion Public Properties + + #region Protected Fields + + #endregion Protected Fields + + #region Protected Properties + + [Inject] + protected MpDataService MDService { get; set; } = null!; + + + protected string selMacchina + { + get + { + return SelFilterDossier.IdxMacchina; + } + set + { + if (!SelFilterDossier.IdxMacchina.Equals(value)) + { + SelFilterDossier.CurrPage = 1; + SelFilterDossier.IdxMacchina = value; + StateHasChanged(); + Task.Delay(1); + reportChange(); + } + } + } + + + protected int selMaxRecord + { + get + { + return SelFilterDossier.MaxRecord; + } + + set + { + if (!SelFilterDossier.MaxRecord.Equals(value)) + { + SelFilterDossier.MaxRecord = value; + reportChange(); + } + } + } + + protected DateTime selDtRef + { + get + { + return SelFilterDossier.DtRef; + } + + set + { + if (!SelFilterDossier.DtRef.Equals(value)) + { + SelFilterDossier.DtRef = value; + reportChange(); + } + } + } + + #endregion Protected Properties + + #region Protected Methods + + protected override async Task OnInitializedAsync() + { + SelFilterDossier = new SelectDossierParams(); + ListMacchine = await MDService.MacchineWithFlux(); + ListDossier = await MDService.DossiersGetLastFilt(selMacchina, selDtRef, selMaxRecord); + await FilterChanged.InvokeAsync(SelFilterDossier); + } + + protected void toggleParams() + { + showEditPar = !showEditPar; + } + + #endregion Protected Methods + + #region Private Fields + + private List? ListDossier = null; + private List? ListMacchine = null; + + #endregion Private Fields + + #region Private Properties + + private bool showEditPar { get; set; } = false; + + #endregion Private Properties + + #region Private Methods + + private void reportChange() + { + FilterChanged.InvokeAsync(SelFilterDossier); + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/MP.SPEC/Components/ListDossiers.razor b/MP.SPEC/Components/ListDossiers.razor new file mode 100644 index 00000000..03ffa350 --- /dev/null +++ b/MP.SPEC/Components/ListDossiers.razor @@ -0,0 +1,103 @@ +@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 + +
    +
    + } + + } +
    +
    +} + + + + diff --git a/MP.SPEC/Components/ListDossiers.razor.cs b/MP.SPEC/Components/ListDossiers.razor.cs new file mode 100644 index 00000000..e89fe063 --- /dev/null +++ b/MP.SPEC/Components/ListDossiers.razor.cs @@ -0,0 +1,197 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using MP.Data.DatabaseModels; +using MP.SPEC.Data; + +namespace MP.SPEC.Components +{ + public partial class ListDossiers + { + #region Public Properties + + [Parameter] + public EventCallback RecordSel { get; set; } + + [Parameter] + public SelectDossierParams SelFilter { get; set; } = null!; + + [Parameter] + public EventCallback TotRecordChanged { 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; + } + + 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; + } + + #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; + + ListRecords = await MDService.DossiersGetLastFilt(SelMacchina, SelDtRef, MaxRecord); + + await reloadData(); + } + + protected async void OnSeachUpdated() + { + await InvokeAsync(() => + { + currPage = 1; + StateHasChanged(); + }); + } + + protected async Task selRecord(Dossiers selRec) + { + currRecord = selRec; + await RecordSel.InvokeAsync(selRec); + listaFlux = MDService.convertToFluxLog(selRec.Valore); + await toggleTableFlux(); + } + + protected async Task UpdateData() + { + currRecord = null; + await reloadData(true); + } + + #endregion Protected Methods + + #region Private Fields + + private int _totalCount = 0; + private Dossiers? currRecord = null; + private List? ListRecords; + private List? SearchRecords; + + #endregion Private Fields + + #region Private Properties + + private int currPage + { + get => MessageService.currPage; + set => MessageService.currPage = value; + } + + private bool isLoading { get; set; } = false; + private List? listaFlux { get; set; } = null; + + private int MaxRecord + { + get => SelFilter.MaxRecord; + } + + private int numRecord + { + get => MessageService.numRecord; + set => MessageService.numRecord = value; + } + + private DateTime SelDtRef + { + get => SelFilter.DtRef; + } + + private string SelMacchina + { + get => SelFilter.IdxMacchina; + } + + private int totalCount + { + get => _totalCount; + set + { + if (_totalCount != value) + { + _totalCount = value; + TotRecordChanged.InvokeAsync(value); + } + } + } + + private bool visualizzaFlux { get; set; } = true; + + #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() + { + currRecord = null; + visualizzaFlux = true; + await Task.Delay(1); + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/MP.SPEC/Components/ListODL.razor b/MP.SPEC/Components/ListODL.razor index ef06e110..fb225426 100644 --- a/MP.SPEC/Components/ListODL.razor +++ b/MP.SPEC/Components/ListODL.razor @@ -19,13 +19,13 @@ else @**@ - Articolo - Macchina + Articolo + Macchina # pz - T.Ciclo - Inizio - Note - Richiesta + T.Ciclo + Inizio + Note + Richiesta diff --git a/MP.SPEC/Components/ListPARAMS.razor b/MP.SPEC/Components/ListPARAMS.razor index 9874b541..9efdc64e 100644 --- a/MP.SPEC/Components/ListPARAMS.razor +++ b/MP.SPEC/Components/ListPARAMS.razor @@ -19,9 +19,9 @@ else @**@ - Data - Macchina - Parametro + Data + Macchina + Parametro Valore diff --git a/MP.SPEC/Components/ListPODL.razor b/MP.SPEC/Components/ListPODL.razor index f6e3c908..966b1e2e 100644 --- a/MP.SPEC/Components/ListPODL.razor +++ b/MP.SPEC/Components/ListPODL.razor @@ -19,12 +19,12 @@ else - Articolo - Fase - Macchina + Articolo + Fase + Macchina # pz - T.Ciclo - Note + T.Ciclo + Note diff --git a/MP.SPEC/Components/ParamsFilter.razor b/MP.SPEC/Components/ParamsFilter.razor index 71bfb86c..41e13353 100644 --- a/MP.SPEC/Components/ParamsFilter.razor +++ b/MP.SPEC/Components/ParamsFilter.razor @@ -1,29 +1,44 @@ - +
    -
    - @if (!liveUpdate) - { - - } - else - { - - } +
    +
    +
    + + @if (!liveUpdate) + { + + } + else + { + + } +
    +
    + + @if (selMacchina != "*") + { + + } +
    +
    +
    @if (showEditPar) { -
    +
    -
    -
    - @@ -44,9 +59,8 @@ -
    -
    - @@ -62,34 +76,37 @@ } else { -
    +
    } -
    - + + @if (ListMacchine != null) { - + foreach (var item in ListMacchine) + { + + } } - } - -
    -
    - + + + +
    + diff --git a/MP.SPEC/Components/ParamsFilter.razor.cs b/MP.SPEC/Components/ParamsFilter.razor.cs index ed1ef126..a715db76 100644 --- a/MP.SPEC/Components/ParamsFilter.razor.cs +++ b/MP.SPEC/Components/ParamsFilter.razor.cs @@ -17,7 +17,11 @@ namespace MP.SPEC.Components #region Protected Fields - protected string lastUpdate = "-"; + protected string lastUpdate + { + get => SelFilter.lastUpdate; + set => SelFilter.lastUpdate = value; + } #endregion Protected Fields @@ -145,6 +149,14 @@ namespace MP.SPEC.Components } } + protected async Task takeSnapshot() + { + // fermo udpate + liveUpdate = false; + await MDService.DossiersTakeParamsSnapshot(selMacchina, 10); + lastUpdate = $"Last Snapshot: {DateTime.Now:yyyy/MM/dd HH:mm:ss}"; + } + #endregion Protected Methods #region Private Fields diff --git a/MP.SPEC/Data/MessageService.cs b/MP.SPEC/Data/MessageService.cs index 79ca19ff..02a690b2 100644 --- a/MP.SPEC/Data/MessageService.cs +++ b/MP.SPEC/Data/MessageService.cs @@ -150,7 +150,7 @@ private string searchVal = ""; private bool showSearch; private string stateSel = "*"; - private string tipoSearch = "*"; + private string tipoSearch = ""; #endregion Private Fields diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index 2c864fec..64e95ba8 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; @@ -20,8 +21,12 @@ namespace MP.SPEC.Data // setup compoenti REDIS redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis")); + redisConnAdmin = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("RedisAdmin")); redisDb = redisConn.GetDatabase(); + // leggo cache lungo periodo + int.TryParse(_configuration.GetValue("ServerConf:redisLongTimeCache"), out redisLongTimeCache); + _logger.LogInformation("Redis INIT"); // setup canali pub/sub @@ -62,7 +67,6 @@ namespace MP.SPEC.Data public async Task> AnagStatiComm() { - int maxAgeConfig = 5; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); List? result = new List(); @@ -80,7 +84,7 @@ namespace MP.SPEC.Data result = await Task.FromResult(dbController.AnagStatiComm()); // serializzp e salvo... rawData = JsonConvert.SerializeObject(result); - await redisDb.StringSetAsync(redisStatoCom, rawData, getRandTOut(maxAgeConfig)); + await redisDb.StringSetAsync(redisStatoCom, rawData, getRandTOut(redisLongTimeCache)); stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; Log.Debug($"AnagStatiComm Read from DB: {ts.TotalMilliseconds}ms"); @@ -94,7 +98,6 @@ namespace MP.SPEC.Data public async Task> AnagTipoArtLV() { - int maxAgeConfig = 5; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); List? result = new List(); @@ -112,7 +115,7 @@ namespace MP.SPEC.Data result = await Task.FromResult(dbController.AnagTipoArtLV()); // serializzp e salvo... rawData = JsonConvert.SerializeObject(result); - await redisDb.StringSetAsync(redisTipoArt, rawData, getRandTOut(maxAgeConfig)); + await redisDb.StringSetAsync(redisTipoArt, rawData, getRandTOut(redisLongTimeCache)); stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; Log.Debug($"AnagTipoArtLV Read from DB: {ts.TotalMilliseconds}ms"); @@ -224,7 +227,6 @@ namespace MP.SPEC.Data public async Task> ConfigGetAll() { - int maxAgeConfig = 5; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); List? result = new List(); @@ -242,7 +244,7 @@ namespace MP.SPEC.Data result = await Task.FromResult(dbController.ConfigGetAll()); // serializzp e salvo... rawData = JsonConvert.SerializeObject(result); - await redisDb.StringSetAsync(redisConfKey, rawData, getRandTOut(maxAgeConfig)); + await redisDb.StringSetAsync(redisConfKey, rawData, getRandTOut(redisLongTimeCache)); stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; Log.Debug($"ConfigGetAll Read from DB: {ts.TotalMilliseconds}ms"); @@ -272,6 +274,14 @@ namespace MP.SPEC.Data return await Task.FromResult(dbController.ConfigUpdate(updRec)); } + 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; + } + public void Dispose() { // Clear database controller @@ -279,6 +289,65 @@ namespace MP.SPEC.Data redisConn.Dispose(); } + /// + /// Elenco ultimi n record DOssiers (che contengono ad esempio "salvataggi" di FLuxLog) dato + /// macchina (ordinato x data registrazione) + /// + /// * = tutte, altrimenti solo x una data macchina + /// Data di riferimento (Massima) per estrazione records + /// numero massimo record da restituire + /// + public async Task> DossiersGetLastFilt(string IdxMacchina, DateTime DtRef, int MaxRec) + { + List? result = new List(); + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string readType = "DB"; + string currKey = $"{redisDossByMac}:{IdxMacchina}"; + // cerco in redis dato valore sel macchina... + RedisValue rawData = redisDb.StringGet(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + readType = "REDIS"; + } + else + { + result = await Task.FromResult(dbController.DossiersGetLastFilt(IdxMacchina, DtRef, MaxRec)); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache / 5)); + } + if (result == null) + { + result = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"DossiersGetLastFilt | Read from {readType}: {ts.TotalMilliseconds}ms"); + return result; + } + + /// + /// Effettua salvataggio snapshot parametri (con stored) + svuota eventuale cache redis + /// + /// macchina + /// NUm massimo secondi per recuperare dati correnti + /// + public async Task DossiersTakeParamsSnapshot(string IdxMacchina, int MaxSec) + { + bool answ = false; + await Task.Delay(1); + // chiamo stored x salvare parametri + dbController.DossiersTakeParamsSnapshot(IdxMacchina, MaxSec); + // svuoto cache redis x macchina + string currKey = $"{redisDossByMac}:{IdxMacchina}"; + redisDb.StringSet(currKey, "", TimeSpan.FromSeconds(1)); + currKey = $"{redisDossByMac}:*"; + redisDb.StringSet(currKey, "", TimeSpan.FromSeconds(1)); + return answ; + } + /// /// Restitusice elenco aziende /// @@ -302,6 +371,27 @@ namespace MP.SPEC.Data return Task.FromResult(dbController.ElencoLink()); } + public async Task FlushRedisCache() + { + await Task.Delay(1); + bool answ = false; + var listEndpoints = redisConnAdmin.GetEndPoints(); + var server = redisConnAdmin.GetServer(listEndpoints[0]); + RedisValue pattern = new RedisValue($"{redisBaseAddr}*"); + if (server != null) + { + var keyList = server.Keys(redisDb.Database, pattern); + foreach (var item in keyList) + { + await redisDb.KeyDeleteAsync(item); + } + // brutalmente rimuovo intero contenuto DB... DANGER + //await server.FlushDatabaseAsync(); + answ = true; + } + return answ; + } + /// /// Elenco ultimi n record flux log dato macchina e flusso (ordinato x data registrazione) /// @@ -379,8 +469,6 @@ namespace MP.SPEC.Data Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); string readType = "DB"; - // 5 minuti valore cache - int maxAgeMin = 5; string currKey = redisMacList; // cerco in redis dato valore sel macchina... RedisValue rawData = redisDb.StringGet(currKey); @@ -394,7 +482,7 @@ namespace MP.SPEC.Data result = await Task.FromResult(dbController.MacchineGetAll()); // serializzp e salvo... rawData = JsonConvert.SerializeObject(result); - redisDb.StringSet(currKey, rawData, getRandTOut(maxAgeMin)); + redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache)); } if (result == null) { @@ -416,8 +504,6 @@ namespace MP.SPEC.Data Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); string readType = "DB"; - // 5 minuti valore cache - int maxAgeMin = 5; string currKey = redisMacByFlux; // cerco in redis dato valore sel macchina... RedisValue rawData = redisDb.StringGet(currKey); @@ -431,7 +517,7 @@ namespace MP.SPEC.Data result = await Task.FromResult(dbController.MacchineWithFlux()); // serializzp e salvo... rawData = JsonConvert.SerializeObject(result); - redisDb.StringSet(currKey, rawData, getRandTOut(maxAgeMin)); + redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache)); } if (result == null) { @@ -454,8 +540,6 @@ namespace MP.SPEC.Data Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); string readType = "DB"; - // 5 minuti valore cache - int maxAgeMin = 5; string currKey = $"{redisFluxByMac}:{IdxMacchina}"; // cerco in redis dato valore sel macchina... RedisValue rawData = redisDb.StringGet(currKey); @@ -469,7 +553,7 @@ namespace MP.SPEC.Data result = await Task.FromResult(dbController.ParametriGetFilt(IdxMacchina)); // serializzp e salvo... rawData = JsonConvert.SerializeObject(result); - redisDb.StringSet(currKey, rawData, getRandTOut(maxAgeMin)); + redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache)); } if (result == null) { @@ -526,16 +610,16 @@ namespace MP.SPEC.Data #region Private Fields - private const string redisConfKey = "MP:SPEC:Cache:Config"; - private const string redisFluxByMac = "MP:SPEC:Cache:FluxByMac"; - private const string redisMacByFlux = "MP:SPEC:Cache:MacByFlux"; - private const string redisMacList = "MP:SPEC:Cache:MacList"; - private const string redisStatoCom = "MP:SPEC:Cache:StatoCom"; - private const string redisTipoArt = "MP:SPEC:Cache:TipoArt"; + private const string redisBaseAddr = "MP:"; + private const string redisConfKey = redisBaseAddr + "SPEC:Cache:Config"; + private const string redisDossByMac = redisBaseAddr + "SPEC:Cache:DossByMac"; + private const string redisFluxByMac = redisBaseAddr + "SPEC:Cache:FluxByMac"; + private const string redisMacByFlux = redisBaseAddr + "SPEC:Cache:MacByFlux"; + private const string redisMacList = redisBaseAddr + "SPEC:Cache:MacList"; + private const string redisStatoCom = redisBaseAddr + "SPEC:Cache:StatoCom"; + private const string redisTipoArt = redisBaseAddr + "SPEC:Cache:TipoArt"; private static IConfiguration _configuration = null!; - private static ILogger _logger = null!; - private static Logger Log = LogManager.GetCurrentClassLogger(); /// @@ -543,11 +627,18 @@ namespace MP.SPEC.Data /// private ConnectionMultiplexer redisConn = null!; + /// + /// Oggetto per connessione a REDIS modalità admin (ex flux dati) + /// + private ConnectionMultiplexer redisConnAdmin = null!; + /// /// Oggetto DB redis da impiegare x chiamate R/W /// private IDatabase redisDb = null!; + private int redisLongTimeCache = 5; + #endregion Private Fields } } \ No newline at end of file diff --git a/MP.SPEC/Data/SelectDossierParams.cs b/MP.SPEC/Data/SelectDossierParams.cs new file mode 100644 index 00000000..ebcf3928 --- /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)Math.Ceiling((double)(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(5); + 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/Data/SelectFluxParams.cs b/MP.SPEC/Data/SelectFluxParams.cs index 685d046b..92559e14 100644 --- a/MP.SPEC/Data/SelectFluxParams.cs +++ b/MP.SPEC/Data/SelectFluxParams.cs @@ -18,6 +18,7 @@ public int MaxRecord { get; set; } = 100; public int TempoAgg { get; set; } = 2000; public int CurrPage { get; set; } = 1; + public string lastUpdate { get; set; } = "-"; #endregion Public Properties @@ -46,6 +47,9 @@ if (CurrPage != item.CurrPage) return false; + if (lastUpdate != item.lastUpdate) + return false; + return true; } diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj index 45d1f9ee..55d5b54d 100644 --- a/MP.SPEC/MP.SPEC.csproj +++ b/MP.SPEC/MP.SPEC.csproj @@ -5,6 +5,7 @@ enable enable MP.SPEC + 6.16.2209.2110 @@ -38,6 +39,12 @@ Always + + Always + + + + diff --git a/MP.SPEC/Pages/Articoli.razor b/MP.SPEC/Pages/Articoli.razor index f4c1a9ff..d6e4522f 100644 --- a/MP.SPEC/Pages/Articoli.razor +++ b/MP.SPEC/Pages/Articoli.razor @@ -17,15 +17,18 @@
    - + @if (ListAziende != null) { - + foreach (var item in ListAziende) + { + + } } - } - + +
    @if (currRecord != null) @@ -119,11 +122,11 @@ - Articolo - Disegno - Descrizione - Tipo - Azienda + Articolo + Disegno + Descrizione + Tipo + Azienda diff --git a/MP.SPEC/Pages/DOSS.razor b/MP.SPEC/Pages/DOSS.razor new file mode 100644 index 00000000..0b62dd06 --- /dev/null +++ b/MP.SPEC/Pages/DOSS.razor @@ -0,0 +1,37 @@ +@page "/DOSS" + +
    +
    +
    +
    +

    DOSSIERS

    +
    +
    + @if (isFiltering) + { + + filtro x macchina / periodo + } + else + { + + } +
    +
    +
    +
    + @if (isLoading) + { + + } + else + { + + } +
    + +
    + + diff --git a/MP.SPEC/Pages/DOSS.razor.cs b/MP.SPEC/Pages/DOSS.razor.cs new file mode 100644 index 00000000..2038917f --- /dev/null +++ b/MP.SPEC/Pages/DOSS.razor.cs @@ -0,0 +1,91 @@ +using Microsoft.AspNetCore.Components; +using MP.SPEC.Components; +using MP.SPEC.Data; + +namespace MP.SPEC.Pages +{ + public partial class DOSS + { + #region Protected Fields + + protected DataPager pagerODL = null!; + + #endregion Protected Fields + + #region Protected Properties + + [Inject] + protected MessageService MsgService { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected void ForceReload(int newNum) + { + numRecord = newNum; + } + + protected override async Task OnInitializedAsync() + { + isLoading = true; + isFiltering = true; + // disabilito ricerca... + MsgService.SearchVal = ""; + MsgService.ShowSearch = false; + // fix pagina + await Task.Delay(1); + var modFilter = currFilter; + modFilter.CurrPage = 1; + currFilter = modFilter; + await Task.Delay(1); + isFiltering = false; + } + + protected void updateTotal(int newTotCount) + { + totalCount = newTotCount; + } + + #endregion Protected Methods + + #region Private Properties + + private SelectDossierParams currFilter { get; set; } = new SelectDossierParams(); + + private int currPage + { + get => MsgService.currPage; + set => MsgService.currPage = value; + } + + private bool isFiltering { get; set; } = false; + private bool isLoading { get; set; } = true; + + private int numRecord + { + get => MsgService.numRecord; + set => MsgService.numRecord = value; + } + + private int totalCount { get; set; } = 0; + + #endregion Private Properties + + #region Private Methods + + private async Task updateFilter(SelectDossierParams newParams) + { + isFiltering = false; + isLoading = true; + await Task.Delay(1); + currPage = 1; + await Task.Delay(1); + await InvokeAsync(() => StateHasChanged()); + currFilter = newParams; + isLoading = false; + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/MP.SPEC/Pages/Index.razor b/MP.SPEC/Pages/Index.razor index b3173e20..0616f89b 100644 --- a/MP.SPEC/Pages/Index.razor +++ b/MP.SPEC/Pages/Index.razor @@ -18,9 +18,7 @@
    -
    MAPO MES Custom Pages
    - -
    +
    @if (ElencoLink == null) @@ -46,7 +44,16 @@
    -

    Custom pages azienda @currAzienda

    + +
    +
    +

    @currAzienda

    +
    +
    +

    MAPO MES Custom Pages

    +
    +
    +
    diff --git a/MP.SPEC/Pages/ODL.razor b/MP.SPEC/Pages/ODL.razor index c99f8b4d..10b5550c 100644 --- a/MP.SPEC/Pages/ODL.razor +++ b/MP.SPEC/Pages/ODL.razor @@ -2,223 +2,29 @@
    -
    -
    -
    -
    -

    ODL

    -
    -
    - -
    - -
    -
    +
    +
    +

    ODL

    -
    -
    -
    -
    -
    -
    - @**@ - - -
    -
    -
    - + + @if (ListStati != null) + { + foreach (var item in ListStati) { - foreach (var item in ListStati) - { - - } + } - -
    + } +
    - - @if (reqNew) - { -
    -
    -
    - Azienda - - Art Search - -
    -
    -
    -
    -
    -
    - Articolo - -
    -
    -
    - } - else if (currRecordOdl != null) - { -
    -
    -
    -
    Modifica ODL
    -
    - @*
    -
    -
    - Codice - -
    -
    -
    -
    - Disegno - -
    -
    -
    -
    - -
    -
    -
    -
    - - -
    -
    -
    -
    -
    - -
    -
    -
    - -
    -
    -
    -
    - -
    -
    -
    *@ -
    -
    -
    -
    - } - else if (currRecordPOdl != null) - { -
    -
    -
    -
    Modifica PODL
    -
    - - @*
    -
    -
    - Codice - -
    -
    -
    -
    - Disegno - -
    -
    -
    -
    - -
    -
    -
    -
    - - -
    -
    -
    -
    -
    - -
    -
    -
    - -
    -
    -
    -
    - -
    -
    -
    *@ -
    -
    -
    -
    - }
    - +