Effettuata riscrittura metodi Dispose sui vari servizi e controller

This commit is contained in:
Samuele Locatelli
2025-07-24 10:43:47 +02:00
parent 6ff1da7c66
commit a4b580f4bd
103 changed files with 584 additions and 709 deletions
+45 -34
View File
@@ -222,45 +222,56 @@
</tr>
</thead>
<tbody>
@foreach (var item in ListDay)
@if (ListDay == null)
{
<tr>
<td>
@if (item.Imported == null)
{
<button class="btn btn-sm btn-primary" @onclick="() => DoEdit(item)"><i class="fa-solid fa-pen"></i></button>
}
else
{
<button class="btn btn-sm btn-secondary disabled"><i class="fa-solid fa-pen"></i></button>
}
</td>
<td>@item.IdxMacchina</td>
<td>@(EvDescript(item.IdxTipoEv))</td>
<td>
<div>@item.CodArticolo</div>
@if (!string.IsNullOrEmpty(item.KeyRichiesta))
{
<small>@item.KeyRichiesta</small>
}
</td>
<td title="@($"{item.InizioStato:yyyy.MM.dd HH:mm:ss} --> {item.FineStato:yyyy.MM.dd HH:mm:ss}")">@($"{item.InizioStato:HH:mm}")</td>
<td class="text-end">@item.PzBuoni</td>
<td class="text-end">@($"{item.TCiclo:f2}")</td>
<td class="text-end">@($"{item.MinProd:f2}")</td>
<td class="text-end">
@if (item.Imported == null)
{
<button class="btn btn-sm btn-danger" @onclick="() => DoDelete(item)"><i class="fa-solid fa-trash-can"></i></button>
}
else
{
<button class="btn btn-sm btn-secondary disabled"><i class="fa-solid fa-trash-can"></i></button>
}
<td colspan="9">
<div class="alert alert-info fs-6">Nessun dato disponibile</div>
</td>
</tr>
}
else
{
foreach (var item in ListDay)
{
<tr>
<td>
@if (item.Imported == null)
{
<button class="btn btn-sm btn-primary" @onclick="() => DoEdit(item)"><i class="fa-solid fa-pen"></i></button>
}
else
{
<button class="btn btn-sm btn-secondary disabled"><i class="fa-solid fa-pen"></i></button>
}
</td>
<td>@item.IdxMacchina</td>
<td>@(EvDescript(item.IdxTipoEv))</td>
<td>
<div>@item.CodArticolo</div>
@if (!string.IsNullOrEmpty(item.KeyRichiesta))
{
<small>@item.KeyRichiesta</small>
}
</td>
<td title="@($"{item.InizioStato:yyyy.MM.dd HH:mm:ss} --> {item.FineStato:yyyy.MM.dd HH:mm:ss}")">@($"{item.InizioStato:HH:mm}")</td>
<td class="text-end">@item.PzBuoni</td>
<td class="text-end">@($"{item.TCiclo:f2}")</td>
<td class="text-end">@($"{item.MinProd:f2}")</td>
<td class="text-end">
@if (item.Imported == null)
{
<button class="btn btn-sm btn-danger" @onclick="() => DoDelete(item)"><i class="fa-solid fa-trash-can"></i></button>
}
else
{
<button class="btn btn-sm btn-secondary disabled"><i class="fa-solid fa-trash-can"></i></button>
}
</td>
</tr>
}
}
</tbody>
</table>
</div>
+6 -2
View File
@@ -335,7 +335,7 @@ namespace MP_TAB3.Components
{
innerCircleVals.Add(new CircleGaugeMulti.CircSegm() { Color = "#CD1916", Value = datiProdAct.PzConfScarto });
}
if (CRecMSE.extraVal > 0)
if (CRecMSE != null && CRecMSE.extraVal > 0)
{
outerCircleVals.Add(new CircleGaugeMulti.CircSegm() { Color = "#1367FD", Value = CRecMSE.extraVal });
}
@@ -529,7 +529,11 @@ namespace MP_TAB3.Components
return true;
if (LastIdxMacchSub != IdxMacchSub)
return true;
if (!LastRecMSE.MostlyEquals(RecMSE))
if (LastRecMSE == null && RecMSE != null)
return true;
if (LastRecMSE != null && RecMSE == null)
return true;
if (LastRecMSE != null && !LastRecMSE.MostlyEquals(RecMSE))
return true;
return false;
+1 -1
View File
@@ -58,7 +58,7 @@
</td>
<td class="fs-4 fw-bold">@actOdl.CodArticolo</td>
<td class="fs-4 fw-bold text-end">@item.PezziConf</td>
<td class="fs-4 fw-bold text-end text-danger">@item.PezziScar</td>
<td class="fs-4 fw-bold text-end">@item.PezziScar</td>
@if (ShowRilav)
{
<td class="text-end">@item.PezziDaRilav</td>
@@ -80,20 +80,31 @@
</tr>
</thead>
<tbody>
@foreach (var record in ListTK)
@if (ListTK == null)
{
<tr>
<td>
@record.CodArtParent
</td>
<td>
@record.CodArtChild
</td>
<td class="text-end">
<div>@record.Qty</div>
<td colspan="3">
<div class="alert alert-info fs-6">Nessun dato disponibile</div>
</td>
</tr>
}
else
{
foreach (var record in ListTK)
{
<tr>
<td>
@record.CodArtParent
</td>
<td>
@record.CodArtChild
</td>
<td class="text-end">
<div>@record.Qty</div>
</td>
</tr>
}
}
</tbody>
</table>
}
+1 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<Version>6.16.2507.2319</Version>
<Version>6.16.2507.2410</Version>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP_TAB3</RootNamespace>
</PropertyGroup>
+13 -11
View File
@@ -127,9 +127,11 @@ namespace MP_TAB3.Pages
public void Dispose()
{
ListMSE = null;
TDFeeder.dataPipe.EA_NewMessage -= DataPipe_EA_NewMessage;
TDFeeder.blinkPipe.EA_NewMessage -= BlinkPipe_EA_NewMessage;
ListMSE = null;
ListMachineEnabled = null;
AllDataMSE = null;
GC.Collect();
}
@@ -316,20 +318,20 @@ namespace MP_TAB3.Pages
}
#endif
PubSubEventArgs currArgs = (PubSubEventArgs)e;
// conversione on-the-fly List<string> --> allarmi
if (!string.IsNullOrEmpty(currArgs.newMessage))
// conversione on-the-fly List<string> --> allarmi
if (!string.IsNullOrEmpty(currArgs.newMessage))
{
try
{
try
List<MappaStatoExplModel>? dataList = JsonConvert.DeserializeObject<List<MappaStatoExplModel>>(currArgs.newMessage);
if (dataList != null)
{
List<MappaStatoExplModel>? dataList = JsonConvert.DeserializeObject<List<MappaStatoExplModel>>(currArgs.newMessage);
if (dataList != null)
{
InvokeAsync(() => SaveData(dataList));
}
InvokeAsync(() => SaveData(dataList));
}
catch
{ }
}
catch
{ }
}
InvokeAsync(() =>
{
StateHasChanged();
-1
View File
@@ -35,7 +35,6 @@ builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddSingleton<TabDataFeeder>();
builder.Services.AddSingleton<StatusData>();
builder.Services.AddSingleton<ListSelectDataSrv>();
builder.Services.AddSingleton<OrderDataSrv>();
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 6.16.2507.2319</h4>
<h4>Versione: 6.16.2507.2410</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
6.16.2507.2319
6.16.2507.2410
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2507.2319</version>
<version>6.16.2507.2410</version>
<url>https://nexus.steamware.net/repository/SWS/MP-TAB3/stable/LAST/MP-TAB3.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-TAB3/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+1 -6
View File
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
+1 -8
View File
@@ -1,11 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MP.Core.DTO
namespace MP.Core.DTO
{
public class ManualStatusDTO
{
+1 -4
View File
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data;
using System.ComponentModel.DataAnnotations.Schema;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
+1 -6
View File
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
namespace MP.Core.DTO
{
+2 -2
View File
@@ -635,7 +635,7 @@ namespace MP.Data.Controllers
}
/// <summary>
/// Effettua salvataggio snapshot parametri (con stored) + svuota eventuale cache redis
/// Effettua salvataggio snapshot parametri (con stored) + svuota eventuale cache redisConn
/// </summary>
/// <param name="idxMacchina">macchina</param>
/// <param name="maxSec">Num massimo secondi per recuperare dati correnti</param>
@@ -658,7 +658,7 @@ namespace MP.Data.Controllers
}
/// <summary>
/// Effettua salvataggio snapshot parametri (con stored) + svuota eventuale cache redis
/// Effettua salvataggio snapshot parametri (con stored) + svuota eventuale cache redisConn
/// </summary>
/// <param name="idxMacchina">macchina</param>
/// <param name="dtMin">Data min x selezione</param>
-5
View File
@@ -1,11 +1,6 @@
using MP.Core.Objects;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MP.Data.DTO
{
-1
View File
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
+1 -3
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
// <Auto-Generated>
+1 -6
View File
@@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
#nullable disable
// <Auto-Generated>
+1 -3
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
+1 -6
View File
@@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MP.Data.DbModels
{
+1 -6
View File
@@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
-4
View File
@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
+1 -4
View File
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
// <Auto-Generated>
+1 -3
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
-4
View File
@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
+1 -3
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
+1 -6
View File
@@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MP.Data.DbModels
{
+1 -6
View File
@@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MP.Data.DbModels
{
+1 -3
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
-4
View File
@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
+1 -3
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
-1
View File
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
+1 -3
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
// <Auto-Generated>
-1
View File
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
-1
View File
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
-3
View File
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
+1 -4
View File
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
// <Auto-Generated>
+1 -4
View File
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
// <Auto-Generated>
@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
+1 -3
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace MP.Data.DbModels
-1
View File
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
namespace MP.Data.DbModels
+1 -3
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
+1 -3
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
+1 -3
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
+1 -4
View File
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
#nullable disable
-2
View File
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data;
#nullable disable
// <Auto-Generated>
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
-1
View File
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
-1
View File
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
-1
View File
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
-1
View File
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
-1
View File
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
-2
View File
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
// <Auto-Generated>
+1 -4
View File
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
#nullable disable
// <Auto-Generated>
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
-1
View File
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
-1
View File
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
+1 -4
View File
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
+1 -3
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
+1 -3
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
-2
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
+1 -3
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
+1 -4
View File
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
-4
View File
@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
+1 -4
View File
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
#nullable disable
-1
View File
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
-1
View File
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
-1
View File
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
-2
View File
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using static MP.Core.Objects.Enums;
#nullable disable
// <Auto-Generated>
-3
View File
@@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using MP.Core.Objects;
using static MP.Core.Objects.Enums;
using static MP.TaskMan.Objects.Enums;
#nullable disable
+1 -6
View File
@@ -1,9 +1,4 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using static MP.Core.Objects.Enums;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
// <Auto-Generated>
+1 -3
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace MP.Data.DbModels
+1 -7
View File
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
+1 -3
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations.Schema;
namespace MP.Data.DbModels
{
+1 -3
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations.Schema;
namespace MP.Data.DbModels
{
+1 -3
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
-1
View File
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
+1 -3
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
// <Auto-Generated>
-4
View File
@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
+1 -4
View File
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
#nullable disable
// <Auto-Generated>
+1 -7
View File
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
namespace MP.Data.DbModels
{
-2
View File
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
// <Auto-Generated>
+36 -14
View File
@@ -3,18 +3,21 @@ using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Channels;
namespace MP.Data
{
public class MessagePipe
public class MessagePipe : IDisposable
{
#region Public Constructors
public MessagePipe(IConnectionMultiplexer redisConn, string channelName, bool enableLog = false)
{
_channel = channelName;
redis = redisConn;
redisDb = redis.GetDatabase();
rChannel = new RedisChannel(_channel, RedisChannel.PatternMode.Literal);
this.redisConn = redisConn;
redisDb = this.redisConn.GetDatabase();
redisSub = this.redisConn.GetSubscriber();
this.enableLog = enableLog;
// aggiungo sottoscrittore
setupSubscriber();
@@ -30,6 +33,12 @@ namespace MP.Data
#region Public Methods
public void Dispose()
{
redisDb = null;
redisSub = null;
}
/// <summary>
/// Invio messaggio sul canale + salvataggio in cache REDIS
/// </summary>
@@ -74,8 +83,15 @@ namespace MP.Data
public bool sendMessage(string newMess)
{
bool answ = false;
if (!string.IsNullOrEmpty(_channel))
{
#if false
ISubscriber sub = redis.GetSubscriber();
sub.Publish(_channel, newMess);
#endif
var numCli = redisSub.Publish(rChannel, newMess);
answ = numCli > 0;
}
return answ;
}
@@ -89,29 +105,35 @@ namespace MP.Data
#region Private Fields
/// <summary>
/// Nome Canale associato al gestore pipeline messaggi
/// </summary>
private string _channel = "";
private bool enableLog = false;
private Dictionary<string, int> numSent = new Dictionary<string, int>();
private IConnectionMultiplexer redis;
private IDatabase redisDb;
#endregion Private Fields
#region Private Properties
/// <summary>
/// Canale associato al gestore pipeline messaggi
/// Channel di comunicazione REDIS
/// </summary>
private string _channel { get; set; } = "";
private RedisChannel rChannel;
#endregion Private Properties
private IConnectionMultiplexer redisConn;
private IDatabase redisDb;
private ISubscriber redisSub;
#endregion Private Fields
#region Private Methods
private void setupSubscriber()
{
ISubscriber sub = redis.GetSubscriber();
//Subscribe to the channel named messages
#if false
// Subscribe to the channel named messages
ISubscriber sub = redisConn.GetSubscriber();
sub.Subscribe(_channel, (channel, message) =>
#endif
redisSub.Subscribe(rChannel, (channel, message) =>
{
if (enableLog)
{
+31 -9
View File
@@ -16,16 +16,38 @@ namespace MP.Data.Services
/// <summary>
/// Classe di partenza x costruzione servizi di accesso dati + cache
/// </summary>
public class BaseServ
public class BaseServ:IDisposable
{
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
private bool _disposed = false;
protected virtual void Dispose(bool disposing)
{
if (!_disposed)
{
if (disposing)
{
// Free managed resources here
redisDb = null;
}
// Free unmanaged resources here
_disposed = true;
}
}
#region Public Constructors
public BaseServ(IConfiguration configuration)
public BaseServ(IConfiguration configuration, IConnectionMultiplexer redConn)
{
_configuration = configuration;
// setup compoenti REDIS
redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis"));
// setup componenti REDIS
this.redisConn = redConn;
redisDb = redisConn.GetDatabase();
// json serializer... FIX errore loop circolare https://www.ryadel.com/en/jsonserializationexception-self-referencing-loop-detected-error-fix-entity-framework-asp-net-core/
@@ -53,7 +75,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
IOB_data? result = new IOB_data();
// cerco in redis...
// cerco in redisConn...
string currKey = RedHashMpIO($"hM2IOB:{IdxMacchina}");
RedisValue rawData = redisDb.StringGet(currKey);
//if (!string.IsNullOrEmpty($"{rawData}"))
@@ -89,7 +111,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
Dictionary<string, string> result = new Dictionary<string, string>();
// cerco in redis...
// cerco in redisConn...
string currKey = RedHashMpIO($"IOB:{IdxMacchina}:MachIobConf");
try
{
@@ -123,7 +145,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
string result = "";
// cerco in redis...
// cerco in redisConn...
string currKey = RedHashMpIO($"IOB:{IdxMacchina}:ConfYaml");
try
{
@@ -155,9 +177,9 @@ namespace MP.Data.Services
/// <summary>
/// Oggetto per connessione a REDIS
/// </summary>
protected ConnectionMultiplexer redisConn = null!;
protected IConnectionMultiplexer redisConn = null!;
//ISubscriber sub = redis.GetSubscriber();
//ISubscriber sub = redisConn.GetSubscriber();
/// <summary>
/// Oggetto DB redis da impiegare x chiamate R/W
/// </summary>
+6 -1
View File
@@ -9,10 +9,15 @@ namespace MP.Data.Services
/// <summary>
/// Gestore statistiche esecuzione processi x analisi timing
/// </summary>
public class ExecStatsCollector
public class ExecStatsCollector : IDisposable
{
#region Public Methods
public void Dispose()
{
TrackData.Clear();
}
/// <summary>
/// restituisce una stringa da poter emettere in log con il summary degli eventi tracciati ed eventuale reset...
/// </summary>
+30 -6
View File
@@ -9,6 +9,7 @@ using NLog;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Linq;
using System.Text;
@@ -20,7 +21,7 @@ namespace MP.Data.Services
{
#region Public Constructors
public LandDataService(IConfiguration configuration) : base(configuration)
public LandDataService(IConfiguration configuration, IConnectionMultiplexer redConn) : base(configuration, redConn)
{
// conf DB
string connStr = _configuration.GetConnectionString("MP.Land");
@@ -41,7 +42,7 @@ namespace MP.Data.Services
#region Public Properties
public static Controllers.MpLandController dbController { get; set; } = null!;
public static MpLandController dbController { get; set; } = null!;
#endregion Public Properties
@@ -58,7 +59,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<DbSizeModel> result = new List<DbSizeModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:DbInfo:ALL";
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -122,7 +123,7 @@ namespace MP.Data.Services
//ordino x idxmacchina...
dbResult = dbResult.OrderBy(x => x.IdxMacchina).ToList();
// serializzo in cache redis
// serializzo in cache redisConn
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
redisDb.StringSet(currKey, rawData, UltraLongCache);
}
@@ -146,7 +147,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<RemoteRebootLogModel> result = new List<RemoteRebootLogModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:RemRebLog:ALL";
RedisValue rawData = redisDb.StringGet(currKey);
//if (!string.IsNullOrEmpty($"{rawData}"))
@@ -182,7 +183,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<RemoteRebootLogModel> result = new List<RemoteRebootLogModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:RemRebLog:LAST";
RedisValue rawData = redisDb.StringGet(currKey);
//if (!string.IsNullOrEmpty($"{rawData}"))
@@ -209,9 +210,32 @@ namespace MP.Data.Services
#endregion Public Methods
#region Protected Methods
protected override void Dispose(bool disposing)
{
if (!_disposed)
{
if (disposing)
{
// Free managed resources here
dbController.Dispose();
}
// Free unmanaged resources here
_disposed = true;
}
// Call base class implementation.
base.Dispose(disposing);
}
#endregion Protected Methods
#region Private Fields
private static Logger Log = LogManager.GetCurrentClassLogger();
private bool _disposed = false;
private string redisBaseKey = "MP:LAND:Cache";
#endregion Private Fields
+29 -38
View File
@@ -6,6 +6,7 @@ using NLog;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Diagnostics;
using System.IO;
@@ -18,19 +19,12 @@ namespace MP.Data.Services
/// <summary>
/// Classe accesso dati filtrati per operatore
/// </summary>
public class ListSelectDataSrv : BaseServ, IDisposable
public class ListSelectDataSrv : BaseServ
{
#region Public Constructors
public ListSelectDataSrv(IConfiguration configuration) : base(configuration)
public ListSelectDataSrv(IConfiguration configuration, IConnectionMultiplexer redConn) : base(configuration, redConn)
{
#if false
_configuration = configuration;
// setup compoenti REDIS
redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis"));
redisDb = redisConn.GetDatabase();
#endif
// conf DB
string connStr = _configuration.GetConnectionString("MP.All");
if (string.IsNullOrEmpty(connStr))
@@ -69,7 +63,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<AnagArticoliModel>? result = new List<AnagArticoliModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:Art:{azienda}:{searchVal}:{numRecord}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
@@ -81,7 +75,7 @@ namespace MP.Data.Services
{
result = dbController.ArticoliGetSearch(numRecord, azienda, searchVal);
#if false
result = await Task.FromResult(dbController.ArticoliGetSearch(numRecord, azienda, searchVal));
result = await Task.FromResult(dbController.ArticoliGetSearch(numRecord, azienda, searchVal));
#endif
// serializzp e salvo...
rawData = JsonConvert.SerializeObject(result);
@@ -106,7 +100,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<ConfigModel>? result = new List<ConfigModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:Conf";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
@@ -130,15 +124,6 @@ namespace MP.Data.Services
return result;
}
public void Dispose()
{
// Clear database controller
dbController.Dispose();
// redis dispose
redisConn = null;
redisDb = null;
}
/// <summary>
/// Pulizia cache Redis (tutta)
/// </summary>
@@ -171,7 +156,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<LinkMenuModel>? result = new List<LinkMenuModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:Menu:ALL";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
@@ -206,7 +191,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<LinkMenuModel>? result = new List<LinkMenuModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:Menu:{tipoLink}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
//if (!string.IsNullOrEmpty($"{rawData}"))
@@ -242,7 +227,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<MacchineModel>? result = new List<MacchineModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:Macc:{MatrOpr}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
//if (!string.IsNullOrEmpty($"{rawData}"))
@@ -269,26 +254,32 @@ namespace MP.Data.Services
#endregion Public Methods
#region Protected Fields
#region Protected Methods
#if false
/// <summary>
/// Oggetto per connessione a REDIS
/// </summary>
protected ConnectionMultiplexer redisConn = null!;
protected override void Dispose(bool disposing)
{
if (!_disposed)
{
if (disposing)
{
// Free managed resources here
dbController.Dispose();
}
/// <summary>
/// Oggetto DB redis da impiegare x chiamate R/W
/// </summary>
protected IDatabase redisDb = null!;
#endif
// Free unmanaged resources here
_disposed = true;
}
#endregion Protected Fields
// Call base class implementation.
base.Dispose(disposing);
}
#endregion Protected Methods
#region Private Fields
private static Logger Log = LogManager.GetCurrentClassLogger();
private bool _disposed = false;
private string redisBaseKey = "MP:ALL:Cache";
#endregion Private Fields
@@ -296,7 +287,7 @@ namespace MP.Data.Services
#region Private Methods
/// <summary>
/// Esegue flush memoria redis dato pattern
/// Esegue flush memoria redisConn dato pattern
/// </summary>
/// <param name="pattern"></param>
/// <returns></returns>
+9 -8
View File
@@ -32,7 +32,7 @@ namespace MP.Data.Services
#region Public Constructors
public MessageService(IConfiguration configuration, ILocalStorageService genLocalStorage, ISessionStorageService sessStore, TabDataService tdService, SharedMemService smServ)
public MessageService(IConfiguration configuration, IConnectionMultiplexer redConn, ILocalStorageService genLocalStorage, ISessionStorageService sessStore, TabDataService tdService, SharedMemService smServ)
{
_configuration = configuration;
@@ -42,8 +42,8 @@ namespace MP.Data.Services
TDService = tdService;
SMService = smServ;
// setup compoenti REDIS
redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis"));
// setup componenti REDIS
this.redisConn = redConn;
redisDb = redisConn.GetDatabase();
}
@@ -296,9 +296,10 @@ namespace MP.Data.Services
public void Dispose()
{
// redis dispose
redisConn = null;
redisDb = null;
_rigaOper = null;
userListMachine.Clear();
UserPrefs.Clear();
}
public async Task<bool> DoLogIn(string decodValue, bool saveOpr)
@@ -663,10 +664,10 @@ namespace MP.Data.Services
/// <summary>
/// Oggetto per connessione a REDIS
/// </summary>
protected ConnectionMultiplexer redisConn = null!;
protected IConnectionMultiplexer redisConn = null!;
/// <summary>
/// Oggetto DB redis da impiegare x chiamate R/W
/// Oggetto DB redisConn da impiegare x chiamate R/W
/// </summary>
protected IDatabase redisDb = null!;
@@ -723,7 +724,7 @@ namespace MP.Data.Services
}
/// <summary>
/// Recupero HashSet redis come Dictionary
/// Recupero HashSet redisConn come Dictionary
/// </summary>
/// <param name="currKey"></param>
/// <param name="dict"></param>
+34 -14
View File
@@ -7,11 +7,11 @@ using System.Threading.Tasks;
namespace MP.Data.Services
{
public class MonDataFeeder : StatusData, IDisposable
public class MonDataFeeder : StatusData
{
#region Public Constructors
public MonDataFeeder(IConfiguration configuration) : base(configuration)
public MonDataFeeder(IConfiguration configuration, IConnectionMultiplexer redConn) : base(configuration, redConn)
{
// setup canali pub/sub
dataPipe = new MessagePipe(redisConn, Constants.MON_ACT_MSE_DATA_KEY);
@@ -33,12 +33,6 @@ namespace MP.Data.Services
#region Public Methods
public new void Dispose()
{
base.Dispose();
stopTimers();
}
/// <summary>
/// Impostazione forzata timer refresh
/// </summary>
@@ -62,20 +56,46 @@ namespace MP.Data.Services
public void stopTimers()
{
// stop timers
fastTimer.Elapsed -= ElapsedFastTimer;
fastTimer.Enabled = false;
fastTimer.Stop();
fastTimer.Dispose();
if (fastTimer != null)
{
fastTimer.Elapsed -= ElapsedFastTimer;
fastTimer.Enabled = false;
fastTimer.Stop();
fastTimer.Dispose();
}
}
#endregion Public Methods
#region Protected Methods
protected override void Dispose(bool disposing)
{
if (!_disposed)
{
if (disposing)
{
// Free managed resources here
stopTimers();
dataPipe = null;
blinkPipe = null;
}
// Free unmanaged resources here
_disposed = true;
}
// Call base class implementation.
base.Dispose(disposing);
}
#endregion Protected Methods
#region Private Fields
private static System.Timers.Timer fastTimer = new System.Timers.Timer(4000);
private static Logger Log = LogManager.GetCurrentClassLogger();
private bool _disposed = false;
private int fastRefreshMs = 1000;
#endregion Private Fields
+24 -31
View File
@@ -6,6 +6,7 @@ using NLog;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Diagnostics;
using System.IO;
@@ -18,20 +19,12 @@ namespace MP.Data.Services
/// <summary>
/// Classe accesso dati ordini
/// </summary>
public class OrderDataSrv : BaseServ, IDisposable
public class OrderDataSrv : BaseServ
{
#region Public Constructors
public OrderDataSrv(IConfiguration configuration): base(configuration)
public OrderDataSrv(IConfiguration configuration, IConnectionMultiplexer redConn) : base(configuration, redConn)
{
#if false
_configuration = configuration;
// setup compoenti REDIS
redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis"));
redisDb = redisConn.GetDatabase();
#endif
// conf DB
string connStr = _configuration.GetConnectionString("MP.All");
if (string.IsNullOrEmpty(connStr))
@@ -67,7 +60,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<ConfigModel>? result = new List<ConfigModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:Conf";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
//if (!string.IsNullOrEmpty($"{rawData}"))
@@ -92,15 +85,6 @@ namespace MP.Data.Services
return result;
}
public void Dispose()
{
// Clear database controller
dbController.Dispose();
// redis dispose
redisConn = null;
redisDb = null;
}
/// <summary>
/// Elenco ODL filtrati x articolo e macchina
/// </summary>
@@ -119,7 +103,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<ODLExpModel>? result = new List<ODLExpModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:ODL:{IdxMacchina}:{CodArt}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
//if (!string.IsNullOrEmpty($"{rawData}"))
@@ -146,23 +130,32 @@ namespace MP.Data.Services
#endregion Public Methods
#region Protected Fields
#region Protected Methods
/// <summary>
/// Oggetto per connessione a REDIS
/// </summary>
protected ConnectionMultiplexer redisConn = null!;
protected override void Dispose(bool disposing)
{
if (!_disposed)
{
if (disposing)
{
// Free managed resources here
dbController.Dispose();
}
/// <summary>
/// Oggetto DB redis da impiegare x chiamate R/W
/// </summary>
protected IDatabase redisDb = null!;
// Free unmanaged resources here
_disposed = true;
}
#endregion Protected Fields
// Call base class implementation.
base.Dispose(disposing);
}
#endregion Protected Methods
#region Private Fields
private static Logger Log = LogManager.GetCurrentClassLogger();
private bool _disposed = false;
private string redisBaseKey = "MP:ALL:Cache";
#endregion Private Fields
+62 -23
View File
@@ -9,24 +9,17 @@ namespace MP.Data.Services
{
public class SharedMemService : BaseServ
{
#region Public Constructors
/// <summary>
/// Init servizio TAB
/// </summary>
/// <param name="configuration"></param>
public SharedMemService(IConfiguration configuration) : base(configuration)
public SharedMemService(IConfiguration configuration, IConnectionMultiplexer redConn) : base(configuration, redConn)
{
}
#region Private Fields
private static Logger Log = LogManager.GetCurrentClassLogger();
/// <summary>
/// Oggetto vocabolario x uso continuo traduzione
/// </summary>
private List<VocabolarioModel> ObjVocabolario = new List<VocabolarioModel>();
#endregion Private Fields
#endregion Public Constructors
#region Public Properties
@@ -60,16 +53,16 @@ namespace MP.Data.Services
/// </summary>
public Dictionary<string, string> DictMacchine { get; set; } = new Dictionary<string, string>();
/// <summary>
/// Dizionario macchine con info multi(int)
/// </summary>
public Dictionary<string, int> DictMacchMulti { get; set; } = new Dictionary<string, int>();
/// <summary>
/// Dizionario macchine con info manual(bool)
/// </summary>
public Dictionary<string, bool> DictMacchManual { get; set; } = new Dictionary<string, bool>();
/// <summary>
/// Dizionario macchine con info multi(int)
/// </summary>
public Dictionary<string, int> DictMacchMulti { get; set; } = new Dictionary<string, int>();
/// <summary>
/// Dizionario Menu
/// </summary>
@@ -106,7 +99,7 @@ namespace MP.Data.Services
public List<AnagStatiModel> ListStati { get; set; } = new List<AnagStatiModel>();
/// <summary>
/// Lista completa stati
/// Lista completa lemmi e traduzioni vocabolario
/// </summary>
public List<VocabolarioModel> ListVocab { get; set; } = new List<VocabolarioModel>();
@@ -117,12 +110,6 @@ namespace MP.Data.Services
#endregion Public Properties
#region Private Properties
private List<LinkMenuModel> AllMenuData { get; set; } = new List<LinkMenuModel>();
#endregion Private Properties
#region Public Methods
/// <summary>
@@ -130,6 +117,7 @@ namespace MP.Data.Services
/// </summary>
public void ClearCache()
{
#if false
DictMacchine = new Dictionary<string, string>();
DictMacchMulti = new Dictionary<string, int>();
DictMenu = new Dictionary<string, List<LinkMenuModel>>();
@@ -138,6 +126,22 @@ namespace MP.Data.Services
DictEventi = new Dictionary<int, AnagEventiModel>();
DictStati = new Dictionary<int, AnagStatiModel>();
DictVocab = new Dictionary<string, string>();
#endif
AllMenuData.Clear();
DbConfig.Clear();
DictConfig.Clear();
DictEventi.Clear();
DictMacchine.Clear();
DictMacchManual.Clear();
DictMacchMulti.Clear();
DictMenu.Clear();
DictStati.Clear();
DictVocab.Clear();
ListEventi.Clear();
ListM2S.Clear();
ListMSFD.Clear();
ListStati.Clear();
ListVocab.Clear();
Log.Info("SharedMemService | Cache resetted!");
}
@@ -321,5 +325,40 @@ namespace MP.Data.Services
}
#endregion Public Methods
#region Protected Methods
protected override void Dispose(bool disposing)
{
if (!_disposed)
{
if (disposing)
{
// Free managed resources here
ClearCache();
}
// Free unmanaged resources here
_disposed = true;
}
// Call base class implementation.
base.Dispose(disposing);
}
#endregion Protected Methods
#region Private Fields
private static Logger Log = LogManager.GetCurrentClassLogger();
private bool _disposed = false;
#endregion Private Fields
#region Private Properties
private List<LinkMenuModel> AllMenuData { get; set; } = new List<LinkMenuModel>();
#endregion Private Properties
}
}
+40 -18
View File
@@ -20,12 +20,12 @@ namespace MP.Data.Services
{
#region Public Constructors
public StatusData(IConfiguration configuration)
public StatusData(IConfiguration configuration, IConnectionMultiplexer redConn)
{
_configuration = configuration;
// setup compoenti REDIS
redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis"));
// setup componenti REDIS
this.redisConn = redConn;
redisDb = redisConn.GetDatabase();
// conf DB
@@ -36,7 +36,7 @@ namespace MP.Data.Services
}
else
{
dbController = new Controllers.MpMonController(configuration);
dbController = new MpMonController(configuration);
StringBuilder sb = new StringBuilder();
sb.AppendLine($"StatusData | MpMonController OK");
Log.Info(sb.ToString());
@@ -64,7 +64,7 @@ namespace MP.Data.Services
#region Public Properties
public static Controllers.MpMonController dbController { get; set; } = null!;
public static MpMonController dbController { get; set; } = null!;
/// <summary>
/// Dizionario dei tag configurati per IOB
@@ -85,7 +85,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<ConfigModel>? result = new List<ConfigModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:Conf";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
//if (!string.IsNullOrEmpty($"{rawData}"))
@@ -112,11 +112,8 @@ namespace MP.Data.Services
public void Dispose()
{
// Clear database controller
dbController.Dispose();
// redis dispose
redisConn = null;
redisDb = null;
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
@@ -173,7 +170,7 @@ namespace MP.Data.Services
string source = "DB";
sw.Start();
List<MacchineModel>? result = new List<MacchineModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{Constants.redisMacchine}:ALL";
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -204,7 +201,7 @@ namespace MP.Data.Services
string source = "DB";
sw.Start();
List<MacchineModel>? result = new List<MacchineModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{Constants.redisMacchine}:{CodGruppo}";
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -323,7 +320,7 @@ namespace MP.Data.Services
string source = "DB";
sw.Start();
List<MappaStatoExplModel>? result = new List<MappaStatoExplModel>();
// cerco in redis...
// cerco in redisConn...
RedisValue rawData = redisDb.StringGet(Constants.redisMseKey);
if (rawData.HasValue && !forceDb)
{
@@ -353,9 +350,8 @@ namespace MP.Data.Services
/// <summary>
/// Oggetto per connessione a REDIS
/// </summary>
protected ConnectionMultiplexer redisConn = null!;
protected IConnectionMultiplexer redisConn = null!;
//ISubscriber sub = redis.GetSubscriber();
/// <summary>
/// Oggetto DB redis da impiegare x chiamate R/W
/// </summary>
@@ -363,10 +359,36 @@ namespace MP.Data.Services
#endregion Protected Fields
#region Protected Methods
protected virtual void Dispose(bool disposing)
{
if (!_disposed)
{
if (disposing)
{
// Free managed resources here
currTagConf.Clear();
MachineNumPz.Clear();
MachineProdStatus.Clear();
// REDIS dispose
redisDb = null;
// Clear database controller
dbController.Dispose();
}
// Free unmanaged resources here
_disposed = true;
}
}
#endregion Protected Methods
#region Private Fields
private static IConfiguration _configuration = null!;
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
private static Logger Log = LogManager.GetCurrentClassLogger();
private bool _disposed = false;
/// <summary>
/// Cache breve durata
@@ -398,7 +420,7 @@ namespace MP.Data.Services
#region Private Methods
/// <summary>
/// Esegue flush memoria redis dato pattern
/// Esegue flush memoria redisConn dato pattern
/// </summary>
/// <param name="pattern"></param>
/// <returns></returns>
+27 -10
View File
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace MP.Data.Services
{
public class TabDataFeeder : StatusData, IDisposable
public class TabDataFeeder : StatusData
{
#region Private Fields
@@ -21,12 +21,11 @@ namespace MP.Data.Services
#region Public Constructors
public TabDataFeeder(IConfiguration configuration) : base(configuration)
public TabDataFeeder(IConfiguration configuration, IConnectionMultiplexer redConn) : base(configuration, redConn)
{
// setup canali pub/sub
dataPipe = new MessagePipe(redisConn, Constants.TAB_ACT_MSE_DATA_KEY, false);
blinkPipe = new MessagePipe(redisConn, Constants.TAB_ACT_BLINK_KEY, false);
// avvio timers...
startTimers();
}
@@ -43,10 +42,25 @@ namespace MP.Data.Services
#region Public Methods
public new void Dispose()
private bool _disposed = false;
protected override void Dispose(bool disposing)
{
base.Dispose();
stopTimers();
if (!_disposed)
{
if (disposing)
{
// Free managed resources here
stopTimers();
dataPipe = null;
blinkPipe = null;
}
// Free unmanaged resources here
_disposed = true;
}
// Call base class implementation.
base.Dispose(disposing);
}
/// <summary>
@@ -72,10 +86,13 @@ namespace MP.Data.Services
public void stopTimers()
{
// stop timers
fastTimer.Elapsed -= ElapsedFastTimer;
fastTimer.Enabled = false;
fastTimer.Stop();
fastTimer.Dispose();
if (fastTimer != null)
{
fastTimer.Elapsed -= ElapsedFastTimer;
fastTimer.Enabled = false;
fastTimer.Stop();
fastTimer.Dispose();
}
}
#endregion Public Methods
+88 -196
View File
@@ -9,6 +9,7 @@ using NLog;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Diagnostics;
using System.Globalization;
@@ -18,7 +19,7 @@ using System.Threading.Tasks;
namespace MP.Data.Services
{
public class TabDataService : BaseServ, IDisposable
public class TabDataService : BaseServ
{
#region Public Constructors
@@ -26,14 +27,10 @@ namespace MP.Data.Services
/// Init servizio TAB
/// </summary>
/// <param name="configuration"></param>
public TabDataService(IConfiguration configuration) : base(configuration)
public TabDataService(IConfiguration configuration, IConnectionMultiplexer redConn) : base(configuration, redConn)
{
_configuration = configuration;
// setup compoenti REDIS
redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis"));
redisDb = redisConn.GetDatabase();
// conf DB
ConnStr = _configuration.GetConnectionString("MP.All");
if (string.IsNullOrEmpty(ConnStr))
@@ -171,7 +168,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<AlarmLogModel>? result = new List<AlarmLogModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:AlarmLog:{idxMacchina}:{dtFrom:yyyyMMdd-HHmmss}:{dtTo::yyyyMMdd-HHmmss}:{showMulti}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
@@ -231,7 +228,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<AnagEventiModel>? result = new List<AnagEventiModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:AnagEventi:ALL";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
@@ -265,7 +262,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<vSelEventiBCodeModel>? result = new List<vSelEventiBCodeModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:VSEB:{IdxMacch}";
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -300,7 +297,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<AnagTagsModel>? result = new List<AnagTagsModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:AnagTags";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
@@ -337,7 +334,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<AnagStatiModel>? result = new List<AnagStatiModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:AnagStati";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
//if (!string.IsNullOrEmpty($"{rawData}"))
@@ -376,7 +373,7 @@ namespace MP.Data.Services
string readType = "DB";
string sKey = string.IsNullOrEmpty(tipo) ? "ALL" : tipo;
string currKey = $"{Utils.redisArtList}:{azienda}:Tipo:{sKey}";
// cerco in redis dato valore sel idxMaccSel...
// cerco in redisConn dato valore sel idxMaccSel...
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
{
@@ -414,7 +411,7 @@ namespace MP.Data.Services
sw.Start();
List<CommentiModel> result = new List<CommentiModel>();
DateTime adesso = DateTime.Now;
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:Commenti:{idxMacchina}:{adesso:yyMMdd-HHmm}:{numDays}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
//if (!string.IsNullOrEmpty($"{rawData}"))
@@ -488,7 +485,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<ConfigModel>? result = new List<ConfigModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:Conf";
RedisValue rawData = redisDb.StringGet(currKey);
//if (!string.IsNullOrEmpty($"{rawData}"))
@@ -656,15 +653,28 @@ namespace MP.Data.Services
return SteamCrypto.DecryptString(encData, Constants.passPhrase);
}
public void Dispose()
private bool _disposed = false;
protected override void Dispose(bool disposing)
{
// Clear database controller
dbTabController.Dispose();
dbIocController.Dispose();
dbInveController.Dispose();
// redis dispose
redisConn = null;
redisDb = null;
if (!_disposed)
{
if (disposing)
{
// Free managed resources here
dbTabController.Dispose();
dbIocController.Dispose();
dbInveController.Dispose();
CurrConfig.Clear();
connStrParams.Clear();
esCollect.Dispose();
}
// Free unmanaged resources here
_disposed = true;
}
// Call base class implementation.
base.Dispose(disposing);
}
/// <summary>
@@ -700,7 +710,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<AnagOperatoriModel>? result = new List<AnagOperatoriModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:ElencoOpr";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
@@ -770,7 +780,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<EventListModel> result = new List<EventListModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:EvList:Last:{idxMacchina}:{idxTipo}:{dtLimit:yyyyMMdd-HHmm}:{maxRec}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
//if (!string.IsNullOrEmpty($"{rawData}"))
@@ -851,7 +861,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<FermiNonQualModel> result = new List<FermiNonQualModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:FNQ:{idxMacchina}:{gg}:{durataMin:N0}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
@@ -1054,7 +1064,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<InsManualiModel>? result = new List<InsManualiModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:InsMan:{idxMacchina}:{dtFrom:yyyyMMdd-HHmmss}:{dtTo::yyyyMMdd-HHmmss}";
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -1236,44 +1246,6 @@ namespace MP.Data.Services
return fatto;
}
#if false
/// <summary>
/// Recupero info IOB x TAB (da info registrate IOB-WIN--&gt; MP-IO)
/// </summary>
/// <param name="IdxMacchina"></param>
/// <returns></returns>
public IOB_data IobInfo(string IdxMacchina)
{
string source = "DB";
Stopwatch sw = new Stopwatch();
sw.Start();
IOB_data? result = new IOB_data();
// cerco in redis...
string currKey = RedHashMpIO($"hM2IOB:{IdxMacchina}");
RedisValue rawData = redisDb.StringGet(currKey);
//if (!string.IsNullOrEmpty($"{rawData}"))
if (rawData.HasValue)
{
result = JsonConvert.DeserializeObject<IOB_data>($"{rawData}");
source = "REDIS";
}
else
{
Log.Error($"Errore: non trovato valore <IOB_data> valido in REDIS | key: {currKey}");
Log.Info($"REDIS | conf: {redisConn.Configuration}");
Log.Info($" --> Valore trovato:{Environment.NewLine}{rawData}");
}
if (result == null)
{
result = new IOB_data();
Log.Debug($"Init valore default <IOB_data> | IdxMacchina: {IdxMacchina}");
}
sw.Stop();
Log.Debug($"IobInfo per {IdxMacchina} | {source} | {sw.Elapsed.TotalMilliseconds}ms");
return result;
}
#endif
/// <summary>
/// Recupero info IOB x TAB (da info registrate IOB-WIN--&gt; MP-IO)
/// </summary>
@@ -1285,7 +1257,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
IOB_data? result = new IOB_data();
// cerco in redis...
// cerco in redisConn...
string currKey = RedHashMpIO($"hM2IOB:{IdxMacchina}");
RedisValue rawData = await redisDb.StringGetAsync(currKey);
//if (!string.IsNullOrEmpty($"{rawData}"))
@@ -1319,7 +1291,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<PODLExpModel>? result = new List<PODLExpModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:PODL:{idxMacchina}:{onlyFree}:{onlyDirect}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
@@ -1353,7 +1325,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<ListValuesModel>? result = new List<ListValuesModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:ListVal:{tabName}:{fieldName}";
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -1391,7 +1363,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<AnagLottiArca> result = new List<AnagLottiArca>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:LottoExt:{codMagazzino}:{codArt}:{codLotto}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
@@ -1438,7 +1410,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<Macchine2SlaveModel> result = new List<Macchine2SlaveModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:Mach2Slave";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
//if (!string.IsNullOrEmpty($"{rawData}"))
@@ -1477,7 +1449,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<MacchineModel> result = new List<MacchineModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:MachByMatOp:{MatrOpr}";
RedisValue rawData = redisDb.StringGet(currKey);
//if (!string.IsNullOrEmpty($"{rawData}"))
@@ -1520,7 +1492,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<ObjItemDTO>? result = new List<ObjItemDTO>();
// cerco in redis...
// cerco in redisConn...
string currKey = RedHashMpIO($"CurrentParameters:{idxMacchina}");
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue && rawData.Length() > 2)
@@ -1629,74 +1601,6 @@ namespace MP.Data.Services
return answ;
}
#if false
/// <summary>
/// Recupero info Machine-IOB x TAB (da info registrate IOB-WIN --&gt; MP-IO)
/// </summary>
/// <param name="IdxMacchina"></param>
/// <returns></returns>
public Dictionary<string, string> MachIobConf(string IdxMacchina)
{
string source = "NA";
Stopwatch sw = new Stopwatch();
sw.Start();
Dictionary<string, string> result = new Dictionary<string, string>();
// cerco in redis...
string currKey = RedHashMpIO($"IOB:{IdxMacchina}:MachIobConf");
try
{
result = redisDb
.HashGetAll(currKey)
.ToDictionary(x => $"{x.Name}", x => $"{x.Value}");
source = "REDIS";
}
catch (Exception exc)
{
Log.Error($"Errore in MachIobConf{Environment.NewLine}{exc}");
}
if (result == null)
{
result = new Dictionary<string, string>();
Log.Debug($"Init valore default MachIobConf | IdxMacchina: {IdxMacchina}");
}
sw.Stop();
Log.Debug($"MachIobConf per {IdxMacchina} | {source} | {sw.Elapsed.TotalMilliseconds}ms");
return result;
}
/// <summary>
/// Recupero Conf Yaml Machine-IOB
/// </summary>
/// <param name="IdxMacchina"></param>
/// <returns></returns>
public string MachIobYamlConf(string IdxMacchina)
{
string source = "NA";
Stopwatch sw = new Stopwatch();
sw.Start();
string result = "";
// cerco in redis...
string currKey = RedHashMpIO($"IOB:{IdxMacchina}:ConfYaml");
try
{
result = redisDb.StringGet(currKey);
source = "REDIS";
}
catch (Exception exc)
{
Log.Error($"Errore in MachIobYamlConf{Environment.NewLine}{exc}");
}
if (result == null)
{
result = "";
Log.Debug($"Init valore default MachIobYamlConf | IdxMacchina: {IdxMacchina}");
}
sw.Stop();
Log.Debug($"MachIobYamlConf per {IdxMacchina} | {source} | {sw.Elapsed.TotalMilliseconds}ms");
return result;
}
#endif
/// <summary>
/// Restitusice elenco KVP dei TASK SALVATI (da passare a IOB-WIN) per l'impianto indicato
/// </summary>
@@ -1707,7 +1611,7 @@ namespace MP.Data.Services
{
// hard coded dimensione vettore DatiMacchine
Dictionary<string, string> answ = new Dictionary<string, string>();
// ORA recupero da memoria redis...
// ORA recupero da memoria redisConn...
try
{
var currKey = (RedisKey)savedTaskHash(idxMacchina);
@@ -1732,7 +1636,7 @@ namespace MP.Data.Services
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
MappaStatoExplModel result = new MappaStatoExplModel();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{Constants.redisMseKeySingle}:{idxMacchSub}";
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue && !forceDb)
@@ -1805,7 +1709,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
ODLExpModel result = new ODLExpModel();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:ODL:{idxOdl}:{onlyUnused}";
RedisValue rawData = redisDb.StringGet(currKey);
#if false
@@ -1887,7 +1791,7 @@ namespace MP.Data.Services
// se vuoto esco subito...
if (!string.IsNullOrEmpty(idxMacchina))
{
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:ODL:{idxMacchina}:CURR";
RedisValue rawData = redisDb.StringGet(currKey);
#if false
@@ -2044,7 +1948,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
ODLModel result = new ODLModel();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:ODL:{idxMacchina}:LAST";
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue && !forceDb)
@@ -2083,7 +1987,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<ODLModel>? result = new List<ODLModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:ODL:{idxMacchina}:{dtStart:yyyyMMdd-HHmmss}:{dtEnd:yyyyMMdd-HHmmss}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
@@ -2120,7 +2024,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
ODLModel result = new ODLModel();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:ODL:{idxMacchina}:LAST";
var results = await Task.FromResult(dbTabController.OdlReopenOdlMacc(idxMacchina));
// riordino
@@ -2249,7 +2153,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
bool answ = false;
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisUserDataKey}:CurrOpr:{matrOpr}:CurrDevGuid:{DevGuid}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
@@ -2275,7 +2179,7 @@ namespace MP.Data.Services
public TimeSpan OperatoreGetGuidTTL(int matrOpr, Guid currDevGuid)
{
TimeSpan answ = new TimeSpan();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisUserDataKey}:CurrOpr:{matrOpr}:CurrDevGuid:{currDevGuid}";
answ = GetKeyTTL(currKey);
return answ;
@@ -2292,7 +2196,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
string answ = "";
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisUserDataKey}:CurrOpr:{matrOpr}:CurrDevGuid:{currDevGuid}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
@@ -2344,7 +2248,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
string answ = "";
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisUserDataKey}:CurrOpr:{matrOpr}:CurrDevGuid:{currDevGuid}";
//RedisValue rawData = await redisDb.StringGetAsync(currKey);
// serializzo e salvo...
@@ -2374,7 +2278,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<PzProdModel> result = new List<PzProdModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:PzProd:{idxMacchina}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
@@ -2438,7 +2342,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
PODLExpModel result = new PODLExpModel();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:PODL:{idxPODL}";
RedisValue rawData;
rawData = redisDb.StringGet(currKey);
@@ -2514,7 +2418,7 @@ namespace MP.Data.Services
stopWatch.Start();
string readType = "DB";
string currKey = $"{Utils.redisPOdlList}_kit:ByParent:{IdxPodlParent}";
// cerco in redis dato valore sel idxMaccSel...
// cerco in redisConn dato valore sel idxMaccSel...
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
{
@@ -2558,7 +2462,7 @@ namespace MP.Data.Services
else
{
answ = await pzCounterTC(idxMacchina);
// salvo in redis...
// salvo in redisConn...
await saveCounter(idxMacchina, answ.ToString());
}
}
@@ -2653,7 +2557,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<RegistroControlliModel>? result = new List<RegistroControlliModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:RecContr:{idxMacchina}:{idxODL}:{dataFrom:yyyyyMMdd-HHmm}:{dataFrom:yyyyyMMdd-HHmm}:{showMulti}";
#if false
RedisValue rawData = redisDb.StringGet(currKey);
@@ -2706,7 +2610,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<ElencoConfermeProdModel> result = new List<ElencoConfermeProdModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:ElConfProd:{idxMacchina}:{dataFrom:yyyyyMMdd-HHmm}:{dataFrom:yyyyyMMdd-HHmm}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
@@ -2771,7 +2675,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<RegistroControlliModel>? result = new List<RegistroControlliModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:RecContr:{idxMacchina}:LAST";
RedisValue rawData = redisDb.StringGet(currKey);
#if false
@@ -2825,7 +2729,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<RegistroDichiarazioniModel>? result = new List<RegistroDichiarazioniModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:RegDichiar:{idxMacchina}:{tagCode}:{matrOpr}:{idxODL}:{dataFrom:yyyyyMMdd-HHmm}:{dataTo:yyyyyMMdd-HHmm}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
@@ -2911,7 +2815,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<RegistroScartiModel>? result = new List<RegistroScartiModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:RegScarti:{idxMacchina}:{idxODL}:{dataFrom:yyyyyMMdd-HHmm}:{dataTo:yyyyyMMdd-HHmm}:{showMulti}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
@@ -2995,7 +2899,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<RegistroScartiKitModel>? result = new List<RegistroScartiKitModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:RegScartiKit:{ParentRec.IdxMacchina}:{ParentRec.DataOra:yyyyyMMdd-HHmm}:{ParentRec.Causale}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
@@ -3145,7 +3049,7 @@ namespace MP.Data.Services
{
Log.Info($"Eccezione in calcolo timeout dati macchina: idxMacchina{idxMacchina} | TShort: {tOutShort} | TLong {tOutLong}{Environment.NewLine}{exc}");
}
// salvo in redis!
// salvo in redisConn!
redisHashDictSet(currKey, answ, TimeSpan.FromSeconds(redDtMacTOut));
}
return answ;
@@ -3183,7 +3087,7 @@ namespace MP.Data.Services
Value = "FER"
};
var result = dbTabController.MicroStatoMacchinaUpsert(newRecMS);
// reset in redis
// reset in redisConn
await resetDatiMacchina(idxMacchina);
}
@@ -3225,7 +3129,7 @@ namespace MP.Data.Services
if (newCounter >= 0)
{
string redKey = redHash($"PzCount:{idxMacchina}");
// verifico SE ci sia chiave in redis (ALTRIMENTI rileggo da DB)
// verifico SE ci sia chiave in redisConn (ALTRIMENTI rileggo da DB)
string redVal = redisDb.StringGet(redKey);
if (!string.IsNullOrEmpty(redVal))
{
@@ -3323,7 +3227,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<ST_AnagGruppi>? result = new List<ST_AnagGruppi>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:ST:AnagGruppiModel";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
@@ -3433,7 +3337,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<ST_ActRow>? result = new List<ST_ActRow>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:STAR:{codGruppo}:{idxODL}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
//if (!string.IsNullOrEmpty($"{rawData}"))
@@ -3472,7 +3376,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<ST_ActRow>? result = new List<ST_ActRow>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:STAR:{codGruppo}:{label}:{idxODL}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
//if (!string.IsNullOrEmpty($"{rawData}"))
@@ -3509,7 +3413,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<ST_ActRow>? result = new List<ST_ActRow>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:STAR:Pend:{idxODL}";
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -3545,7 +3449,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
StatoMacchineModel? result = new StatoMacchineModel();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:StatoMacc:{idxMacchina}";
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -3584,7 +3488,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
StatoProdModel? result = new StatoProdModel();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:StatoProd:{idxMacchina}:{dtReq:HHmm}";
RedisValue rawData = redisDb.StringGet(currKey);
#if false
@@ -3635,7 +3539,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<TemplateKitModel>? result = new List<TemplateKitModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{Utils.redisKitTempl}:{codParent}:{codChild}";
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -3669,7 +3573,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
TurniMaccModel? result = new TurniMaccModel();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:TurniMacc:{idxMacchina}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
//if (!string.IsNullOrEmpty($"{rawData}"))
@@ -3704,7 +3608,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<TurniMaccModel>? result = new List<TurniMaccModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:TurniMacc:All";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
@@ -3756,7 +3660,7 @@ namespace MP.Data.Services
/// <summary>
/// Intera vista v_MSFD
/// </summary>
/// <param name="doForce">forza rilettura + save su redis</param>
/// <param name="doForce">forza rilettura + save su redisConn</param>
/// <returns></returns>
public async Task<List<VMSFDModel>> VMSFDGetAll(bool doForce = false)
{
@@ -3765,7 +3669,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<VMSFDModel> result = new List<VMSFDModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:MSFD:ALL";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue && !doForce)
@@ -3801,7 +3705,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<VMSFDModel>? result = new List<VMSFDModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:MSFD:MACCH:{idxMacc}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
//if (!string.IsNullOrEmpty($"{rawData}"))
@@ -3838,7 +3742,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<VMSFDModel>? result = new List<VMSFDModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:MSFD:MULTI:{idxMacc}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
//if (!string.IsNullOrEmpty($"{rawData}"))
@@ -3870,7 +3774,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<VocabolarioModel>? result = new List<VocabolarioModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:Vocab";
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
@@ -3904,7 +3808,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<vSelCauScartoModel>? result = new List<vSelCauScartoModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:VSCS";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
@@ -3940,7 +3844,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<vSelOdlModel>? result = new List<vSelOdlModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:VSODL:{idxMacchina}:{numRec}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
@@ -3977,7 +3881,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<vSelOdlModel>? result = new List<vSelOdlModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:VSODL:{idxMacchina}:ALL_{showAll}:{numDayAdd}";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue && rawData.Length() > 2)
@@ -4007,18 +3911,6 @@ namespace MP.Data.Services
protected int expMinutes = 1;
protected string MpIoNS = "";
/// <summary>
/// Oggetto per connessione a REDIS
/// </summary>
protected ConnectionMultiplexer redisConn = null!;
/// <summary>
/// Oggetto DB redis da impiegare x chiamate R/W
/// </summary>
protected IDatabase redisDb = null!;
#endregion Protected Fields
#region Protected Properties
@@ -4092,7 +3984,7 @@ namespace MP.Data.Services
#region Private Methods
/// <summary>
/// Esegue flush memoria redis dato pattern, metodo sincrono
/// Esegue flush memoria redisConn dato pattern, metodo sincrono
/// </summary>
/// <param name="pattern"></param>
/// <returns></returns>
@@ -4120,7 +4012,7 @@ namespace MP.Data.Services
}
/// <summary>
/// Esegue flush memoria redis dato pattern in async
/// Esegue flush memoria redisConn dato pattern in async
/// </summary>
/// <param name="pattern"></param>
/// <returns></returns>
@@ -4166,7 +4058,7 @@ namespace MP.Data.Services
{
// hard coded dimensione vettore DatiMacchine
Dictionary<string, string> answ = new Dictionary<string, string>();
// ORA recupero da memoria redis...
// ORA recupero da memoria redisConn...
try
{
var currKey = (RedisKey)exeTaskHash(idxMacchina);
@@ -4227,7 +4119,7 @@ namespace MP.Data.Services
}
/// <summary>
/// Recupero HashSet redis come Dictionary
/// Recupero HashSet redisConn come Dictionary
/// </summary>
/// <param name="currKey"></param>
/// <param name="dict"></param>
+33 -33
View File
@@ -6,6 +6,7 @@ using NLog;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Diagnostics;
using System.IO;
@@ -18,19 +19,14 @@ namespace MP.Data.Services
/// <summary>
/// Classe accesso processi traduzione
/// </summary>
public class TranslateSrv : BaseServ, IDisposable
public class TranslateSrv : BaseServ
{
#region Public Constructors
public TranslateSrv(IConfiguration configuration) : base(configuration)
public TranslateSrv(IConfiguration configuration, IConnectionMultiplexer redConn) : base(configuration, redConn)
{
Stopwatch sw = Stopwatch.StartNew();
Stopwatch sw = new Stopwatch();
sw.Start();
_configuration = configuration;
// setup compoenti REDIS
redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis"));
redisDb = redisConn.GetDatabase();
// conf DB
string connStr = _configuration.GetConnectionString("MP.Voc");
if (string.IsNullOrEmpty(connStr))
@@ -66,7 +62,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<ConfigModel>? result = new List<ConfigModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:Conf";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
//if (!string.IsNullOrEmpty($"{rawData}"))
@@ -91,15 +87,6 @@ namespace MP.Data.Services
return result;
}
public void Dispose()
{
// Clear database controller
dbController.Dispose();
// redis dispose
redisConn = null;
redisDb = null;
}
/// <summary>
/// Pulizia cache Redis (tutta)
/// </summary>
@@ -135,7 +122,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<LingueModel>? result = new List<LingueModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:Lang";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
//if (!string.IsNullOrEmpty($"{rawData}"))
@@ -187,7 +174,7 @@ namespace MP.Data.Services
Stopwatch sw = new Stopwatch();
sw.Start();
List<VocabolarioModel>? result = new List<VocabolarioModel>();
// cerco in redis...
// cerco in redisConn...
string currKey = $"{redisBaseKey}:Voc";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
//if (!string.IsNullOrEmpty($"{rawData}"))
@@ -201,7 +188,7 @@ namespace MP.Data.Services
result = dbController.VocabolarioGetAll();
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
redisDb.StringSet(currKey, rawData, LongCache);
redisDb.StringSet(currKey, rawData, UltraLongCache);
}
if (result == null)
{
@@ -221,22 +208,35 @@ namespace MP.Data.Services
/// </summary>
protected static Dictionary<string, string> DictVocab = new Dictionary<string, string>();
/// <summary>
/// Oggetto per connessione a REDIS
/// </summary>
protected ConnectionMultiplexer redisConn = null!;
/// <summary>
/// Oggetto DB redis da impiegare x chiamate R/W
/// </summary>
protected IDatabase redisDb = null!;
#endregion Protected Fields
#region Protected Methods
protected override void Dispose(bool disposing)
{
if (!_disposed)
{
if (disposing)
{
// Free managed resources here
DictVocab.Clear();
dbController.Dispose();
}
// Free unmanaged resources here
_disposed = true;
}
// Call base class implementation.
base.Dispose(disposing);
}
#endregion Protected Methods
#region Private Fields
private static Logger Log = LogManager.GetCurrentClassLogger();
private bool _disposed = false;
private string redisBaseKey = "MP:Voc:Cache";
#endregion Private Fields
@@ -254,7 +254,7 @@ namespace MP.Data.Services
}
/// <summary>
/// Esegue flush memoria redis dato pattern
/// Esegue flush memoria redisConn dato pattern
/// </summary>
/// <param name="pattern"></param>
/// <returns></returns>
+1 -3
View File
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable

Some files were not shown because too many files have changed in this diff Show More