diff --git a/MP.Data/Controllers/MpInveController.cs b/MP.Data/Controllers/MpInveController.cs index c63e2840..72d9af88 100644 --- a/MP.Data/Controllers/MpInveController.cs +++ b/MP.Data/Controllers/MpInveController.cs @@ -40,7 +40,7 @@ namespace MP.Data.Controllers public List ListLottiEsterni(string codArt, string codLotto, string codMagazzino) { List dbResult = new List(); - using (var dbCtx = new MoonPro_InveContext(_configuration)) + using (var dbCtx = new MoonPro_ISContext(_configuration)) { var DataGiac = new SqlParameter("@DataGiac", DateTime.Now); var CodArt = new SqlParameter("@CodArt", codArt); diff --git a/MP.Data/MoonPro_ISContext.cs b/MP.Data/MoonPro_ISContext.cs new file mode 100644 index 00000000..811c716b --- /dev/null +++ b/MP.Data/MoonPro_ISContext.cs @@ -0,0 +1,89 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.Extensions.Configuration; +using MP.Data.DatabaseModels; +using NLog; + +#nullable disable +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace MP.Data +{ + public partial class MoonPro_ISContext : DbContext + { + #region Private Fields + + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + + private IConfiguration _configuration; + + #endregion Private Fields + + #region Public Constructors + + /// + /// Indispensabile x prima generazione migrations EFCore + /// + + [Obsolete("This constructor should never be used directly, and is only needed to generate entityframework stuff. Connection string can be adapted as pleased.")] + public MoonPro_ISContext() + { + } + + public MoonPro_ISContext(IConfiguration configuration) + { + _configuration = configuration; + } + + public MoonPro_ISContext(DbContextOptions options) : base(options) + { + } + + #endregion Public Constructors + + #region Public Properties + + #region PER INVE + + public virtual DbSet DbLottoArca { get; set; } + + #endregion PER INVE + + #endregion Public Properties + + #region Private Methods + + partial void OnModelCreatingPartial(ModelBuilder modelBuilder); + + #endregion Private Methods + + #region Protected Methods + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + if (!optionsBuilder.IsConfigured) + { + string connString = _configuration.GetConnectionString("Mp.IS"); + if (!string.IsNullOrEmpty(connString)) + { + optionsBuilder.UseSqlServer(connString); + } + else + { + optionsBuilder.UseSqlServer("Server=SQL2016DEV;Database=MoonPro_IS_EdilChim;Trusted_Connection=True;"); + } + } + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS"); + + OnModelCreatingPartial(modelBuilder); + } + + #endregion Protected Methods + } +} \ No newline at end of file diff --git a/MP.INVE/Components/ProcSuggestion.razor b/MP.INVE/Components/ProcSuggestion.razor index 755dab34..91a77d3c 100644 --- a/MP.INVE/Components/ProcSuggestion.razor +++ b/MP.INVE/Components/ProcSuggestion.razor @@ -57,7 +57,7 @@ -
+
@if (articoloScan != "" && quantitaScan != 0) { @@ -79,7 +79,7 @@ } else if (alreadyScan != null) { -
    +
    • Codice Scannerizzato:
      @@ -119,7 +119,7 @@ else if (alreadyScan != null)
    -
    +
    @if (!alreadyScan.IsUnique) { @@ -127,9 +127,8 @@ else if (alreadyScan != null) } else { -
    Questo oggetto risulta essere univoco perciò non è possibile salvare una nuova scansione
    +
    Trovato UDC | scansione già effettuata / UDC caricato (impossibile caricare 2 volte)
    } -
    } else @@ -145,7 +144,7 @@ else
  • Articolo:
    - @if (lastScan != null && lastScan != "") + @if (!string.IsNullOrEmpty(lastScan)) { } @@ -159,7 +158,7 @@ else
  • Quantità:
    - @if (lastScan != null && lastScan != "") + @if (!string.IsNullOrEmpty(lastScan)) { } @@ -172,7 +171,7 @@ else
  • Note:
    - @if (lastScan != null && lastScan != "") + @if (!string.IsNullOrEmpty(lastScan)) { } @@ -183,7 +182,7 @@ else
-
+
@if (articoloScan != "" && quantitaScan != 0) { diff --git a/MP.INVE/Components/ProcSuggestion.razor.cs b/MP.INVE/Components/ProcSuggestion.razor.cs index fc2ff761..10628f25 100644 --- a/MP.INVE/Components/ProcSuggestion.razor.cs +++ b/MP.INVE/Components/ProcSuggestion.razor.cs @@ -27,7 +27,7 @@ namespace MP.INVE.Components [Inject] private MiDataService MIService { get; set; } = null!; [Parameter] - public string lastScan { get; set; } = null!; + public string lastScan { get; set; } = ""; //[Parameter] //public EventCallback udcSend { get; set; } [Parameter] @@ -69,71 +69,90 @@ namespace MP.INVE.Components protected override async Task OnParametersSetAsync() { - await MIService.ConfigResetCache(); - var result = await MIService.tryGetConfig("MAG_SmartUdcEdit"); - elencoScansioni = MIService.ScanList(); - var exists = elencoScansioni.Select(x => x.ScanValue).Contains(lastScan); - var scansioneClone = elencoScansioni.Where(x => x.ScanValue == lastScan).FirstOrDefault(); - - if (exists) + // se il valore scansionato è != null... + if (string.IsNullOrEmpty(lastScan)) { - if (scansioneClone != null) - { - isScannedLotto = scansioneClone.ScanValue.StartsWith("M2"); - isMod = true; - if (scansioneClone.IsUnique) - { - isMod = false; - } - alreadyScan = elencoScansioni.Where(x => x.ScanValue == lastScan).FirstOrDefault(); - currUdc = null; - currLotto = null; - - } + await Task.Delay(1); } else { - if (result != null) - { - canMod = result; - } - await Task.Delay(1); - searchRecordsUDC = MIService.ElencoUDC(); - udc = searchRecordsUDC.Where(x => x.UDC == lastScan).FirstOrDefault(); + await MIService.ConfigResetCache(); + var result = await MIService.tryGetConfig("MAG_SmartUdcEdit"); + elencoScansioni = MIService.ScanList(); + var exists = elencoScansioni.Select(x => x.ScanValue).Contains(lastScan); + var scansioneClone = elencoScansioni.Where(x => x.ScanValue == lastScan).FirstOrDefault(); - if (udc != null && !udc.UDC.Contains("MSL")) + if (exists) { + if (scansioneClone != null) + { + isScannedLotto = scansioneClone.ScanValue.StartsWith("M2"); + isMod = true; + if (scansioneClone.IsUnique) + { + isMod = false; + } + alreadyScan = elencoScansioni.Where(x => x.ScanValue == lastScan).FirstOrDefault(); + currUdc = null; + currLotto = null; - currUdc = udc; - tipo = "UDC"; - lottoScan = udc.lottoNav.Lotto; - articoloScan = udc.lottoNav.CodArt; - quantitaScan = udc.Qta; - noteScan = udc.Note; + } } else { - searchRecordsLottoInterni = MIService.ElencoLotti(); - lottoInterno = searchRecordsLottoInterni.Where(x => x.Lotto == lastScan).FirstOrDefault(); - if (lottoInterno != null) + if (result != null) { - tipo = "LOTTO"; - currLotto = lottoInterno; - lottoScan = lottoInterno.Lotto; - articoloScan = lottoInterno.CodArt; - quantitaScan = 0; + canMod = result; + } + await Task.Delay(1); + searchRecordsUDC = MIService.ElencoUDC(); + udc = searchRecordsUDC.Where(x => x.UDC == lastScan).FirstOrDefault(); + + if (udc != null && !udc.UDC.Contains("MSL")) + { + + currUdc = udc; + tipo = "UDC"; + lottoScan = udc.lottoNav.Lotto; + articoloScan = udc.lottoNav.CodArt; + quantitaScan = udc.Qta; + noteScan = udc.Note; } else { - searchRecordsLottoEsterni = MIService.ListLottiEsterni(articoloScan, lastScan, magID.ToString()); - lottoEsterno = searchRecordsLottoEsterni.FirstOrDefault(); - currLotto = null; - currUdc = null; - alreadyScan = null; - lottoScan = lastScan; - articoloScan = ""; - quantitaScan = 0; - noteScan = ""; + searchRecordsLottoInterni = MIService.ElencoLotti(); + lottoInterno = searchRecordsLottoInterni.Where(x => x.Lotto == lastScan).FirstOrDefault(); + if (lottoInterno != null) + { + tipo = "LOTTO"; + currLotto = lottoInterno; + lottoScan = lottoInterno.Lotto; + articoloScan = lottoInterno.CodArt; + quantitaScan = 0; + } + else + { + searchRecordsLottoEsterni = MIService.ListLottiEsterni(articoloScan, lastScan, magID.ToString()); + lottoEsterno = searchRecordsLottoEsterni.FirstOrDefault(); + if (lottoEsterno != null) + { + tipo = "LOTTO EXT"; + //currLotto = lottoEsterno; + //lottoScan = lottoEsterno.Lotto; + //articoloScan = lottoInterno.CodArt; + quantitaScan = 0; + } + else + { + currLotto = null; + currUdc = null; + alreadyScan = null; + lottoScan = lastScan; + articoloScan = ""; + quantitaScan = 0; + noteScan = ""; + } + } } } } @@ -143,96 +162,95 @@ namespace MP.INVE.Components protected decimal qtaLotto = 0; protected async void insertScan() { - + var artExists = await MIService.artBySearch(articoloScan); if (artExists != null) { - var alertInsert = await JSRuntime.InvokeAsync("confirm", $"Confermi di voler salvare la seguente scansione per la sessione {sessID}?"); - if (alertInsert) + //var alertInsert = await JSRuntime.InvokeAsync("confirm", $"Confermi di voler salvare la seguente scansione per la sessione {sessID}?"); + //if (alertInsert) + //{ + if (currUdc != null) { - - if (currUdc != null) + if ((currUdc.lottoNav.CodArt != udc.lottoNav.CodArt) || (currUdc.Qta != udc.Qta)) { - if ((currUdc.lottoNav.CodArt != udc.lottoNav.CodArt) || (currUdc.Qta != udc.Qta)) - { - isForced = true; - } - //if() - - ScanDataModel newScan = new ScanDataModel() - { - DtScan = DateTime.Now, - UserScan = userScan, - ScanValue = lastScan, - IsForced = isForced, - CodArticolo = currUdc.lottoNav.CodArt, - Lotto = currUdc.lottoNav.Lotto, - RifExt = currUdc.lottoNav.RifExt, - Qty = currUdc.Qta, - Note = currUdc.Note, - IsKnown = true, - IsUnique = true, - InveSessID = sessID - }; - - - - await MIService.InsertNewScansione(newScan); - NavManager.NavigateTo(NavManager.Uri, true); + isForced = true; } - else if (currLotto != null) + //if() + + ScanDataModel newScan = new ScanDataModel() { - ScanDataModel newScan = new ScanDataModel() - { - DtScan = DateTime.Now, - UserScan = userScan, - ScanValue = lastScan, - IsForced = true, - CodArticolo = currLotto.CodArt, - Lotto = currLotto.Lotto, - RifExt = currLotto.RifExt, - Qty = qtaLotto, - Note = currLotto.Note, - IsKnown = true, - IsUnique = false, - InveSessID = sessID - }; - await MIService.InsertNewScansione(newScan); - NavManager.NavigateTo(NavManager.Uri, true); - } - else if (alreadyScan != null) - { - ScanDataModel newScan = new ScanDataModel() - { - DtScan = DateTime.Now, - UserScan = userScan, - ScanValue = lastScan, - IsForced = true, - CodArticolo = alreadyScan.CodArticolo, - Lotto = alreadyScan.Lotto, - RifExt = alreadyScan.RifExt, - Qty = alreadyScan.Qty, - Note = alreadyScan.Note, - IsKnown = alreadyScan.IsKnown, - IsUnique = alreadyScan.IsUnique, - InveSessID = sessID - }; - await MIService.InsertNewScansione(newScan); - NavManager.NavigateTo(NavManager.Uri, true); - } - } - else - { - currLotto = null; - currUdc = null; - alreadyScan = null; + DtScan = DateTime.Now, + UserScan = userScan, + ScanValue = lastScan, + IsForced = isForced, + CodArticolo = currUdc.lottoNav.CodArt, + Lotto = currUdc.lottoNav.Lotto, + RifExt = currUdc.lottoNav.RifExt, + Qty = currUdc.Qta, + Note = currUdc.Note, + IsKnown = true, + IsUnique = true, + InveSessID = sessID + }; + + + + await MIService.InsertNewScansione(newScan); NavManager.NavigateTo(NavManager.Uri, true); } + else if (currLotto != null) + { + ScanDataModel newScan = new ScanDataModel() + { + DtScan = DateTime.Now, + UserScan = userScan, + ScanValue = lastScan, + IsForced = true, + CodArticolo = currLotto.CodArt, + Lotto = currLotto.Lotto, + RifExt = currLotto.RifExt, + Qty = qtaLotto, + Note = currLotto.Note, + IsKnown = true, + IsUnique = false, + InveSessID = sessID + }; + await MIService.InsertNewScansione(newScan); + NavManager.NavigateTo(NavManager.Uri, true); + } + else if (alreadyScan != null) + { + ScanDataModel newScan = new ScanDataModel() + { + DtScan = DateTime.Now, + UserScan = userScan, + ScanValue = lastScan, + IsForced = true, + CodArticolo = alreadyScan.CodArticolo, + Lotto = alreadyScan.Lotto, + RifExt = alreadyScan.RifExt, + Qty = alreadyScan.Qty, + Note = alreadyScan.Note, + IsKnown = alreadyScan.IsKnown, + IsUnique = alreadyScan.IsUnique, + InveSessID = sessID + }; + await MIService.InsertNewScansione(newScan); + NavManager.NavigateTo(NavManager.Uri, true); + } + //} + //else + //{ + // currLotto = null; + // currUdc = null; + // alreadyScan = null; + // NavManager.NavigateTo(NavManager.Uri, true); + //} } else { - await JSRuntime.InvokeVoidAsync("alert", $"l'articolo {articoloScan} non risulta presente nelle nostre anagrafiche. Inserire un articolo giusto o controllare di non aver sbagliato a digitare"); + await JSRuntime.InvokeVoidAsync("alert", $"Articolo errato: {articoloScan} non trovato in anagrafica"); } } diff --git a/MP.INVE/MP.INVE.csproj b/MP.INVE/MP.INVE.csproj index b51e1a46..c1bcd4ce 100644 --- a/MP.INVE/MP.INVE.csproj +++ b/MP.INVE/MP.INVE.csproj @@ -5,7 +5,7 @@ enable enable MP.INVE - 6.16.2212.1212 + 6.16.2212.1216 diff --git a/MP.INVE/Pages/Acquisizione.razor b/MP.INVE/Pages/Acquisizione.razor index 9b42ab01..94640064 100644 --- a/MP.INVE/Pages/Acquisizione.razor +++ b/MP.INVE/Pages/Acquisizione.razor @@ -1,37 +1,33 @@ @page "/Acquisizione" - - -
-
-

Acquisizione

-
-
-
+
Last scan: @rawScan
-
+
@*if (rawScan != null) { }*@
- +
diff --git a/MP.INVE/Pages/Acquisizione.razor.cs b/MP.INVE/Pages/Acquisizione.razor.cs index d6829cef..9729773e 100644 --- a/MP.INVE/Pages/Acquisizione.razor.cs +++ b/MP.INVE/Pages/Acquisizione.razor.cs @@ -35,29 +35,44 @@ namespace MP.INVE.Pages private bool logged { get; set; } = false; protected string rawScan { get; set; } = null!; - protected string idOPeratore { get; set; } = null!; + protected string idOpr { get; set; } = null!; protected int sessionId { get; set; } = 0; protected int magazzinoId { get; set; } = 0; protected int nScansioniTot { get; set; } = 0; + + protected string descr { get; set; } = ""; + protected string magInv { get; set; } = ""; + protected List? eleScansioni; //protected AnagUdcModel currUdc{ get; set; } = null!; protected override async Task OnInitializedAsync() { await Task.Delay(1); var uri = NavManager.ToAbsoluteUri(NavManager.Uri); - if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("idOperatore", out var _matrOpr) && QueryHelpers.ParseQuery(uri.Query).TryGetValue("idSessione", out var _inveSessionId) && QueryHelpers.ParseQuery(uri.Query).TryGetValue("IdMag", out var _idMag)) + if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("idOpr", out var _matrOpr) && QueryHelpers.ParseQuery(uri.Query).TryGetValue("idSess", out var _inveSessionId) && QueryHelpers.ParseQuery(uri.Query).TryGetValue("codMag", out var _idMag)) { - idOPeratore = _matrOpr; + idOpr = _matrOpr; sessionId = int.Parse(_inveSessionId); magazzinoId = int.Parse(_idMag); eleScansioni = MIService.ScanBySession(sessionId); nScansioniTot = eleScansioni.Count(); + // recupero dati della sessione di inventario... + var currSessions = MIService.InventSessCurrList(); + var currInv = currSessions.Where(x=> x.InveSessID== sessionId).FirstOrDefault(); + if (currInv != null) + { + descr = currInv.Description; + magInv = currInv.AnagMagNav.DescMag; + } } } protected void saveScan(string newScan) { - rawScan = newScan; + if (!string.IsNullOrEmpty(newScan)) + { + rawScan = newScan; + } } } } \ No newline at end of file diff --git a/MP.INVE/Pages/Jumper.razor.cs b/MP.INVE/Pages/Jumper.razor.cs index a7efba86..c0cc5080 100644 --- a/MP.INVE/Pages/Jumper.razor.cs +++ b/MP.INVE/Pages/Jumper.razor.cs @@ -12,9 +12,11 @@ namespace MP.INVE.Pages { #region Protected Properties - protected string authKey { get; set; } = null!; + protected string authKey { get; set; } = ""; - protected string idOPeratore { get; set; } = null!; + protected string codMag { get; set; } = ""; + + protected string idOpr { get; set; } = ""; protected int inveSessionId { get; set; } = 0; @@ -38,21 +40,22 @@ namespace MP.INVE.Pages { await Task.Delay(1); var uri = NavManager.ToAbsoluteUri(NavManager.Uri); - if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("MatrOpr", out var _matrOpr) && QueryHelpers.ParseQuery(uri.Query).TryGetValue("UserAuthKey", out var _authKey) && QueryHelpers.ParseQuery(uri.Query).TryGetValue("idSessione", out var _inveSessionId)) + if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("MatrOpr", out var _matrOpr) && QueryHelpers.ParseQuery(uri.Query).TryGetValue("UserAuthKey", out var _authKey) && QueryHelpers.ParseQuery(uri.Query).TryGetValue("idSessione", out var _inveSessionId) && QueryHelpers.ParseQuery(uri.Query).TryGetValue("idMag", out var _codMag)) { - idOPeratore = _matrOpr; + idOpr = _matrOpr; authKey = _authKey; + codMag = _codMag; inveSessionId = int.Parse(_inveSessionId); } string pw = MIService.DeriptData(authKey); - logged = MIService.loginOperatore(int.Parse(idOPeratore), pw); + logged = MIService.loginOperatore(int.Parse(idOpr), pw); if (logged) { operatore = MIService.ElencoOperatori(); if (operatore != null) { - AnagOperatoriModel? currOpr = operatore.Where(x => (x.MatrOpr == int.Parse(idOPeratore)) && (x.authKey == pw)).SingleOrDefault(); + AnagOperatoriModel? currOpr = operatore.Where(x => (x.MatrOpr == int.Parse(idOpr)) && (x.authKey == pw)).SingleOrDefault(); if (currOpr != null) { @@ -69,7 +72,7 @@ namespace MP.INVE.Pages await localStorage.SetItemAsync("MatrOpr", currOpr); await sessionStorage.SetItemAsync("idSessione", inveSessionId); } - NavManager.NavigateTo($"Acquisizione?idSessione={inveSessionId}&idOperatore={idOPeratore}"); + NavManager.NavigateTo($"Acquisizione?idSess={inveSessionId}&idOpr={idOpr}&codMag={codMag}"); } } } diff --git a/MP.INVE/Pages/_Layout.cshtml b/MP.INVE/Pages/_Layout.cshtml index 3059250f..7c5553b6 100644 --- a/MP.INVE/Pages/_Layout.cshtml +++ b/MP.INVE/Pages/_Layout.cshtml @@ -32,9 +32,7 @@ - - @*Gestione autoriconnessione: https://github.com/dotnet/aspnetcore/issues/38305 (vedere anche https://docs.microsoft.com/it-it/aspnet/core/blazor/fundamentals/signalr?view=aspnetcore-6.0#modify-the-reconnection-handler-blazor-server)*@