diff --git a/MP.Data/Controllers/MpInveController.cs b/MP.Data/Controllers/MpInveController.cs index 8455f3ac..5d23402e 100644 --- a/MP.Data/Controllers/MpInveController.cs +++ b/MP.Data/Controllers/MpInveController.cs @@ -208,6 +208,26 @@ namespace MP.Data.Controllers return dbResult; } + /// + /// Export dei dati data la sessione + /// + /// + /// + public List ExportSessionDetail(int sessionID) + { + List dbResult = new List(); + using (var dbCtx = new MoonPro_InveContext(_configuration)) + { + dbResult = dbCtx + .DbExpSessione + .Where(x => (x.InveSessId == sessionID)) + .AsNoTracking() + .OrderBy(x => x.DtScan) + .ToList(); + } + return dbResult; + } + /// /// Elenco Scansioni dato Id sessione inventario /// diff --git a/MP.Data/DatabaseModels/VExpInveSession.cs b/MP.Data/DatabaseModels/VExpInveSession.cs new file mode 100644 index 00000000..fc6bbf32 --- /dev/null +++ b/MP.Data/DatabaseModels/VExpInveSession.cs @@ -0,0 +1,50 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace MP.Data.DatabaseModels +{ + public partial class VExpInveSession + { + #region Public Properties + + [MaxLength(50)] + public string CodArtExt { get; set; } + + public string CodArticolo { get; set; } + + public string CodMag { get; set; } + + [MaxLength(50)] + public string CodStato { get; set; } + + public string DescMag { get; set; } + + [MaxLength(250)] + public string DescrArt { get; set; } + + public string Description { get; set; } + + public DateTime DtEnd { get; set; } = new DateTime(2099, 12, 31); + + public DateTime DtScan { get; set; } + + public DateTime DtStart { get; set; } = new DateTime(1900, 01, 01); + + [Column("InveSessID")] + public int InveSessId { get; set; } + + public string Lotto { get; set; } + public string Note { get; set; } + public decimal Qty { get; set; } + + [Column("ScanID")] + public int ScanId { get; set; } + + public string ScanValue { get; set; } + public string UserCrea { get; set; } + public string UserScan { get; set; } + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP.Data/MoonPro_InveContext.cs b/MP.Data/MoonPro_InveContext.cs index 383ecec5..828b8057 100644 --- a/MP.Data/MoonPro_InveContext.cs +++ b/MP.Data/MoonPro_InveContext.cs @@ -55,6 +55,7 @@ namespace MP.Data public virtual DbSet DbArtMag { get; set; } public virtual DbSet DbLottoArca { get; set; } public virtual DbSet DbTotLotti { get; set; } + public virtual DbSet DbExpSessione { get; set; } #endregion PER INVE #region PER SPEC @@ -92,6 +93,22 @@ namespace MP.Data protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS"); + modelBuilder.Entity(entity => + { + entity.HasNoKey(); + + entity.ToView("v_Exp_InveSession"); + + //entity.Property(e => e.DtEnd).HasColumnType("datetime"); + + //entity.Property(e => e.DtStart).HasColumnType("datetime"); + + //entity.Property(e => e.InveSessId).HasColumnName("InveSessID"); + + entity.Property(e => e.Qty).HasColumnType("decimal(18, 6)"); + + entity.Property(e => e.ScanId).HasColumnName("ScanID"); + }); OnModelCreatingPartial(modelBuilder); } diff --git a/MP.INVE/Data/MiDataService.cs b/MP.INVE/Data/MiDataService.cs index b23209b3..cbd85e32 100644 --- a/MP.INVE/Data/MiDataService.cs +++ b/MP.INVE/Data/MiDataService.cs @@ -1,90 +1,15 @@ -using Blazored.LocalStorage; -using Egw.Core; -using Microsoft.AspNetCore.Mvc.ModelBinding; +using Egw.Core; using MP.Data.Conf; using MP.Data.DatabaseModels; -using MP.Data.DTO; -using MP.INVE.Pages; using Newtonsoft.Json; using NLog; using StackExchange.Redis; using System.Diagnostics; -using System.Text; namespace MP.INVE.Data { public class MiDataService : IDisposable { - #region Protected Fields - - protected const string passPhrase = "7871D817-C71F-4DFC-BF12-00A95BE507B5"; - - protected Random rand = new Random(); - - #endregion Protected Fields - - #region Private Fields - - private const string redisBaseAddr = "MP:INVE"; - - private const string redisConfigBaseAddr = ":Config"; - - private const string redisElencoOperatori = redisBaseAddr + redisOperatoriBaseAddr + ":ListOperatori"; - - private const string redisLottiBaseAddr = ":Lotti"; - - private const string redisLottiEsterni = redisBaseAddr + redisLottiBaseAddr + ":LottiEsterni"; - - private const string redisLottiInterni = redisBaseAddr + redisLottiBaseAddr + ":LottiInterni"; - - private const string redisMagList = redisBaseAddr + ":ListMag"; - - private const string redisOperatoreLogged = redisBaseAddr + redisOperatoriBaseAddr + ":OperatoreLogged"; - - private const string redisOperatoriBaseAddr = ":Operatore"; - - private const string redisScanBaseAddr = redisBaseAddr + ":Scan"; - - private const string redisSessionBaseAddr = ":Session"; - - private const string redisSessionCurrList = redisBaseAddr + redisSessionBaseAddr + ":ListSessHist"; - - private const string redisSessionHistList = redisBaseAddr + redisSessionBaseAddr + ":ListSessCurr"; - - private const string redisTotLottoAddr = ":TotaleLotto"; - - private const string redisUdcBaseAddr = ":UDC"; - - private static IConfiguration _configuration = null!; - - private static ILogger _logger = null!; - - private static Logger Log = LogManager.GetCurrentClassLogger(); - - /// - /// Oggetto vocabolario x uso continuo traduzione - /// - private List ObjVocabolario = new List(); - - /// - /// Oggetto per connessione a REDIS - /// - 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 - #region Public Constructors public MiDataService(IConfiguration configuration, ILogger logger) @@ -130,11 +55,6 @@ namespace MP.INVE.Data #endregion Public Properties - #region Private Properties - - - #endregion Private Properties - #region Public Methods /// @@ -291,36 +211,6 @@ namespace MP.INVE.Data return result; } - public List MagazziniList() - { - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - List result = new List(); - string source = "DB"; - // cerco in redis... - RedisValue rawData = redisDb.StringGet(redisMagList); - if (!string.IsNullOrEmpty($"{rawData}")) - { - result = JsonConvert.DeserializeObject>($"{rawData}"); - source = "REDIS"; - } - else - { - result = dbController.MagazziniList(); - // serializzo e salvo... - rawData = JsonConvert.SerializeObject(result); - redisDb.StringSetAsync(redisMagList, rawData, getRandTOut(redisLongTimeCache)); - } - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"ElencoMagazzini Read from {source}: {ts.TotalMilliseconds}ms"); - if (result == null) - { - result = new List(); - } - return result; - } - public List ElencoOperatori() { string source = ""; @@ -390,6 +280,29 @@ namespace MP.INVE.Data return SteamCrypto.EncryptString(rawData, passPhrase); } + /// + /// Export sessione scansioni inventario (in dettaglio) + /// + /// + /// + public List ExportSessionDetail(int sessID) + { + string source = ""; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + List? result = new List(); + result = dbController.ExportSessionDetail(sessID); + source = "DB"; + if (result == null) + { + result = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"ExportSessionDetail Read from {source}: {ts.TotalMilliseconds}ms"); + return result; + } + /// /// Svuota tutta la sessione dalla root di gestione /// @@ -401,6 +314,7 @@ namespace MP.INVE.Data bool answ = await ExecFlushRedisPattern(pattern); return answ; } + /// /// Svuota solo il pattern richiesto /// @@ -414,9 +328,7 @@ namespace MP.INVE.Data return answ; } - /// - /// Svuota cahce sessioni inventario - /// + /// Svuota cahce sessioni inventario public async Task FlushSessInvCache() { bool answ = await FlushRedisCache(redisSessionCurrList) && await FlushRedisCache(redisSessionHistList); @@ -649,43 +561,33 @@ namespace MP.INVE.Data return result; } - public List ScanBySession(int idSessione) + public List MagazziniList() { - string source = ""; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); - List? result = new List(); + List result = new List(); + string source = "DB"; // cerco in redis... + RedisValue rawData = redisDb.StringGet(redisMagList); + if (!string.IsNullOrEmpty($"{rawData}")) { - var ListAll = ScanList(); - result = ListAll.Where(x => x.InveSessID == idSessione).ToList(); - if (result == null) - { - result = new List(); - } - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"ScanBySession Read from {source}: {ts.TotalMilliseconds}ms"); - return result; + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = dbController.MagazziniList(); + // serializzo e salvo... + rawData = JsonConvert.SerializeObject(result); + redisDb.StringSetAsync(redisMagList, rawData, getRandTOut(redisLongTimeCache)); } - } - /// - /// Scansioni dati UDC e sessione - /// - /// - /// - /// - public ScanDataModel ScanByUdcSession(string udc, int inveSessId) - { - string source = ""; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - ScanDataModel? result = new ScanDataModel(); - result = dbController.ScanByUdcSession(udc, inveSessId); - source = "DB"; stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"ScanByUdcSession Read from {source}: {ts.TotalMilliseconds}ms"); + Log.Debug($"ElencoMagazzini Read from {source}: {ts.TotalMilliseconds}ms"); + if (result == null) + { + result = new List(); + } return result; } @@ -710,6 +612,47 @@ namespace MP.INVE.Data return result; } + public List ScanBySession(int idSessione) + { + string source = ""; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + List? result = new List(); + // cerco in redis... + { + var ListAll = ScanList(); + result = ListAll.Where(x => x.InveSessID == idSessione).ToList(); + if (result == null) + { + result = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"ScanBySession Read from {source}: {ts.TotalMilliseconds}ms"); + return result; + } + } + + /// + /// Scansioni dati UDC e sessione + /// + /// + /// + /// + public ScanDataModel ScanByUdcSession(string udc, int inveSessId) + { + string source = ""; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + ScanDataModel? result = new ScanDataModel(); + result = dbController.ScanByUdcSession(udc, inveSessId); + source = "DB"; + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"ScanByUdcSession Read from {source}: {ts.TotalMilliseconds}ms"); + return result; + } + public List ScanByValueSessionOpr(string scanData, int inveSessId, string Opr) { string source = ""; @@ -821,6 +764,14 @@ namespace MP.INVE.Data #endregion Public Methods + #region Protected Fields + + protected const string passPhrase = "7871D817-C71F-4DFC-BF12-00A95BE507B5"; + + protected Random rand = new Random(); + + #endregion Protected Fields + #region Protected Methods /// @@ -836,6 +787,68 @@ namespace MP.INVE.Data #endregion Protected Methods + #region Private Fields + + private const string redisBaseAddr = "MP:INVE"; + + private const string redisConfigBaseAddr = ":Config"; + + private const string redisElencoOperatori = redisBaseAddr + redisOperatoriBaseAddr + ":ListOperatori"; + + private const string redisLottiBaseAddr = ":Lotti"; + + private const string redisLottiEsterni = redisBaseAddr + redisLottiBaseAddr + ":LottiEsterni"; + + private const string redisLottiInterni = redisBaseAddr + redisLottiBaseAddr + ":LottiInterni"; + + private const string redisMagList = redisBaseAddr + ":ListMag"; + + private const string redisOperatoreLogged = redisBaseAddr + redisOperatoriBaseAddr + ":OperatoreLogged"; + + private const string redisOperatoriBaseAddr = ":Operatore"; + + private const string redisScanBaseAddr = redisBaseAddr + ":Scan"; + + private const string redisSessionBaseAddr = ":Session"; + + private const string redisSessionCurrList = redisBaseAddr + redisSessionBaseAddr + ":ListSessHist"; + + private const string redisSessionHistList = redisBaseAddr + redisSessionBaseAddr + ":ListSessCurr"; + + private const string redisTotLottoAddr = ":TotaleLotto"; + + private const string redisUdcBaseAddr = ":UDC"; + + private static IConfiguration _configuration = null!; + + private static ILogger _logger = null!; + + private static Logger Log = LogManager.GetCurrentClassLogger(); + + /// + /// Oggetto vocabolario x uso continuo traduzione + /// + private List ObjVocabolario = new List(); + + /// + /// Oggetto per connessione a REDIS + /// + 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 + #region Private Methods /// diff --git a/MP.INVE/MP.INVE.csproj b/MP.INVE/MP.INVE.csproj index e456678f..21999b47 100644 --- a/MP.INVE/MP.INVE.csproj +++ b/MP.INVE/MP.INVE.csproj @@ -5,7 +5,7 @@ enable enable MP.INVE - 6.16.2212.1915 + 6.16.2212.2213 diff --git a/MP.INVE/Pages/Download.cshtml b/MP.INVE/Pages/Download.cshtml new file mode 100644 index 00000000..24ad9108 --- /dev/null +++ b/MP.INVE/Pages/Download.cshtml @@ -0,0 +1,5 @@ +@page "/Download" + +@model MP.INVE.Pages.DownloadModel +@{ +} diff --git a/MP.INVE/Pages/Download.cshtml.cs b/MP.INVE/Pages/Download.cshtml.cs new file mode 100644 index 00000000..3dcaea04 --- /dev/null +++ b/MP.INVE/Pages/Download.cshtml.cs @@ -0,0 +1,47 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace MP.INVE.Pages +{ + /// + /// Gestione donwnload file csv + /// + /// da valutare eventualmente xlsx con https://github.com/closedxml/closedxml + /// + public class DownloadModel : PageModel + { + #region Private Fields + + private readonly IWebHostEnvironment _env; + + #endregion Private Fields + + #region Public Constructors + + public DownloadModel(IWebHostEnvironment env) + { + _env = env; + } + + #endregion Public Constructors + + #region Public Methods + + public IActionResult OnGet() + { + string fileName = "OUT.csv"; + if (Request.Query.ContainsKey("fileName")) + { + fileName = Request.Query["fileName"]; + } + var filePath = Path.Combine(_env.ContentRootPath, "temp\\", fileName); + //var filePath = Path.Combine(_env.WebRootPath, "..\\temp\\", fileName); + + byte[] fileBytes = System.IO.File.ReadAllBytes(filePath); + + return File(fileBytes, "application/force-download", fileName); + } + + #endregion Public Methods + } +} diff --git a/MP.INVE/Pages/Invio.razor b/MP.INVE/Pages/Invio.razor index 323c0c15..c3ad8e10 100644 --- a/MP.INVE/Pages/Invio.razor +++ b/MP.INVE/Pages/Invio.razor @@ -80,6 +80,16 @@ else + @if (fileExist) + { + Save + } + else + { + + } @if (sessione.DtEnd == null) { diff --git a/MP.INVE/Pages/Invio.razor.cs b/MP.INVE/Pages/Invio.razor.cs index f2cdbfb4..40a8af7c 100644 --- a/MP.INVE/Pages/Invio.razor.cs +++ b/MP.INVE/Pages/Invio.razor.cs @@ -52,6 +52,36 @@ namespace MP.INVE.Pages #endregion Protected Properties #region Protected Methods + /// + /// Effettua salvataggio su file CSV + /// + protected async void ExportCSV() + { + var fullData = MIService.ExportSessionDetail(sessID); + await MP.Data.Utils.SaveToCsv(fullData, fullPath, ';'); + await InvokeAsync(StateHasChanged); + } + + protected bool fileExist + { + get + { + return File.Exists(fullPath); + } + } + + protected string fullPath + { + get => $"{exportDir}\\{fileName}"; + } + + protected string exportDir = $"{Directory.GetCurrentDirectory()}\\temp"; + + protected string fileName + { + get => $"{sessID}.csv"; + } + protected async void apriSessione(int sessID) { @@ -130,6 +160,11 @@ namespace MP.INVE.Pages protected async Task returnToSessions() { + // svuoto eventuale vecchio file + if (fileExist) + { + File.Delete(fullPath); + } await resetCacheSessInv(); // ritorno pagina... NavManager.NavigateTo("InveSession", true); @@ -246,5 +281,6 @@ namespace MP.INVE.Pages } #endregion Private Methods + } } \ No newline at end of file diff --git a/MP.INVE/Resources/ChangeLog.html b/MP.INVE/Resources/ChangeLog.html index 0c65bcd2..94ca78cb 100644 --- a/MP.INVE/Resources/ChangeLog.html +++ b/MP.INVE/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOINVE -

