diff --git a/MP.Data/Controllers/MpInveController.cs b/MP.Data/Controllers/MpInveController.cs index e371b009..8455f3ac 100644 --- a/MP.Data/Controllers/MpInveController.cs +++ b/MP.Data/Controllers/MpInveController.cs @@ -127,8 +127,10 @@ namespace MP.Data.Controllers /// /// Elenco Scansioni Totali /// + /// + /// /// - public ScanDataModel ScanByUdcSession(string udc, int InveSessId) + public ScanDataModel ScanByUdcSession(string Udc, int InveSessId) { ScanDataModel dbResult = new ScanDataModel(); using (var dbCtx = new MoonPro_InveContext(_configuration)) @@ -137,7 +139,7 @@ namespace MP.Data.Controllers { dbResult = dbCtx .DbScanData - .Where(x => (x.ScanValue == udc) && (x.InveSessID == InveSessId)) + .Where(x => (x.ScanValue == Udc) && (x.InveSessID == InveSessId)) .AsNoTracking() .OrderByDescending(x => x.DtScan) .FirstOrDefault(); @@ -146,7 +148,7 @@ namespace MP.Data.Controllers { dbResult = dbCtx .DbScanData - .Where(x => (x.ScanValue == udc)) + .Where(x => (x.ScanValue == Udc)) .AsNoTracking() .OrderByDescending(x => x.DtScan) .FirstOrDefault(); @@ -154,6 +156,39 @@ namespace MP.Data.Controllers } return dbResult; } + + /// + /// Elenco Scansioni dato lotto e sessione + /// + /// + /// + /// + public List ScanByLottoSession(string Lotto, int InveSessId) + { + List dbResult = new List(); + using (var dbCtx = new MoonPro_InveContext(_configuration)) + { + if (InveSessId != 0) + { + dbResult = dbCtx + .DbScanData + .Where(x => (x.Lotto == Lotto) && (x.InveSessID == InveSessId)) + .AsNoTracking() + .OrderByDescending(x => x.DtScan) + .ToList(); + } + else + { + dbResult = dbCtx + .DbScanData + .Where(x => (x.Lotto == Lotto)) + .AsNoTracking() + .OrderByDescending(x => x.DtScan) + .ToList(); + } + } + return dbResult; + } /// /// Elenco Scansioni per valore, operatore e sessione /// @@ -339,7 +374,7 @@ namespace MP.Data.Controllers /// Elenco Magazzini /// /// - public List ElencoMagazzini() + public List MagazziniList() { List dbResult = new List(); using (var dbCtx = new MoonPro_InveContext(_configuration)) @@ -443,7 +478,7 @@ namespace MP.Data.Controllers #region gestione UDC /// - /// elenco udc + /// elenco Udc /// /// public List ElencoUdc() @@ -461,7 +496,7 @@ namespace MP.Data.Controllers return dbResult; } /// - /// check udc + /// check Udc /// /// /// diff --git a/MP.INVE/Components/CmpTop.razor.cs b/MP.INVE/Components/CmpTop.razor.cs index 3eb00344..900957a1 100644 --- a/MP.INVE/Components/CmpTop.razor.cs +++ b/MP.INVE/Components/CmpTop.razor.cs @@ -19,10 +19,9 @@ namespace MP.INVE.Components // rimando a pagina corrente NavManager.NavigateTo(NavManager.Uri, true); } - public async Task LogOut() { - await localStorage.ClearAsync(); + await MsgService.clearLocalStorageAsync(); // rimando a pagina login NavManager.NavigateTo("OperatoreLogin", true); } @@ -33,8 +32,11 @@ namespace MP.INVE.Components [Inject] protected IJSRuntime JSRuntime { get; set; } = null!; + [Inject] protected MiDataService MIDataService { get; set; } = null!; + [Inject] + protected MessageService MsgService { get; set; } = null!; #endregion Protected Properties @@ -44,16 +46,19 @@ namespace MP.INVE.Components protected async Task getId() { +#if false OperatoreDTO answ = new OperatoreDTO(); answ = await localStorage.GetItemAsync("MatrOpr"); +#endif + OperatoreDTO answ = await MsgService.getCurrOperDtoAsync(); if (!NavManager.Uri.Contains("Jumper?")) { - if (answ != null) + if (answ.MatrOpr != 0) { userName = $"{answ.Cognome} {answ.Nome} ({answ.MatrOpr})"; if (NavManager.Uri.Contains("OperatoreLogin")) { - NavManager.NavigateTo("Starter", true); + NavManager.NavigateTo("ElencoMagazzini", true); } } else @@ -72,10 +77,6 @@ namespace MP.INVE.Components await getId(); } - protected override async Task OnAfterRenderAsync(bool firstRender) - { - await getId(); - } #endregion Protected Methods @@ -89,10 +90,14 @@ namespace MP.INVE.Components [Inject] private NavigationManager NavManager { get; set; } = null!; + [Inject] private ISessionStorageService sessionStorage { get; set; } = null!; + +#if false [Inject] private ILocalStorageService localStorage { get; set; } = null!; +#endif #endregion Private Properties } diff --git a/MP.INVE/Components/InveSessionList.razor b/MP.INVE/Components/InveSessionList.razor index f777e5c3..eb6f4e03 100644 --- a/MP.INVE/Components/InveSessionList.razor +++ b/MP.INVE/Components/InveSessionList.razor @@ -70,10 +70,7 @@ - @if (inCorso) - { - - } + diff --git a/MP.INVE/Components/InveSessionList.razor.cs b/MP.INVE/Components/InveSessionList.razor.cs index 02c22582..1434fecc 100644 --- a/MP.INVE/Components/InveSessionList.razor.cs +++ b/MP.INVE/Components/InveSessionList.razor.cs @@ -1,27 +1,28 @@ -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.INVE; -using MP.INVE.Shared; -using MP.INVE.Components; -using MP.INVE.Data; -using MP.Data.DatabaseModels; using Blazored.LocalStorage; +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using MP.Data.DatabaseModels; +using MP.INVE.Data; namespace MP.INVE.Components { public partial class InveSessionList : IDisposable { + #region Public Properties + + public string currIdMag { get; set; } + + public int currIdSess { get; set; } + + [Parameter] + public SelectInveSessionParams currParams { get; set; } = null!; + + [Parameter] + public bool isLoading { get; set; } + + #endregion Public Properties + + #region Public Methods public void Dispose() { @@ -31,8 +32,128 @@ namespace MP.INVE.Components SearchRecords = null; GC.Collect(); } - private int magazzino { get; set; } = 0; + + #endregion Public Methods + + #region Protected Properties + + protected string BaseUrlTab { get => $"{Configuration["ServerConf:BaseUrlJumper"]}"; } + + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + + [Inject] + protected ILocalStorageService localStorage { get; set; } = null!; + + [Inject] + protected NavigationManager NavManager { get; set; } = null!; + + protected string rawCode + { + get + { + string answ = ""; + answ = $"{BaseUrlTab}IdSessione={currIdSess}&IdMag={currIdMag}&MatrOpr={idOperatore}&UserAuthKey={authKey}"; + return answ; + } + } + + #endregion Protected Properties + + #region Protected Methods + + protected async Task getCurrSess(int idSess, string idMag) + { + currIdSess = idSess; + currIdMag = idMag; + await JSRuntime.InvokeVoidAsync("clearContent", $"qrCodeImg_{101}"); + await JSRuntime.InvokeVoidAsync("displayQr", $"qrCodeImg_{101}", rawCode); + } + + protected override async Task OnParametersSetAsync() + { + await reloadData(); + await popola(); + } + + protected async Task popola() + { + await Task.Delay(1); + if (reqNew) + { + elencoOperatori = MIDataservice.ElencoOperatori(); + ElencoMagazzini = MIDataservice.MagazziniList(); + } + } + + #endregion Protected Methods + + #region Private Fields + + private List? ElencoMagazzini; + private List? elencoOperatori; + private List? elencoSessioni; + private List? SearchRecords; + + #endregion Private Fields + + #region Private Properties + + private string authKey + { + get => currParams.authKey; + set => currParams.authKey = value; + } + private string searchVal + { + get => currParams.searchVal; + set => currParams.searchVal = value; + } + + [Inject] + private IConfiguration Configuration { get; set; } = null!; + + private int currPage + { + get => currParams.CurrPage; + set + { + currParams.CurrPage = value; + StateHasChanged(); + } + } + private string desc { get; set; } = ""; + private DateTime dtEnd { get; set; } = DateTime.Now; + private DateTime dtStart { get; set; } = DateTime.Now.AddMonths(-1); + + private string idOperatore + { + get => currParams.idOperatore; + set => currParams.idOperatore = value; + } + + private bool inCorso + { + get => currParams.inCorso; + set => currParams.inCorso = value; + } + + private int magazzino { get; set; } = 0; + + [Inject] + private MiDataService MIDataservice { get; set; } = null!; + + private int numRecord + { + get => currParams.NumRec; + set + { + currParams.NumRec = value; + StateHasChanged(); + } + } + private bool reqNew { get => currParams.reqNew; @@ -44,40 +165,10 @@ namespace MP.INVE.Components get => currParams.TotCount; set => currParams.TotCount = value; } - private int numRecord - { - get => currParams.NumRec; - set - { - currParams.NumRec = value; - StateHasChanged(); - } - } - private int currPage - { - get => currParams.CurrPage; - set - { - currParams.CurrPage = value; - StateHasChanged(); - } - } - private string idOperatore - { - get => currParams.idOperatore; - set => currParams.idOperatore = value; - } - private string authKey - { - get => currParams.authKey; - set => currParams.authKey = value; - } - private bool inCorso - { - get => currParams.inCorso; - set => currParams.inCorso = value; - } + #endregion Private Properties + + #region Private Methods private void closeNew() { @@ -86,38 +177,16 @@ namespace MP.INVE.Components ElencoMagazzini = new List(); } - private DateTime dtStart { get; set; } = DateTime.Now.AddMonths(-1); - private DateTime dtEnd { get; set; } = DateTime.Now; - - protected string BaseUrlTab { get => $"{Configuration["ServerConf:BaseUrlJumper"]}"; } - - - protected string rawCode + private async Task deleteSession(InventorySessionModel session) { - get + var alert = await JSRuntime.InvokeAsync("confirm", "Confermi di voler creare una nuova sessione per il magazzino selezionato?"); + if (alert) { - string answ = ""; - answ = $"{BaseUrlTab}IdSessione={currIdSess}&IdMag={currIdMag}&MatrOpr={idOperatore}&UserAuthKey={authKey}"; - return answ; + await MIDataservice.deleteSessione(session); + NavManager.NavigateTo(NavManager.Uri, true); + await reloadData(); } } - protected async Task popola() - { - await Task.Delay(1); - if (reqNew) - { - elencoOperatori = MIDataservice.ElencoOperatori(); - ElencoMagazzini = MIDataservice.ElencoMagazzini(); - } - } - - protected async Task getCurrSess(int idSess, string idMag) - { - currIdSess = idSess; - currIdMag = idMag; - await JSRuntime.InvokeVoidAsync("clearContent", $"qrCodeImg_{101}"); - await JSRuntime.InvokeVoidAsync("displayQr", $"qrCodeImg_{101}", rawCode); - } private async Task insertNewSession() { @@ -144,22 +213,7 @@ namespace MP.INVE.Components closeNew(); } } - protected override async Task OnParametersSetAsync() - { - await reloadData(); - await popola(); - } - private async Task deleteSession(InventorySessionModel session) - { - var alert = await JSRuntime.InvokeAsync("confirm", "Confermi di voler creare una nuova sessione per il magazzino selezionato?"); - if (alert) - { - await MIDataservice.deleteSessione(session); - NavManager.NavigateTo(NavManager.Uri, true); - await reloadData(); - } - } private async Task reloadData() { elencoSessioni = null; @@ -172,6 +226,12 @@ namespace MP.INVE.Components { SearchRecords = MIDataservice.InventSessHistList(); } + //verifico filtro ricerca mag + if (!string.IsNullOrEmpty(searchVal)) + { + StringComparison strComp = StringComparison.CurrentCultureIgnoreCase; + SearchRecords = SearchRecords.Where(x => x.AnagMagNav.DescMag.Contains(searchVal, strComp) || x.Description.Contains(searchVal, strComp)).ToList(); + } totalCount = SearchRecords.Count; elencoSessioni = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); await Task.Delay(1); @@ -180,29 +240,6 @@ namespace MP.INVE.Components isLoading = false; } - [Parameter] - public SelectInveSessionParams currParams { get; set; } = null!; - - [Parameter] - public bool isLoading { get; set; } - - public int currIdSess { get; set; } - public string currIdMag { get; set; } - - [Inject] - private MiDataService MIDataservice { get; set; } = null!; - [Inject] - private IConfiguration Configuration { get; set; } = null!; - [Inject] - protected ILocalStorageService localStorage { get; set; } = null!; - [Inject] - protected NavigationManager NavManager { get; set; } = null!; - [Inject] - protected IJSRuntime JSRuntime { get; set; } = null!; - - private List? elencoSessioni; - private List? SearchRecords; - private List? elencoOperatori; - private List? ElencoMagazzini; + #endregion Private Methods } } \ No newline at end of file diff --git a/MP.INVE/Components/ListScan.razor.cs b/MP.INVE/Components/ListScan.razor.cs index 8ffdd6e3..40456e7d 100644 --- a/MP.INVE/Components/ListScan.razor.cs +++ b/MP.INVE/Components/ListScan.razor.cs @@ -1,19 +1,5 @@ -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.INVE; -using MP.INVE.Shared; -using MP.INVE.Components; using MP.Data.DatabaseModels; using MP.INVE.Data; @@ -21,26 +7,51 @@ namespace MP.INVE.Components { public partial class ListScan { - [Inject] - MiDataService MIService { get; set; } = null!; - [Inject] - IJSRuntime JSRuntime { get; set; } = null!; + #region Public Properties + [Parameter] public string lastScan { get; set; } = ""; - [Parameter] - public string userScan { get; set; } = null!; - [Parameter] - public int sessID { get; set; } = 0; + [Parameter] public string magID { get; set; } = ""; + + [Parameter] + public int sessID { get; set; } = 0; + + [Parameter] + public string userScan { get; set; } = null!; + + #endregion Public Properties + + #region Protected Properties + protected string rawScan { get; set; } = null!; - List? elencoSCAN; + #endregion Protected Properties + + #region Protected Methods + protected override async Task OnParametersSetAsync() { await Task.Delay(1); - } + #endregion Protected Methods + + #region Private Fields + + private List? elencoSCAN; + + #endregion Private Fields + + #region Private Properties + + [Inject] + private IJSRuntime JSRuntime { get; set; } = null!; + + [Inject] + private MiDataService MIService { get; set; } = null!; + + #endregion Private Properties } } \ No newline at end of file diff --git a/MP.INVE/Components/ListTotLotto.razor b/MP.INVE/Components/ListTotLotto.razor index 7d3c919d..72d45a9b 100644 --- a/MP.INVE/Components/ListTotLotto.razor +++ b/MP.INVE/Components/ListTotLotto.razor @@ -1,38 +1,55 @@ -

