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(); +} +