Update gestione editing fermate

This commit is contained in:
Samuele Locatelli
2023-10-09 17:06:35 +02:00
parent 16e0a8b56e
commit ef0a96561c
10 changed files with 323 additions and 202 deletions
+19 -26
View File
@@ -1,34 +1,12 @@
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 Newtonsoft.Json;
using NLog;
using System.Reflection.Metadata;
namespace MP_TAB_SERV.Components
{
public partial class LongStopList
{
[Parameter]
public string fnqName { get; set; } = "";
#region Public Properties
[Parameter]
public string fnqArticle { get; set; } = "";
@@ -39,11 +17,26 @@ namespace MP_TAB_SERV.Components
[Parameter]
public double fnqDurMin { get; set; } = 0;
[Parameter]
public string fnqName { get; set; } = "";
[Parameter]
public string fnqSemaforo { get; set; } = "";
#endregion Public Properties
#region Protected Properties
[Inject]
protected MessageService MsgServ { get; set; } = null!;
[Inject]
protected NavigationManager NavMan { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
/// <summary>
/// Rimanda alla pagina fermate selezionando periodo corretto...
/// </summary>
@@ -52,10 +45,10 @@ namespace MP_TAB_SERV.Components
{
await Task.Delay(1);
// salva la data-ora evento richiesto...
await MsgServ.DtRifCommentoSet(fnqDateTime);
await MsgServ.CommentoDtRifSet(fnqDateTime);
NavMan.NavigateTo("prod-stop");
}
[Inject]
protected NavigationManager NavMan { get; set; } = null!;
#endregion Protected Methods
}
}
+45 -3
View File
@@ -1,4 +1,4 @@
using global::System;
using global::System;
using global::System.Collections.Generic;
using global::System.Linq;
using global::System.Threading.Tasks;
@@ -45,7 +45,7 @@ namespace MP_TAB_SERV.Components
[Parameter]
public string Title { get; set; } = "NA";
[Parameter]
public EventListModel? CurrComm
public EventListModel? CurrRecord
{
//get;
set
@@ -107,7 +107,7 @@ namespace MP_TAB_SERV.Components
MatrOpr = MatrOpr,
pallet = "-"
};
// elimino vecchio se c'è...
// elimino vecchio se c'è...
await TabServ.EvListDelete(IdxMacc, DateSel);
// inserisco
await TabServ.EvListInsert(newRec, MP.Data.Objects.Enums.tipoInputEvento.commento);
@@ -120,6 +120,48 @@ namespace MP_TAB_SERV.Components
protected override void OnInitialized()
{
idxTipoCommento = SMServ.GetConfInt("idxTipoCommento");
dltMinRealtime = SMServ.GetConfInt("dltMinRealtime");
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
// cerco se ci sia una data-ora rif salvata...
DateSel = await MServ.CommentoDtRifGet(false);
if (!insRealtime)
{
await Task.Delay(1);
UserComment = await MServ.CommentoValGet(true);
if (ShowBtn)
{
DateSel = await MServ.CommentoDtRifGet(true);
ShowBtn = false;
await InvokeAsync(StateHasChanged);
}
}
}
protected int dltMinRealtime = 1;
/// <summary>
/// Determina se insert sia Realtime o batch con DataOra (in base a diff tra DataOra
/// selezionata e realtime, se superiore ad X minuti NON realtime)
/// </summary>
public bool insRealtime
{
get
{
bool answ = true;
try
{
if (Math.Abs(DateSel.Subtract(DateTime.Now).TotalMinutes) > dltMinRealtime)
{
answ = false;
}
}
catch
{ }
return answ;
}
}
protected void ToggleCtrl()
+2 -2
View File
@@ -80,10 +80,10 @@
</div>
<div class="d-flex justify-content-between">
<div class="col-6 p-2">
<button class="btn btn-sm btn-info w-100"><i class="fa fa-edit"></i></button>
<button class="btn btn-sm btn-info w-100" @onclick="() => EditRec(item)"><i class="fa fa-edit"></i></button>
</div>
<div class="col-6 p-2">
<button class="btn btn-sm btn-danger w-100"><i class="fa fa-trash"></i></button>
<button class="btn btn-sm btn-danger w-100" @onclick="() => DeteleRec(item)"><i class="fa fa-trash"></i></button>
</div>
</div>
</div>
+92 -41
View File
@@ -1,6 +1,6 @@
using global::Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using MP.Data.DatabaseModels;
using MP.Data.DTO;
using MP.Data.Services;
namespace MP_TAB_SERV.Components
@@ -16,30 +16,6 @@ namespace MP_TAB_SERV.Components
#region Protected Properties
protected int NumComm
{
get => numComm;
set
{
if (numComm != value)
{
numComm = value;
ReloadComments().ConfigureAwait(false);
}
}
}
protected int NumGiorni
{
get => _numGiorni;
set
{
if (_numGiorni != value)
{
_numGiorni = value;
ReloadFnq().ConfigureAwait(false);
}
}
}
protected int DurataMin
{
get => _durataMin;
@@ -48,13 +24,57 @@ namespace MP_TAB_SERV.Components
if (_durataMin != value)
{
_durataMin = value;
ReloadFnq().ConfigureAwait(false);
var pUpd = Task.Run(async () =>
{
await ReloadFnq();
});
pUpd.Wait();
}
}
}
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
[Inject]
protected MessageService MsgServ { get; set; } = null!;
[Inject]
protected NavigationManager NavMan { get; set; } = null!;
protected int NumComm
{
get => numComm;
set
{
if (numComm != value)
{
numComm = value;
var pUpd = Task.Run(async () =>
{
await ReloadComments();
});
pUpd.Wait();
}
}
}
protected int NumGiorni
{
get => _numGiorni;
set
{
if (_numGiorni != value)
{
_numGiorni = value;
var pUpd = Task.Run(async () =>
{
await ReloadFnq();
});
pUpd.Wait();
}
}
}
private int numComm { get; set; } = 10;
private int _numGiorni { get; set; } = 3;
private int _durataMin { get; set; } = 30;
protected List<CommentiModel> RecordListComments { get; set; } = new List<CommentiModel>();
protected List<FermiNonQualModel> RecordListFnq { get; set; } = new List<FermiNonQualModel>();
@@ -66,6 +86,28 @@ namespace MP_TAB_SERV.Components
#region Protected Methods
protected async Task DeteleRec(CommentiModel currRec)
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Sicuro di voelr eliminare il record?"))
return;
await Task.Delay(1);
await TabServ.EvListDelete(currRec.IdxMacchina, currRec.InizioStato);
// ricarico
await ReloadComments();
await ReloadFnq();
}
protected async Task EditRec(CommentiModel currRec)
{
await Task.Delay(1);
// salvo
await MsgServ.CommentoDtRifSet(currRec.InizioStato);
await MsgServ.CommentoValSet(currRec.Value);
// navigo
NavMan.NavigateTo("notes");
}
protected override async Task OnParametersSetAsync()
{
await ReloadComments();
@@ -74,16 +116,15 @@ namespace MP_TAB_SERV.Components
#endregion Protected Methods
#region Private Methods
#region Private Properties
private async Task ReloadComments()
{
RecordListComments = await TabServ.CommentiGetLastByMacc(RecMSE?.IdxMacchina, NumComm);
}
private async Task ReloadFnq()
{
RecordListFnq = await TabServ.FermiNonQualificatiFilt(RecMSE?.IdxMacchina, NumGiorni, DurataMin);
}
private int _durataMin { get; set; } = 30;
private int _numGiorni { get; set; } = 3;
private int numComm { get; set; } = 10;
#endregion Private Properties
#region Private Methods
private async Task DoUpdate(bool forceReload)
{
@@ -93,18 +134,28 @@ namespace MP_TAB_SERV.Components
}
}
private async Task ReloadComments()
{
RecordListComments = await TabServ.CommentiGetLastByMacc(RecMSE?.IdxMacchina, NumComm);
}
private async Task ReloadFnq()
{
RecordListFnq = await TabServ.FermiNonQualificatiFilt(RecMSE?.IdxMacchina, NumGiorni, DurataMin);
}
private string setSemaforo(string sem)
{
string answ = "";
if(sem == "sBl")
if (sem == "sBl")
{
answ = "bg-primary text-warning";
}
else if(sem == "sGr")
else if (sem == "sGr")
{
answ = "bg-secondary text-dark";
}
else if(sem == "sGi")
else if (sem == "sGi")
{
answ = "bg-warning text-dark";
}
+1 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<Version>6.16.2310.914</Version>
<Version>6.16.2310.916</Version>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP_TAB_SERV</RootNamespace>
</PropertyGroup>
+17 -21
View File
@@ -17,17 +17,15 @@ namespace MP_TAB_SERV.Pages
get
{
bool answ = true;
#if false
try
{
if (Math.Abs(dataOraEv.Subtract(DateTime.Now).TotalMinutes) > memLayer.ML.CRI("dltMinRealtime"))
{
answ = false;
}
}
catch
{ }
#endif
//try
//{
// if (Math.Abs(DtRif.Subtract(DateTime.Now).TotalMinutes) > dltMinRealtime)
// {
// answ = false;
// }
//}
//catch
//{ }
return answ;
}
}
@@ -53,16 +51,11 @@ namespace MP_TAB_SERV.Pages
protected MessageService MServ { get; set; } = null!;
[Inject]
protected MessageService MsgServ { get; set; } = null!;
[Inject]
protected SharedMemService MStor { get; set; } = null!;
protected SharedMemService SMServ { get; set; } = null!;
[Inject]
protected TabDataService TabServ { get; set; } = null!;
[Inject]
protected TabDataService TabSrv { get; set; } = null!;
#endregion Protected Properties
@@ -80,7 +73,7 @@ namespace MP_TAB_SERV.Pages
if (IdxEv > 0)
{
var rigaEvento = MStor.GetEventRow(IdxEv);
var rigaEvento = SMServ.GetEventRow(IdxEv);
if (rigaEvento != null)
{
var rigaStato = await TabServ.StatoMacchina(IdxMacc);
@@ -192,9 +185,12 @@ namespace MP_TAB_SERV.Pages
protected override async Task OnInitializedAsync()
{
// leggo gli altri dati
await ReloadData();
}
#endregion Protected Methods
#region Private Properties
@@ -216,13 +212,13 @@ namespace MP_TAB_SERV.Pages
{
try
{
IdxMacc = await MsgServ.IdxMaccGet();
IdxMacc = await MServ.IdxMaccGet();
// recupero MSE macchina....
if (!string.IsNullOrEmpty(IdxMacc))
{
CurrMSE = await MsgServ.GetMachineMse(IdxMacc);
CurrMSE = await MServ.GetMachineMse(IdxMacc);
}
var eventsAll = await TabSrv.AnagEventiGetByMacch(IdxMacc);
var eventsAll = await TabServ.AnagEventiGetByMacch(IdxMacc);
if (eventsAll != null)
{
events2show = eventsAll.Where(x => x.EventoTablet).OrderBy(x => x.Label).ToList();
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 6.16.2310.914</h4>
<h4>Versione: 6.16.2310.916</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
6.16.2310.914
6.16.2310.916
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2310.914</version>
<version>6.16.2310.916</version>
<url>https://nexus.steamware.net/repository/SWS/MP-TAB-SERV/stable/LAST/MP-TAB-SERV.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-TAB-SERV/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+144 -105
View File
@@ -101,19 +101,6 @@ namespace MP.Data.Services
}
}
public string UserAuthKey
{
get
{
string answ = "";
if (_rigaOper != null)
{
answ = _rigaOper.authKey;
}
return answ;
}
}
public AnagOperatoriModel? RigaOper
{
get => _rigaOper;
@@ -128,6 +115,19 @@ namespace MP.Data.Services
}
}
public string UserAuthKey
{
get
{
string answ = "";
if (_rigaOper != null)
{
answ = _rigaOper.authKey;
}
return answ;
}
}
#endregion Public Properties
#region Public Methods
@@ -142,6 +142,70 @@ namespace MP.Data.Services
await sessionStore.ClearAsync();
}
/// <summary>
/// DateTime riferimento evento x commento fermata
/// </summary>
/// <param name="remAfter"></param>
/// <returns></returns>
public async Task<DateTime> CommentoDtRifGet(bool remAfter)
{
DateTime answ = DateTime.Now;
bool hasKey = await sessionStore.ContainKeyAsync(KeyCommDtRif);
if (hasKey)
{
//try
//{
// recupero
answ = await sessionStore.GetItemAsync<DateTime>(KeyCommDtRif);
// svuoto data registrata se richiesto
if (remAfter)
{
await sessionStore.RemoveItemAsync(KeyCommDtRif);
}
//}
//catch { }
}
return answ;
}
/// <summary>
/// Macchine attualmente selezionata
/// </summary>
public async Task CommentoDtRifSet(DateTime DtRif)
{
await sessionStore.SetItemAsync(KeyCommDtRif, DtRif);
}
/// <summary>
/// Commento fermata x recupero in editing
/// </summary>
/// <param name="remAfter"></param>
/// <returns></returns>
public async Task<string> CommentoValGet(bool remAfter)
{
string answ = "";
bool hasKey = await sessionStore.ContainKeyAsync(KeyCommText);
if (hasKey)
{
// recupero
answ = await sessionStore.GetItemAsync<string>(KeyCommText);
// svuoto data registrata se richiesto
if (remAfter)
{
await sessionStore.RemoveItemAsync(KeyCommText);
}
}
return answ;
}
/// <summary>
/// Macchine attualmente selezionata
/// </summary>
public async Task CommentoValSet(string Valore)
{
await sessionStore.SetItemAsync(KeyCommText, Valore);
}
/// <summary>
/// Restituisce il valore Ipv4 del Device da localstorage
/// </summary>
@@ -205,29 +269,81 @@ namespace MP.Data.Services
}
/// <summary>
/// Macchine attualmente selezionata
/// Effettua salvataggio in localstorage dei dati MSE correnti
/// </summary>
public async Task DtRifCommentoSet(DateTime DtRif)
{
await sessionStore.SetItemAsync("DtRifComm", DtRif);
}
/// <summary>
/// DateTime riferimento evento x commento fermata
/// </summary>
/// <param name="remAfter"></param>
/// <param name="currListMSE"></param>
/// <returns></returns>
public async Task<DateTime> DtRifCommentoGet(bool remAfter)
/// <exception cref="NotImplementedException"></exception>
public async Task SaveMse(List<MappaStatoExpl> currListMSE)
{
// recupero
var answ = await sessionStore.GetItemAsync<DateTime>("DtRifComm");
// svuoto data registrata se richiesto
if (remAfter)
foreach (var item in currListMSE)
{
await sessionStore.RemoveItemAsync("DtRifComm");
string serVal = JsonConvert.SerializeObject(item);
await localStorage.SetItemAsync(machineMse(item.IdxMacchina), serVal);
}
}
/// <summary>
/// Scrive il valore di IPV4 del device nel localstoragee
/// </summary>
/// <param name="newVal"></param>
/// <returns></returns>
public async Task<bool> setDevIpv4Async(string newVal)
{
bool answ = false;
try
{
await localStorage.SetItemAsync(KeyDevIp4, newVal);
answ = true;
}
catch (Exception ex)
{
Log.Error($"Eccezione in setDevIpv4Async{Environment.NewLine}{ex}");
}
return answ;
}
/// <summary>
/// Scrive il valore di DeviceSecret nel localstoragee
/// </summary>
/// <param name="newVal"></param>
/// <returns></returns>
public async Task<bool> setDevSecretAsync(string newVal)
{
bool answ = false;
try
{
await localStorage.SetItemAsync(KeyDevSec, newVal);
answ = true;
}
catch (Exception ex)
{
Log.Error($"Eccezione in setDevSecretAsync{Environment.NewLine}{ex}");
}
return answ;
}
#endregion Public Methods
#region Protected Fields
protected const string KeyDevIp4 = "DevIpv4";
protected const string KeyDevSec = "DevSec";
protected const string KeyMacDict = "MachineDict";
#endregion Protected Fields
#region Protected Properties
protected ILocalStorageService localStorage { get; set; } = null!;
protected ISessionStorageService sessionStore { get; set; } = null!;
#endregion Protected Properties
#region Private Fields
private const string KeyCommDtRif = "DtRifComm";
private const string KeyCommText = "ValComm";
#if false
public bool IsActive
{
@@ -343,72 +459,6 @@ namespace MP.Data.Services
public DateTime targetDate { get; set; } = DateTime.Today;
public DateTime targetDateMancTimb { get; set; }
#endif
/// <summary>
/// Effettua salvataggio in localstorage dei dati MSE correnti
/// </summary>
/// <param name="currListMSE"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public async Task SaveMse(List<MappaStatoExpl> currListMSE)
{
foreach (var item in currListMSE)
{
string serVal = JsonConvert.SerializeObject(item);
await localStorage.SetItemAsync(machineMse(item.IdxMacchina), serVal);
}
}
/// <summary>
/// Scrive il valore di IPV4 del device nel localstoragee
/// </summary>
/// <param name="newVal"></param>
/// <returns></returns>
public async Task<bool> setDevIpv4Async(string newVal)
{
bool answ = false;
try
{
await localStorage.SetItemAsync(KeyDevIp4, newVal);
answ = true;
}
catch (Exception ex)
{
Log.Error($"Eccezione in setDevIpv4Async{Environment.NewLine}{ex}");
}
return answ;
}
/// <summary>
/// Scrive il valore di DeviceSecret nel localstoragee
/// </summary>
/// <param name="newVal"></param>
/// <returns></returns>
public async Task<bool> setDevSecretAsync(string newVal)
{
bool answ = false;
try
{
await localStorage.SetItemAsync(KeyDevSec, newVal);
answ = true;
}
catch (Exception ex)
{
Log.Error($"Eccezione in setDevSecretAsync{Environment.NewLine}{ex}");
}
return answ;
}
#endregion Public Methods
#region Protected Fields
protected const string KeyDevIp4 = "DevIpv4";
protected const string KeyDevSec = "DevSec";
protected const string KeyMacDict = "MachineDict";
#endregion Protected Fields
#if false
public void ReportDateChange()
@@ -476,17 +526,6 @@ namespace MP.Data.Services
}
}
#endif
#region Protected Properties
protected ILocalStorageService localStorage { get; set; } = null!;
protected ISessionStorageService sessionStore { get; set; } = null!;
#endregion Protected Properties
#region Private Fields
private AnagOperatoriModel? _rigaOper;
private Logger Log = LogManager.GetCurrentClassLogger();