Totale lotti

- -
QRApri ID sessione Magazzino Operatore
- - - - - - - - - - - @if (elencoTotLotto != null) - { - @foreach (var item in elencoTotLotto) - { +
+
+
LottoArticoloDescrizione ArtTot colliTot lotto
+ - - - - - + + + + + + - } - } - -
- @item.Lotto - - @item.CodArticolo - - @item.DescrArt - - @item.NumColli - - @($"{item.TotLotto:N2}") - + @if (currRecord != null) + { + + } + LottoCod.Art.Descrizione Articolo# ColliQty Tot
+ + + @if (elencoTotLotto != null) + { + @foreach (var item in elencoTotLotto) + { + + + + + + @item.Lotto + + + @item.CodArticolo + + + @item.DescrArt + + + @item.NumColli + + + @($"{item.TotLotto:N2}") + + + } + } + + + + @if (currRecord != null) + { +
+ +
+ } + \ No newline at end of file diff --git a/MP.INVE/Components/ListTotLotto.razor.cs b/MP.INVE/Components/ListTotLotto.razor.cs index b8bc91a2..ffd122f5 100644 --- a/MP.INVE/Components/ListTotLotto.razor.cs +++ b/MP.INVE/Components/ListTotLotto.razor.cs @@ -1,19 +1,4 @@ -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.INVE; -using MP.INVE.Shared; -using MP.INVE.Components; using MP.Data.DatabaseModels; using MP.INVE.Data; @@ -21,35 +6,72 @@ namespace MP.INVE.Components { public partial class ListTotLotto { + #region Public Properties + + [Parameter] + public SelectInvioParams currParams { get; set; } = null!; + + [Parameter] + public bool isLoading { get; set; } + + [Parameter] + public string searchVal { get; set; } = ""; + + [Parameter] + public int SessionID { get; set; } = 0; + + [Parameter] + public EventCallback updateRecordCount { get; set; } + + #endregion Public Properties + + #region Public Methods + public void Dispose() { elencoTotLotto = null; SearchRecords = null; GC.Collect(); } - [Parameter] - public int SessionID { get; set; } = 0; + + #endregion Public Methods + + #region Protected Fields + + protected List? elencoTotLotto; + + #endregion Protected Fields + + #region Protected Properties [Inject] protected MiDataService MIService { get; set; } = null!; - private int totalCount + + #endregion Protected Properties + + #region Protected Methods + + protected override async Task OnParametersSetAsync() { - get => currParams.TotCount; - set + await Task.Delay(1); + if (SessionID != 0) { - currParams.TotCount = value; - StateHasChanged(); - } - } - private int numRecord - { - get => currParams.NumRec; - set - { - currParams.NumRec = value; - StateHasChanged(); + await reloadData(); } } + + #endregion Protected Methods + + #region Private Fields + + private List? SearchRecords; + + #endregion Private Fields + + #region Private Properties + + private int _totalCount { get; set; } = 0; + private int currPage { get => currParams.CurrPage; @@ -60,20 +82,79 @@ namespace MP.INVE.Components } } - protected async override Task OnParametersSetAsync() + private int numRecord { - await Task.Delay(1); - if (SessionID != 0) + get => currParams.NumRec; + set { - await reloadData(); + currParams.NumRec = value; + StateHasChanged(); } } + + private int totalCount + { + get => _totalCount; + set + { + if (_totalCount != value) + { + _totalCount = value; + updateRecordCount.InvokeAsync(value); + } + } + } + + + protected async Task selRecord(InveSessTotLotModel selRecord) + { + currRecord = selRecord; + await Task.Delay(1); + } + + protected async Task resetSel() + { + currRecord = null; + await Task.Delay(1); + } + public string checkSelect(InveSessTotLotModel thisRecord) + { + string answ = ""; + if (currRecord != null) + { + try + { + answ = (currRecord.Lotto == thisRecord.Lotto && currRecord.CodArticolo==thisRecord.CodArticolo) ? "table-info" : ""; + } + catch + { } + } + return answ; + } + + public string mainCss + { + get => currRecord != null ? "col-9" : "col-12"; + } + + protected InveSessTotLotModel? currRecord { get; set; } = null; + + #endregion Private Properties + + #region Private Methods + private async Task reloadData() { elencoTotLotto = null; - totalCount = 0; + //totalCount = 0; isLoading = true; SearchRecords = MIService.InveSessTotLotList(SessionID); + // se ho search --> filtro... + if (!string.IsNullOrEmpty(searchVal)) + { + StringComparison strComp = StringComparison.CurrentCultureIgnoreCase; + SearchRecords = SearchRecords.Where(x => x.CodArticolo.Contains(searchVal, strComp) || x.DescrArt.Contains(searchVal, strComp) || x.Lotto.Contains(searchVal, strComp)).ToList(); + } totalCount = SearchRecords.Count; elencoTotLotto = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); await Task.Delay(1); @@ -81,12 +162,7 @@ namespace MP.INVE.Components await Task.Delay(1); isLoading = false; } - protected List? elencoTotLotto; - private List? SearchRecords; - [Parameter] - public SelectInvioParams currParams { get; set; } = null!; - [Parameter] - public bool isLoading { get; set; } + #endregion Private Methods } } \ No newline at end of file diff --git a/MP.INVE/Components/LotScanDetail.razor b/MP.INVE/Components/LotScanDetail.razor new file mode 100644 index 00000000..c5244c69 --- /dev/null +++ b/MP.INVE/Components/LotScanDetail.razor @@ -0,0 +1,44 @@ +
+
+
+
+ @LottoSel +
+
+ @CodArtSel +
+
+
+
+ + + + + + + + + + @if (ListRecords != null) + { + @foreach (var item in ListRecords) + { + + + + + + } + } + +
DTimeUserQty
+ + @($"{item.DtScan:yy.MM.dd HH:mm:ss}") + + + @item.UserScan + + @($"{item.Qty:N2}") +
+
+
diff --git a/MP.INVE/Components/LotScanDetail.razor.cs b/MP.INVE/Components/LotScanDetail.razor.cs new file mode 100644 index 00000000..4f7c71d0 --- /dev/null +++ b/MP.INVE/Components/LotScanDetail.razor.cs @@ -0,0 +1,72 @@ +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.INVE; +using MP.INVE.Shared; +using MP.INVE.Components; +using MP.Data.DatabaseModels; +using MP.INVE.Data; + +namespace MP.INVE.Components +{ + public partial class LotScanDetail + { + + [Parameter] + public string LottoSel { get; set; } = ""; + + [Parameter] + public string CodArtSel { get; set; } = ""; + [Parameter] + public int InveSessID { get; set; } = 0; + + protected override async Task OnParametersSetAsync() + { + await reloadData(); + } + + private async Task reloadData() + { + ListRecords = null; + //totalCount = 0; + isLoading = true; + SearchRecords = await MIService.ScanByLottoSession(LottoSel, InveSessID); + totalCount = SearchRecords.Count; + ListRecords = SearchRecords;//.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); + await Task.Delay(1); + await InvokeAsync(() => StateHasChanged()); + await Task.Delay(1); + isLoading = false; + } + + private int _totalCount { get; set; } = 0; + private int totalCount + { + get => _totalCount; + set + { + if (_totalCount != value) + { + _totalCount = value; + //updateRecordCount.InvokeAsync(value); + } + } + } + private List? SearchRecords; + protected List? ListRecords; + public bool isLoading { get; set; } + + [Inject] + protected MiDataService MIService { get; set; } = null!; + } +} \ No newline at end of file diff --git a/MP.INVE/Components/MagList.razor.cs b/MP.INVE/Components/MagList.razor.cs index 439e3ca7..0e687681 100644 --- a/MP.INVE/Components/MagList.razor.cs +++ b/MP.INVE/Components/MagList.razor.cs @@ -90,7 +90,7 @@ namespace MP.INVE.Components isLoading = true; ElencoMagazzini = null; SearchRecords = null; - SearchRecords = MIDataservice.ElencoMagazzini(); + SearchRecords = MIDataservice.MagazziniList(); totalCount = SearchRecords.Count; ElencoMagazzini = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); await Task.Delay(1); diff --git a/MP.INVE/Components/NavMenuTerm.razor.cs b/MP.INVE/Components/NavMenuTerm.razor.cs index 19867279..8e1e8691 100644 --- a/MP.INVE/Components/NavMenuTerm.razor.cs +++ b/MP.INVE/Components/NavMenuTerm.razor.cs @@ -23,7 +23,6 @@ namespace MP.INVE.Components public partial class NavMenuTerm { private bool collapseNavMenu = true; - //public List? ElencoLink { get; set; } private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; private void ToggleNavMenu() { @@ -39,6 +38,7 @@ namespace MP.INVE.Components protected string @cssCancScan = ""; protected override async Task OnInitializedAsync() { + await Task.Delay(1); if (isScan) { cssCancScan = "bg-info"; @@ -52,8 +52,8 @@ namespace MP.INVE.Components cssCancBack = "background-color: rgba(255,255,255,0.7)"; cssCanc = "fw-bold text-decoration-underline"; } - // recupero elenco JQM - //ElencoLink = await MDService.ElencoLink(); + // verifico se sia tutto OK (sessione aperta) + } protected bool showText { get; set; } = true; diff --git a/MP.INVE/Components/ProcSuggestion.razor b/MP.INVE/Components/ProcSuggestion.razor index 5f7eb404..bcaf3f73 100644 --- a/MP.INVE/Components/ProcSuggestion.razor +++ b/MP.INVE/Components/ProcSuggestion.razor @@ -10,76 +10,84 @@ @if (!firstMsg) { + @if (!isQtaSbagliata) + { -
    -
  • - Lotto: -
    - - @tipo -
    -
  • -
  • - Articolo: -
    - - @if ((canMod != "false") || (tipo != "U") || (!isKnown)) - { - - } -
    -
  • -
  • - Quantità: -
    - @if (currLottoInterno != null || currLottoEsterno != null) - { - - } - else - { - - } - @if ((canMod != "false") || (tipo != "U") || (!isKnown)) - { - - } -
    -
  • -
  • - Note: -
    - -
    -
  • -
-
- @if (articoloScan != "" && quantitaScan != 0 && canSave) - { - - - } - else if (articoloScan == "" && quantitaScan != 0) - { -
Dati mancanti: Codice articolo
- } - else if (quantitaScan == 0 && articoloScan != "") - { -
Dati mancanti: Quantità a "0"
- } - else if (isKnown) - { -
Codice già scansionato per la sessione corrente
- } - else - { -
Dati mancanti: Codice articolo e Quantità
- } -
+
    +
  • + Lotto: +
    + + @tipo +
    +
  • +
  • + Articolo: +
    + + @if ((canMod != "false") || (tipo != "U") || (!isKnown)) + { + + } +
    +
  • +
  • + Quantità: +
    + @if (currLottoInterno != null || currLottoEsterno != null) + { + + } + else + { + + } + @if ((canMod != "false") || (tipo != "U") || (!isKnown)) + { + + } +
    +
  • +
  • + Note: +
    + +
    +
  • +
+
+ @if (articoloScan != "" && quantitaScan != 0 && canSave) + { + + + } + else if (articoloScan == "" && quantitaScan != 0) + { +
Dati mancanti: Codice articolo
+ } + else if (quantitaScan == 0 && articoloScan != "") + { +
Dati mancanti: Quantità a "0"
+ } + else if (isKnown) + { +
Codice già scansionato per la sessione corrente
+ } + + else + { +
Dati mancanti: Codice articolo e Quantità
+ } +
+ } + else + { +
Quantità registrata minore o uguale a 0
+ } } else { diff --git a/MP.INVE/Components/ProcSuggestion.razor.cs b/MP.INVE/Components/ProcSuggestion.razor.cs index c8a43ee1..e7a08a51 100644 --- a/MP.INVE/Components/ProcSuggestion.razor.cs +++ b/MP.INVE/Components/ProcSuggestion.razor.cs @@ -59,6 +59,7 @@ namespace MP.INVE.Components protected bool isKnown = false; protected bool canSave = true; protected string oldArt = ""; + protected bool isQtaSbagliata = false; protected override async Task OnAfterRenderAsync(bool firstRender) { await Task.Delay(1); @@ -74,12 +75,13 @@ namespace MP.INVE.Components currLottoInterno = null; currUdc = null; alreadyScan = null; - + isQtaSbagliata = false; + // se il valore scansionato è != null... if (string.IsNullOrEmpty(lastScan)) { firstMsg = true; - await Task.Delay(1); + await Task.Delay(1); } else { @@ -129,19 +131,26 @@ namespace MP.INVE.Components if (udc != null) { - var udcString = udc.UDC.Substring(2, 3); - if (udcString == "MFI") + if (udc.Qta > 0) { + var udcString = udc.UDC.Substring(2, 3); + if (udcString == "MFI") + { - isKnown = true; - canSave = true; - currUdc = udc; - tipo = "U"; - lottoScan = udc.lottoNav.Lotto; - oldArt = udc.lottoNav.CodArt; - articoloScan = udc.lottoNav.CodArt; - quantitaScan = Math.Round(udc.Qta, 2); - noteScan = udc.Note; + isKnown = true; + canSave = true; + currUdc = udc; + tipo = "U"; + lottoScan = udc.lottoNav.Lotto; + oldArt = udc.lottoNav.CodArt; + articoloScan = udc.lottoNav.CodArt; + quantitaScan = Math.Round(udc.Qta, 2); + noteScan = udc.Note; + } + } + else + { + isQtaSbagliata = true; } } else diff --git a/MP.INVE/Data/MessageService.cs b/MP.INVE/Data/MessageService.cs index 985557d0..948b53f4 100644 --- a/MP.INVE/Data/MessageService.cs +++ b/MP.INVE/Data/MessageService.cs @@ -1,8 +1,69 @@ -namespace MP.INVE.Data +using Blazored.LocalStorage; +using Microsoft.AspNetCore.Components; +using MP.Data.DTO; +using NLog; +using NLog.Fluent; + +namespace MP.INVE.Data { public class MessageService { - #region Public Events + protected ILocalStorageService localStorage { get; set; } = null!; + + public MessageService(ILocalStorageService genLocalStorage) + { + localStorage = genLocalStorage; + } + + private static Logger Log = LogManager.GetCurrentClassLogger(); + + /// + /// Effettua pulizia localstorage + /// + /// + public async Task clearLocalStorageAsync() + { + bool answ = false; + try + { + await localStorage.ClearAsync(); + answ = true; + } + catch (Exception exc) + { + //Log.Error($"Eccezione in clearLocalStorage{Environment.NewLine}{exc}"); + } + return answ; + } + + /// + /// Restituisce il record OperatoreDTO da localstorage + /// + /// + public async Task getCurrOperDtoAsync() + { + OperatoreDTO answ = new OperatoreDTO(); + var result = await localStorage.GetItemAsync("Opr"); + if (result != null) + { + answ = result; + } + return answ; + } + + /// + /// scrive il record OperatoreDTO nel localstorage + /// + /// + public async Task setCurrOperDtoAsync(OperatoreDTO opr) + { + bool answ = false; + await localStorage.SetItemAsync("Opr", opr); + answ = true; + return answ; + } + +#if false public event Action EA_PageUpdated = null!; @@ -12,10 +73,6 @@ public event Action EA_StatoSearch = null!; - #endregion Public Events - - #region Public Properties - public int currPage { get => _currPage; @@ -123,10 +180,6 @@ } } - #endregion Public Properties - - #region Protected Methods - protected void reportPaging() { if (EA_PageUpdated != null) @@ -143,24 +196,15 @@ } } - #endregion Protected Methods - - #region Private Fields - private string searchVal = ""; private bool showSearch; private string stateSel = "*"; private string tipoSearch = ""; - #endregion Private Fields - - #region Private Properties - private int _currPage { get; set; } = 1; private int _numRecord { get; set; } = 10; private int _totalCount { get; set; } = 0; - - #endregion Private Properties +#endif } } \ No newline at end of file diff --git a/MP.INVE/Data/MiDataService.cs b/MP.INVE/Data/MiDataService.cs index 94cffed8..b23209b3 100644 --- a/MP.INVE/Data/MiDataService.cs +++ b/MP.INVE/Data/MiDataService.cs @@ -1,7 +1,9 @@ -using Egw.Core; +using Blazored.LocalStorage; +using Egw.Core; using Microsoft.AspNetCore.Mvc.ModelBinding; using MP.Data.Conf; using MP.Data.DatabaseModels; +using MP.Data.DTO; using MP.INVE.Pages; using Newtonsoft.Json; using NLog; @@ -13,6 +15,76 @@ 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) @@ -58,18 +130,39 @@ namespace MP.INVE.Data #endregion Public Properties + #region Private Properties + + + #endregion Private Properties + #region Public Methods - public string DeriptData(string encData) + /// + /// Aggiornamento record selezionato + /// + /// + /// + public async Task artBySearch(string artSearch) { - return SteamCrypto.DecryptString(encData, passPhrase); + var dbResult = dbController.artBySearch(artSearch); + // elimino cache redis... + await Task.Delay(1); + return dbResult; } - public void Dispose() + public async Task CloseOpenSessione(int sessID, bool flgClose) { + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + bool result = false; + string source = "DB"; + result = await dbController.CloseOpenSessione(sessID, flgClose); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"CloseOpenSessione Read from {source}: {ts.TotalMilliseconds}ms"); + return result; } - public async Task> ConfigGetAll() { Stopwatch stopWatch = new Stopwatch(); @@ -101,25 +194,6 @@ namespace MP.INVE.Data return result; } - /// - /// Restituisce valore della stringa (SE disponibile) - /// - /// - /// - public async Task tryGetConfig(string keyName) - { - string answ = ""; - // preselezione valori - var configData = await ConfigGetAll(); - var currRec = configData.FirstOrDefault(x => x.Chiave == keyName); - if (currRec != null) - { - answ = currRec.Valore; - } - - return answ; - } - /// /// Reset dati cache config /// @@ -129,38 +203,35 @@ namespace MP.INVE.Data await redisDb.StringSetAsync(redisConfigBaseAddr, ""); } - - public async Task InsertNewScansione(ScanDataModel newScan) + public async Task DeleteMag(AnagMagModel Mag) { bool result = false; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); - result = await dbController.InsertNewScansione(newScan); + result = await dbController.DeleteMag(Mag); // elimino cache redis... - RedisValue pattern = new RedisValue(redisScanBaseAddr); + RedisValue pattern = new RedisValue($"{redisMagList}:*"); bool answ = await ExecFlushRedisPattern(pattern); stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"InsertNewScansione | Id scansione: {newScan.ScanID} | Id sessione: {newScan.InveSessID} | {ts.TotalMilliseconds}ms"); + Log.Debug($"DeleteMag | Codice magazzino: {Mag.CodMag} | Descrizione magazzino: {Mag.DescMag} | {ts.TotalMilliseconds}ms"); return result; - // aggiungo record al DB } - - public async Task InsertNewSessione(InventorySessionModel newSess) + public async Task deleteScansione(ScanDataModel scan) { bool result = false; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); - result = await dbController.InsertNewSessione(newSess); + result = await dbController.deleteScansione(scan); // elimino cache redis... - RedisValue pattern = new RedisValue($"{redisBaseAddr}{redisSessionBaseAddr}*"); + RedisValue pattern = new RedisValue($"{redisScanBaseAddr}*"); bool answ = await ExecFlushRedisPattern(pattern); stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"InsertNewSessione | Id sessione: {newSess.InveSessID} | Descrizione sessione: {newSess.Description} | {ts.TotalMilliseconds}ms"); + Log.Debug($"deleteScansione | Id scansione: {scan.ScanID} | Codice scansionato: {scan.ScanValue} | {ts.TotalMilliseconds}ms"); return result; - // aggiungo record al DB + // elimino record dal DB } public async Task deleteSessione(InventorySessionModel session) @@ -178,107 +249,76 @@ namespace MP.INVE.Data return result; // elimino record dal DB } - public async Task deleteScansione(ScanDataModel scan) + + public string DeriptData(string encData) { - bool result = false; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - result = await dbController.deleteScansione(scan); - // elimino cache redis... - RedisValue pattern = new RedisValue($"{redisScanBaseAddr}*"); - bool answ = await ExecFlushRedisPattern(pattern); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"deleteScansione | Id scansione: {scan.ScanID} | Codice scansionato: {scan.ScanValue} | {ts.TotalMilliseconds}ms"); - return result; - // elimino record dal DB + return SteamCrypto.DecryptString(encData, passPhrase); } - public async Task InsertNewMag(AnagMagModel newMag) + public void Dispose() { - bool result = false; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - result = await dbController.InsertNewMag(newMag); - // elimino cache redis... - RedisValue pattern = new RedisValue($"{redisMagList}"); - bool answ = await ExecFlushRedisPattern(pattern); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"InsertNewMag | Codice magazzino: {newMag.CodMag} | Descrizione magazzino: {newMag.DescMag} | {ts.TotalMilliseconds}ms"); - return result; - // aggiungo record al DB - } - public async Task UpdateMag(AnagMagModel Mag) - { - bool result = false; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - result = await dbController.UpdateMag(Mag); - // elimino cache redis... - RedisValue pattern = new RedisValue($"{redisMagList}"); - bool answ = await ExecFlushRedisPattern(pattern); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"UpdateMag | Codice magazzino: {Mag.CodMag} | Descrizione magazzino: {Mag.DescMag} | {ts.TotalMilliseconds}ms"); - return result; - // aggiungo record al DB - } - public async Task DeleteMag(AnagMagModel Mag) - { - bool result = false; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - result = await dbController.DeleteMag(Mag); - // elimino cache redis... - RedisValue pattern = new RedisValue($"{redisMagList}:*"); - bool answ = await ExecFlushRedisPattern(pattern); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"DeleteMag | Codice magazzino: {Mag.CodMag} | Descrizione magazzino: {Mag.DescMag} | {ts.TotalMilliseconds}ms"); - return result; } - public bool loginOperatore(int matrOpr, string authkey) + public List ElencoLotti() { string source = ""; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); - AnagOperatoriModel? result = new AnagOperatoriModel(); - bool answ = false; + List? result = new List(); // cerco in redis... - RedisValue rawData = redisDb.StringGet($"{redisElencoOperatori}:{matrOpr}:{authkey}"); + RedisValue rawData = redisDb.StringGet(redisLottiInterni); if (!string.IsNullOrEmpty($"{rawData}")) { + result = JsonConvert.DeserializeObject>($"{rawData}"); - result = JsonConvert.DeserializeObject($"{rawData}"); - if (result != null) - { - answ = true; - source = "REDIS"; - } + source = "REDIS"; } else { - answ = dbController.LoginOperatore(matrOpr, authkey); - if (answ) - { - result = ElencoOperatori().Where(x => (x.MatrOpr == matrOpr) && (x.authKey == authkey)).SingleOrDefault(); - } + result = dbController.ElencoLotti(); // serializzo e salvo... rawData = JsonConvert.SerializeObject(result); - redisDb.StringSetAsync(redisOperatoreLogged, rawData, getRandTOut(redisLongTimeCache)); + redisDb.StringSetAsync(redisLottiInterni, rawData, getRandTOut(redisLongTimeCache)); source = "DB"; - } if (result == null) { - result = new AnagOperatoriModel(); + result = new List(); } stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"loginOperatore Read from {source}: {ts.TotalMilliseconds}ms"); - return answ; + Log.Debug($"ElencoLotti Read from {source}: {ts.TotalMilliseconds}ms"); + 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() @@ -313,147 +353,6 @@ namespace MP.INVE.Data return result; } - - public List LottoEsterno(string codArt, string codLotto, string codMagazzino) - { - string source = ""; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - List? result = new List(); - // cerco in redis... - result = dbController.LottoEsterno(codArt, codLotto, codMagazzino); - source = "DB"; - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"LottoEsterno Read from {source}: {ts.TotalMilliseconds}ms"); - return result; - } - - public List ScanList() - { - string source = ""; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - List? result = new List(); - // cerco in redis... - RedisValue rawData = redisDb.StringGet(redisScanBaseAddr); - if (!string.IsNullOrEmpty($"{rawData}")) - { - result = JsonConvert.DeserializeObject>($"{rawData}"); - - source = "REDIS"; - } - else - { - result = dbController.ScanList(); - // serializzo e salvo... - rawData = JsonConvert.SerializeObject(result); - redisDb.StringSetAsync(redisScanBaseAddr, rawData, getRandTOut(redisLongTimeCache)); - source = "DB"; - } - if (result == null) - { - result = new List(); - } - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"ScanList Read from {source}: {ts.TotalMilliseconds}ms"); - return result; - } - public List InveSessTotLotList(int sessID) - { - string source = ""; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - List? result = new List(); - result = dbController.InveSessTotLotList(sessID); - source = "DB"; - if (result == null) - { - result = new List(); - } - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"InveSessTotLotList Read from {source}: {ts.TotalMilliseconds}ms"); - return result; - } - - 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 = ""; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - List? result = new List(); - result = dbController.ScanByValueSessionOpr(scanData, inveSessId, Opr); - source = "DB"; - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"ScanByValueSessionOpr Read from {source}: {ts.TotalMilliseconds}ms"); - 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; - } - } - - /// - /// Aggiornamento record selezionato - /// - /// - /// - public async Task UpdateScan(ScanDataModel currRec) - { - var dbResult = await dbController.updateScan(currRec); - // elimino cache redis... - RedisValue pattern = new RedisValue(redisScanBaseAddr); - bool answ = await ExecFlushRedisPattern(pattern); - await Task.Delay(1); - return dbResult; - } - /// - /// Aggiornamento record selezionato - /// - /// - /// - public async Task artBySearch(string artSearch) - { - var dbResult = dbController.artBySearch(artSearch); - // elimino cache redis... - await Task.Delay(1); - return dbResult; - } - public List ElencoUDC() { string source = ""; @@ -486,74 +385,114 @@ namespace MP.INVE.Data return result; } - public AnagUdcModel IsUDC(string udc) - { - string source = ""; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - AnagUdcModel? result = new AnagUdcModel(); - result = dbController.IsUDC(udc); - source = "DB"; - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"IsUDC Read from {source}: {ts.TotalMilliseconds}ms"); - return result; - } - public AnagLottoModel LottoInterno(string lotto) - { - string source = ""; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - AnagLottoModel? result = new AnagLottoModel(); - result = dbController.LottoInterno(lotto); - source = "DB"; - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"LottoInterno Read from {source}: {ts.TotalMilliseconds}ms"); - return result; - } - public List ElencoLotti() - { - string source = ""; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - List? result = new List(); - // cerco in redis... - RedisValue rawData = redisDb.StringGet(redisLottiInterni); - if (!string.IsNullOrEmpty($"{rawData}")) - { - result = JsonConvert.DeserializeObject>($"{rawData}"); - - source = "REDIS"; - } - else - { - result = dbController.ElencoLotti(); - // serializzo e salvo... - rawData = JsonConvert.SerializeObject(result); - redisDb.StringSetAsync(redisLottiInterni, rawData, getRandTOut(redisLongTimeCache)); - source = "DB"; - } - if (result == null) - { - result = new List(); - } - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"ElencoLotti Read from {source}: {ts.TotalMilliseconds}ms"); - return result; - } - public string EncriptData(string rawData) { return SteamCrypto.EncryptString(rawData, passPhrase); } + /// + /// Svuota tutta la sessione dalla root di gestione + /// + /// + public async Task FlushRedisCache() + { + await Task.Delay(1); + RedisValue pattern = new RedisValue($"{redisBaseAddr}*"); + bool answ = await ExecFlushRedisPattern(pattern); + return answ; + } + /// + /// Svuota solo il pattern richiesto + /// + /// + /// + public async Task FlushRedisCache(string basePattern) + { + await Task.Delay(1); + RedisValue pattern = new RedisValue($"{basePattern}*"); + bool answ = await ExecFlushRedisPattern(pattern); + return answ; + } + + /// + /// Svuota cahce sessioni inventario + /// + public async Task FlushSessInvCache() + { + bool answ = await FlushRedisCache(redisSessionCurrList) && await FlushRedisCache(redisSessionHistList); + return answ; + } + + public async Task InsertNewMag(AnagMagModel newMag) + { + bool result = false; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + result = await dbController.InsertNewMag(newMag); + // elimino cache redis... + RedisValue pattern = new RedisValue($"{redisMagList}"); + bool answ = await ExecFlushRedisPattern(pattern); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"InsertNewMag | Codice magazzino: {newMag.CodMag} | Descrizione magazzino: {newMag.DescMag} | {ts.TotalMilliseconds}ms"); + return result; + // aggiungo record al DB + } + + public async Task InsertNewScansione(ScanDataModel newScan) + { + bool result = false; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + result = await dbController.InsertNewScansione(newScan); + // elimino cache redis... + RedisValue pattern = new RedisValue(redisScanBaseAddr); + bool answ = await ExecFlushRedisPattern(pattern); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"InsertNewScansione | Id scansione: {newScan.ScanID} | Id sessione: {newScan.InveSessID} | {ts.TotalMilliseconds}ms"); + return result; + // aggiungo record al DB + } + + public async Task InsertNewSessione(InventorySessionModel newSess) + { + bool result = false; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + result = await dbController.InsertNewSessione(newSess); + // elimino cache redis... + RedisValue pattern = new RedisValue($"{redisBaseAddr}{redisSessionBaseAddr}*"); + bool answ = await ExecFlushRedisPattern(pattern); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"InsertNewSessione | Id sessione: {newSess.InveSessID} | Descrizione sessione: {newSess.Description} | {ts.TotalMilliseconds}ms"); + return result; + // aggiungo record al DB + } + + public InventorySessionModel InventSessByID(int sessID) + { + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + InventorySessionModel result = new InventorySessionModel(); + string source = "DB"; + result = dbController.InventSessByID(sessID); + if (result == null) + { + result = new InventorySessionModel(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"InventSessByID Read from {source}: {ts.TotalMilliseconds}ms"); + return result; + } + public List InventSessCurrList() { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); - List result = new List(); + List? result = new List(); string source = "DB"; // cerco in redis... RedisValue rawData = redisDb.StringGet(redisSessionCurrList); @@ -579,36 +518,6 @@ namespace MP.INVE.Data return result; } - public List ElencoMagazzini() - { - 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.ElencoMagazzini(); - // 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 InventSessHistList() { Stopwatch stopWatch = new Stopwatch(); @@ -639,35 +548,214 @@ namespace MP.INVE.Data return result; } - public InventorySessionModel InventSessByID(int sessID) + public List InveSessTotLotList(int sessID) { + string source = ""; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); - InventorySessionModel result = new InventorySessionModel(); - string source = "DB"; - result = dbController.InventSessByID(sessID); + List? result = new List(); + result = dbController.InveSessTotLotList(sessID); + source = "DB"; if (result == null) { - result = new InventorySessionModel(); + result = new List(); } stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"InventSessByID Read from {source}: {ts.TotalMilliseconds}ms"); + Log.Debug($"InveSessTotLotList Read from {source}: {ts.TotalMilliseconds}ms"); return result; } - public async Task CloseOpenSessione(int sessID, bool flgClose) + public AnagUdcModel IsUDC(string udc) { + string source = ""; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); - bool result = false; - string source = "DB"; - result = await dbController.CloseOpenSessione(sessID, flgClose); + AnagUdcModel? result = new AnagUdcModel(); + result = dbController.IsUDC(udc); + source = "DB"; stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"CloseOpenSessione Read from {source}: {ts.TotalMilliseconds}ms"); + Log.Debug($"IsUDC Read from {source}: {ts.TotalMilliseconds}ms"); return result; } + + public bool loginOperatore(int matrOpr, string authkey) + { + string source = ""; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + AnagOperatoriModel? result = new AnagOperatoriModel(); + bool answ = false; + // cerco in redis... + RedisValue rawData = redisDb.StringGet($"{redisElencoOperatori}:{matrOpr}:{authkey}"); + if (!string.IsNullOrEmpty($"{rawData}")) + { + result = JsonConvert.DeserializeObject($"{rawData}"); + if (result != null) + { + answ = true; + source = "REDIS"; + } + } + else + { + answ = dbController.LoginOperatore(matrOpr, authkey); + if (answ) + { + result = ElencoOperatori().Where(x => (x.MatrOpr == matrOpr) && (x.authKey == authkey)).SingleOrDefault(); + } + // serializzo e salvo... + rawData = JsonConvert.SerializeObject(result); + redisDb.StringSetAsync(redisOperatoreLogged, rawData, getRandTOut(redisLongTimeCache)); + source = "DB"; + } + if (result == null) + { + result = new AnagOperatoriModel(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"loginOperatore Read from {source}: {ts.TotalMilliseconds}ms"); + return answ; + } + + public List LottoEsterno(string codArt, string codLotto, string codMagazzino) + { + string source = ""; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + List? result = new List(); + // cerco in redis... + result = dbController.LottoEsterno(codArt, codLotto, codMagazzino); + source = "DB"; + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"LottoEsterno Read from {source}: {ts.TotalMilliseconds}ms"); + return result; + } + + public AnagLottoModel LottoInterno(string lotto) + { + string source = ""; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + AnagLottoModel? result = new AnagLottoModel(); + result = dbController.LottoInterno(lotto); + source = "DB"; + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"LottoInterno Read from {source}: {ts.TotalMilliseconds}ms"); + 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; + } + + /// + /// Scansioni dato lotto e sessione + /// + /// + /// + /// + public async Task> ScanByLottoSession(string lotto, int inveSessId) + { + string source = ""; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + List? result = new List(); + result = dbController.ScanByLottoSession(lotto, inveSessId); + source = "DB"; + stopWatch.Stop(); + await Task.Delay(1); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"ScanByLottoSession Read from {source}: {ts.TotalMilliseconds}ms"); + return result; + } + + public List ScanByValueSessionOpr(string scanData, int inveSessId, string Opr) + { + string source = ""; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + List? result = new List(); + result = dbController.ScanByValueSessionOpr(scanData, inveSessId, Opr); + source = "DB"; + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"ScanByValueSessionOpr Read from {source}: {ts.TotalMilliseconds}ms"); + return result; + } + + public List ScanList() + { + string source = ""; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + List? result = new List(); + // cerco in redis... + RedisValue rawData = redisDb.StringGet(redisScanBaseAddr); + if (!string.IsNullOrEmpty($"{rawData}")) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + + source = "REDIS"; + } + else + { + result = dbController.ScanList(); + // serializzo e salvo... + rawData = JsonConvert.SerializeObject(result); + redisDb.StringSetAsync(redisScanBaseAddr, rawData, getRandTOut(redisLongTimeCache)); + source = "DB"; + } + if (result == null) + { + result = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"ScanList Read from {source}: {ts.TotalMilliseconds}ms"); + return result; + } + public async Task TransferSessione(int sessID) { Stopwatch stopWatch = new Stopwatch(); @@ -680,16 +768,59 @@ namespace MP.INVE.Data Log.Debug($"TransferSessione Read from {source}: {ts.TotalMilliseconds}ms"); return result; } + + /// + /// Restituisce valore della stringa (SE disponibile) + /// + /// + /// + public async Task tryGetConfig(string keyName) + { + string answ = ""; + // preselezione valori + var configData = await ConfigGetAll(); + var currRec = configData.FirstOrDefault(x => x.Chiave == keyName); + if (currRec != null) + { + answ = currRec.Valore; + } + + return answ; + } + + public async Task UpdateMag(AnagMagModel Mag) + { + bool result = false; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + result = await dbController.UpdateMag(Mag); + // elimino cache redis... + RedisValue pattern = new RedisValue($"{redisMagList}"); + bool answ = await ExecFlushRedisPattern(pattern); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"UpdateMag | Codice magazzino: {Mag.CodMag} | Descrizione magazzino: {Mag.DescMag} | {ts.TotalMilliseconds}ms"); + return result; + // aggiungo record al DB + } + + /// + /// Aggiornamento record selezionato + /// + /// + /// + public async Task UpdateScan(ScanDataModel currRec) + { + var dbResult = await dbController.updateScan(currRec); + // elimino cache redis... + RedisValue pattern = new RedisValue(redisScanBaseAddr); + bool answ = await ExecFlushRedisPattern(pattern); + await Task.Delay(1); + return dbResult; + } + #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 /// @@ -702,13 +833,10 @@ namespace MP.INVE.Data double rndValue = (double)stdMinutes + (double)rand.Next(1, 60) / 60; return TimeSpan.FromMinutes(rndValue); } - public async Task FlushRedisCache() - { - await Task.Delay(1); - RedisValue pattern = new RedisValue($"{redisBaseAddr}*"); - bool answ = await ExecFlushRedisPattern(pattern); - return answ; - } + + #endregion Protected Methods + + #region Private Methods /// /// Esegue flush memoria redis dato pattern @@ -739,53 +867,6 @@ namespace MP.INVE.Data return answ; } - #endregion Protected Methods - - #region Private Fields - - private const string redisBaseAddr = "MP:INVE"; - private const string redisSessionBaseAddr = ":Session"; - private const string redisOperatoriBaseAddr = ":Operatore"; - private const string redisLottiBaseAddr = ":Lotti"; - private const string redisUdcBaseAddr = ":UDC"; - private const string redisTotLottoAddr = ":TotaleLotto"; - private const string redisLottiInterni = redisBaseAddr + redisLottiBaseAddr + ":LottiInterni"; - private const string redisLottiEsterni = redisBaseAddr + redisLottiBaseAddr + ":LottiEsterni"; - private const string redisConfigBaseAddr = ":Config"; - private const string redisScanBaseAddr = redisBaseAddr + ":Scan"; - private const string redisElencoOperatori = redisBaseAddr + redisOperatoriBaseAddr + ":ListOperatori"; - private const string redisOperatoreLogged = redisBaseAddr + redisOperatoriBaseAddr + ":OperatoreLogged"; - private const string redisSessionCurrList = redisBaseAddr + redisSessionBaseAddr + ":ListSessHist"; - private const string redisSessionHistList = redisBaseAddr + redisSessionBaseAddr + ":ListSessCurr"; - private const string redisMagList = redisBaseAddr + ":ListMag"; - 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 + #endregion Private Methods } } \ No newline at end of file diff --git a/MP.INVE/Data/SelectInveSessionParams.cs b/MP.INVE/Data/SelectInveSessionParams.cs index 641536c3..9fbd04aa 100644 --- a/MP.INVE/Data/SelectInveSessionParams.cs +++ b/MP.INVE/Data/SelectInveSessionParams.cs @@ -23,6 +23,7 @@ namespace MP.INVE.Data public int currIdSession { get; set; } = 0; public int currIdMag { get; set; } = 0; public bool reqNew { get; set; } = false; + public string searchVal { get; set; } = ""; #endregion Public Properties @@ -33,6 +34,9 @@ namespace MP.INVE.Data if (!(obj is SelectInveSessionParams item)) return false; + if (searchVal != item.searchVal) + return false; + if (MaxRecord != item.MaxRecord) return false; diff --git a/MP.INVE/MP.INVE.csproj b/MP.INVE/MP.INVE.csproj index efe90c46..e456678f 100644 --- a/MP.INVE/MP.INVE.csproj +++ b/MP.INVE/MP.INVE.csproj @@ -5,7 +5,7 @@ enable enable MP.INVE - 6.16.2212.1610 + 6.16.2212.1915 diff --git a/MP.INVE/Pages/Acquisizione.razor b/MP.INVE/Pages/Acquisizione.razor index f2122071..dfe0ef8c 100644 --- a/MP.INVE/Pages/Acquisizione.razor +++ b/MP.INVE/Pages/Acquisizione.razor @@ -1,27 +1,5 @@ @page "/Acquisizione" -@*
-
MP.INVE
-
- Acquisizione -
-
- -
-
- -
-
-
Menu
- -
- -
*@
@@ -41,9 +19,6 @@
- @*if (rawScan != null) - { - }*@
diff --git a/MP.INVE/Pages/Cancellazione.razor b/MP.INVE/Pages/Cancellazione.razor index 744564f8..13f4ada8 100644 --- a/MP.INVE/Pages/Cancellazione.razor +++ b/MP.INVE/Pages/Cancellazione.razor @@ -1,36 +1,14 @@ @page "/Cancellazione" -@*
-
MP.INVE
-
- Cancellazione -
-
- -
-
-
-
-
Menu
- -
-
- - -
-
*@
- @if (currScan != null) { -
+
Dati ultima scansione @@ -72,7 +50,7 @@ Quantità:
- @Math.Round(currScan.Qty, 0) + @Math.Round(currScan.Qty, 2)
diff --git a/MP.INVE/Pages/ClosedSession.razor b/MP.INVE/Pages/ClosedSession.razor new file mode 100644 index 00000000..8785d2b3 --- /dev/null +++ b/MP.INVE/Pages/ClosedSession.razor @@ -0,0 +1,7 @@ +@page "/ClosedSession" +
+ +
+

ClosedSession

+ + diff --git a/MP.INVE/Pages/ClosedSession.razor.cs b/MP.INVE/Pages/ClosedSession.razor.cs new file mode 100644 index 00000000..a19bbebc --- /dev/null +++ b/MP.INVE/Pages/ClosedSession.razor.cs @@ -0,0 +1,54 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.WebUtilities; +using MP.INVE.Data; + +namespace MP.INVE.Pages +{ + public partial class ClosedSession + { + #region Protected Properties + + protected string descr { get; set; } = ""; + protected string idOpr { get; set; } = null!; + protected string link { get; set; } = ""; + protected string magazzinoId { get; set; } = ""; + + protected string magInv { get; set; } = ""; + + [Inject] + protected MiDataService MIService { get; set; } = null!; + + [Inject] + protected NavigationManager NavManager { get; set; } = null!; + + protected int sessionId { get; set; } = 0; + + #endregion Protected Properties + + #region Protected Methods + + protected override async Task OnInitializedAsync() + { + await Task.Delay(1); + var uri = NavManager.ToAbsoluteUri(NavManager.Uri); + 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)) + { + idOpr = _matrOpr; + sessionId = int.Parse(_inveSessionId); + magazzinoId = _idMag; + + // 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; + } + } + link = $"ClosedSession?idOpr={idOpr}&sessID={sessionId}"; + } + + #endregion Protected Methods + } +} \ No newline at end of file diff --git a/MP.INVE/Pages/Contacts.razor.cs b/MP.INVE/Pages/Contacts.razor.cs index dc094d4b..1155597b 100644 --- a/MP.INVE/Pages/Contacts.razor.cs +++ b/MP.INVE/Pages/Contacts.razor.cs @@ -24,7 +24,6 @@ namespace MP.INVE.Pages { Titolo = "MP INVE"; Messaggio = "I nostri contattatti e siti di supporto"; - AppMService.ShowSearch = false; } #endregion Protected Methods diff --git a/MP.INVE/Pages/Starter.razor b/MP.INVE/Pages/ElencoMagazzini.razor similarity index 100% rename from MP.INVE/Pages/Starter.razor rename to MP.INVE/Pages/ElencoMagazzini.razor diff --git a/MP.INVE/Pages/Starter.razor.cs b/MP.INVE/Pages/ElencoMagazzini.razor.cs similarity index 93% rename from MP.INVE/Pages/Starter.razor.cs rename to MP.INVE/Pages/ElencoMagazzini.razor.cs index e15de5c8..f59742f5 100644 --- a/MP.INVE/Pages/Starter.razor.cs +++ b/MP.INVE/Pages/ElencoMagazzini.razor.cs @@ -22,7 +22,7 @@ using MP.Data.DatabaseModels; namespace MP.INVE.Pages { - public partial class Starter + public partial class ElencoMagazzini { [Inject] private IConfiguration Configuration { get; set; } = null!; @@ -85,13 +85,14 @@ namespace MP.INVE.Pages } - private List? ElencoMagazzini; - protected override async Task OnInitializedAsync() + private List? ListaMagazzini; + + protected override async Task OnParametersSetAsync() { - await Task.Delay(1); await reloadData(); - //await getId(); + await Task.Delay(1); } + private void openNew() { reqNew = true; @@ -106,9 +107,9 @@ namespace MP.INVE.Pages private async Task reloadData() { await Task.Delay(1); - ElencoMagazzini = null; + //ListaMagazzini = null; isLoading = true; - ElencoMagazzini = MIDataservice.ElencoMagazzini(); + //ListaMagazzini = MIDataservice.MagazziniList(); isLoading = false; } @@ -128,7 +129,7 @@ namespace MP.INVE.Pages await MIDataservice.InsertNewMag(newMag); NavManager.NavigateTo(NavManager.Uri, true); //await MIDataservice.FlushRedisCache(); - await reloadData(); + //await reloadData(); } else { diff --git a/MP.INVE/Pages/Index.razor.cs b/MP.INVE/Pages/Index.razor.cs index 5f7b5a65..8b106951 100644 --- a/MP.INVE/Pages/Index.razor.cs +++ b/MP.INVE/Pages/Index.razor.cs @@ -1,19 +1,11 @@ -using Blazored.LocalStorage; -using Microsoft.AspNetCore.Components; using MP.Data.DatabaseModels; -using MP.Data.DTO; -using MP.INVE.Data; namespace MP.INVE.Pages { public partial class Index { - #region Public Properties - //public List? ElencoLink { get; set; } - #endregion Public Properties - #region Protected Methods protected override async Task OnInitializedAsync() @@ -34,14 +26,9 @@ namespace MP.INVE.Pages //await getId(); await Task.Delay(1); } + #endregion Protected Methods - #region Private Fields - - private string currAzienda = ""; - - #endregion Private Fields - #region Private Properties private List? configData { get; set; } = null; diff --git a/MP.INVE/Pages/InveSession.razor b/MP.INVE/Pages/InveSession.razor index 84685ce3..3e90668e 100644 --- a/MP.INVE/Pages/InveSession.razor +++ b/MP.INVE/Pages/InveSession.razor @@ -4,10 +4,19 @@
-
-

Sessione

+
+
+
+ Sessione +
+
+ +
+
-
+
In corso @@ -18,10 +27,12 @@
-
- +
+
+ + + +
@@ -32,7 +43,7 @@ } else { - + }
diff --git a/MP.INVE/Pages/InveSession.razor.cs b/MP.INVE/Pages/InveSession.razor.cs index 618ca295..0ac93b5d 100644 --- a/MP.INVE/Pages/InveSession.razor.cs +++ b/MP.INVE/Pages/InveSession.razor.cs @@ -28,13 +28,11 @@ namespace MP.INVE.Pages private SelectInveSessionParams currParams = new SelectInveSessionParams(); - private List? elencoSessioni; - private List? SearchRecords; - private List? elencoOperatori; - private List? ElencoMagazzini; - - private DataPager pagerSession = null!; - + protected string searchVal + { + get => currParams.searchVal; + set => currParams.searchVal = value; + } protected override async Task OnInitializedAsync() { await getId(); @@ -50,6 +48,11 @@ namespace MP.INVE.Pages await Task.Delay(1); } + protected async Task reset() + { + searchVal = ""; + await Task.Delay(1); + } private bool isLoading { get; set; } = false; @@ -124,11 +127,12 @@ namespace MP.INVE.Pages { currPage = newNum; } - + [Inject] + protected MessageService MsgService { get; set; } = null!; protected async Task getId() { OperatoreDTO local = new OperatoreDTO(); - local = await localStorage.GetItemAsync("MatrOpr"); + local = await MsgService.getCurrOperDtoAsync(); if (local != null) { idOperatore = local.MatrOpr.ToString(); diff --git a/MP.INVE/Pages/Invio.razor b/MP.INVE/Pages/Invio.razor index 972f1022..323c0c15 100644 --- a/MP.INVE/Pages/Invio.razor +++ b/MP.INVE/Pages/Invio.razor @@ -12,7 +12,19 @@ else
-

Invio

+
+ Invio +
+
+ +
+
+
+ + + +
+
@@ -65,26 +77,26 @@ else
- @if (sessione.DtEnd == null) { - + } else { - + } @if ((sessione.DtEnd != null) && (!sessione.Transferred)) { - - + + } else { - - + + }
@@ -104,17 +116,20 @@ else { @if (sessID != 0) { - +
+
+ Totale lotti +
+
+ +
+ +
} }
- - @*if (sessID != 0) - { - - }*@
} } diff --git a/MP.INVE/Pages/Invio.razor.cs b/MP.INVE/Pages/Invio.razor.cs index 51abbc87..f2cdbfb4 100644 --- a/MP.INVE/Pages/Invio.razor.cs +++ b/MP.INVE/Pages/Invio.razor.cs @@ -1,79 +1,77 @@ -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.INVE; -using MP.INVE.Shared; -using MP.INVE.Components; using Blazored.LocalStorage; -using MP.Data.DTO; -using MP.Data; -using MP.INVE.Data; -using MP.Data.DatabaseModels; +using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.WebUtilities; +using Microsoft.JSInterop; +using MP.Data.DatabaseModels; +using MP.Data.DTO; +using MP.INVE.Data; namespace MP.INVE.Pages { public partial class Invio { + #region Public Properties + [Inject] public MiDataService MIService { get; set; } = null!; + #endregion Public Properties + + #region Protected Fields + protected SelectInvioParams invioParams = new SelectInvioParams(); + protected bool isLoading = false; + protected bool mostra = false; protected SelectInveSessionParams sessParams = new SelectInveSessionParams(); - private int totalCount + #endregion Protected Fields + + #region Protected Properties + + protected string BaseUrlTab { get => $"{Configuration["ServerConf:BaseUrlJumper"]}"; } + + protected string codMag { get; set; } = ""; + + [Inject] + protected MessageService MsgService { get; set; } = null!; + + protected string rawCode { - get => invioParams.TotCount; - set + get { - if (invioParams.TotCount != value) - { - invioParams.TotCount = value; - } + string answ = ""; + answ = $"{BaseUrlTab}IdSessione={sessID}&IdMag={codMag}&MatrOpr={idOperatore}&UserAuthKey={authKey}"; + return answ; } } - private int numRecord + + protected string searchVal { get; set; } = ""; + + protected int sessID { get; set; } = 0; + + #endregion Protected Properties + + #region Protected Methods + + protected async void apriSessione(int sessID) { - get => invioParams.NumRec; - set + var open = await MIService.CloseOpenSessione(sessID, false); + await resetCacheSessInv(); + if (open) { - if (invioParams.NumRec != value) - { - invioParams.NumRec = value; - } + NavManager.NavigateTo(NavManager.Uri, true); } } - private int currPage + + protected async void chiudiSessione(int sessID) { - get => invioParams.CurrPage; - set + var closed = await MIService.CloseOpenSessione(sessID, true); + await resetCacheSessInv(); + if (closed) { - if (invioParams.CurrPage != value) - { - invioParams.CurrPage = value; - } + NavManager.NavigateTo(NavManager.Uri, true); } } - private string idOperatore - { - get => sessParams.idOperatore; - set => sessParams.idOperatore = value; - } - private string authKey - { - get => sessParams.authKey; - set => sessParams.authKey = value; - } protected void ForceReload(int newNum) { @@ -84,52 +82,26 @@ namespace MP.INVE.Pages { currPage = newNum; } - protected bool mostra = false; + + protected async Task getId() + { + OperatoreDTO local = new OperatoreDTO(); + local = await MsgService.getCurrOperDtoAsync(); + if (local != null) + { + idOperatore = local.MatrOpr.ToString(); + authKey = local.hashAuthKey; + } + } protected void mostraDati() { mostra = true; } - protected async void chiudiSessione(int sessID) - { - var closed = await MIService.CloseOpenSessione(sessID, true); - if (closed) - { - NavManager.NavigateTo(NavManager.Uri, true); - } - } - protected async void apriSessione(int sessID) - { - var open = await MIService.CloseOpenSessione(sessID, false); - if (open) - { - NavManager.NavigateTo(NavManager.Uri, true); - } - } - protected async void trasfSessione(int sessID) - { - var trasf = await MIService.TransferSessione(sessID); - if (trasf) - { - NavManager.NavigateTo(NavManager.Uri, true); - } - } - protected override async Task OnInitializedAsync() - { - - var uri = NavManager.ToAbsoluteUri(NavManager.Uri); - if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("sessID", out var _inveSessionId) && QueryHelpers.ParseQuery(uri.Query).TryGetValue("codMag", out var _idMag)) - { - sessID = int.Parse(_inveSessionId); - codMag = _idMag; - } - - await reloadData(); - - } - protected async override Task OnAfterRenderAsync(bool firstRender) + protected override async Task OnAfterRenderAsync(bool firstRender) { + await Task.Delay(50); if (firstRender) { if (sessione != null) @@ -144,33 +116,118 @@ namespace MP.INVE.Pages } } - [Inject] - private IConfiguration Configuration { get; set; } = null!; - [Inject] - private IJSRuntime JSRuntime { get; set; } = null!; - [Inject] - private NavigationManager NavManager { get; set; } = null!; - [Inject] - private ILocalStorageService localStorage { get; set; } = null!; - protected string BaseUrlTab { get => $"{Configuration["ServerConf:BaseUrlJumper"]}"; } - - - protected string rawCode + protected override async Task OnInitializedAsync() { - get + var uri = NavManager.ToAbsoluteUri(NavManager.Uri); + if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("sessID", out var _inveSessionId) && QueryHelpers.ParseQuery(uri.Query).TryGetValue("codMag", out var _idMag)) { - string answ = ""; - answ = $"{BaseUrlTab}IdSessione={sessID}&IdMag={codMag}&MatrOpr={idOperatore}&UserAuthKey={authKey}"; - return answ; + sessID = int.Parse(_inveSessionId); + codMag = _idMag; + } + + await reloadData(); + } + + protected async Task returnToSessions() + { + await resetCacheSessInv(); + // ritorno pagina... + NavManager.NavigateTo("InveSession", true); + } + + protected async void trasfSessione(int sessID) + { + var trasf = await MIService.TransferSessione(sessID); + await resetCacheSessInv(); + if (trasf) + { + NavManager.NavigateTo(NavManager.Uri, true); } } + protected void UpdateTotCount(int newTotCount) + { + totalCount = newTotCount; + } + + #endregion Protected Methods + + #region Private Fields + private InventorySessionModel? sessione; - protected bool isLoading = false; + + #endregion Private Fields + + #region Private Properties + + private int _totalCount { get; set; } = 0; + + private string authKey + { + get => sessParams.authKey; + set => sessParams.authKey = value; + } + + [Inject] + private IConfiguration Configuration { get; set; } = null!; + + private int currPage + { + get => invioParams.CurrPage; + set + { + if (invioParams.CurrPage != value) + { + invioParams.CurrPage = value; + } + } + } + + private string idOperatore + { + get => sessParams.idOperatore; + set => sessParams.idOperatore = value; + } + + [Inject] + private IJSRuntime JSRuntime { get; set; } = null!; + + [Inject] + private ILocalStorageService localStorage { get; set; } = null!; + + [Inject] + private NavigationManager NavManager { get; set; } = null!; + + private int numRecord + { + get => invioParams.NumRec; + set + { + if (invioParams.NumRec != value) + { + invioParams.NumRec = value; + } + } + } + + private int totalCount + { + get => invioParams.TotCount; + set + { + if (invioParams.TotCount != value) + { + invioParams.TotCount = value; + } + } + } + + #endregion Private Properties + + #region Private Methods private async Task reloadData() { - sessione = null; isLoading = true; sessione = MIService.InventSessByID(sessID); @@ -178,19 +235,16 @@ namespace MP.INVE.Pages isLoading = false; } - protected int sessID { get; set; } = 0; - protected string codMag { get; set; } = ""; - - - protected async Task getId() + private void reset() { - OperatoreDTO local = new OperatoreDTO(); - local = await localStorage.GetItemAsync("MatrOpr"); - if (local != null) - { - idOperatore = local.MatrOpr.ToString(); - authKey = local.hashAuthKey; - } + searchVal = ""; } + + private async Task resetCacheSessInv() + { + await MIService.FlushSessInvCache(); + } + + #endregion Private Methods } } \ No newline at end of file diff --git a/MP.INVE/Pages/Jumper.razor.cs b/MP.INVE/Pages/Jumper.razor.cs index c0cc5080..ebbaefd0 100644 --- a/MP.INVE/Pages/Jumper.razor.cs +++ b/MP.INVE/Pages/Jumper.razor.cs @@ -25,6 +25,8 @@ namespace MP.INVE.Pages [Inject] protected MiDataService MIService { get; set; } = null!; + [Inject] + protected MessageService MsgService { get; set; } = null!; [Inject] protected NavigationManager NavManager { get; set; } = null!; @@ -69,7 +71,10 @@ namespace MP.INVE.Pages dtExp = DateTime.Now.AddMinutes(1) }; +#if false await localStorage.SetItemAsync("MatrOpr", currOpr); +#endif + await MsgService.setCurrOperDtoAsync(sessionOpr); await sessionStorage.SetItemAsync("idSessione", inveSessionId); } NavManager.NavigateTo($"Acquisizione?idSess={inveSessionId}&idOpr={idOpr}&codMag={codMag}"); diff --git a/MP.INVE/Pages/OperatoreLogin.razor.cs b/MP.INVE/Pages/OperatoreLogin.razor.cs index 9af22264..7cdb4d99 100644 --- a/MP.INVE/Pages/OperatoreLogin.razor.cs +++ b/MP.INVE/Pages/OperatoreLogin.razor.cs @@ -60,8 +60,9 @@ namespace MP.INVE.Pages elencoOperatori = MIDataservice.ElencoOperatori(); isLoading = false; } - - private void login() + [Inject] + protected MessageService MsgService { get; set; } = null!; + private async void login() { logged = MIDataservice.loginOperatore(idOperatore, authKey); @@ -80,7 +81,10 @@ namespace MP.INVE.Pages hashAuthKey = hash, dtExp = DateTime.Now.AddMinutes(1) }; - localStorage.SetItemAsync("MatrOpr", sessionOpr); +#if false + localStorage.SetItemAsync("MatrOpr", sessionOpr); +#endif + await MsgService.setCurrOperDtoAsync(sessionOpr); NavManager.NavigateTo("InveSession", true); } } diff --git a/MP.INVE/Resources/ChangeLog.html b/MP.INVE/Resources/ChangeLog.html index caaf0c73..0c65bcd2 100644 --- a/MP.INVE/Resources/ChangeLog.html +++ b/MP.INVE/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOINVE -

Versione: 6.16.2212.1610

+

Versione: 6.16.2212.1915


Note di rilascio:
  • diff --git a/MP.INVE/Resources/VersNum.txt b/MP.INVE/Resources/VersNum.txt index 31f86dce..0ce79757 100644 --- a/MP.INVE/Resources/VersNum.txt +++ b/MP.INVE/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2212.1610 +6.16.2212.1915 diff --git a/MP.INVE/Resources/manifest.xml b/MP.INVE/Resources/manifest.xml index 3e35ff8d..81e37a78 100644 --- a/MP.INVE/Resources/manifest.xml +++ b/MP.INVE/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2212.1610 + 6.16.2212.1915 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.INVE/Shared/NavMenu.razor b/MP.INVE/Shared/NavMenu.razor index 544e4bd0..e921f79d 100644 --- a/MP.INVE/Shared/NavMenu.razor +++ b/MP.INVE/Shared/NavMenu.razor @@ -52,26 +52,36 @@
-@* + @* *@ @**@ + +
+ +
+
+ Invio +
+
+
*@ }
diff --git a/MP.INVE/appsettings.Production.json b/MP.INVE/appsettings.Production.json index 8aa1fd63..65a7782c 100644 --- a/MP.INVE/appsettings.Production.json +++ b/MP.INVE/appsettings.Production.json @@ -10,8 +10,11 @@ "AllowedHosts": "*", "CodApp": "MP.INVE", "ConnectionStrings": { - "Mp.Data": "Server=localhost\\SQLEXPRESS;Database=MoonPro; User ID=steamware;Password=viadante16; integrated security=False; MultipleActiveResultSets=True; App=Blazor.ServerApp;", - "Redis": "localhost:6379,DefaultDatabase=13,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false" + "Mp.Inve": "Server=SQL2016DEV;Database=MoonPro_MAG; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.INVE;", + "Mp.IS": "Server=SQL2016DEV;Database=MoonPro_IS_EdilChim; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.INVE;", + "Mp.Data": "Server=SQL2016DEV;Database=MoonPro; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.INVE;", + "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" }, "ServerConf": { "maxAge": "2000", @@ -19,4 +22,4 @@ "redisLongTimeCache": 15, "MpIoBaseUrl": "http://localhost/MP/IO/" } -} +} \ No newline at end of file