SPEC, test su FTP

- ok force sync
- ok chiusura ODL
This commit is contained in:
Samuele Locatelli
2024-11-02 10:59:57 +01:00
parent 605d2a16b7
commit 800cbaaec4
9 changed files with 124 additions and 73 deletions
+2 -4
View File
@@ -1,6 +1,4 @@
@using MP.SPEC.Components
@using MP.SPEC.Data
@if (ListRecords == null)
{
<LoadingData></LoadingData>
@@ -17,7 +15,7 @@ else
<div class="col-6 col-lg-8">
@if (enableForceSync)
{
<button @onclick="() => forceSyncDb()" class="btn btn-success btn-sm">Forza sync &rarr; macchina <i class="bi bi-fast-forward-circle"></i></button>
<button @onclick="() => ForceSyncDb()" class="btn btn-success btn-sm">Forza sync &rarr; macchina <i class="bi bi-fast-forward-circle"></i></button>
}
else
{
+31 -50
View File
@@ -1,10 +1,13 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.JSInterop;
using MP.Data.DatabaseModels;
using MP.SPEC.Components;
using MP.SPEC.Data;
using MP.SPEC.Services;
using NLog;
namespace MP.SPEC.Components
{
public partial class ListODL : IDisposable
@@ -96,29 +99,45 @@ namespace MP.SPEC.Components
// effettua chiusura sul DB
await MDService.ODLClose(currRecord.IdxOdl, currRecord.IdxMacchina, 0, true);
Log.Info($"Effettuata chiusura ODL {currRecord.IdxOdl}");
// RESETTO task x setComm, setArt, SetPzComm
await MpIoApiCall.addTask2Exe(currRecord.IdxMacchina, "setArt", "");
await MpIoApiCall.addTask2Exe(currRecord.IdxMacchina, "setComm", "");
await MpIoApiCall.addTask2Exe(currRecord.IdxMacchina, "setPzComm","");
// richiesto anche sync DB
await MpIoApiCall.callSyncDb(currRecord.IdxMacchina);
// ricarica...
await selRecord(null);
}
await reloadData();
await ReloadData();
}
/// <summary>
/// Richiesta invio sync all'IOB-WIN
/// </summary>
/// <returns></returns>
protected async Task forceSyncDb()
protected async Task ForceSyncDb()
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sei sicuro di voler (re)inviare i dati (Articoli, PODL) all'impianto?"))
return;
if (currRecord != null)
{
await callSyncDb(currRecord.IdxMacchina);
Log.Info($"Richiesto forceSyncDb per idxMacc {currRecord.IdxMacchina}");
// imposto task x setComm, setArt, SetPzComm
await MpIoApiCall.addTask2Exe(currRecord.IdxMacchina, "setArt", currRecord.CodArticolo);
await MpIoApiCall.addTask2Exe(currRecord.IdxMacchina, "setComm", $"ODL{currRecord.IdxOdl:00000000}");
await MpIoApiCall.addTask2Exe(currRecord.IdxMacchina, "setPzComm", $"{currRecord.NumPezzi}");
// richiesto anche sync DB
await MpIoApiCall.callSyncDb(currRecord.IdxMacchina);
Log.Info($"Richiesto ForceSyncDb per idxMacc {currRecord.IdxMacchina}");
// ricarica...
await selRecord(null);
}
await reloadData();
await ReloadData();
}
protected int getPodl(int idxOdl)
@@ -180,23 +199,13 @@ namespace MP.SPEC.Components
protected override async Task OnParametersSetAsync()
{
await reloadData();
}
protected async void OnSeachUpdated()
{
await InvokeAsync(() =>
{
PagerResetReq.InvokeAsync(true);
Task task = UpdateData();
StateHasChanged();
});
await ReloadData();
}
protected async Task resetSel()
{
await selRecord(null);
await reloadData();
await ReloadData();
}
protected async Task selBrowseRecord(ODLExpModel? currRec)
@@ -239,7 +248,7 @@ namespace MP.SPEC.Components
protected async Task UpdateData()
{
await selRecord(null);
await reloadData();
await ReloadData();
}
#endregion Protected Methods
@@ -316,44 +325,16 @@ namespace MP.SPEC.Components
#region Private Methods
/// <summary>
/// Chiama metodo x chiedere sync DB
/// </summary>
/// <param name="selRec"></param>
/// <returns></returns>
private async Task addTask2Exe(string idxMacc, string taskName, string taskVal)
{
// compongo URL e chiamo
string restUrl = $"IOB/addTask2Exe/{idxMacc}?taskName={taskName}&taskVal={taskVal}";
try
{
var response = await MpIoApiCall.callMpIoUrlGet(restUrl);
}
catch (Exception exc)
{
Log.Error($"Errore durante chiamata: {Environment.NewLine}{exc}");
}
}
/// <summary>
/// Chiama metodo x chiedere sync DB
/// </summary>
/// <param name="IdxMacc"></param>
/// <returns></returns>
private async Task callSyncDb(string IdxMacc)
{
// chiamo aggiunta task SyncDb...
await addTask2Exe(IdxMacc, "syncDbData", "");
}
private async Task reloadData()
private async Task ReloadData()
{
isLoading = true;
SearchRecords = await MDService.OdlListGetFilt(currFilter.IsActive, currFilter.SearchVal, currFilter.CodFase, currFilter.CodReparto, currFilter.IdxMacchina, currFilter.DtStart, currFilter.DtEnd);
totalCount = SearchRecords.Count;
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
await Task.Delay(1);
await InvokeAsync(() => StateHasChanged());
#if false
await InvokeAsync(StateHasChanged);
#endif
isLoading = false;
}
+21
View File
@@ -261,6 +261,10 @@ namespace MP.SPEC.Components
evMess = $"Registrata inizio Produzione | PODL {selRec.IdxPromessa} | ODL {newOdl.IdxOdl} | ART {newOdl.CodArticolo}";
processaEvento(selRec.IdxMacchina, idxEvento, evMess, newOdl.IdxOdl, newOdl.CodArticolo);
// imposto task x setComm, setArt, SetPzComm
await callTask2Exe(selRec.IdxMacchina, "setArt", newOdl.CodArticolo);
await callTask2Exe(selRec.IdxMacchina, "setComm", $"ODL{newOdl.IdxOdl:00000000}");
await callTask2Exe(selRec.IdxMacchina, "setPzComm", $"{newOdl.NumPezzi}");
// chiamo task x IOB
await callForceUpdate(selRec.IdxMacchina);
await Task.Delay(1);
@@ -271,6 +275,10 @@ namespace MP.SPEC.Components
// svuoto memorie pagina...
await MDService.FlushRedisCache();
// svuoto cache MpIoNsCache
await MDService.FlushMpIoOdlCache();
// ricarico pagina!
NavManager.NavigateTo(NavManager.Uri, true);
}
}
@@ -470,6 +478,19 @@ namespace MP.SPEC.Components
await addTask2Exe(IdxMacc, "syncDbData", "");
}
/// <summary>
/// Chiama metodo x chiedere registrazione di un Task2Exe a MP-IO
/// </summary>
/// <param name="IdxMacc">IdxMacchina interessata</param>
/// <param name="KeyReq">Richiesta da impostare</param>
/// <param name="ValReq">Valore da impostare</param>
/// <returns></returns>
private async Task callTask2Exe(string IdxMacc, string KeyReq, string ValReq)
{
// chiamo aggiunta task SyncDb...
await addTask2Exe(IdxMacc, KeyReq, ValReq);
}
/// <summary>
/// verifica se sia avviabile ODL x macchina
/// </summary>
+15
View File
@@ -1764,6 +1764,21 @@ namespace MP.SPEC.Data
return answ;
}
/// <summary>
/// Flush cache relativa a MP-IO x dati ODL
/// </summary>
/// <returns></returns>
public async Task<bool> FlushMpIoOdlCache()
{
// svuoto dalla cache REDIS del server IO...
bool ok01 = await ResetIoCache("CurrODL");
bool ok02 = await ResetIoCache("CurrOdlRow");
bool ok03 = await ResetIoCache("CurrStatoMacc");
bool ok04 = await ResetIoCache("DtMac");
return ok01 && ok02 && ok03 && ok04;
}
/// <summary>
/// Statistiche ODL calcolate (da stored stp_STAT_ODL)
/// </summary>
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP.SPEC</RootNamespace>
<Version>6.16.2410.3111</Version>
<Version>6.16.2411.210</Version>
<UserSecretsId>1800a78a-6ff1-40f9-b490-87fb8bfc1394</UserSecretsId>
</PropertyGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 6.16.2410.3111</h4>
<h4>Versione: 6.16.2411.210</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
6.16.2410.3111
6.16.2411.210
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2410.3111</version>
<version>6.16.2411.210</version>
<url>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+51 -15
View File
@@ -7,22 +7,12 @@ namespace MP.SPEC.Services
{
/// <summary>
/// Classe per chiamare metodi da MP-IO
///
/// rif:
/// https://www.ezzylearning.net/tutorial/making-http-requests-in-blazor-server-apps
/// https://wellsb.com/csharp/aspnet/blazor-httpclientfactory-and-web-api/
///
/// rif: https://www.ezzylearning.net/tutorial/making-http-requests-in-blazor-server-apps https://wellsb.com/csharp/aspnet/blazor-httpclientfactory-and-web-api/
/// </summary>
public class IOApiService
{
private readonly IHttpClientFactory _clientFactory;
private static ILogger<MpDataService> _logger = null!;
private static IConfiguration _configuration = null!;
private static Logger Log = LogManager.GetCurrentClassLogger();
private static string MpIoBaseUrl = "";
#region Public Constructors
public IOApiService(IHttpClientFactory clientFactory, IConfiguration configuration, ILogger<MpDataService> logger)
{
@@ -33,6 +23,40 @@ namespace MP.SPEC.Services
// conf url x chiamate REST
MpIoBaseUrl = _configuration.GetValue<string>("ServerConf:MpIoBaseUrl");
}
#endregion Public Constructors
#region Public Methods
/// <summary>
/// Chiama metodo x registrare esecuzione task da IOB
/// </summary>
/// <param name="selRec"></param>
/// <returns></returns>
public async Task addTask2Exe(string idxMacc, string taskName, string taskVal)
{
// compongo URL e chiamo
string restUrl = $"IOB/addTask2Exe/{idxMacc}?taskName={taskName}&taskVal={taskVal}";
try
{
var response = await callMpIoUrlGet(restUrl);
}
catch (Exception exc)
{
Log.Error($"Errore durante chiamata addTask2Exe:{Environment.NewLine}{exc}");
}
}
/// <summary>
/// Chiama metodo x chiedere sync DB
/// </summary>
/// <param name="IdxMacc"></param>
/// <returns></returns>
public async Task callSyncDb(string IdxMacc)
{
// chiamo aggiunta task SyncDb...
await addTask2Exe(IdxMacc, "syncDbData", "");
}
/// <summary>
/// Effettua chiamata ad MP-IO
/// </summary>
@@ -50,7 +74,7 @@ namespace MP.SPEC.Services
{
var stringResponse = await response.Content.ReadAsStringAsync();
result = stringResponse;
Log.Info($"Richiesta call per {MpIoBaseUrl}{relUrl}");
Log.Info($"Effettuata coin successo call per {MpIoBaseUrl}{relUrl}");
}
else
{
@@ -59,5 +83,17 @@ namespace MP.SPEC.Services
}
return result;
}
#endregion Public Methods
#region Private Fields
private static IConfiguration _configuration = null!;
private static ILogger<MpDataService> _logger = null!;
private static Logger Log = LogManager.GetCurrentClassLogger();
private static string MpIoBaseUrl = "";
private readonly IHttpClientFactory _clientFactory;
#endregion Private Fields
}
}
}