@CurrAction.Message
-
-
-
+
+ @CurrAction.Parameter
+
@if (CurrAction.ShowConfirm)
@@ -33,5 +33,3 @@
}
-
-
diff --git a/MP.SPEC/Components/AskCloseOdl.razor.cs b/MP.SPEC/Components/AskCloseOdl.razor.cs
index 290f2cea..75945dde 100644
--- a/MP.SPEC/Components/AskCloseOdl.razor.cs
+++ b/MP.SPEC/Components/AskCloseOdl.razor.cs
@@ -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
(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
}
}
\ No newline at end of file
diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs
index 507f662c..2018b81a 100644
--- a/MP.SPEC/Data/MpDataService.cs
+++ b/MP.SPEC/Data/MpDataService.cs
@@ -63,7 +63,7 @@ namespace MP.SPEC.Data
/// Recupera eventuali azioni richieste
///
///
- public async Task ActionGetReq()
+ public async Task 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;
}
diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj
index ee97ef8d..7fa7a059 100644
--- a/MP.SPEC/MP.SPEC.csproj
+++ b/MP.SPEC/MP.SPEC.csproj
@@ -5,7 +5,7 @@
enable
enable
MP.SPEC
- 6.16.2212.916
+ 6.16.2212.917
diff --git a/MP.SPEC/Pages/Test.razor b/MP.SPEC/Pages/Test.razor
index d3073f2f..60775048 100644
--- a/MP.SPEC/Pages/Test.razor
+++ b/MP.SPEC/Pages/Test.razor
@@ -8,18 +8,24 @@
@if (CurrAction != null)
{
-
+
-
+
+
diff --git a/MP.SPEC/Pages/Test.razor.cs b/MP.SPEC/Pages/Test.razor.cs
index 7e22f823..58be09e9 100644
--- a/MP.SPEC/Pages/Test.razor.cs
+++ b/MP.SPEC/Pages/Test.razor.cs
@@ -61,7 +61,8 @@ namespace MP.SPEC.Pages
CancelAction = "DisableAction",
ConfirmAction = "CloseODL",
DtReq = DateTime.Now,
- IsActive = true
+ IsActive = true,
+ Parameter = "1"
};
}
}
diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html
index 277f909e..4705158a 100644
--- a/MP.SPEC/Resources/ChangeLog.html
+++ b/MP.SPEC/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
Modulo MAPOSPEC
-
Versione: 6.16.2212.916
+
Versione: 6.16.2212.917
Note di rilascio:
-
diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt
index d4c32d28..b33cddbb 100644
--- a/MP.SPEC/Resources/VersNum.txt
+++ b/MP.SPEC/Resources/VersNum.txt
@@ -1 +1 @@
-6.16.2212.916
+6.16.2212.917
diff --git a/MP.SPEC/Resources/manifest.xml b/MP.SPEC/Resources/manifest.xml
index 347792c8..68def6b2 100644
--- a/MP.SPEC/Resources/manifest.xml
+++ b/MP.SPEC/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 6.16.2212.916
+ 6.16.2212.917
https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip
https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html
false