Versione: 6.16.2212.1915

+

Versione: 6.16.2212.2213


Note di rilascio:
  • diff --git a/MP.INVE/Resources/VersNum.txt b/MP.INVE/Resources/VersNum.txt index 0ce79757..9ca0744b 100644 --- a/MP.INVE/Resources/VersNum.txt +++ b/MP.INVE/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2212.1915 +6.16.2212.2213 diff --git a/MP.INVE/Resources/manifest.xml b/MP.INVE/Resources/manifest.xml index 81e37a78..ad5567e9 100644 --- a/MP.INVE/Resources/manifest.xml +++ b/MP.INVE/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2212.1915 + 6.16.2212.2213 https://nexus.steamware.net/repository/SWS/MP-INVE/stable/LAST/MP.INVE.zip https://nexus.steamware.net/repository/SWS/MP-INVE/stable/LAST/ChangeLog.html false diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index ddc1321b..d8925e97 100644 --- a/MP.SPEC/Data/MpDataService.cs +++ b/MP.SPEC/Data/MpDataService.cs @@ -458,26 +458,6 @@ namespace MP.SPEC.Data return answ; } - /// - /// Effettua salvataggio snapshot parametri (con stored) + svuota eventuale cache redis - /// - /// macchina - /// NUm massimo secondi per recuperare dati correnti - /// DataOra riferimento x cui prendere valori antecedenti - /// - public async Task DossiersTakeParamsSnapshot(string IdxMacchina, int MaxSec, DateTime DtRif) - { - bool answ = false; - await Task.Delay(1); - // chiamo stored x salvare parametri - dbController.DossiersTakeParamsSnapshot(IdxMacchina, MaxSec, DtRif); - // elimino cache redis... - RedisValue pattern = new RedisValue($"{redisDossByMac}:*"); - answ = await ExecFlushRedisPattern(pattern); - Log.Info($"Svuotata cache dossier | {pattern}"); - return answ; - } - /// /// Effettua salvataggio snapshot parametri (con stored) + svuota eventuale cache redis /// diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj index 644ec40e..0214db77 100644 --- a/MP.SPEC/MP.SPEC.csproj +++ b/MP.SPEC/MP.SPEC.csproj @@ -5,7 +5,7 @@ enable enable MP.SPEC - 6.16.2212.1220 + 6.16.2212.2211 diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html index 86ee3164..36d2458d 100644 --- a/MP.SPEC/Resources/ChangeLog.html +++ b/MP.SPEC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

    Versione: 6.16.2212.1220

    +

    Versione: 6.16.2212.2211


    Note di rilascio:
    • diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt index 00223c89..b7981b6d 100644 --- a/MP.SPEC/Resources/VersNum.txt +++ b/MP.SPEC/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2212.1220 +6.16.2212.2211 diff --git a/MP.SPEC/Resources/manifest.xml b/MP.SPEC/Resources/manifest.xml index c877e1e4..9f6760a8 100644 --- a/MP.SPEC/Resources/manifest.xml +++ b/MP.SPEC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2212.1220 + 6.16.2212.2211 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 diff --git a/MP.SPEC/appsettings.json b/MP.SPEC/appsettings.json index b8e6b52e..0bf7e81d 100644 --- a/MP.SPEC/appsettings.json +++ b/MP.SPEC/appsettings.json @@ -9,6 +9,7 @@ "CodApp": "MP.SPEC", "ConnectionStrings": { "Mp.Data": "Server=SQL2016DEV;Database=MoonPro; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.SPEC;", + "Mp.Inve": "Server=SQL2016DEV;Database=MoonPro_MAG; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.SPEC;", "Redis": "localhost:6379,DefaultDatabase=1,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false", "RedisAdmin": "localhost:6379,DefaultDatabase=1,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false,allowAdmin=true" },