From 7a599e6441bc0ccfd422f77ce0af6f16e1b36f5e Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Mon, 21 Nov 2022 10:09:04 +0100 Subject: [PATCH 01/11] elenco magazzini: -creato componente separato -aggiunta datapager --- MP.INVE/Components/InveSessionList.razor.cs | 4 +- MP.INVE/Components/MagList.razor | 93 +++++++++++++ MP.INVE/Components/MagList.razor.cs | 145 ++++++++++++++++++++ MP.INVE/Data/SelectMagListParams.cs | 60 ++++++++ MP.INVE/MP.INVE.csproj | 2 +- MP.INVE/Pages/Starter.razor | 96 +------------ MP.INVE/Pages/Starter.razor.cs | 101 +++++++------- MP.INVE/Resources/ChangeLog.html | 2 +- MP.INVE/Resources/VersNum.txt | 2 +- MP.INVE/Resources/manifest.xml | 2 +- 10 files changed, 361 insertions(+), 146 deletions(-) create mode 100644 MP.INVE/Components/MagList.razor create mode 100644 MP.INVE/Components/MagList.razor.cs create mode 100644 MP.INVE/Data/SelectMagListParams.cs diff --git a/MP.INVE/Components/InveSessionList.razor.cs b/MP.INVE/Components/InveSessionList.razor.cs index 53d0c314..c7c22979 100644 --- a/MP.INVE/Components/InveSessionList.razor.cs +++ b/MP.INVE/Components/InveSessionList.razor.cs @@ -131,7 +131,7 @@ namespace MP.INVE.Components }; await MIDataservice.InsertNewSessione(newSess); - NavManager.NavigateTo(NavManager.Uri, true); + NavManager.NavigateTo("Session", true); await reloadData(); } else @@ -150,7 +150,7 @@ namespace MP.INVE.Components if (alert) { await MIDataservice.deleteSessione(session); - NavManager.NavigateTo(NavManager.Uri, true); + NavManager.NavigateTo("Session", true); await reloadData(); } } diff --git a/MP.INVE/Components/MagList.razor b/MP.INVE/Components/MagList.razor new file mode 100644 index 00000000..d8a0cec8 --- /dev/null +++ b/MP.INVE/Components/MagList.razor @@ -0,0 +1,93 @@ +@if (reqNew) +{ +
+
+
+
+
+ Avvia una nuova sessione +
+
+
+
+
+
+
+
+ Codice magazzino + +
+
+
+
+ Descrizione + +
+
+
+
+
+
+
+
+
+
+ +
+
+
+ @if (codMag != "") + { +
+ +
+ } +
+
+
+
+
+
+} + + + + + + + + + + + + @if (elencoMagazzini != null) + { + @foreach (var item in elencoMagazzini) + { + + + + + + + + + + } + } + +
ID magazzinoCodice magazzinoCodice aziendaDescrizione
+ @item.MagID + + @item.CodMag + + @item.CodCS + + @item.DescMag + + +
+ + diff --git a/MP.INVE/Components/MagList.razor.cs b/MP.INVE/Components/MagList.razor.cs new file mode 100644 index 00000000..9f41e6b6 --- /dev/null +++ b/MP.INVE/Components/MagList.razor.cs @@ -0,0 +1,145 @@ +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 Blazored.SessionStorage; +using MP.Data.DatabaseModels; +using MP.INVE.Data; + +namespace MP.INVE.Components +{ + public partial class MagList + { + [Inject] + private IConfiguration Configuration { get; set; } = null!; + + [Inject] + private ISessionStorageService sessionStorage { get; set; } = null!; + [Inject] + private ILocalStorageService localStorage { get; set; } = null!; + + [Inject] + private MiDataService MIDataservice { get; set; } = null!; + + [Inject] + private NavigationManager NavManager { get; set; } = null!; + + [Inject] + private IJSRuntime JSRuntime { get; set; } = null!; + + [Parameter] + public SelectMagListParams currParams { get; set; } = null!; + + [Parameter] + public bool isLoading { get; set; } + + protected override async Task OnParametersSetAsync() + { + await reloadData(); + } + private void closeNew() + { + reqNew = false; + codMag = ""; + desc = ""; + } + private List? elencoMagazzini; + private List? SearchRecords; + private async Task insertNewMag() + { + var alert = await JSRuntime.InvokeAsync("confirm", "Confermi di voler creare un nuovo magazzino?"); + + if (alert) + { + AnagMagModel newMag = new AnagMagModel() + { + CodMag = codMag, + CodCS = "EC", + DescMag = desc, + Nascosto = false + }; + await MIDataservice.InsertNewMag(newMag); + NavManager.NavigateTo("Elencomagazzini", true); + //await MIDataservice.FlushRedisCache(); + await reloadData(); + } + else + { + closeNew(); + } + } + + private async Task reloadData() + { + isLoading = true; + elencoMagazzini = null; + SearchRecords = null; + SearchRecords = MIDataservice.ElencoMagazzini(); + totalCount = SearchRecords.Count; + elencoMagazzini = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); + await Task.Delay(1); + await InvokeAsync(() => StateHasChanged()); + await Task.Delay(1); + isLoading = false; + } + private async Task deleteMag(AnagMagModel mag) + { + var alert = await JSRuntime.InvokeAsync("confirm", "Confermi di voler eliminare il magazzino selezionato?"); + if (alert) + { + await MIDataservice.DeleteMag(mag); + NavManager.NavigateTo("Elencomagazzini", true); + await reloadData(); + } + } + private bool reqNew + { + get => currParams.reqNew; + set => currParams.reqNew = value; + } + + private int totalCount + { + 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 bool inCorso + { + get => currParams.inCorso; + set => currParams.inCorso = value; + } + private string codMag { get; set; } = ""; + private string desc { get; set; } = ""; + } +} \ No newline at end of file diff --git a/MP.INVE/Data/SelectMagListParams.cs b/MP.INVE/Data/SelectMagListParams.cs new file mode 100644 index 00000000..a601179b --- /dev/null +++ b/MP.INVE/Data/SelectMagListParams.cs @@ -0,0 +1,60 @@ +using MP.Data; + +namespace MP.INVE.Data +{ + public class SelectMagListParams + { + #region Public Constructors + + public SelectMagListParams() + { } + + #endregion Public Constructors + + #region Public Properties + + public int CurrPage { get; set; } = 1; + public int NumRec { get; set; } = 10; + public int TotCount { get; set; } = 0; + public int MaxRecord { get; set; } = 100; + public bool inCorso { get; set; } = true; + public bool reqNew { get; set; } = false; + + #endregion Public Properties + + #region Public Methods + + public override bool Equals(object obj) + { + if (!(obj is SelectInveSessionParams item)) + return false; + + if (MaxRecord != item.MaxRecord) + return false; + + if (TotCount != item.TotCount) + return false; + + if (NumRec != item.NumRec) + + if (CurrPage != item.CurrPage) + return false; + + if (inCorso != item.inCorso) + return false; + + if (reqNew != item.reqNew) + return false; + + + return true; + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } + + #endregion Public Methods + } +} \ No newline at end of file diff --git a/MP.INVE/MP.INVE.csproj b/MP.INVE/MP.INVE.csproj index 4b888e6e..ee51c709 100644 --- a/MP.INVE/MP.INVE.csproj +++ b/MP.INVE/MP.INVE.csproj @@ -5,7 +5,7 @@ enable enable MP.INVE - 6.16.2211.2108 + 6.16.2211.2110 diff --git a/MP.INVE/Pages/Starter.razor b/MP.INVE/Pages/Starter.razor index a23b7545..f4cf3b72 100644 --- a/MP.INVE/Pages/Starter.razor +++ b/MP.INVE/Pages/Starter.razor @@ -25,102 +25,12 @@ } else { - @if (reqNew) - { -
-
-
-
-
- Avvia una nuova sessione -
-
-
-
-
-
-
-
- Codice magazzino - -
-
-
-
- Descrizione - -
-
-
-
-
-
-
-
-
-
- -
-
-
- @if (codMag != "") - { -
- -
- } -
-
-
-
-
-
- } - - - - - - - - - - - - @if (elencoMagazzini != null) - { - @foreach (var item in elencoMagazzini) - { - - - - - - - - - - } - } - -
ID magazzinoCodice magazzinoCodice aziendaDescrizione
- @item.MagID - - @item.CodMag - - @item.CodCS - - @item.DescMag - - -
+ } - diff --git a/MP.INVE/Pages/Starter.razor.cs b/MP.INVE/Pages/Starter.razor.cs index 25b42cc3..76cd6bf4 100644 --- a/MP.INVE/Pages/Starter.razor.cs +++ b/MP.INVE/Pages/Starter.razor.cs @@ -38,7 +38,52 @@ namespace MP.INVE.Pages [Inject] private NavigationManager NavManager { get; set; } = null!; + public SelectMagListParams currParams = new SelectMagListParams(); + private int totalCount + { + get => currParams.TotCount; + set => currParams.TotCount = value; + } + private int numRecord + { + get => currParams.NumRec; + set + { + if (currParams.NumRec != value) + { + currParams.NumRec = value; + } + } + } + private int currPage + { + get => currParams.CurrPage; + set + { + if (currParams.CurrPage != value) + { + currParams.CurrPage = value; + } + } + } + private bool reqNew + { + get => currParams.reqNew; + set => currParams.reqNew = value; + } + private bool inCorso + { + get => currParams.inCorso; + set + { + if (currParams.inCorso != value) + { + currParams.inCorso = value; + } + } + + } private List? elencoMagazzini; protected override async Task OnInitializedAsync() @@ -101,57 +146,19 @@ namespace MP.INVE.Pages await reloadData(); } } + protected void ForceReload(int newNum) + { + numRecord = newNum; + } + + protected void ForceReloadPage(int newNum) + { + currPage = newNum; + } - private int idOperatore { get; set; } = 0; - private string authKey { get; set; } = ""; - private bool reqNew { get; set; } = false; private bool isLoading { get; set; } = false; private string codMag { get; set; } = ""; private string desc { get; set; } = ""; - -#if false - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if (firstRender) - { - await JSRuntime.InvokeVoidAsync("clearContent", $"qrCodeImg_{101}"); - await JSRuntime.InvokeVoidAsync("displayQr", $"qrCodeImg_{101}", rawCode); - } - } -#endif - - protected string BaseUrlTab { get => $"{Configuration["ServerConf:BaseUrl"]}"; } - -#if false - protected async Task getId() - { - OperatoreDTO sess = new OperatoreDTO(); - OperatoreDTO local = new OperatoreDTO(); - sess = await sessionStorage.GetItemAsync("MatrOpr"); - local = await localStorage.GetItemAsync("MatrOpr"); - if ((local != null)) - { - string auth = local.hashAuthKey; - idOperatore = local.MatrOpr; - authKey = auth; - } - else - { - NavManager.NavigateTo("OperatoreLogin"); - } - } -#endif -#if false - protected string rawCode - { - get - { - string answ = ""; - answ = $"{BaseUrlTab}MatrOpr={idOperatore}&UserAuthKey={authKey}"; - return answ; - } - } -#endif } } \ No newline at end of file diff --git a/MP.INVE/Resources/ChangeLog.html b/MP.INVE/Resources/ChangeLog.html index 8b7359cb..1f572910 100644 --- a/MP.INVE/Resources/ChangeLog.html +++ b/MP.INVE/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOINVE -

