From 6cc1a94d99f3f1f6db18ee832bcea3ca7bd37320 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 2 Oct 2023 16:47:33 +0200 Subject: [PATCH 1/2] Bozza fix filt --- MP-TAB-SERV/Components/TcHistoryFilter.razor | 1 - .../Components/TcHistoryFilter.razor.cs | 17 ++- MP-TAB-SERV/Pages/TCHistory.razor | 90 ------------- MP-TAB-SERV/Pages/TCHistory.razor.cs | 124 ++++++++++++++++++ MP-TAB-SERV/Pages/User.razor | 101 ++++++++++++++ 5 files changed, 235 insertions(+), 98 deletions(-) create mode 100644 MP-TAB-SERV/Pages/TCHistory.razor.cs create mode 100644 MP-TAB-SERV/Pages/User.razor diff --git a/MP-TAB-SERV/Components/TcHistoryFilter.razor b/MP-TAB-SERV/Components/TcHistoryFilter.razor index db692364..aaad01ac 100644 --- a/MP-TAB-SERV/Components/TcHistoryFilter.razor +++ b/MP-TAB-SERV/Components/TcHistoryFilter.razor @@ -2,7 +2,6 @@ @using NLog; @using System.Net.Http @using System.Net.Http.Json -@inject HttpClient Http @inject SharedMemService MServ @inject IConfiguration config diff --git a/MP-TAB-SERV/Components/TcHistoryFilter.razor.cs b/MP-TAB-SERV/Components/TcHistoryFilter.razor.cs index 5b0d0dbf..b6f04a41 100644 --- a/MP-TAB-SERV/Components/TcHistoryFilter.razor.cs +++ b/MP-TAB-SERV/Components/TcHistoryFilter.razor.cs @@ -40,6 +40,10 @@ namespace MP_TAB_SERV.Components [Parameter] public EventCallback E_IdxMacc { get; set; } + + [Inject] + protected ListSelectDataSrv CtrDataServ { get; set; } = null!; + protected string BaseAddr = ""; protected override async Task OnInitializedAsync() { @@ -74,11 +78,11 @@ namespace MP_TAB_SERV.Components if (!ListArtDisabled) { Log.Debug("GetArticoli"); - string ApiUrl = $"{BaseAddr}api/ListSelect/GetDictArticoli?SearchArt={SearchVal}"; - var rawData = await Http.GetFromJsonAsync>(ApiUrl); + var rawData = await CtrDataServ.ArticoliGetSearch(10000, "*", searchVal); + // trasformo! if (rawData != null) { - ListArticoliAll = rawData; + ListArticoliAll = rawData.ToDictionary(x => x.CodArticolo, x => $"{x.CodArticolo} | {x.DescArticolo} | {x.Disegno}"); } } } @@ -110,13 +114,12 @@ namespace MP_TAB_SERV.Components if (ListMacchineAll == null || ListMacchineAll.Count == 0) { Log.Debug("START ReloadMacchine"); - string ApiUrl = $"{BaseAddr}api/ListSelect/GetDictMacc?MatrOpr={MatrOpr}"; - var rawData = await Http.GetFromJsonAsync>(ApiUrl); + var rawData = await CtrDataServ.MacchineByMatrOper(MatrOpr); + // trasformo! if (rawData != null) { - ListMacchineAll = rawData; + ListMacchineAll = rawData.ToDictionary(x => x.IdxMacchina, x => $"{x.IdxMacchina} | {x.Nome}"); } - Log.Debug("END ReloadMacchine"); } } diff --git a/MP-TAB-SERV/Pages/TCHistory.razor b/MP-TAB-SERV/Pages/TCHistory.razor index 21319aa5..6cc87a79 100644 --- a/MP-TAB-SERV/Pages/TCHistory.razor +++ b/MP-TAB-SERV/Pages/TCHistory.razor @@ -1,7 +1,5 @@ @page "/tc-history" -@inject HttpClient Http -
@@ -97,92 +95,4 @@
-@code { - [Parameter] - public int MatrOpr { get; set; } = 0; - [Inject] - protected IConfiguration config { get; set; } = null!; - - protected int SearchMinChar = 3; - protected string CodArt = ""; - protected string IdxMacc = "*"; - protected string BaseAddr = ""; - protected bool isLoading = false; - - protected int NumRecPage = 5; - protected int TotalCount = 0; - protected int PageNum = 1; - - protected List ListComplete { get; set; } = new List(); - protected List ListODL { get; set; } = new List(); - - protected override async Task OnInitializedAsync() - { - BaseAddr = config.GetValue("OptConf:BaseAddr") ?? ""; - await ReloadData(); - } - - protected async Task SelCodArt(string newCodArt) - { - CodArt = newCodArt; - await ReloadData(); - } - protected async Task SelIdxMacc(string newIdxMacc) - { - IdxMacc = newIdxMacc; - await ReloadData(); - } - - protected async Task ReloadData() - { - isLoading = true; - if (!string.IsNullOrEmpty(CodArt)) - { - string ApiUrl = $"{BaseAddr}api/ODL/GetODL?CodArt={CodArt}&IdxMacchina={IdxMacc}"; - try - { - var rawData = await Http.GetFromJsonAsync>(ApiUrl); - if (rawData != null) - { - ListComplete = rawData; - TotalCount = ListComplete.Count; - // esegue paginazione - UpdateTable(); - } - } - catch (Exception exc) - { - Log.Error($"Error on dataload{Environment.NewLine}{exc}"); - } - } - isLoading = false; - } - - protected void UpdateTable() - { - // esegue paginazione - if (TotalCount > NumRecPage) - { - ListODL = ListComplete.Skip((PageNum - 1) * NumRecPage).Take(NumRecPage).ToList(); - } - else - { - ListODL = ListComplete; - } - } - - protected void SavePage(int newNum) - { - PageNum = newNum; - UpdateTable(); - } - - protected void SaveNumRec(int newNum) - { - NumRecPage = newNum; - UpdateTable(); - } - - private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); -} diff --git a/MP-TAB-SERV/Pages/TCHistory.razor.cs b/MP-TAB-SERV/Pages/TCHistory.razor.cs new file mode 100644 index 00000000..0a684d99 --- /dev/null +++ b/MP-TAB-SERV/Pages/TCHistory.razor.cs @@ -0,0 +1,124 @@ +using global::System; +using global::System.Collections.Generic; +using global::System.Linq; +using global::System.Threading.Tasks; +using global::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_TAB_SERV; +using MP_TAB_SERV.Shared; +using MP_TAB_SERV.Components; +using MP.Data; +using MP.Data.DatabaseModels; +using MP.Data.DTO; +using MP.Data.Services; +using NLog; + +namespace MP_TAB_SERV.Pages +{ + public partial class TCHistory + { + [Parameter] + public int MatrOpr { get; set; } = 0; + + [Inject] + protected IConfiguration config { get; set; } = null!; + + [Inject] + protected OrderDataSrv CtrDataServ { get; set; } = null!; + + protected int SearchMinChar = 3; + protected string CodArt = ""; + protected string IdxMacc = "*"; + protected string BaseAddr = ""; + protected bool isLoading = false; + protected int NumRecPage = 5; + protected int TotalCount = 0; + protected int PageNum = 1; + protected List ListComplete { get; set; } = new List(); + protected List ListODL { get; set; } = new List(); + + protected override async Task OnInitializedAsync() + { + BaseAddr = config.GetValue("OptConf:BaseAddr") ?? ""; + await ReloadData(); + } + + protected async Task SelCodArt(string newCodArt) + { + CodArt = newCodArt; + await ReloadData(); + } + + protected async Task SelIdxMacc(string newIdxMacc) + { + IdxMacc = newIdxMacc; + await ReloadData(); + } + + protected async Task ReloadData() + { + isLoading = true; + if (!string.IsNullOrEmpty(CodArt)) + { + try + { +#if false + string ApiUrl = $"{BaseAddr}api/ODL/GetODL?CodArt={CodArt}&IdxMacchina={IdxMacc}"; + var rawData = await Http.GetFromJsonAsync>(ApiUrl); + if (rawData != null) + { + ListComplete = rawData; + TotalCount = ListComplete.Count; + // esegue paginazione + UpdateTable(); + } +#endif + ListComplete= await CtrDataServ.ListODLFilt(CodArt, IdxMacc); + TotalCount = ListComplete.Count; + // esegue paginazione + UpdateTable(); + } + catch (Exception exc) + { + Log.Error($"Error on dataload{Environment.NewLine}{exc}"); + } + } + + isLoading = false; + } + + protected void UpdateTable() + { + // esegue paginazione + if (TotalCount > NumRecPage) + { + ListODL = ListComplete.Skip((PageNum - 1) * NumRecPage).Take(NumRecPage).ToList(); + } + else + { + ListODL = ListComplete; + } + } + + protected void SavePage(int newNum) + { + PageNum = newNum; + UpdateTable(); + } + + protected void SaveNumRec(int newNum) + { + NumRecPage = newNum; + UpdateTable(); + } + + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + } +} \ No newline at end of file diff --git a/MP-TAB-SERV/Pages/User.razor b/MP-TAB-SERV/Pages/User.razor new file mode 100644 index 00000000..c395555f --- /dev/null +++ b/MP-TAB-SERV/Pages/User.razor @@ -0,0 +1,101 @@ +@page "/user" + + +@inject IJSRuntime JSRuntime +@inject IHttpContextAccessor httpContextAccessor + +

User

+ + + +
+
+
+
+
+ +
+
+ USER DATA +
+
+
+
+
    +
  • +
    User
    +
    USERNAME[999]
    +
  • +
  • +
    Server Time
    +
    @($"{DateTime.Now.ToString("dddd dd.MM.yyyy HH:mm.ss")}")
    +
  • +
  • +
    Client IP
    +
    @currIpv4
    +
  • +
  • +
    Browser Size
    +
    @($"{Width}x{Height}")
    +
  • +
+
+
+ +
+
+
+ +@code { + public int Height { get; set; } = 0; + public int Width { get; set; } = 0; + public string currIpv4 { get; set; } = ""; + + public class WindowDimension + { + public int Width { get; set; } + public int Height { get; set; } + } + protected async override Task OnAfterRenderAsync(bool firstRender) + { + //await Task.Delay(500); + if (firstRender) + { + await getWDim(); + StateHasChanged(); + Log.Debug($"Dimensioni schermo: {Width}x{Height}"); + } + } + protected async override Task OnInitializedAsync() + { + await Task.Delay(1); + if (string.IsNullOrEmpty(currIpv4)) + { + // ricalcolo e salvo... + if (httpContextAccessor.HttpContext != null) + { + var remoteIp = $"{httpContextAccessor.HttpContext.Connection?.RemoteIpAddress}"; + // provo a recuperare ipV4... + currIpv4 = EgwCoreLib.Razor.Data.IpUtils.getLocalIpv4(remoteIp); + } + } + } + protected async Task getWDim() + { + var dimension = await JSRuntime.InvokeAsync("getWindowDimensions"); + Height = dimension.Height; + Width = dimension.Width; + } + + + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); +} + From a7b3165cd7c6a8fd39b6032c905b686de12c1833 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 2 Oct 2023 16:51:52 +0200 Subject: [PATCH 2/2] Update gestione filtro TC --- .../Components/TcHistoryFilter.razor.cs | 275 ++++++++++-------- 1 file changed, 156 insertions(+), 119 deletions(-) diff --git a/MP-TAB-SERV/Components/TcHistoryFilter.razor.cs b/MP-TAB-SERV/Components/TcHistoryFilter.razor.cs index b6f04a41..ef97bc52 100644 --- a/MP-TAB-SERV/Components/TcHistoryFilter.razor.cs +++ b/MP-TAB-SERV/Components/TcHistoryFilter.razor.cs @@ -1,38 +1,12 @@ -using global::System; -using global::System.Collections.Generic; -using global::System.Linq; -using global::System.Threading.Tasks; using global::Microsoft.AspNetCore.Components; -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_TAB_SERV; -using MP_TAB_SERV.Shared; -using MP_TAB_SERV.Components; -using MP.Data; -using MP.Data.DatabaseModels; -using MP.Data.DTO; using MP.Data.Services; using NLog; -using System.Net.Http; -using System.Net.Http.Json; namespace MP_TAB_SERV.Components { public partial class TcHistoryFilter { - [Parameter] - public int MatrOpr { get; set; } = 102; - - [Parameter] - public string Title { get; set; } = "TC History"; - - [Parameter] - public int SearchMinChar { get; set; } + #region Public Properties [Parameter] public EventCallback E_CodArt { get; set; } @@ -40,52 +14,109 @@ namespace MP_TAB_SERV.Components [Parameter] public EventCallback E_IdxMacc { get; set; } + [Parameter] + public int MatrOpr { get; set; } = 102; + + [Parameter] + public int SearchMinChar { get; set; } + + [Parameter] + public string Title { get; set; } = "TC History"; + + #endregion Public Properties + + #region Protected Fields + + protected string BaseAddr = ""; + + #endregion Protected Fields + + #region Protected Properties + + protected string CodArtSel + { + get => codArtSel; + set + { + if (codArtSel != value) + { + codArtSel = value; + var pUpd = Task.Run(async () => + { + await ReportArt(); + }); + pUpd.Wait(); + } + } + } [Inject] protected ListSelectDataSrv CtrDataServ { get; set; } = null!; - protected string BaseAddr = ""; - protected override async Task OnInitializedAsync() - { - BaseAddr = config.GetValue("OptConf:BaseAddr") ?? ""; - await ReloadAllData(); - } + protected int DisplayCount { get; set; } = 0; - protected async Task ReloadAllData() + protected string IdxMaccSel { - await ReloadArticoli(); - await ReloadMacchine(); - } - - protected async Task ReloadArticoli() - { - await GetArticoli(); - FiltArticoli(); - } - - protected async Task ReportArt() - { - await E_CodArt.InvokeAsync(CodArtSel); - } - - protected async Task ReportMacc() - { - await E_IdxMacc.InvokeAsync(IdxMaccSel); - } - - protected async Task GetArticoli() - { - if (!ListArtDisabled) + get => codArtSel; + set { - Log.Debug("GetArticoli"); - var rawData = await CtrDataServ.ArticoliGetSearch(10000, "*", searchVal); - // trasformo! - if (rawData != null) + if (idxMaccSel != value) { - ListArticoliAll = rawData.ToDictionary(x => x.CodArticolo, x => $"{x.CodArticolo} | {x.DescArticolo} | {x.Disegno}"); + idxMaccSel = value; + var pUpd = Task.Run(async () => + { + await ReportMacc(); + }); + pUpd.Wait(); } } } + private string idxMaccSel { get; set; } = ""; + + protected bool ListArtDisabled { get => string.IsNullOrEmpty(SearchVal) || SearchVal.Length < SearchMinChar; } + + protected Dictionary? ListArticoli { get; set; } = null; + + protected Dictionary ListArticoliAll { get; set; } = new Dictionary(); + + protected Dictionary ListMacchineAll { get => MServ.DictMacchine; set => MServ.DictMacchine = value; } + + protected int Num2Displ + { + get => num2Displ; + set + { + if (num2Displ != value) + { + num2Displ = value; + FiltArticoli(); + } + } + } + + protected string SearchVal + { + get => searchVal; + set + { + if (searchVal != value) + { + searchVal = value; + var pUpd = Task.Run(async () => + { + await ReloadArticoli(); + }); + pUpd.Wait(); + + } + } + } + + protected int TotalCount { get; set; } = 0; + + #endregion Protected Properties + + #region Protected Methods protected void FiltArticoli() { @@ -109,6 +140,53 @@ namespace MP_TAB_SERV.Components } } + protected async Task GetArticoli() + { + if (!ListArtDisabled) + { + Log.Debug("GetArticoli"); + var rawData = await CtrDataServ.ArticoliGetSearch(10000, "*", searchVal); + // trasformo! + if (rawData != null) + { + ListArticoliAll = rawData.ToDictionary(x => x.CodArticolo, x => $"{x.CodArticolo} | {x.DescArticolo} | {x.Disegno}"); + } + } + } + + protected override async Task OnInitializedAsync() + { + BaseAddr = config.GetValue("OptConf:BaseAddr") ?? ""; + await ReloadAllData(); + } + + protected override async Task OnParametersSetAsync() + { +#if false + // update IdxMaccSel + await ReportMacc(); + + // update SearchVal + await ReloadArticoli(); + + // updateCodArtSel + await ReportArt(); +#endif + //return base.OnParametersSetAsync(); + } + + protected async Task ReloadAllData() + { + await ReloadArticoli(); + await ReloadMacchine(); + } + + protected async Task ReloadArticoli() + { + await GetArticoli(); + FiltArticoli(); + } + protected async Task ReloadMacchine() { if (ListMacchineAll == null || ListMacchineAll.Count == 0) @@ -124,71 +202,30 @@ namespace MP_TAB_SERV.Components } } - protected bool ListArtDisabled { get => string.IsNullOrEmpty(SearchVal) || SearchVal.Length < SearchMinChar; } - - protected string SearchVal + protected async Task ReportArt() { - get => searchVal; - set - { - if (searchVal != value) - { - searchVal = value; - } - } + await E_CodArt.InvokeAsync(CodArtSel); } - protected string CodArtSel + protected async Task ReportMacc() { - get => codArtSel; - set - { - if (codArtSel != value) - { - codArtSel = value; - } - } + await E_IdxMacc.InvokeAsync(IdxMaccSel); } - protected int Num2Displ - { - get => num2Displ; - set - { - if (num2Displ != value) - { - num2Displ = value; - FiltArticoli(); - } - } - } + #endregion Protected Methods - protected string IdxMaccSel { get; set; } = ""; - - protected override async Task OnParametersSetAsync() - { -#if false - // update IdxMaccSel - await ReportMacc(); - - // update SearchVal - await ReloadArticoli(); - - // updateCodArtSel - await ReportArt(); -#endif - //return base.OnParametersSetAsync(); - } - - protected Dictionary ListMacchineAll { get => MServ.DictMacchine; set => MServ.DictMacchine = value; } - protected Dictionary ListArticoliAll { get; set; } = new Dictionary(); - protected Dictionary? ListArticoli { get; set; } = null; - protected int TotalCount { get; set; } = 0; - protected int DisplayCount { get; set; } = 0; - private string searchVal { get; set; } = ""; - private string codArtSel { get; set; } = ""; - private int num2Displ { get; set; } = 20; + #region Private Fields private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); + + #endregion Private Fields + + #region Private Properties + + private string codArtSel { get; set; } = ""; + private int num2Displ { get; set; } = 20; + private string searchVal { get; set; } = ""; + + #endregion Private Properties } } \ No newline at end of file