TAB:
- Completato riorg codice filtro
This commit is contained in:
@@ -4,17 +4,17 @@
|
||||
|
||||
@inject HttpClient Http
|
||||
|
||||
<div class="row">
|
||||
<div class="row small">
|
||||
<div class="col-12 col-md-3 mb-2">
|
||||
<div class="form-floating">
|
||||
<div class="form-floating small">
|
||||
<input type="text" class="form-control" @bind="SearchVal">
|
||||
<label for="floatingInput"><i class="fa-solid fa-magnifying-glass"></i> Articolo (3+ char)</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-md-6 mb-2">
|
||||
<div class="form-floating">
|
||||
<select class="form-select" disabled="@ListArtDisabled" @bind="@CodArtSel">
|
||||
<option value="" selected>-- No Select --</option>
|
||||
<select class="form-select form-select-sm" disabled="@ListArtDisabled" @bind="@CodArtSel">
|
||||
<option value="" selected>-- Nessuno --</option>
|
||||
@if (ListArticoli == null)
|
||||
{
|
||||
<option value="" disabled>No record found</option>
|
||||
@@ -25,10 +25,6 @@
|
||||
{
|
||||
<option value="@item.Key">@item.Value</option>
|
||||
}
|
||||
@* @foreach (var item in ListArticoli)
|
||||
{
|
||||
<option value="@item.CodArticolo">@item.CodArticolo | @item.DescArticolo | @item.Disegno</option>
|
||||
} *@
|
||||
}
|
||||
</select>
|
||||
<label for="floatingSelect">Selezione Articolo (@DisplayCount / <b>@TotalCount</b>)</label>
|
||||
@@ -36,19 +32,25 @@
|
||||
</div>
|
||||
<div class="col-12 col-md-3 mb-2">
|
||||
<div class="form-floating">
|
||||
<select class="form-select" disabled="@ListMacDisabled">
|
||||
<option value="0" selected>-- Selezione Impianto --</option>
|
||||
<option value="1">One</option>
|
||||
<option value="2">Two</option>
|
||||
<option value="3">Three</option>
|
||||
<select class="form-select form-select-sm" disabled="@ListMacDisabled" @bind="@IdxMaccSel">
|
||||
<option value="" selected>-- Nessuno --</option>
|
||||
@if (ListMacchineAll == null)
|
||||
{
|
||||
<option value="" disabled>No record found</option>
|
||||
}
|
||||
else
|
||||
{
|
||||
@foreach (var item in ListMacchineAll)
|
||||
{
|
||||
<option value="@item.Key">@item.Value</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
<label for="floatingSelect">Selezione Impianto (ODL/ART)</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
@@ -65,12 +67,16 @@
|
||||
|
||||
protected async Task ReloadAllData()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(SearchVal))
|
||||
await ReloadArticoli();
|
||||
await ReloadMacchine();
|
||||
}
|
||||
protected async Task ReloadArticoli()
|
||||
{
|
||||
bool done = false;
|
||||
if (!ListArtDisabled)
|
||||
{
|
||||
string ArtApiUrl = $"{BaseAddr}api/ListSelect/GetDictArticoli?SearchArt={SearchVal}";
|
||||
// string ArtApiUrl = $"{BaseAddr}api/ListSelect/GetArticoli?SearchArt={SearchVal}";
|
||||
// var rawData = await Http.GetFromJsonAsync<List<AnagArticoli>>(ArtApiUrl);
|
||||
var rawData = await Http.GetFromJsonAsync<Dictionary<string,string>>(ArtApiUrl);
|
||||
string ApiUrl = $"{BaseAddr}api/ListSelect/GetDictArticoli?SearchArt={SearchVal}";
|
||||
var rawData = await Http.GetFromJsonAsync<Dictionary<string, string>>(ApiUrl);
|
||||
if (rawData != null)
|
||||
{
|
||||
ListArticoliAll = rawData;
|
||||
@@ -81,17 +87,28 @@
|
||||
TotalCount = ListArticoliAll.Count;
|
||||
ListArticoli = ListArticoliAll.Take(Num2Displ).ToDictionary(x => x.Key, x => x.Value);
|
||||
DisplayCount = ListArticoli.Count;
|
||||
}
|
||||
else
|
||||
{
|
||||
TotalCount = 0;
|
||||
ListArticoli = new Dictionary<string, string>();
|
||||
DisplayCount = 0;
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
if (!done)
|
||||
{
|
||||
TotalCount = 0;
|
||||
ListArticoli = new Dictionary<string, string>();
|
||||
DisplayCount = 0;
|
||||
}
|
||||
}
|
||||
protected async Task ReloadMacchine()
|
||||
{
|
||||
if (!ListMacDisabled)
|
||||
{
|
||||
string ApiUrl = $"{BaseAddr}api/ListSelect/GetDictMacc?MatrOpr={MatrOpr}";
|
||||
var rawData = await Http.GetFromJsonAsync<Dictionary<string, string>>(ApiUrl);
|
||||
if (rawData != null)
|
||||
{
|
||||
ListMacchineAll = rawData;
|
||||
}
|
||||
}
|
||||
await Task.Delay(1);
|
||||
}
|
||||
|
||||
|
||||
protected bool ListArtDisabled
|
||||
{
|
||||
@@ -120,9 +137,7 @@
|
||||
{
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
// await E_SearchUpd.InvokeAsync(value);
|
||||
// await Task.Delay(1);
|
||||
await ReloadAllData();
|
||||
await ReloadArticoli();
|
||||
});
|
||||
pUpd.Wait();
|
||||
}
|
||||
@@ -139,14 +154,38 @@
|
||||
private string searchVal { get; set; } = "";
|
||||
|
||||
|
||||
protected string CodArtSel { get; set; } = "";
|
||||
protected string CodArtSel
|
||||
{
|
||||
get => codArtSel;
|
||||
set
|
||||
{
|
||||
if (codArtSel != value)
|
||||
{
|
||||
codArtSel = value;
|
||||
// try
|
||||
// {
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
await ReloadMacchine();
|
||||
});
|
||||
pUpd.Wait();
|
||||
// }
|
||||
// catch (Exception exc)
|
||||
// {
|
||||
// Log.Error($"CodArtSel{Environment.NewLine}{exc}");
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
protected string IdxMaccSel { get; set; } = "";
|
||||
|
||||
|
||||
private string codArtSel { get; set; } = "";
|
||||
|
||||
protected Dictionary<string, string> ListMacchineAll { get; set; } = new Dictionary<string, string>();
|
||||
protected Dictionary<string, string> ListArticoliAll { get; set; } = new Dictionary<string, string>();
|
||||
protected Dictionary<string, string>? ListArticoli { get; set; } = null;
|
||||
|
||||
// protected List<AnagArticoli>? ListArticoli { get; set; } = null;
|
||||
|
||||
|
||||
[Parameter]
|
||||
@@ -157,12 +196,6 @@
|
||||
|
||||
|
||||
|
||||
[Parameter]
|
||||
public List<Macchine> ListMacchineAll { get; set; } = new List<Macchine>();
|
||||
|
||||
// [Parameter]
|
||||
// public List<AnagArticoli> ListArticoliAll { get; set; } = new List<AnagArticoli>();
|
||||
|
||||
[Parameter]
|
||||
public int MatrOpr { get; set; } = 102;
|
||||
[Parameter]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
@inherits LayoutComponentBase
|
||||
@inject OprFiltData MDataService
|
||||
@inject ListSelectDataSrv MDataService
|
||||
|
||||
<div class="page">
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@inject OprFiltData MDataService
|
||||
@inject ListSelectDataSrv MDataService
|
||||
|
||||
@* <div class="row w-100 slideMen"> *@
|
||||
@* <div class="row w-100 slideMen">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@page "/tc-history"
|
||||
|
||||
|
||||
<MP_TAB.Client.Pages.TCHistory SearchMinChar="@SrcMinChar" E_FiltSearchUpd="DoSearchUpd" ListArticoli="@SearchArticoli"></MP_TAB.Client.Pages.TCHistory>
|
||||
<MP_TAB.Client.Pages.TCHistory></MP_TAB.Client.Pages.TCHistory>
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
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 System.Net.Http.Json;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using Microsoft.AspNetCore.Components.Routing;
|
||||
using Microsoft.AspNetCore.Components.Sections;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.AspNetCore.Components.Web.Virtualization;
|
||||
using Microsoft.JSInterop;
|
||||
using MP.Data;
|
||||
using MP.Data.DatabaseModels;
|
||||
using MP.Data.DTO;
|
||||
using MP.Data.Services;
|
||||
using MP_TAB;
|
||||
using MP_TAB.Components;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace MP_TAB.Components.Pages
|
||||
{
|
||||
public partial class TCHistory
|
||||
{
|
||||
#region Protected Properties
|
||||
|
||||
protected string azienda { get; set; } = "*";
|
||||
|
||||
protected List<Macchine>? ListMacchine { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Matricola operatore corrente (da rendere parametrico con gest operatore)
|
||||
/// </summary>
|
||||
protected int MatrOpr { get; set; } = 102;
|
||||
|
||||
[Inject]
|
||||
protected OprFiltData MDataService { get; set; } = null!;
|
||||
|
||||
protected int NumRec { get; set; } = 100000;
|
||||
protected List<AnagArticoli> SearchArticoli { get; set; } = new List<AnagArticoli>();
|
||||
protected string SearchVal { get; set; } = "";
|
||||
protected int SrcMinChar { get; set; } = 3;
|
||||
protected int TotalCount { get; set; } = 0;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected async Task DoSearchUpd(string newSearch)
|
||||
{
|
||||
SearchVal = newSearch;
|
||||
await ReloadFiltData();
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
//await ReloadAllData();
|
||||
}
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
await ReloadAllData();
|
||||
// return base.OnParametersSetAsync();
|
||||
}
|
||||
|
||||
protected async Task ReloadAllData()
|
||||
{
|
||||
await ReloadFiltData();
|
||||
TotalCount = SearchArticoli != null ? SearchArticoli.Count : 0;
|
||||
}
|
||||
|
||||
protected async Task ReloadFiltData()
|
||||
{
|
||||
// ricarica SOLO SE ho almeno un filtro valido...
|
||||
if (!string.IsNullOrEmpty(SearchVal))
|
||||
{
|
||||
SearchArticoli = await MDataService.ArticoliGetSearch(NumRec, azienda, SearchVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
SearchArticoli = new List<AnagArticoli>();
|
||||
}
|
||||
ListMacchine = await MDataService.MacchineByMatrOper(MatrOpr);
|
||||
}
|
||||
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ namespace MP_TAB.Controllers
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public ListSelectController(IConfiguration configuration, OprFiltData DataService)
|
||||
public ListSelectController(IConfiguration configuration, ListSelectDataSrv DataService)
|
||||
{
|
||||
Log.Info("Starting ListSelectController");
|
||||
_configuration = configuration;
|
||||
@@ -50,7 +50,6 @@ namespace MP_TAB.Controllers
|
||||
return answ;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("GetDictArticoli")]
|
||||
public async Task<Dictionary<string, string>> GetDictArticoli(string SearchArt, string Azienda = "*", int NumRec = 100000)
|
||||
{
|
||||
@@ -67,7 +66,28 @@ namespace MP_TAB.Controllers
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in GetArticoli | SearchArt: {SearchArt} | Azienda: {Azienda} | NumRec: {NumRec}{Environment.NewLine}{exc}");
|
||||
Log.Error($"Eccezione in GetDictArticoli | SearchArt: {SearchArt} | Azienda: {Azienda} | NumRec: {NumRec}{Environment.NewLine}{exc}");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
[HttpGet("GetDictMacc")]
|
||||
public async Task<Dictionary<string, string>> GetDictMacc(int MatrOpr)
|
||||
{
|
||||
Dictionary<string, string> answ = new Dictionary<string, string>();
|
||||
await Task.Delay(1);
|
||||
try
|
||||
{
|
||||
var rawData = await FiltDataServ.MacchineByMatrOper(MatrOpr);
|
||||
// trasformo!
|
||||
if (rawData != null)
|
||||
{
|
||||
answ = rawData.ToDictionary(x => x.IdxMacchina, x => $"{x.IdxMacchina} | {x.Nome}");
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in GetDictMacc | MatrOpr: {MatrOpr}{Environment.NewLine}{exc}");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
@@ -84,7 +104,7 @@ namespace MP_TAB.Controllers
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private OprFiltData FiltDataServ { get; set; } = null!;
|
||||
private ListSelectDataSrv FiltDataServ { get; set; } = null!;
|
||||
|
||||
#endregion Private Properties
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ var redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis);
|
||||
// Add services x accesso dati
|
||||
builder.Services.AddSingleton<IConnectionMultiplexer>(redisMultiplexer);
|
||||
builder.Services.AddSingleton<StatusData>();
|
||||
builder.Services.AddSingleton<OprFiltData>();
|
||||
builder.Services.AddSingleton<ListSelectDataSrv>();
|
||||
|
||||
// nuova versione contenuti...
|
||||
builder.Services.AddRazorComponents()
|
||||
|
||||
@@ -18,11 +18,11 @@ namespace MP.Data.Services
|
||||
/// <summary>
|
||||
/// Classe accesso dati filtrati per operatore
|
||||
/// </summary>
|
||||
public class OprFiltData : BaseServ, IDisposable
|
||||
public class ListSelectDataSrv : BaseServ, IDisposable
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public OprFiltData(IConfiguration configuration)
|
||||
public ListSelectDataSrv(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
|
||||
@@ -55,6 +55,43 @@ namespace MP.Data.Services
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Elenco tabella Articoli da filtro
|
||||
/// </summary>
|
||||
/// <param name="numRecord">Numero record max da recuperare</param>
|
||||
/// <param name="azienda">cod azienda, * = tutte</param>
|
||||
/// <param name="searchVal">Ricerca testuale</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagArticoli>> ArticoliGetSearch(int numRecord, string azienda, string searchVal)
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<AnagArticoli>? result = new List<AnagArticoli>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Art:{azienda}:{searchVal}:{numRecord}";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<AnagArticoli>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await Task.FromResult(dbController.ArticoliGetSearch(numRecord, azienda, searchVal));
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<AnagArticoli>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"ArticoliGetSearch | azienda: {azienda} | searchVal: {searchVal} | numRecord: {numRecord} | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
public Task<List<ConfigModel>> ConfigGetAll()
|
||||
{
|
||||
return Task.FromResult(dbController.ConfigGetAll().ToList());
|
||||
@@ -101,7 +138,6 @@ namespace MP.Data.Services
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Macchine dato operatore secondo gruppi (macchine/operatore)
|
||||
/// </summary>
|
||||
@@ -137,45 +173,6 @@ namespace MP.Data.Services
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Elenco tabella Articoli da filtro
|
||||
/// </summary>
|
||||
/// <param name="numRecord">Numero record max da recuperare</param>
|
||||
/// <param name="azienda">cod azienda, * = tutte</param>
|
||||
/// <param name="searchVal">Ricerca testuale</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagArticoli>> ArticoliGetSearch(int numRecord, string azienda, string searchVal)
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<AnagArticoli>? result = new List<AnagArticoli>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Art:{azienda}:{searchVal}:{numRecord}";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<AnagArticoli>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await Task.FromResult(dbController.ArticoliGetSearch(numRecord, azienda, searchVal));
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<AnagArticoli>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"ArticoliGetSearch | azienda: {azienda} | searchVal: {searchVal} | numRecord: {numRecord} | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
Reference in New Issue
Block a user