- Rivisitazione completa gestione riconnessione blazor 8
- fic logico e grafico
This commit is contained in:
Samuele Locatelli
2025-03-21 10:18:45 +01:00
parent 32d872c0eb
commit e7dcefb069
14 changed files with 129 additions and 98 deletions
+27 -21
View File
@@ -9,10 +9,10 @@ namespace MP.MON.Client.Components
#region Public Properties
[Parameter]
public Version version { get; set; } = null!;
public int slowRefreshSec { get; set; } = 300;
[Parameter]
public int slowRefreshSec { get; set; } = 300;
public Version version { get; set; } = null!;
#endregion Public Properties
@@ -27,16 +27,6 @@ namespace MP.MON.Client.Components
}
}
protected int slowRefreshMs
{
get
{
// tempo variabile tra +/- 10% del target
int answ = rnd.Next(900, 1100) * slowRefreshSec;
return answ;
}
}
private Random rnd;
public void ElapsedTimer(object? source, System.Timers.ElapsedEventArgs e)
{
// dispongo i vari timers...
@@ -46,12 +36,6 @@ namespace MP.MON.Client.Components
NavManager.NavigateTo(NavManager.Uri, true);
}
private void disposeTimers()
{
aTimer.Elapsed -= ElapsedTimer;
aTimer.Stop();
aTimer.Dispose();
}
public void StartTimer()
{
// timer lento
@@ -85,6 +69,16 @@ namespace MP.MON.Client.Components
[Inject]
protected NavigationManager NavManager { get; set; } = null!;
protected int slowRefreshMs
{
get
{
// tempo variabile tra +/- 10% del target
int answ = rnd.Next(900, 1100) * slowRefreshSec;
return answ;
}
}
#endregion Protected Properties
#region Protected Methods
@@ -103,15 +97,15 @@ namespace MP.MON.Client.Components
await getWDim();
StateHasChanged();
StartTimer();
Console.WriteLine($"Dimensioni schermo: {Width}x{Height} - timer avviato");
Console.WriteLine($"Footer | Dimensioni schermo: {Width}x{Height} | slowRefreshSec: {slowRefreshSec}");
}
//Console.WriteLine($"OnAfterRenderAsync completato");
Console.WriteLine($"Footer | OnAfterRenderAsync completato");
}
protected override void OnInitialized()
{
rnd = new Random();
Console.WriteLine($"OnInitialized Footer completato | slowRefreshSec: {slowRefreshSec} ");
Console.WriteLine($"Footer | OnInitialized completato");
}
#endregion Protected Methods
@@ -119,6 +113,7 @@ namespace MP.MON.Client.Components
#region Private Fields
private static System.Timers.Timer aTimer = null!;
private Random rnd;
#endregion Private Fields
@@ -129,5 +124,16 @@ namespace MP.MON.Client.Components
private int Width { get; set; } = 0;
#endregion Private Properties
#region Private Methods
private void disposeTimers()
{
aTimer.Elapsed -= ElapsedTimer;
aTimer.Stop();
aTimer.Dispose();
}
#endregion Private Methods
}
}
-2
View File
@@ -14,7 +14,5 @@
<span class="text-white fw-bold fs-2">
@($"{DateTime.Now:HH:mm:ss}")
</span>
@* <img class="logoImg img-fluid" src="images/logoCliente.png" height="24" />
<span class=" text-white">EgalWare</span> *@
</div>
+1 -1
View File
@@ -8,7 +8,7 @@ namespace MP.MON.Client.Components
protected override void OnInitialized()
{
StartTimer();
Console.WriteLine($"OnInitialized Header completato");
Console.WriteLine($"Header | OnInitialized completato");
}
@@ -1,44 +0,0 @@
@using MP.Core.Conf
@using MP.Core.DTO;
@if (useNewDisplay)
{
<DetailViewMSE CurrRecord="@currRecord" currTagConf="@currTagConf" currTagVal="@currTagVal" doAnimate="@doAnimate" keepAliveMin="@keepAliveMin" showArt="@showArt" doBlink="@doBlink" maxChar4Scroll="@maxChar4Scroll" @rendermode="InteractiveServer"></DetailViewMSE>
}
else
{
<DetailMSE CurrRecord="@currRecord" currTagConf="@currTagConf" currTagVal="@currTagVal" doAnimate="@doAnimate" keepAliveMin="@keepAliveMin" showArt="@showArt" doBlink="@doBlink" maxChar4Scroll="@maxChar4Scroll" cssOverlayOff="@cssOverlayOff" @rendermode="InteractiveServer"></DetailMSE>
}
@code {
[Parameter]
public MappaStatoExplDTO? currRecord { get; set; } = null;
[Parameter]
public List<TagData>? currTagConf { get; set; } = null;
[Parameter]
public Dictionary<string, string> currTagVal { get; set; } = new Dictionary<string, string>();
[Parameter]
public bool doAnimate { get; set; } = true;
[Parameter]
public bool doBlink { get; set; } = false;
[Parameter]
public int keepAliveMin { get; set; } = 5;
[Parameter]
public int maxChar4Scroll { get; set; } = 20;
[Parameter]
public string showArt { get; set; } = "";
[Parameter]
public bool useNewDisplay { get; set; } = true;
[Parameter]
public string cssOverlayOff { get; set; } = "";
}
+12 -7
View File
@@ -1,16 +1,17 @@
(() => {
const maximumRetryCount = 3600;
const retryIntervalMilliseconds = 1000;
const reconnectModal = document.getElementById('reconnect-modal');
const maximumRetryCount = 1800;
const retryIntervalMilliseconds = 2000;
const rectModalBox = document.getElementById('reconnect-modal');
const recModal = document.getElementById('reconnect-modal-text');
const startReconnectionProcess = () => {
reconnectModal.style.display = 'block';
rectModalBox.style.display = 'block';
let isCanceled = false;
(async () => {
for (let i = 0; i < maximumRetryCount; i++) {
reconnectModal.innerText = `Attempting to reconnect: ${i + 1} of ${maximumRetryCount}`;
recModal.innerText = `Tentativo riconnessione: ${i + 1} / ${maximumRetryCount}`;
await new Promise(resolve => setTimeout(resolve, retryIntervalMilliseconds));
@@ -40,7 +41,7 @@
return {
cancel: () => {
isCanceled = true;
reconnectModal.style.display = 'none';
rectModalBox.style.display = 'none';
},
};
};
@@ -50,10 +51,14 @@
Blazor.start({
circuit: {
reconnectionHandler: {
onConnectionDown: () => currentReconnectionProcess ??= startReconnectionProcess(),
onConnectionDown: () => {
currentReconnectionProcess ??= startReconnectionProcess();
console.log("Connection Lost!");
},
onConnectionUp: () => {
currentReconnectionProcess?.cancel();
currentReconnectionProcess = null;
console.log("Connection restored!");
}
}
}
+12 -16
View File
@@ -16,26 +16,22 @@
<body>
<Routes />
<div class="reconnect-modal"></div>
<div id="reconnect-modal">
<div id="reconnect-modal-box" class="pt-5 px-2 bg-dark bg-gradient border border-info border-5 shadow rounded rounded-3 opacity-95">
<div id="reconnect-modal-text" class="d-flex justify-content-around titolo text-white">Reconnecting...</div>
<div class="d-flex justify-content-around py-3">
<i class="fas fa-spinner fa-spin text-warning fs-1"></i>
</div>
<div class="d-flex justify-content-around small fs-2 text-primary">
mancanza di comunicazione con il server
</div>
</div>
</div>
<script src="lib/WindowSize.js"></script>
@* <script src="_framework/blazor.web.js"></script> *@
<script src="_framework/blazor.web.js" autostart="false"></script>
<script src="lib/boot.js"></script>
@* <script>
Blazor.start({
reconnectionOptions: {
maxRetries: 3600,
retryIntervalMilliseconds: 2000
},
}).then(() => {
Blazor.defaultReconnectionHandler._reconnectCallback = function (d) {
console.log("Client reconnected, waiting 3 sec and reload!");
setTimeout(function () {
document.location.reload();
}, 3000);
}
});
</script> *@
</body>
</html>
-1
View File
@@ -40,7 +40,6 @@ else
if (currMse != null)
{
<div class="col p-0">
@* <DetailMapSelector CurrRecord="@currMse" currTagConf="@getIobTag(currMse.IdxMacchina)" currTagVal="@getTagVal(currMse.IdxMacchina)" doAnimate="@doAnimate" keepAliveMin="@keepAliveMin" showArt="@showArt" doBlink="@doBlink" maxChar4Scroll="@maxChar4Scroll" cssOverlayOff="@cssOverlayOff" useNewDisplay="@newDisplay" @rendermode="InteractiveServer"></DetailMapSelector> *@
@if (newDisplay)
{
<DetailViewMSE CurrRecord="@currMse" currTagConf="@getIobTag(currMse.IdxMacchina)" currTagVal="@getTagVal(currMse.IdxMacchina)" doAnimate="@doAnimate" keepAliveMin="@keepAliveMin" showArt="@showArt" doBlink="@doBlink" maxChar4Scroll="@maxChar4Scroll" scrollText="@scrollText" brightCss="@brightCss" titleMult="@titleMult" showTC="@showTC" @rendermode="InteractiveServer"></DetailViewMSE>
+1 -1
View File
@@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP.MON</RootNamespace>
<AssemblyName>$(AssemblyName.Replace(' ', '_'))</AssemblyName>
<Version>6.16.2503.2019</Version>
<Version>6.16.2503.2110</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 6.16.2503.2019</h4>
<h4>Versione: 6.16.2503.2110</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
6.16.2503.2019
6.16.2503.2110
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2503.2019</version>
<version>6.16.2503.2110</version>
<url>https://nexus.steamware.net/repository/SWS/MP-MON/stable/LAST/MP.MON.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-MON/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+34
View File
@@ -175,6 +175,9 @@ a,
.opacity-90 {
opacity: 0.9;
}
.opacity-95 {
opacity: 0.95;
}
/* MAIN: gestione layout dinamico mappa... */
.fontSmall {
font-size: 0.75rem;
@@ -345,6 +348,37 @@ a,
transform: translateX(-150%);
}
}
/* gestone reconnect modal*/
#reconnect-modal {
display: none;
/* Hidden by default */
position: fixed;
/* Stay in place */
z-index: 1;
/* Sit on top */
left: 0;
top: 0;
width: 100%;
/* Full width */
height: 100%;
/* Full height */
overflow: auto;
/* Enable scroll if needed */
background-color: #000000;
/* Fallback color */
background-color: rgba(0, 0, 0, 0.5);
/* Black w/ opacity */
}
#reconnect-modal-box {
position: fixed;
top: 20%;
left: 20%;
width: 60%;
height: 30%;
}
#reconnect-modal-box .titolo {
font-size: 4rem;
}
/* area semafori*/
.semBlinkVe,
.semFixVe,
+38 -1
View File
@@ -150,26 +150,34 @@ a, .btn-link {
.bright50 {
filter: brightness(50%);
}
.bright75 {
filter: brightness(75%);
}
.bright90 {
filter: brightness(90%);
}
.bright100 {
}
.bright110 {
filter: brightness(110%);
}
.bright125 {
filter: brightness(125%);
}
.bright150 {
filter: brightness(150%);
}
.bright175 {
filter: brightness(175%);
}
.bright200 {
filter: brightness(200%);
}
@@ -177,13 +185,19 @@ a, .btn-link {
.opacity-80 {
opacity: 0.8
}
.opacity-85 {
opacity: 0.85
}
.opacity-90 {
opacity: 0.9
}
.opacity-95 {
opacity: 0.95
}
/* MAIN: gestione layout dinamico mappa... */
.fontSmall {
font-size: 0.75rem;
@@ -387,8 +401,32 @@ a, .btn-link {
}
}
/* gestone reconnect modal*/
#reconnect-modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.5); /* Black w/ opacity */
}
#reconnect-modal-box {
position: fixed;
top: 20%;
left: 20%;
width: 60%;
height: 30%;
.titolo {
font-size: 4rem;
}
}
/* area semafori*/
.semBlinkVe,
.semFixVe,
@@ -545,7 +583,6 @@ a, .btn-link {
animation: blinkBack 2s ease infinite;
color: Yellow;
}
/* Gestione size caratteri */
.mainHead,
.logoImg {
+1 -1
View File
File diff suppressed because one or more lines are too long