SPEC:
- aggiunta e testata chiusura ODL - aggiunta gestione reload forzoso se sparisce chiamata
This commit is contained in:
@@ -912,14 +912,13 @@ namespace MP.Data.Controllers
|
||||
*/
|
||||
}
|
||||
|
||||
// ora chiudo ODL
|
||||
// ora chiudo ODL con stored SENZA ritorno...
|
||||
try
|
||||
{
|
||||
var dbResult = await dbCtx
|
||||
.DbSetStatOdl
|
||||
.FromSqlRaw("EXEC stp_ODL_fineProd @IdxODL, @IdxMacchina", IdxODL, IdxMacchina)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
var dbResult = dbCtx
|
||||
.Database
|
||||
.ExecuteSqlRaw("EXEC stp_ODL_fineProd @IdxODL, @IdxMacchina", IdxODL, IdxMacchina);
|
||||
fatto = true;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace MP.Data
|
||||
public string CancelAction { get; set; } = "";
|
||||
public string ConfirmAction { get; set; } = "";
|
||||
public DateTime DtReq { get; set; } = DateTime.Now;
|
||||
public bool IsActive { get; set; } = true;
|
||||
public bool IsActive { get; set; } = false;
|
||||
public string Message { get; set; } = "New Message";
|
||||
public bool ShowCancel { get; set; } = true;
|
||||
public bool ShowClose { get; set; } = true;
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close" @onclick="() => doCancel()"></button>
|
||||
}
|
||||
</div>
|
||||
<div class="toast-body pt-5 bg-light rounded-bottom fs-5">
|
||||
<div class="toast-body py-4 bg-light rounded-bottom fs-5">
|
||||
@CurrAction.Message
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<div class="text-center py-3">
|
||||
<strong>@CurrAction.Parameter</strong>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6 d-grid">
|
||||
@if (CurrAction.ShowConfirm)
|
||||
@@ -33,5 +33,3 @@
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Components;
|
||||
using MP.Data;
|
||||
using MP.SPEC.Data;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
|
||||
namespace MP.SPEC.Components
|
||||
{
|
||||
@@ -11,14 +12,133 @@ namespace MP.SPEC.Components
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
MMDataService.BroadastMsgPipe.EA_NewMessage -= BroadastMsgPipe_EA_NewMessage;
|
||||
MDService.BroadastMsgPipe.EA_NewMessage -= BroadastMsgPipe_EA_NewMessage;
|
||||
GC.Collect();
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected DateTime lastRec = DateTime.Now.AddMinutes(-1);
|
||||
|
||||
protected int RefreshPeriod = 2000;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected DisplayAction CurrAction { get; set; } = new DisplayAction();
|
||||
|
||||
[Inject]
|
||||
protected MpDataService MDService { get; set; } = null!;
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected async Task doCancel()
|
||||
{
|
||||
checkActionNull();
|
||||
// verifico il tipo di richiesta...
|
||||
if (!string.IsNullOrEmpty(CurrAction.CancelAction))
|
||||
{
|
||||
switch (CurrAction.CancelAction)
|
||||
{
|
||||
case "DisableAction":
|
||||
case "Reset":
|
||||
default:
|
||||
//// resetto parametro
|
||||
//CurrAction.Parameter = "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
// eseguo chiusura finale
|
||||
CurrAction.IsActive = false;
|
||||
MDService.ActionSetReq(CurrAction);
|
||||
await Task.Delay(1);
|
||||
}
|
||||
|
||||
protected async Task doConfirm()
|
||||
{
|
||||
checkActionNull();
|
||||
bool fatto = false;
|
||||
// verifico il tipo di richiesta...
|
||||
if (!string.IsNullOrEmpty(CurrAction.ConfirmAction))
|
||||
{
|
||||
switch (CurrAction.ConfirmAction)
|
||||
{
|
||||
case "CloseODL":
|
||||
// chiudo ODL
|
||||
int idxOdl = 0;
|
||||
int.TryParse(CurrAction.Parameter, out idxOdl);
|
||||
if (idxOdl > 0)
|
||||
{
|
||||
DateTime oggi = DateTime.Today;
|
||||
// recupero macchina x ODL...
|
||||
var elencoOdl = await MDService.ListODLFilt(true, "*", "*", "*", "*", DateTime.Today.AddMonths(-1), DateTime.Today.AddDays(1));
|
||||
var currOdl = elencoOdl.FirstOrDefault(x => x.IdxOdl == idxOdl);
|
||||
if (currOdl != null && currOdl.IdxOdl == idxOdl)
|
||||
{
|
||||
// effettua chiusura sul DB
|
||||
fatto = await MDService.ODLClose(idxOdl, currOdl.IdxMacchina, 0, true);
|
||||
if (fatto)
|
||||
{
|
||||
Log.Info($"Effettuata chiusura ODL {idxOdl}");
|
||||
CurrAction.Parameter = "";
|
||||
// elimino richiesta
|
||||
CurrAction.IsActive = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"Errore in doConfirm chiusura ODL: non trovato ODL per idxOdl {idxOdl}");
|
||||
}
|
||||
}
|
||||
// resetto parametro
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
MDService.ActionSetReq(CurrAction);
|
||||
await Task.Delay(1);
|
||||
// se fatto --> ricarico!
|
||||
if (fatto)
|
||||
{
|
||||
// rimando a pagina corrente
|
||||
NavManager.NavigateTo(NavManager.Uri, true);
|
||||
}
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await reloadData();
|
||||
MDService.BroadastMsgPipe.EA_NewMessage += BroadastMsgPipe_EA_NewMessage;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
[Inject]
|
||||
private NavigationManager NavManager { get; set; } = null!;
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void BroadastMsgPipe_EA_NewMessage(object? sender, EventArgs e)
|
||||
{
|
||||
bool needReload = false;
|
||||
DateTime adesso = DateTime.Now;
|
||||
PubSubEventArgs currArgs = (PubSubEventArgs)e;
|
||||
if (!string.IsNullOrEmpty(currArgs.newMessage))
|
||||
@@ -29,81 +149,55 @@ namespace MP.SPEC.Components
|
||||
var result = JsonConvert.DeserializeObject<DisplayAction>(currArgs.newMessage);
|
||||
if (result != null)
|
||||
{
|
||||
// se da visibile apssa ad hidden --> segnalo serve reload...
|
||||
needReload = (CurrAction.IsActive && !result.IsActive);
|
||||
CurrAction = result;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
InvokeAsync(() =>
|
||||
if (needReload)
|
||||
{
|
||||
StateHasChanged();
|
||||
});
|
||||
NavManager.NavigateTo(NavManager.Uri, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
InvokeAsync(() =>
|
||||
{
|
||||
StateHasChanged();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected int RefreshPeriod = 2000;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected DisplayAction? CurrAction { get; set; } = null;
|
||||
|
||||
[Inject]
|
||||
protected MpDataService MMDataService { get; set; } = null!;
|
||||
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
private void checkActionNull()
|
||||
{
|
||||
await reloadData();
|
||||
MMDataService.BroadastMsgPipe.EA_NewMessage += BroadastMsgPipe_EA_NewMessage;
|
||||
if (CurrAction == null)
|
||||
{
|
||||
CurrAction = new DisplayAction()
|
||||
{
|
||||
Topic = "Chiusura ODL",
|
||||
Message = "Rilevato possibile fine operazioni, Vuoi chiudere la commessa?",
|
||||
ShowCancel = true,
|
||||
ShowClose = true,
|
||||
ShowConfirm = true,
|
||||
CancelAction = "DisableAction",
|
||||
ConfirmAction = "CloseODL",
|
||||
DtReq = DateTime.Now,
|
||||
IsActive = true
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private async Task reloadData()
|
||||
{
|
||||
CurrAction = await MMDataService.ActionGetReq();
|
||||
CurrAction = await MDService.ActionGetReq();
|
||||
if (CurrAction != null)
|
||||
{
|
||||
await InvokeAsync(() => StateHasChanged());
|
||||
}
|
||||
}
|
||||
|
||||
protected async Task doConfirm()
|
||||
{
|
||||
// verifico il tipo di richiesta...
|
||||
|
||||
// eseguo
|
||||
|
||||
// elimino richiesta
|
||||
CurrAction.IsActive = false;
|
||||
MMDataService.ActionSetReq(CurrAction);
|
||||
}
|
||||
protected async Task doCancel()
|
||||
{
|
||||
// verifico il tipo di richiesta...
|
||||
|
||||
// eseguo
|
||||
CurrAction.IsActive = false;
|
||||
MMDataService.ActionSetReq(CurrAction);
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ namespace MP.SPEC.Data
|
||||
/// Recupera eventuali azioni richieste
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<DisplayAction?> ActionGetReq()
|
||||
public async Task<DisplayAction> ActionGetReq()
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
@@ -77,6 +77,10 @@ namespace MP.SPEC.Data
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Debug($"ActionGetReq Read from REDIS: {ts.TotalMilliseconds}ms");
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new DisplayAction();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>MP.SPEC</RootNamespace>
|
||||
<Version>6.16.2212.916</Version>
|
||||
<Version>6.16.2212.917</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -8,18 +8,24 @@
|
||||
@if (CurrAction != null)
|
||||
{
|
||||
<div class="row mt-5">
|
||||
<div class="col-4">
|
||||
<div class="col-3">
|
||||
<div class="input-group">
|
||||
<label class="input-group-text" for="inputHead">Header</label>
|
||||
<input type="text" class="form-control" id="inputHead" @bind="CurrAction.Topic">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-8">
|
||||
<div class="col-6">
|
||||
<div class="input-group">
|
||||
<label class="input-group-text" for="inputBody">Messaggio</label>
|
||||
<input type="text" class="form-control" id="inputBody" @bind="CurrAction.Message">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<div class="input-group">
|
||||
<label class="input-group-text" for="inputHead">IdxODL</label>
|
||||
<input type="text" class="form-control" id="inputHead" @bind="CurrAction.Parameter">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
</div>
|
||||
<div class="col-4">
|
||||
|
||||
@@ -61,7 +61,8 @@ namespace MP.SPEC.Pages
|
||||
CancelAction = "DisableAction",
|
||||
ConfirmAction = "CloseODL",
|
||||
DtReq = DateTime.Now,
|
||||
IsActive = true
|
||||
IsActive = true,
|
||||
Parameter = "1"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MAPOSPEC </i>
|
||||
<h4>Versione: 6.16.2212.916</h4>
|
||||
<h4>Versione: 6.16.2212.917</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.16.2212.916
|
||||
6.16.2212.917
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>6.16.2212.916</version>
|
||||
<version>6.16.2212.917</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>
|
||||
|
||||
Reference in New Issue
Block a user