From 141473ce28a28c2e7220cd34a894112ca6ab33f7 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 19 Sep 2022 20:01:13 +0200 Subject: [PATCH] Aggiunta metodi gestione lettura dossiers da DB + refresh --- MP.Data/Controllers/MpSpecController.cs | 23 +++++++++++++++++++++++ MP.Data/MoonProContext.cs | 8 +++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs index a3ad818b..1b4897e6 100644 --- a/MP.Data/Controllers/MpSpecController.cs +++ b/MP.Data/Controllers/MpSpecController.cs @@ -309,6 +309,29 @@ namespace MP.Data.Controllers return dbResult; } + + /// + /// 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 + /// numero massimo record da restituire + /// + public List DossiersGetLastFilt(string IdxMacchina, int MaxRec) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetDossiers + .AsNoTracking() + .Where(x => (IdxMacchina == "*" || x.IdxMacchina == IdxMacchina) ) + .OrderByDescending(x => x.DtRif) + .Take(MaxRec) + .ToList(); + } + return dbResult; + } + public List ListLinkFilt(string tipoLink) { List dbResult = new List(); 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 }); });