Versione: 6.16.2211.2108

+

Versione: 6.16.2211.2110


Note di rilascio:
  • diff --git a/MP.INVE/Resources/VersNum.txt b/MP.INVE/Resources/VersNum.txt index b6004b2b..297be395 100644 --- a/MP.INVE/Resources/VersNum.txt +++ b/MP.INVE/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2211.2108 +6.16.2211.2110 diff --git a/MP.INVE/Resources/manifest.xml b/MP.INVE/Resources/manifest.xml index bfe84696..53362599 100644 --- a/MP.INVE/Resources/manifest.xml +++ b/MP.INVE/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2211.2108 + 6.16.2211.2110 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 From 828b5a930ea4f6c46c94eaf4f0d0b432f18f6639 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Mon, 21 Nov 2022 12:06:19 +0100 Subject: [PATCH 02/11] Aggiunta modifica magazzino --- MP.Data/Controllers/MpInveController.cs | 36 +++++++++++++++++++++++++ MP.INVE/Components/MagList.razor | 34 +++++++++++++++++++---- MP.INVE/Components/MagList.razor.cs | 23 +++++++++++++--- MP.INVE/Data/MiDataService.cs | 15 +++++++++++ MP.INVE/MP.INVE.csproj | 2 +- MP.INVE/Resources/ChangeLog.html | 2 +- MP.INVE/Resources/VersNum.txt | 2 +- MP.INVE/Resources/manifest.xml | 2 +- 8 files changed, 103 insertions(+), 13 deletions(-) diff --git a/MP.Data/Controllers/MpInveController.cs b/MP.Data/Controllers/MpInveController.cs index e6c65cb3..cae8eef3 100644 --- a/MP.Data/Controllers/MpInveController.cs +++ b/MP.Data/Controllers/MpInveController.cs @@ -125,6 +125,42 @@ namespace MP.Data.Controllers return fatto; } + /// + /// modifica di un record magazzino + /// + /// + public async Task UpdateMag(AnagMagModel magRec) + { + bool fatto = false; + using (var dbCtx = new MoonPro_InveContext(_configuration)) + { + try + { + var dbResult = + dbCtx + .DbAnagMag + .AsNoTracking() + .Where(x => x.MagID == magRec.MagID) + .FirstOrDefault(); + if (dbResult != null) + { + if (dbResult.DescMag != magRec.DescMag) + { + dbResult.DescMag = magRec.DescMag.ToUpper(); + dbCtx.Entry(dbResult).State = EntityState.Modified; + } + } + await dbCtx.SaveChangesAsync(); + fatto = true; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante UpdateMag{Environment.NewLine}{exc}"); + } + } + return fatto; + } + /// /// delete magazzino /// diff --git a/MP.INVE/Components/MagList.razor b/MP.INVE/Components/MagList.razor index d8a0cec8..f3ac97a6 100644 --- a/MP.INVE/Components/MagList.razor +++ b/MP.INVE/Components/MagList.razor @@ -1,5 +1,6 @@ @if (reqNew) { +
    @@ -15,13 +16,27 @@
    Codice magazzino - + @if (mod) + { + + } + else + { + + }
    -
    +
    Descrizione - + @if (mod) + { + + } + else + { + + }
    @@ -42,6 +57,15 @@
    } + @if (mod) + { + @if (!currMag.DescMag.Contains("NON USARE")) + { +
    + +
    + } + }
    @@ -79,8 +103,8 @@ @item.DescMag - diff --git a/MP.INVE/Components/MagList.razor.cs b/MP.INVE/Components/MagList.razor.cs index 9f41e6b6..4b2b22f0 100644 --- a/MP.INVE/Components/MagList.razor.cs +++ b/MP.INVE/Components/MagList.razor.cs @@ -54,10 +54,13 @@ namespace MP.INVE.Components { reqNew = false; codMag = ""; + mod = false; desc = ""; } private List? elencoMagazzini; private List? SearchRecords; + private AnagMagModel currMag { get; set; } = null!; + private bool mod { get; set; } = false; private async Task insertNewMag() { var alert = await JSRuntime.InvokeAsync("confirm", "Confermi di voler creare un nuovo magazzino?"); @@ -95,15 +98,27 @@ namespace MP.INVE.Components await Task.Delay(1); isLoading = false; } - private async Task deleteMag(AnagMagModel mag) + private async Task modMag(AnagMagModel mag) { - var alert = await JSRuntime.InvokeAsync("confirm", "Confermi di voler eliminare il magazzino selezionato?"); + var alert = await JSRuntime.InvokeAsync("confirm", "Confermi di voler modificare il magazzino selezionato?"); if (alert) { - await MIDataservice.DeleteMag(mag); - NavManager.NavigateTo("Elencomagazzini", true); + + await MIDataservice.UpdateMag(currMag); + NavManager.NavigateTo(NavManager.Uri, true); await reloadData(); } + else + { + closeNew(); + } + } + private async Task reqModMag(AnagMagModel mag) + { + await Task.Delay(1); + mod = true; + reqNew = true; + currMag = mag; } private bool reqNew { diff --git a/MP.INVE/Data/MiDataService.cs b/MP.INVE/Data/MiDataService.cs index ead59261..bcd79e69 100644 --- a/MP.INVE/Data/MiDataService.cs +++ b/MP.INVE/Data/MiDataService.cs @@ -113,6 +113,21 @@ namespace MP.INVE.Data 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; diff --git a/MP.INVE/MP.INVE.csproj b/MP.INVE/MP.INVE.csproj index ee51c709..89270117 100644 --- a/MP.INVE/MP.INVE.csproj +++ b/MP.INVE/MP.INVE.csproj @@ -5,7 +5,7 @@ enable enable MP.INVE - 6.16.2211.2110 + 6.16.2211.2112 diff --git a/MP.INVE/Resources/ChangeLog.html b/MP.INVE/Resources/ChangeLog.html index 1f572910..6508fb1f 100644 --- a/MP.INVE/Resources/ChangeLog.html +++ b/MP.INVE/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOINVE -

    Versione: 6.16.2211.2110

    +

    Versione: 6.16.2211.2112


    Note di rilascio:
    • diff --git a/MP.INVE/Resources/VersNum.txt b/MP.INVE/Resources/VersNum.txt index 297be395..264c3829 100644 --- a/MP.INVE/Resources/VersNum.txt +++ b/MP.INVE/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2211.2110 +6.16.2211.2112 diff --git a/MP.INVE/Resources/manifest.xml b/MP.INVE/Resources/manifest.xml index 53362599..7b8d894f 100644 --- a/MP.INVE/Resources/manifest.xml +++ b/MP.INVE/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2211.2110 + 6.16.2211.2112 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 From ba05a82fcf0186932d7c4cb709ade1f84754a565 Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Mon, 21 Nov 2022 12:11:24 +0100 Subject: [PATCH 03/11] cambio nome e icona sessioni --- MP.INVE/Shared/NavMenu.razor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MP.INVE/Shared/NavMenu.razor b/MP.INVE/Shared/NavMenu.razor index 0dec7c4b..a44fbbcd 100644 --- a/MP.INVE/Shared/NavMenu.razor +++ b/MP.INVE/Shared/NavMenu.razor @@ -45,10 +45,10 @@ From ba1f62266593b7f2e9b87810d8649331e1bf1c5f Mon Sep 17 00:00:00 2001 From: "zaccaria.majid" Date: Mon, 21 Nov 2022 12:43:45 +0100 Subject: [PATCH 04/11] gestione grandezza finestra --- MP.INVE/Pages/_Layout.cshtml | 1 + MP.INVE/Shared/MainLayout.razor | 10 ++++++++-- MP.INVE/Shared/MainLayout.razor.cs | 16 ++++++++++++++++ MP.INVE/Shared/NavMenu.razor | 4 ++-- MP.INVE/wwwroot/lib/WindowSize.js | 6 ++++++ 5 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 MP.INVE/wwwroot/lib/WindowSize.js diff --git a/MP.INVE/Pages/_Layout.cshtml b/MP.INVE/Pages/_Layout.cshtml index f7a5c3fa..967701ec 100644 --- a/MP.INVE/Pages/_Layout.cshtml +++ b/MP.INVE/Pages/_Layout.cshtml @@ -62,5 +62,6 @@ + diff --git a/MP.INVE/Shared/MainLayout.razor b/MP.INVE/Shared/MainLayout.razor index 75da5b44..d7ff713a 100644 --- a/MP.INVE/Shared/MainLayout.razor +++ b/MP.INVE/Shared/MainLayout.razor @@ -6,12 +6,18 @@
      - + @if ((Height != 480) && (Width != 320)) + { + + }
      - + @if ((Height != 480) && (Width != 320)) + { + + }
      @if (userName != "0" || NavManager.Uri.Contains("OperatoreLogin")) diff --git a/MP.INVE/Shared/MainLayout.razor.cs b/MP.INVE/Shared/MainLayout.razor.cs index 089b4dfa..f72febb2 100644 --- a/MP.INVE/Shared/MainLayout.razor.cs +++ b/MP.INVE/Shared/MainLayout.razor.cs @@ -1,5 +1,6 @@ using Blazored.LocalStorage; using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; using MP.Data.DTO; namespace MP.INVE.Shared @@ -44,9 +45,21 @@ namespace MP.INVE.Shared } } + public int Height { get; set; } + public int Width { get; set; } + + public class WindowDimension + { + public int Width { get; set; } + public int Height { get; set; } + } + protected override async Task OnInitializedAsync() { await getId(); + var dimension = await JSRuntime.InvokeAsync("getWindowDimensions"); + Height = dimension.Height; + Width = dimension.Width; } protected void UpdateNavDisplay() @@ -65,6 +78,9 @@ namespace MP.INVE.Shared [Inject] private NavigationManager NavManager { get; set; } = null!; + [Inject] + private IJSRuntime JSRuntime { get; set; } = null!; + #endregion Private Properties } } \ No newline at end of file diff --git a/MP.INVE/Shared/NavMenu.razor b/MP.INVE/Shared/NavMenu.razor index a44fbbcd..cd920e0e 100644 --- a/MP.INVE/Shared/NavMenu.razor +++ b/MP.INVE/Shared/NavMenu.razor @@ -52,7 +52,7 @@
      - *@