Bozza fix filt

This commit is contained in:
Samuele Locatelli
2023-10-02 16:47:33 +02:00
parent 0e13cddcb9
commit 6cc1a94d99
5 changed files with 235 additions and 98 deletions
@@ -2,7 +2,6 @@
@using NLog;
@using System.Net.Http
@using System.Net.Http.Json
@inject HttpClient Http
@inject SharedMemService MServ
@inject IConfiguration config
@@ -40,6 +40,10 @@ namespace MP_TAB_SERV.Components
[Parameter]
public EventCallback<string> 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<Dictionary<string, string>>(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<Dictionary<string, string>>(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");
}
}
-90
View File
@@ -1,7 +1,5 @@
@page "/tc-history"
@inject HttpClient Http
<div class="card">
<div class="card-header px-2">
<TcHistoryFilter Title="Storico Tempi Ciclo" SearchMinChar="@SearchMinChar" E_CodArt="SelCodArt" E_IdxMacc="SelIdxMacc" MatrOpr="@MatrOpr"></TcHistoryFilter>
@@ -97,92 +95,4 @@
</div>
</div>
@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<ODLExpModel> ListComplete { get; set; } = new List<ODLExpModel>();
protected List<ODLExpModel> ListODL { get; set; } = new List<ODLExpModel>();
protected override async Task OnInitializedAsync()
{
BaseAddr = config.GetValue<string>("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<List<ODLExpModel>>(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();
}
+124
View File
@@ -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<ODLExpModel> ListComplete { get; set; } = new List<ODLExpModel>();
protected List<ODLExpModel> ListODL { get; set; } = new List<ODLExpModel>();
protected override async Task OnInitializedAsync()
{
BaseAddr = config.GetValue<string>("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<List<ODLExpModel>>(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();
}
}
+101
View File
@@ -0,0 +1,101 @@
@page "/user"
@inject IJSRuntime JSRuntime
@inject IHttpContextAccessor httpContextAccessor
<h3>User</h3>
<div class="d-flex">
<div class="col-3"></div>
<div class="card col-6">
<div class="card-header text-center">
<div style="font-size: 4rem;">
<i class="fa-solid fa-user"></i>
</div>
<div style="font-size: 1.5rem;">
<span>USER DATA</span>
</div>
</div>
<div class="card-body">
<div>
<ul class="list-group">
<li class="list-group-item d-flex justify-content-between">
<div class="text-start">User</div>
<div class="text-end"><b>USERNAME[999]</b></div>
</li>
<li class="list-group-item d-flex justify-content-between">
<div class="text-start">Server Time</div>
<div class="text-end"><b>@($"{DateTime.Now.ToString("dddd dd.MM.yyyy HH:mm.ss")}")</b></div>
</li>
<li class="list-group-item d-flex justify-content-between">
<div class="text-start">Client IP</div>
<div class="text-end"><b>@currIpv4</b></div>
</li>
<li class="list-group-item d-flex justify-content-between">
<div class="text-start">Browser Size</div>
<div class="text-end"><b>@($"{Width}x{Height}")</b></div>
</li>
</ul>
</div>
</div>
<div class="card-footer">
<button class="w-100 btn btn-success">
<i class="fa-solid fa-gear"></i> &nbsp; ABOUT PAGE
</button>
<hr />
<button class="w-100 btn btn-danger">
<i class="fa-solid fa-right-from-bracket"></i> &nbsp; LOGOUT
</button>
</div>
</div>
<div class="col-3"></div>
</div>
@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<WindowDimension>("getWindowDimensions");
Height = dimension.Height;
Width = dimension.Width;
}
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
}