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..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,49 +14,110 @@ 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 = ""; - protected override async Task OnInitializedAsync() - { - BaseAddr = config.GetValue("OptConf:BaseAddr") ?? ""; - await ReloadAllData(); - } - protected async Task ReloadAllData() - { - await ReloadArticoli(); - await ReloadMacchine(); - } + #endregion Protected Fields - protected async Task ReloadArticoli() - { - await GetArticoli(); - FiltArticoli(); - } + #region Protected Properties - protected async Task ReportArt() + protected string CodArtSel { - 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"); - string ApiUrl = $"{BaseAddr}api/ListSelect/GetDictArticoli?SearchArt={SearchVal}"; - var rawData = await Http.GetFromJsonAsync>(ApiUrl); - if (rawData != null) + if (codArtSel != value) { - ListArticoliAll = rawData; + codArtSel = value; + var pUpd = Task.Run(async () => + { + await ReportArt(); + }); + pUpd.Wait(); } } } + [Inject] + protected ListSelectDataSrv CtrDataServ { get; set; } = null!; + + protected int DisplayCount { get; set; } = 0; + + protected string IdxMaccSel + { + get => codArtSel; + set + { + if (idxMaccSel != value) + { + 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() { bool done = false; @@ -105,63 +140,26 @@ namespace MP_TAB_SERV.Components } } - protected async Task ReloadMacchine() + protected async Task GetArticoli() { - if (ListMacchineAll == null || ListMacchineAll.Count == 0) + if (!ListArtDisabled) { - Log.Debug("START ReloadMacchine"); - string ApiUrl = $"{BaseAddr}api/ListSelect/GetDictMacc?MatrOpr={MatrOpr}"; - var rawData = await Http.GetFromJsonAsync>(ApiUrl); + Log.Debug("GetArticoli"); + var rawData = await CtrDataServ.ArticoliGetSearch(10000, "*", searchVal); + // trasformo! if (rawData != null) { - ListMacchineAll = rawData; + ListArticoliAll = rawData.ToDictionary(x => x.CodArticolo, x => $"{x.CodArticolo} | {x.DescArticolo} | {x.Disegno}"); } - - Log.Debug("END ReloadMacchine"); } } - protected bool ListArtDisabled { get => string.IsNullOrEmpty(SearchVal) || SearchVal.Length < SearchMinChar; } - - protected string SearchVal + protected override async Task OnInitializedAsync() { - get => searchVal; - set - { - if (searchVal != value) - { - searchVal = value; - } - } + BaseAddr = config.GetValue("OptConf:BaseAddr") ?? ""; + await ReloadAllData(); } - protected string CodArtSel - { - get => codArtSel; - set - { - if (codArtSel != value) - { - codArtSel = value; - } - } - } - - protected int Num2Displ - { - get => num2Displ; - set - { - if (num2Displ != value) - { - num2Displ = value; - FiltArticoli(); - } - } - } - - protected string IdxMaccSel { get; set; } = ""; - protected override async Task OnParametersSetAsync() { #if false @@ -172,20 +170,62 @@ namespace MP_TAB_SERV.Components await ReloadArticoli(); // updateCodArtSel - await ReportArt(); + 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; + 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) + { + Log.Debug("START ReloadMacchine"); + var rawData = await CtrDataServ.MacchineByMatrOper(MatrOpr); + // trasformo! + if (rawData != null) + { + ListMacchineAll = rawData.ToDictionary(x => x.IdxMacchina, x => $"{x.IdxMacchina} | {x.Nome}"); + } + Log.Debug("END ReloadMacchine"); + } + } + + protected async Task ReportArt() + { + await E_CodArt.InvokeAsync(CodArtSel); + } + + protected async Task ReportMacc() + { + await E_IdxMacc.InvokeAsync(IdxMaccSel); + } + + #endregion Protected Methods + + #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 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(); +} +