Bozza display ODL
This commit is contained in:
@@ -6,8 +6,8 @@
|
||||
<div class="row small">
|
||||
<div class="col-12 col-sm-6 col-xl-3 mb-2">
|
||||
<div class="form-floating">
|
||||
<select class="form-select form-select-sm" @bind="@IdxMaccSel">
|
||||
<option value="" selected>-- Tutti --</option>
|
||||
<select class="form-select form-select-sm" @bind="@IdxMaccSel" @bind:after="ReportMacc">
|
||||
<option value="*" selected>-- Tutti --</option>
|
||||
@if (ListMacchineAll == null)
|
||||
{
|
||||
<option value="" disabled>No record found</option>
|
||||
@@ -41,7 +41,7 @@
|
||||
</div>
|
||||
<div class="col-12 col-xl-6 mb-2">
|
||||
<div class="form-floating">
|
||||
<select class="form-select form-select-sm" disabled="@ListArtDisabled" @bind="@CodArtSel">
|
||||
<select class="form-select form-select-sm" disabled="@ListArtDisabled" @bind="@CodArtSel" @bind:after="ReportArt">
|
||||
<option value="" selected>-- Nessuno --</option>
|
||||
@if (ListArticoli == null)
|
||||
{
|
||||
@@ -62,19 +62,22 @@
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public int MatrOpr { get; set; } = 102;
|
||||
[Parameter]
|
||||
public string Title { get; set; } = "TC History";
|
||||
[Parameter]
|
||||
public int SearchMinChar { get; set; }
|
||||
[Parameter]
|
||||
public EventCallback<string> E_SearchUpd { get; set; }
|
||||
public EventCallback<string> E_CodArt { get; set; }
|
||||
[Parameter]
|
||||
public EventCallback<string> E_IdxMacc { get; set; }
|
||||
|
||||
[Inject]
|
||||
protected IConfiguration config { get; set; } = null!;
|
||||
|
||||
|
||||
[Parameter]
|
||||
public int MatrOpr { get; set; } = 102;
|
||||
[Parameter]
|
||||
public string Title { get; set; } = "TC History";
|
||||
protected string BaseAddr = "";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
@@ -82,7 +85,6 @@
|
||||
await ReloadAllData();
|
||||
}
|
||||
|
||||
private string BaseAddr = "";
|
||||
|
||||
protected async Task ReloadAllData()
|
||||
{
|
||||
@@ -96,6 +98,15 @@
|
||||
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)
|
||||
|
||||
@@ -1,13 +1,28 @@
|
||||
@attribute [RenderModeAuto]
|
||||
@* @attribute [RenderModeServer] *@
|
||||
|
||||
@inject HttpClient Http
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<MP_TAB.Client.Components.TcHistoryFilter Title="Storico Tempi Ciclo" SearchMinChar="@SearchMinChar" E_SearchUpd="RepSearchUpd" MatrOpr="@MatrOpr"></MP_TAB.Client.Components.TcHistoryFilter>
|
||||
<MP_TAB.Client.Components.TcHistoryFilter Title="Storico Tempi Ciclo" SearchMinChar="@SearchMinChar" E_CodArt="SelCodArt" E_IdxMacc="SelIdxMacc" MatrOpr="@MatrOpr"></MP_TAB.Client.Components.TcHistoryFilter>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<b>griglia risultati</b>
|
||||
|
||||
@if (isLoading)
|
||||
{
|
||||
<i>...loading...</i>
|
||||
}
|
||||
else
|
||||
{
|
||||
<b>griglia risultati</b>
|
||||
@if (ListODL != null && ListODL.Count > 0)
|
||||
{
|
||||
foreach (var item in ListODL)
|
||||
{
|
||||
<p>@item.IdxOdl</p>
|
||||
}
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -15,11 +30,47 @@
|
||||
[Parameter]
|
||||
public int MatrOpr { get; set; } = 0;
|
||||
|
||||
protected int SearchMinChar = 3;
|
||||
[Inject]
|
||||
protected IConfiguration config { get; set; } = null!;
|
||||
|
||||
protected async Task RepSearchUpd(string newSearch)
|
||||
protected int SearchMinChar = 3;
|
||||
protected string CodArt = "";
|
||||
protected string IdxMacc = "";
|
||||
protected string BaseAddr = "";
|
||||
protected bool isLoading = false;
|
||||
|
||||
protected List<ODLExpModel> ListODL { get; set; } = new List<ODLExpModel>();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await Task.Delay(1);
|
||||
// await E_FiltSearchUpd.InvokeAsync(newSearch);
|
||||
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}";
|
||||
var rawData = await Http.GetFromJsonAsync<List<ODLExpModel>>(ApiUrl);
|
||||
if (rawData != null)
|
||||
{
|
||||
ListODL = rawData;
|
||||
}
|
||||
}
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace MP_TAB.Controllers
|
||||
{
|
||||
Log.Info("Starting ListSelectController");
|
||||
_configuration = configuration;
|
||||
FiltDataServ = DataService;
|
||||
CtrDataServ = DataService;
|
||||
Log.Info("Avviato ListSelectController");
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace MP_TAB.Controllers
|
||||
await Task.Delay(1);
|
||||
try
|
||||
{
|
||||
answ = await FiltDataServ.ArticoliGetSearch(NumRec, Azienda, SearchArt);
|
||||
answ = await CtrDataServ.ArticoliGetSearch(NumRec, Azienda, SearchArt);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
@@ -57,7 +57,7 @@ namespace MP_TAB.Controllers
|
||||
await Task.Delay(1);
|
||||
try
|
||||
{
|
||||
var rawData = await FiltDataServ.ArticoliGetSearch(NumRec, Azienda, SearchArt);
|
||||
var rawData = await CtrDataServ.ArticoliGetSearch(NumRec, Azienda, SearchArt);
|
||||
// trasformo!
|
||||
if (rawData != null)
|
||||
{
|
||||
@@ -78,7 +78,7 @@ namespace MP_TAB.Controllers
|
||||
await Task.Delay(1);
|
||||
try
|
||||
{
|
||||
var rawData = await FiltDataServ.MacchineByMatrOper(MatrOpr);
|
||||
var rawData = await CtrDataServ.MacchineByMatrOper(MatrOpr);
|
||||
// trasformo!
|
||||
if (rawData != null)
|
||||
{
|
||||
@@ -104,7 +104,7 @@ namespace MP_TAB.Controllers
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private ListSelectDataSrv FiltDataServ { get; set; } = null!;
|
||||
private ListSelectDataSrv CtrDataServ { get; set; } = null!;
|
||||
|
||||
#endregion Private Properties
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Data.DatabaseModels;
|
||||
using MP.Data.Services;
|
||||
using NLog;
|
||||
using NLog.Fluent;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace MP_TAB.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class ODLController : ControllerBase
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public ODLController(IConfiguration configuration, OrderDataSrv DataService)
|
||||
{
|
||||
Log.Info("Starting ODLController");
|
||||
_configuration = configuration;
|
||||
CtrDataServ = DataService;
|
||||
Log.Info("Avviato ODLController");
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
// GET: api/ListSelect
|
||||
[HttpGet]
|
||||
public string Get()
|
||||
{
|
||||
return "OK";
|
||||
}
|
||||
|
||||
[HttpGet("GetODL")]
|
||||
public async Task<List<ODLExpModel>> GetODL(string CodArt, string IdxMacchina)
|
||||
{
|
||||
List<ODLExpModel> answ = new List<ODLExpModel>();
|
||||
await Task.Delay(1);
|
||||
try
|
||||
{
|
||||
answ = await CtrDataServ.ListODLFilt(CodArt, IdxMacchina);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in GetODL | CodArt: {CodArt} | IdxMacchina: {IdxMacchina}{Environment.NewLine}{exc}");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration = null!;
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private OrderDataSrv CtrDataServ { get; set; } = null!;
|
||||
|
||||
#endregion Private Properties
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ var redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis);
|
||||
builder.Services.AddSingleton<IConnectionMultiplexer>(redisMultiplexer);
|
||||
builder.Services.AddSingleton<StatusData>();
|
||||
builder.Services.AddSingleton<ListSelectDataSrv>();
|
||||
builder.Services.AddSingleton<OrderDataSrv>();
|
||||
builder.Services.AddScoped<UserServ>();
|
||||
|
||||
// nuova versione contenuti...
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace MP.Data.Services
|
||||
{
|
||||
dbController = new Controllers.MpSpecController(configuration);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine($"MenuData | MpSpecController OK");
|
||||
sb.AppendLine($"ListSelectDataSrv | MpSpecController OK");
|
||||
Log.Info(sb.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Data.Conf;
|
||||
using MP.Data.DatabaseModels;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using StackExchange.Redis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe accesso dati ordini
|
||||
/// </summary>
|
||||
public class OrderDataSrv : BaseServ, IDisposable
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public OrderDataSrv(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
|
||||
// setup compoenti REDIS
|
||||
redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis"));
|
||||
redisDb = redisConn.GetDatabase();
|
||||
|
||||
// conf DB
|
||||
string connStr = _configuration.GetConnectionString("Mp.All");
|
||||
if (string.IsNullOrEmpty(connStr))
|
||||
{
|
||||
Log.Error("ConnString empty!");
|
||||
}
|
||||
else
|
||||
{
|
||||
dbController = new Controllers.MpSpecController(configuration);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine($"OrderDataSrv | MpSpecController OK");
|
||||
Log.Info(sb.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public static Controllers.MpSpecController dbController { get; set; } = null!;
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Elenco ODL filtrati x articolo e macchina
|
||||
/// </summary>
|
||||
/// <param name="CodArt">Cod articolo</param>
|
||||
/// <param name="IdxMacchina">Macchina selezionata</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ODLExpModel>> ListODLFilt(string CodArt, string IdxMacchina)
|
||||
{
|
||||
// setup parametri costanti
|
||||
bool inCorso = false;
|
||||
string keyRichPart = "*";
|
||||
string Reparto = "*";
|
||||
DateTime startDate = new DateTime(2000, 1, 1);
|
||||
DateTime endDate = DateTime.Today.AddDays(1);
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<ODLExpModel>? result = new List<ODLExpModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:ODL:{IdxMacchina}:{CodArt}";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<ODLExpModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await Task.FromResult(dbController.ListODLFilt(inCorso,CodArt, keyRichPart, Reparto, IdxMacchina, startDate, endDate));
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<ODLExpModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"ListODLFilt | CodArt: {CodArt} | IdxMacchina: {IdxMacchina} | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Task<List<ConfigModel>> ConfigGetAll()
|
||||
{
|
||||
return Task.FromResult(dbController.ConfigGetAll().ToList());
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database controller
|
||||
dbController.Dispose();
|
||||
}
|
||||
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto per connessione a REDIS
|
||||
/// </summary>
|
||||
protected ConnectionMultiplexer redisConn = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto DB redis da impiegare x chiamate R/W
|
||||
/// </summary>
|
||||
protected IDatabase redisDb = null!;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration = null!;
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private string redisBaseKey = "MP:ALL:Cache";
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user