Riorganizzazione commenti --> note

This commit is contained in:
Samuele Locatelli
2023-10-07 12:27:00 +02:00
parent fd1c96929c
commit 59c973bf4a
18 changed files with 537 additions and 70 deletions
@@ -0,0 +1,39 @@
<h1> RIFARE X COMMENTI!!!</h1>
<div class="row mt-2">
@if (ShowBtn)
{
<div class="col-12">
<button class="btn btn-lg bg-info w-100" @onclick="ToggleCtrl">
<i class="fa-solid fa-star"></i>
&nbsp;
<span class="fs-4 fw-bold">@Title</span>
</button>
</div>
}
else
{
<div class="col-6">
<div class="input-group">
<span class="input-group-text" id="basic-addon1">Data Ora</span>
<input type="datetime-local" class="form-control" id="floatDate" @bind="@DateSel">
</div>
</div>
<div class="col-6">
<button class="btn btn-warning w-100 align-middle" @onclick="doCancel"><i class="fa-solid fa-ban"></i> Annulla</button>
</div>
<div class="col-12 my-1">
<div class="form-floating">
<textarea type="text" class="form-control" id="floatingComm" style="height: 6rem;" @bind="@UserComment"></textarea>
<label for="floatingComm">Commento</label>
</div>
</div>
<div class="col-12">
@if (CanSave)
{
<button class="btn btn-success w-100" @onclick="doSave"><i class="fa-solid fa-plus"></i> Salva</button>
}
</div>
}
</div>
@@ -0,0 +1,162 @@
using global::Microsoft.AspNetCore.Components;
using MP.Data.DatabaseModels;
using MP.Data.Services;
namespace MP_TAB_SERV.Components
{
public partial class CommentEditor
{
#region Public Properties
[Parameter]
public bool CanSave { get; set; } = false;
[Parameter]
public EventCallback<string> E_CommRec { get; set; }
[Parameter]
public EventCallback<DateTime> E_DateSel { get; set; }
[Parameter]
public MappaStatoExpl? RecMSE { get; set; } = null;
[Parameter]
public string Title { get; set; } = "NA";
[Parameter]
public EventListModel? CurrComm
{
//get;
set
{
if (value != null)
{
DateSel = value.InizioStato ?? DateTime.Now;
UserComment = value.Value;
}
}
}
#endregion Public Properties
#region Protected Properties
protected DateTime DateSel
{
get => dateSel;
set
{
if (dateSel != value)
{
dateSel = value;
E_DateSel.InvokeAsync(value).ConfigureAwait(false);
}
}
}
[Inject]
protected MessageService MServ { get; set; } = null!;
[Inject]
protected SharedMemService SMServ { get; set; } = null!;
[Inject]
protected TabDataService TabServ { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected void doCancel()
{
DoReset();
ToggleCtrl();
}
protected async Task doSave()
{
// registro evento
EventListModel newRec = new EventListModel()
{
IdxMacchina = IdxMacc,
InizioStato = DateSel,
IdxTipo = idxTipoCommento,
CodArticolo = CodArt,
Value = UserComment,
MatrOpr = MatrOpr,
pallet = "-"
};
// elimino vecchio se c'è...
await TabServ.EvListDelete(IdxMacc, DateSel);
// inserisco
await TabServ.EvListInsert(newRec, MP.Data.Objects.Enums.tipoInputEvento.barcode);
// reset
DoReset();
ToggleCtrl();
}
protected override void OnInitialized()
{
idxTipoCommento = SMServ.GetConfInt("idxTipoCommento");
}
protected void ToggleCtrl()
{
ShowBtn = !ShowBtn;
}
#endregion Protected Methods
#region Private Fields
private int idxTipoCommento = 0;
#endregion Private Fields
#region Private Properties
private string CodArt
{
get => RecMSE != null ? RecMSE.CodArticolo : "";
}
private DateTime dateSel { get; set; } = DateTime.Now;
private string IdxMacc
{
get => RecMSE != null ? RecMSE.IdxMacchina : "";
}
private int MatrOpr
{
get => MServ.MatrOpr;
}
private bool ShowBtn { get; set; } = true;
private string userComment { get; set; } = "";
private string UserComment
{
get => userComment.Trim();
set
{
if (userComment != value)
{
userComment = value;
E_CommRec.InvokeAsync(value).ConfigureAwait(false);
}
}
}
#endregion Private Properties
#region Private Methods
private void DoReset()
{
UserComment = "";
DateSel = DateTime.Now;
}
#endregion Private Methods
}
}
+1
View File
@@ -1,5 +1,6 @@
<h3>DeclarList</h3>
@code {
}
+36
View File
@@ -0,0 +1,36 @@
<div class="row mt-2">
@if (ShowBtn)
{
<div class="col-12">
<button class="btn btn-lg bg-info w-100" @onclick="ToggleCtrl">
<i class="fa-solid fa-star"></i>
&nbsp;
<span class="fs-4 fw-bold">@Title</span>
</button>
</div>
}
else
{
<div class="col-6">
<div class="input-group">
<span class="input-group-text" id="basic-addon1">Data Ora</span>
<input type="datetime-local" class="form-control" id="floatDate" @bind="@DateSel">
</div>
</div>
<div class="col-6">
<button class="btn btn-warning w-100 align-middle" @onclick="doCancel"><i class="fa-solid fa-ban"></i> Annulla</button>
</div>
<div class="col-12 my-1">
<div class="form-floating">
<textarea type="text" class="form-control" id="floatingComm" style="height: 6rem;" @bind="@UserComment"></textarea>
<label for="floatingComm">Commento</label>
</div>
</div>
<div class="col-12">
@if (CanSave)
{
<button class="btn btn-success w-100" @onclick="doSave"><i class="fa-solid fa-plus"></i> Salva</button>
}
</div>
}
</div>
+181
View File
@@ -0,0 +1,181 @@
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;
namespace MP_TAB_SERV.Components
{
public partial class NotesEditor
{
#region Public Properties
[Parameter]
public bool CanSave { get; set; } = false;
[Parameter]
public EventCallback<string> E_CommRec { get; set; }
[Parameter]
public EventCallback<DateTime> E_DateSel { get; set; }
[Parameter]
public MappaStatoExpl? RecMSE { get; set; } = null;
[Parameter]
public string Title { get; set; } = "NA";
[Parameter]
public EventListModel? CurrComm
{
//get;
set
{
if (value != null)
{
DateSel = value.InizioStato ?? DateTime.Now;
UserComment = value.Value;
}
}
}
#endregion Public Properties
#region Protected Properties
protected DateTime DateSel
{
get => dateSel;
set
{
if (dateSel != value)
{
dateSel = value;
E_DateSel.InvokeAsync(value).ConfigureAwait(false);
}
}
}
[Inject]
protected MessageService MServ { get; set; } = null!;
[Inject]
protected SharedMemService SMServ { get; set; } = null!;
[Inject]
protected TabDataService TabServ { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected void doCancel()
{
DoReset();
ToggleCtrl();
}
protected async Task doSave()
{
// registro evento
EventListModel newRec = new EventListModel()
{
IdxMacchina = IdxMacc,
InizioStato = DateSel,
IdxTipo = idxTipoCommento,
CodArticolo = CodArt,
Value = UserComment,
MatrOpr = MatrOpr,
pallet = "-"
};
// elimino vecchio se c'è...
await TabServ.EvListDelete(IdxMacc, DateSel);
// inserisco
await TabServ.EvListInsert(newRec, MP.Data.Objects.Enums.tipoInputEvento.barcode);
// reset
DoReset();
ToggleCtrl();
}
protected override void OnInitialized()
{
idxTipoCommento = SMServ.GetConfInt("idxTipoCommento");
}
protected void ToggleCtrl()
{
ShowBtn = !ShowBtn;
}
#endregion Protected Methods
#region Private Fields
private int idxTipoCommento = 0;
#endregion Private Fields
#region Private Properties
private string CodArt
{
get => RecMSE != null ? RecMSE.CodArticolo : "";
}
private DateTime dateSel { get; set; } = DateTime.Now;
private string IdxMacc
{
get => RecMSE != null ? RecMSE.IdxMacchina : "";
}
private int MatrOpr
{
get => MServ.MatrOpr;
}
private bool ShowBtn { get; set; } = true;
private string userComment { get; set; } = "";
private string UserComment
{
get => userComment.Trim();
set
{
if (userComment != value)
{
userComment = value;
E_CommRec.InvokeAsync(value).ConfigureAwait(false);
}
}
}
#endregion Private Properties
#region Private Methods
private void DoReset()
{
UserComment = "";
DateSel = DateTime.Now;
}
#endregion Private Methods
}
}
+8 -1
View File
@@ -1,5 +1,12 @@
<h3>NotesMan</h3>
<div class="row">
<div class="col-9">
Lista fermate
</div>
<div class="col-3">
Lista commenti
</div>
</div>
@code {
}
+2 -18
View File
@@ -85,28 +85,12 @@ namespace MP_TAB_SERV.Components
private string IdxMacc
{
get
{
string answ = "";
if (RecMSE != null)
{
answ = RecMSE.IdxMacchina ?? "";
}
return answ;
}
get => RecMSE != null ? RecMSE.IdxMacchina : "";
}
private int IdxOdl
{
get
{
int answ = 0;
if (RecMSE != null)
{
answ = RecMSE.IdxOdl ?? 0;
}
return answ;
}
get => RecMSE != null ? RecMSE.IdxOdl ?? 0 : 0;
}
private int MatrOpr
+1 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<Version>6.16.2310.618</Version>
<Version>6.16.2310.712</Version>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP_TAB_SERV</RootNamespace>
</PropertyGroup>
+1
View File
@@ -9,6 +9,7 @@ else
<div>
<MachineBlock RecMSE="CurrMSE" FullMode="false"></MachineBlock>
</div>
<NotesEditor CanSave="true" Title="Nuovo Commento"></NotesEditor>
<NotesMan></NotesMan>
}
+2 -7
View File
@@ -10,13 +10,8 @@ else
<MachineBlock RecMSE="CurrMSE" FullMode="false"></MachineBlock>
</div>
<div class="w-100 my-2">
<button class="btn btn-info w-100">
<i class="fa-solid fa-star"></i>
&nbsp;
<span class="fs-3 fw-bold">Dich Retroattiva</span>
</button>
</div>
<NotesEditor Title="Dichiarazione Fermo Retroattiva + Commento" RecMSE="CurrMSE"></NotesEditor>
<div class="d-flex justify-content-between flex-wrap align-items-center mb-3">
@if (!string.IsNullOrEmpty(lblOut))
{
+27 -8
View File
@@ -87,8 +87,18 @@ namespace MP_TAB_SERV.Pages
// processo evento...
if (insRealtime)
{
EventListModel newRec = new EventListModel()
{
IdxMacchina = IdxMacc,
InizioStato = DateTime.Now,
IdxTipo = IdxEv,
CodArticolo = rigaStato.CodArticolo,
Value = "DRT",
MatrOpr = MatrOpr,
pallet = rigaStato.pallet
};
// se realtime
await TabServ.scriviRigaEventoBarcode(IdxMacc, IdxEv, rigaStato.CodArticolo, "DRT", MatrOpr, rigaStato.pallet);
await TabServ.EvListInsert(newRec, MP.Data.Objects.Enums.tipoInputEvento.barcode);
// resetta il microstato in modo da ricevere successive info HW
TabServ.resetMicrostatoMacchina(IdxMacc);
}
@@ -195,6 +205,8 @@ namespace MP_TAB_SERV.Pages
}
#endregion Private Properties
[Inject]
protected NavigationManager NavMan { get; set; } = null!;
#region Private Methods
@@ -202,16 +214,23 @@ namespace MP_TAB_SERV.Pages
{
if (string.IsNullOrEmpty(IdxMacc))
{
IdxMacc = await MsgServ.IdxMaccGet();
// recupero MSE macchina....
if (!string.IsNullOrEmpty(IdxMacc))
try
{
CurrMSE = await MsgServ.GetMachineMse(IdxMacc);
IdxMacc = await MsgServ.IdxMaccGet();
// recupero MSE macchina....
if (!string.IsNullOrEmpty(IdxMacc))
{
CurrMSE = await MsgServ.GetMachineMse(IdxMacc);
}
var eventsAll = await TabSrv.AnagEventiGetByMacch(IdxMacc);
if (eventsAll != null)
{
events2show = eventsAll.Where(x => x.EventoTablet).OrderBy(x => x.Label).ToList();
}
}
var eventsAll = await TabSrv.AnagEventiGetByMacch(IdxMacc);
if (eventsAll != null)
catch
{
events2show = eventsAll.Where(x => x.EventoTablet).OrderBy(x => x.Label).ToList();
NavMan.NavigateTo("/", true);
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 6.16.2310.618</h4>
<h4>Versione: 6.16.2310.712</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
6.16.2310.618
6.16.2310.712
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2310.618</version>
<version>6.16.2310.712</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>
+2 -3
View File
@@ -48,9 +48,8 @@
</div>
}
}
@*
<br />
<div class="nav-item px-2">
<NavLink class="nav-link px-2" href="" Match="NavLinkMatch.All">
<span class="bi bi-house-door-fill" aria-hidden="true"></span> Home
@@ -70,7 +69,7 @@
<NavLink class="nav-link px-2" href="CardDemo">
<span class="bi bi-plus-square-fill" aria-hidden="true"></span> CardDemo
</NavLink>
</div>
</div> *@
</nav>
</div>
+32
View File
@@ -302,6 +302,38 @@ namespace MP.Data.Controllers
_configuration = null;
}
/// <summary>
/// Eliminazione record EventList (SE trovato)
/// </summary>
/// <param name="newRec"></param>
/// <returns></returns>
public async Task<bool> EvListDelete(string idxMacchina, DateTime dtEvento)
{
bool fatto = false;
using (var dbCtx = new MoonProContext(_configuration))
{
try
{
var item2del = dbCtx
.DbSetEvList
.Where(x => x.IdxMacchina == idxMacchina && x.InizioStato == dtEvento)
.FirstOrDefault();
if (item2del != null)
{
dbCtx.DbSetEvList.Remove(item2del);
await dbCtx.SaveChangesAsync();
}
}
catch (Exception exc)
{
Log.Error($"Eccezione durante EvListDelete{Environment.NewLine}{exc}");
}
}
await Task.Delay(1);
return fatto;
}
/// <summary>
/// Aggiunta record EventList
/// </summary>
+2 -1
View File
@@ -414,7 +414,8 @@ namespace MP.Data.Objects
public enum tipoInputEvento
{
barcode,
hw
hw,
commento
}
/// <summary>
+38 -28
View File
@@ -424,29 +424,13 @@ namespace MP.Data.Services
}
/// <summary>
/// scrive una riga di evento inviato da Barcode nel db
/// Scrive una riga in EventList inviato nel db + check
/// </summary>
/// <param name="idxMacchina">codice macchina</param>
/// <param name="idxTipo">idx evento</param>
/// <param name="codArticolo">Codice Articolo</param>
/// <param name="value">valore</param>
/// <param name="matrOpr">matricola operatore</param>
/// <param name="pallet">pallet (vuoto se nd)</param>
/// <param name="newRec">Record da registrare</param>
/// <returns></returns>
public async Task<inputComandoMapo> scriviRigaEventoBarcode(string idxMacchina, int idxTipo, string codArticolo, string value, int matrOpr, string pallet)
public async Task<inputComandoMapo> EvListInsert(EventListModel newRec, tipoInputEvento tipoEv)
{
bool inserito = false;
DateTime adesso = DateTime.Now;
EventListModel newRec = new EventListModel()
{
IdxMacchina = idxMacchina,
InizioStato = adesso,
IdxTipo = idxTipo,
CodArticolo = codArticolo,
Value = value,
MatrOpr = matrOpr,
pallet = pallet
};
try
{
// inserisco evento
@@ -454,18 +438,22 @@ namespace MP.Data.Services
}
catch (Exception exc)
{
string logMsg = $"Eccezione in fase di scrittura evento con i seguenti dati | macchina: {idxMacchina} | IdxTipo: {idxTipo} | CodArticolo: {codArticolo} | Value {value} | MatrOpr {matrOpr} | Pallet {pallet}{Environment.NewLine}{exc}";
string logMsg = $"Eccezione in fase di scrittura evento con i seguenti dati | macchina: {newRec.IdxMacchina} | IdxTipo: {newRec.IdxTipo} | CodArticolo: {newRec.CodArticolo} | Value {newRec.Value} | MatrOpr {newRec.MatrOpr} | Pallet {newRec.pallet}{Environment.NewLine}{exc}";
Log.Error(logMsg);
}
try
// se non è un commento...
if (tipoEv != tipoInputEvento.commento)
{
// faccio controllo per eventuale cambio stato da tab transizioni...
dbTabController.CheckCambiaStatoBatch(tipoInputEvento.barcode, idxMacchina, adesso, idxTipo, codArticolo, value, matrOpr, pallet);
}
catch (Exception exc)
{
string logMsg = $"Eccezione in checkCambiaStatoBatch(6) | tipoInputEvento: {tipoInputEvento.barcode} | macchina: {idxMacchina} | dataOra: {adesso} | IdxTipo: {idxTipo} | CodArticolo: {codArticolo} | Value {value} | MatrOpr {matrOpr} | Pallet {pallet}{Environment.NewLine}{exc}";
Log.Error(logMsg);
try
{
// faccio controllo per eventuale cambio stato da tab transizioni...
dbTabController.CheckCambiaStatoBatch(tipoEv, newRec.IdxMacchina, newRec.InizioStato ?? DateTime.Now, newRec.IdxTipo, newRec.CodArticolo, newRec.Value, newRec.MatrOpr, newRec.pallet);
}
catch (Exception exc)
{
string logMsg = $"Eccezione in checkCambiaStatoBatch(6) | tipoInputEvento: {tipoEv} |macchina: {newRec.IdxMacchina} | IdxTipo: {newRec.IdxTipo} | CodArticolo: {newRec.CodArticolo} | Value {newRec.Value} | MatrOpr {newRec.MatrOpr} | Pallet {newRec.pallet}{Environment.NewLine}{exc}";
Log.Error(logMsg);
}
}
// formatto output
inputComandoMapo answ = new inputComandoMapo();
@@ -474,6 +462,28 @@ namespace MP.Data.Services
return answ;
}
/// <summary>
/// Elimina una riga in EventList se trovata
/// </summary>
/// <param name="idxMacchina"></param>
/// <param name="dtEvento"></param>
/// <returns></returns>
public async Task<bool> EvListDelete(string idxMacchina, DateTime dtEvento)
{
bool fatto = false;
try
{
// inserisco evento
fatto = await dbTabController.EvListDelete(idxMacchina, dtEvento);
}
catch (Exception exc)
{
string logMsg = $"Eccezione in EvListDelete | macchina: {idxMacchina} | DataEv: {dtEvento}{Environment.NewLine}{exc}";
Log.Error(logMsg);
}
return fatto;
}
/// <summary>
/// Recupero Righe (Actual) della scheda tecnica da GRUPPO + ODL
/// </summary>