diff --git a/MP-TAB3/Components/InsManual.razor b/MP-TAB3/Components/InsManual.razor index 394a2375..a0f100cf 100644 --- a/MP-TAB3/Components/InsManual.razor +++ b/MP-TAB3/Components/InsManual.razor @@ -222,45 +222,56 @@ - @foreach (var item in ListDay) + @if (ListDay == null) { - - @if (item.Imported == null) - { - - } - else - { - - } - - @item.IdxMacchina - @(EvDescript(item.IdxTipoEv)) - -
@item.CodArticolo
- @if (!string.IsNullOrEmpty(item.KeyRichiesta)) - { - @item.KeyRichiesta - } - - {item.FineStato:yyyy.MM.dd HH:mm:ss}")">@($"{item.InizioStato:HH:mm}") - @item.PzBuoni - @($"{item.TCiclo:f2}") - @($"{item.MinProd:f2}") - - @if (item.Imported == null) - { - - } - else - { - - - } + +
Nessun dato disponibile
} + else + { + foreach (var item in ListDay) + { + + + @if (item.Imported == null) + { + + } + else + { + + } + + @item.IdxMacchina + @(EvDescript(item.IdxTipoEv)) + +
@item.CodArticolo
+ @if (!string.IsNullOrEmpty(item.KeyRichiesta)) + { + @item.KeyRichiesta + } + + {item.FineStato:yyyy.MM.dd HH:mm:ss}")">@($"{item.InizioStato:HH:mm}") + @item.PzBuoni + @($"{item.TCiclo:f2}") + @($"{item.MinProd:f2}") + + @if (item.Imported == null) + { + + } + else + { + + + } + + + } + } diff --git a/MP-TAB3/Components/MachineBlock.razor.cs b/MP-TAB3/Components/MachineBlock.razor.cs index 63c7374e..468c422d 100644 --- a/MP-TAB3/Components/MachineBlock.razor.cs +++ b/MP-TAB3/Components/MachineBlock.razor.cs @@ -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; diff --git a/MP-TAB3/Components/ProdConfMan.razor b/MP-TAB3/Components/ProdConfMan.razor index 6a70fc3c..422f1fc0 100644 --- a/MP-TAB3/Components/ProdConfMan.razor +++ b/MP-TAB3/Components/ProdConfMan.razor @@ -58,7 +58,7 @@ @actOdl.CodArticolo @item.PezziConf - @item.PezziScar + @item.PezziScar @if (ShowRilav) { @item.PezziDaRilav diff --git a/MP-TAB3/Components/ProdKIT/KitDetailModal.razor b/MP-TAB3/Components/ProdKIT/KitDetailModal.razor index 335ec458..44a4a18e 100644 --- a/MP-TAB3/Components/ProdKIT/KitDetailModal.razor +++ b/MP-TAB3/Components/ProdKIT/KitDetailModal.razor @@ -80,20 +80,31 @@ - @foreach (var record in ListTK) + @if (ListTK == null) { - - @record.CodArtParent - - - @record.CodArtChild - - -
@record.Qty
+ +
Nessun dato disponibile
} + else + { + foreach (var record in ListTK) + { + + + @record.CodArtParent + + + @record.CodArtChild + + +
@record.Qty
+ + + } + } } diff --git a/MP-TAB3/MP-TAB3.csproj b/MP-TAB3/MP-TAB3.csproj index 6f085bcc..a464479e 100644 --- a/MP-TAB3/MP-TAB3.csproj +++ b/MP-TAB3/MP-TAB3.csproj @@ -3,7 +3,7 @@ net6.0 enable - 6.16.2507.2319 + 6.16.2507.2410 enable MP_TAB3 diff --git a/MP-TAB3/Pages/StatusMap.razor.cs b/MP-TAB3/Pages/StatusMap.razor.cs index ba89dbc4..5b12615f 100644 --- a/MP-TAB3/Pages/StatusMap.razor.cs +++ b/MP-TAB3/Pages/StatusMap.razor.cs @@ -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 --> allarmi - if (!string.IsNullOrEmpty(currArgs.newMessage)) + // conversione on-the-fly List --> allarmi + if (!string.IsNullOrEmpty(currArgs.newMessage)) + { + try { - try + List? dataList = JsonConvert.DeserializeObject>(currArgs.newMessage); + if (dataList != null) { - List? dataList = JsonConvert.DeserializeObject>(currArgs.newMessage); - if (dataList != null) - { - InvokeAsync(() => SaveData(dataList)); - } + InvokeAsync(() => SaveData(dataList)); } - catch - { } } + catch + { } + } InvokeAsync(() => { StateHasChanged(); diff --git a/MP-TAB3/Program.cs b/MP-TAB3/Program.cs index 4471706a..6e52aee9 100644 --- a/MP-TAB3/Program.cs +++ b/MP-TAB3/Program.cs @@ -35,7 +35,6 @@ builder.Services.AddRazorPages(); builder.Services.AddServerSideBlazor(); builder.Services.AddSingleton(); - builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); diff --git a/MP-TAB3/Resources/ChangeLog.html b/MP-TAB3/Resources/ChangeLog.html index d52aa69e..d6dc4379 100644 --- a/MP-TAB3/Resources/ChangeLog.html +++ b/MP-TAB3/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 6.16.2507.2319

+

Versione: 6.16.2507.2410


Note di rilascio:
  • diff --git a/MP-TAB3/Resources/VersNum.txt b/MP-TAB3/Resources/VersNum.txt index ebd9ef09..b621e3ab 100644 --- a/MP-TAB3/Resources/VersNum.txt +++ b/MP-TAB3/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2507.2319 +6.16.2507.2410 diff --git a/MP-TAB3/Resources/manifest.xml b/MP-TAB3/Resources/manifest.xml index a9eefdf7..62e95fff 100644 --- a/MP-TAB3/Resources/manifest.xml +++ b/MP-TAB3/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2507.2319 + 6.16.2507.2410 https://nexus.steamware.net/repository/SWS/MP-TAB3/stable/LAST/MP-TAB3.zip https://nexus.steamware.net/repository/SWS/MP-TAB3/stable/LAST/ChangeLog.html false diff --git a/MP.Core/DTO/InsManDayDto.cs b/MP.Core/DTO/InsManDayDto.cs index 33bf1360..21523af1 100644 --- a/MP.Core/DTO/InsManDayDto.cs +++ b/MP.Core/DTO/InsManDayDto.cs @@ -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; // // This is here so CodeMaid doesn't reorganize this document diff --git a/MP.Core/DTO/ManualStatusDTO.cs b/MP.Core/DTO/ManualStatusDTO.cs index 75ed97a2..730aa415 100644 --- a/MP.Core/DTO/ManualStatusDTO.cs +++ b/MP.Core/DTO/ManualStatusDTO.cs @@ -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 { diff --git a/MP.Core/DTO/MappaStatoExplDTO.cs b/MP.Core/DTO/MappaStatoExplDTO.cs index a345ee1b..12fe6b44 100644 --- a/MP.Core/DTO/MappaStatoExplDTO.cs +++ b/MP.Core/DTO/MappaStatoExplDTO.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations.Schema; -using System.Data; +using System.ComponentModel.DataAnnotations.Schema; // // This is here so CodeMaid doesn't reorganize this document diff --git a/MP.Core/DTO/repartiDTO.cs b/MP.Core/DTO/repartiDTO.cs index e664c84b..b6883ff0 100644 --- a/MP.Core/DTO/repartiDTO.cs +++ b/MP.Core/DTO/repartiDTO.cs @@ -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 { diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs index 1a8bbe54..3c63a32a 100644 --- a/MP.Data/Controllers/MpSpecController.cs +++ b/MP.Data/Controllers/MpSpecController.cs @@ -635,7 +635,7 @@ namespace MP.Data.Controllers } /// - /// Effettua salvataggio snapshot parametri (con stored) + svuota eventuale cache redis + /// Effettua salvataggio snapshot parametri (con stored) + svuota eventuale cache redisConn /// /// macchina /// Num massimo secondi per recuperare dati correnti @@ -658,7 +658,7 @@ namespace MP.Data.Controllers } /// - /// Effettua salvataggio snapshot parametri (con stored) + svuota eventuale cache redis + /// Effettua salvataggio snapshot parametri (con stored) + svuota eventuale cache redisConn /// /// macchina /// Data min x selezione diff --git a/MP.Data/DTO/IobDTO.cs b/MP.Data/DTO/IobDTO.cs index 02171544..6e2cc8a1 100644 --- a/MP.Data/DTO/IobDTO.cs +++ b/MP.Data/DTO/IobDTO.cs @@ -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 { diff --git a/MP.Data/DbModels/AlarmLogModel.cs b/MP.Data/DbModels/AlarmLogModel.cs index 982c25c2..d7578850 100644 --- a/MP.Data/DbModels/AlarmLogModel.cs +++ b/MP.Data/DbModels/AlarmLogModel.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/AnagArticoliModel.cs b/MP.Data/DbModels/AnagArticoliModel.cs index c98774ab..e1a94480 100644 --- a/MP.Data/DbModels/AnagArticoliModel.cs +++ b/MP.Data/DbModels/AnagArticoliModel.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations.Schema; #nullable disable // diff --git a/MP.Data/DbModels/AnagArticoli_MAG.cs b/MP.Data/DbModels/AnagArticoli_MAG.cs index acf8707d..5ef8183d 100644 --- a/MP.Data/DbModels/AnagArticoli_MAG.cs +++ b/MP.Data/DbModels/AnagArticoli_MAG.cs @@ -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 // diff --git a/MP.Data/DbModels/AnagCountersModel.cs b/MP.Data/DbModels/AnagCountersModel.cs index 9f845a19..78a2828d 100644 --- a/MP.Data/DbModels/AnagCountersModel.cs +++ b/MP.Data/DbModels/AnagCountersModel.cs @@ -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 diff --git a/MP.Data/DbModels/AnagEventiModel.cs b/MP.Data/DbModels/AnagEventiModel.cs index 75270875..d550dc70 100644 --- a/MP.Data/DbModels/AnagEventiModel.cs +++ b/MP.Data/DbModels/AnagEventiModel.cs @@ -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 { diff --git a/MP.Data/DbModels/AnagFLTransModel.cs b/MP.Data/DbModels/AnagFLTransModel.cs index 72ff7823..86394a2c 100644 --- a/MP.Data/DbModels/AnagFLTransModel.cs +++ b/MP.Data/DbModels/AnagFLTransModel.cs @@ -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; // // This is here so CodeMaid doesn't reorganize this document diff --git a/MP.Data/DbModels/AnagGiacenzeModel.cs b/MP.Data/DbModels/AnagGiacenzeModel.cs index 2ea61bc4..82d8907b 100644 --- a/MP.Data/DbModels/AnagGiacenzeModel.cs +++ b/MP.Data/DbModels/AnagGiacenzeModel.cs @@ -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; // // This is here so CodeMaid doesn't reorganize this document diff --git a/MP.Data/DbModels/AnagGruppiModel.cs b/MP.Data/DbModels/AnagGruppiModel.cs index bdbc9aa8..400854b3 100644 --- a/MP.Data/DbModels/AnagGruppiModel.cs +++ b/MP.Data/DbModels/AnagGruppiModel.cs @@ -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 // diff --git a/MP.Data/DbModels/AnagKeyValueModel.cs b/MP.Data/DbModels/AnagKeyValueModel.cs index 5677dcb1..36008d90 100644 --- a/MP.Data/DbModels/AnagKeyValueModel.cs +++ b/MP.Data/DbModels/AnagKeyValueModel.cs @@ -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 diff --git a/MP.Data/DbModels/AnagLottoModel.cs b/MP.Data/DbModels/AnagLottoModel.cs index 1af87b3d..3998fe2a 100644 --- a/MP.Data/DbModels/AnagLottoModel.cs +++ b/MP.Data/DbModels/AnagLottoModel.cs @@ -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; // // This is here so CodeMaid doesn't reorganize this document diff --git a/MP.Data/DbModels/AnagMagModel.cs b/MP.Data/DbModels/AnagMagModel.cs index 4351a568..973ceb63 100644 --- a/MP.Data/DbModels/AnagMagModel.cs +++ b/MP.Data/DbModels/AnagMagModel.cs @@ -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 diff --git a/MP.Data/DbModels/AnagOperatoriModel.cs b/MP.Data/DbModels/AnagOperatoriModel.cs index d6edecb8..7831f83f 100644 --- a/MP.Data/DbModels/AnagOperatoriModel.cs +++ b/MP.Data/DbModels/AnagOperatoriModel.cs @@ -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 { diff --git a/MP.Data/DbModels/AnagStatiModel.cs b/MP.Data/DbModels/AnagStatiModel.cs index d6b6c65d..964ec3ec 100644 --- a/MP.Data/DbModels/AnagStatiModel.cs +++ b/MP.Data/DbModels/AnagStatiModel.cs @@ -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 { diff --git a/MP.Data/DbModels/AnagTagsModel.cs b/MP.Data/DbModels/AnagTagsModel.cs index 878fd494..49b392aa 100644 --- a/MP.Data/DbModels/AnagTagsModel.cs +++ b/MP.Data/DbModels/AnagTagsModel.cs @@ -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 diff --git a/MP.Data/DbModels/AnagUdcModel.cs b/MP.Data/DbModels/AnagUdcModel.cs index d6696e2a..0e8f3426 100644 --- a/MP.Data/DbModels/AnagUdcModel.cs +++ b/MP.Data/DbModels/AnagUdcModel.cs @@ -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; // // This is here so CodeMaid doesn't reorganize this document diff --git a/MP.Data/DbModels/AnagraficaFlussiModel.cs b/MP.Data/DbModels/AnagraficaFlussiModel.cs index 69a3fc08..df304ec3 100644 --- a/MP.Data/DbModels/AnagraficaFlussiModel.cs +++ b/MP.Data/DbModels/AnagraficaFlussiModel.cs @@ -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 diff --git a/MP.Data/DbModels/CommentiModel.cs b/MP.Data/DbModels/CommentiModel.cs index 7dfa3731..3ce3baf5 100644 --- a/MP.Data/DbModels/CommentiModel.cs +++ b/MP.Data/DbModels/CommentiModel.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/ConfigModel.cs b/MP.Data/DbModels/ConfigModel.cs index 041e41f1..60bbe77b 100644 --- a/MP.Data/DbModels/ConfigModel.cs +++ b/MP.Data/DbModels/ConfigModel.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations.Schema; #nullable disable // diff --git a/MP.Data/DbModels/DdbTurni.cs b/MP.Data/DbModels/DdbTurni.cs index 637c2fe8..482f4ba4 100644 --- a/MP.Data/DbModels/DdbTurni.cs +++ b/MP.Data/DbModels/DdbTurni.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/ElencoConfermeProdModel.cs b/MP.Data/DbModels/ElencoConfermeProdModel.cs index f8b7b437..7647c64d 100644 --- a/MP.Data/DbModels/ElencoConfermeProdModel.cs +++ b/MP.Data/DbModels/ElencoConfermeProdModel.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/EventListModel.cs b/MP.Data/DbModels/EventListModel.cs index c4ba5bd7..fecaf2b8 100644 --- a/MP.Data/DbModels/EventListModel.cs +++ b/MP.Data/DbModels/EventListModel.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/FermiNonQualModel.cs b/MP.Data/DbModels/FermiNonQualModel.cs index e6a03840..cb24d6dc 100644 --- a/MP.Data/DbModels/FermiNonQualModel.cs +++ b/MP.Data/DbModels/FermiNonQualModel.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; #nullable disable diff --git a/MP.Data/DbModels/Gruppi2MaccModel.cs b/MP.Data/DbModels/Gruppi2MaccModel.cs index eff27663..83b574f1 100644 --- a/MP.Data/DbModels/Gruppi2MaccModel.cs +++ b/MP.Data/DbModels/Gruppi2MaccModel.cs @@ -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 // diff --git a/MP.Data/DbModels/Gruppi2OperModel.cs b/MP.Data/DbModels/Gruppi2OperModel.cs index 34dc2a4e..6747831d 100644 --- a/MP.Data/DbModels/Gruppi2OperModel.cs +++ b/MP.Data/DbModels/Gruppi2OperModel.cs @@ -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 // diff --git a/MP.Data/DbModels/InventorySessionModel.cs b/MP.Data/DbModels/InventorySessionModel.cs index 8fabf5dc..bec5e29d 100644 --- a/MP.Data/DbModels/InventorySessionModel.cs +++ b/MP.Data/DbModels/InventorySessionModel.cs @@ -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; // // This is here so CodeMaid doesn't reorganize this document diff --git a/MP.Data/DbModels/IstanzeKitModel.cs b/MP.Data/DbModels/IstanzeKitModel.cs index a3853604..62b1ec40 100644 --- a/MP.Data/DbModels/IstanzeKitModel.cs +++ b/MP.Data/DbModels/IstanzeKitModel.cs @@ -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 diff --git a/MP.Data/DbModels/KeepAliveModel.cs b/MP.Data/DbModels/KeepAliveModel.cs index 77c6fd05..452512a0 100644 --- a/MP.Data/DbModels/KeepAliveModel.cs +++ b/MP.Data/DbModels/KeepAliveModel.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; namespace MP.Data.DbModels diff --git a/MP.Data/DbModels/LingueModel.cs b/MP.Data/DbModels/LingueModel.cs index 695b6487..26cb1b2c 100644 --- a/MP.Data/DbModels/LingueModel.cs +++ b/MP.Data/DbModels/LingueModel.cs @@ -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 diff --git a/MP.Data/DbModels/LinkMenuModel.cs b/MP.Data/DbModels/LinkMenuModel.cs index 7199ba71..5918df7a 100644 --- a/MP.Data/DbModels/LinkMenuModel.cs +++ b/MP.Data/DbModels/LinkMenuModel.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/MacchineModel.cs b/MP.Data/DbModels/MacchineModel.cs index 5ed75e4f..a636685f 100644 --- a/MP.Data/DbModels/MacchineModel.cs +++ b/MP.Data/DbModels/MacchineModel.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/MacchineStatModel.cs b/MP.Data/DbModels/MacchineStatModel.cs index dbaad00a..968c1793 100644 --- a/MP.Data/DbModels/MacchineStatModel.cs +++ b/MP.Data/DbModels/MacchineStatModel.cs @@ -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 diff --git a/MP.Data/DbModels/MappaStatoExplModel.cs b/MP.Data/DbModels/MappaStatoExplModel.cs index 3adea883..caa2bbb2 100644 --- a/MP.Data/DbModels/MappaStatoExplModel.cs +++ b/MP.Data/DbModels/MappaStatoExplModel.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; -using System.Data; #nullable disable // diff --git a/MP.Data/DbModels/MicroStatoMacchinaModel.cs b/MP.Data/DbModels/MicroStatoMacchinaModel.cs index ceacd583..6b068f8f 100644 --- a/MP.Data/DbModels/MicroStatoMacchinaModel.cs +++ b/MP.Data/DbModels/MicroStatoMacchinaModel.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/ODLExpModel.cs b/MP.Data/DbModels/ODLExpModel.cs index dfdee3fd..ec0af9b6 100644 --- a/MP.Data/DbModels/ODLExpModel.cs +++ b/MP.Data/DbModels/ODLExpModel.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/ODLModel.cs b/MP.Data/DbModels/ODLModel.cs index 79ae4dbb..caaf0845 100644 --- a/MP.Data/DbModels/ODLModel.cs +++ b/MP.Data/DbModels/ODLModel.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/OdlEnergyModel.cs b/MP.Data/DbModels/OdlEnergyModel.cs index a303cde5..ade03e62 100644 --- a/MP.Data/DbModels/OdlEnergyModel.cs +++ b/MP.Data/DbModels/OdlEnergyModel.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/PODLExpModel.cs b/MP.Data/DbModels/PODLExpModel.cs index 5352f1c0..05617844 100644 --- a/MP.Data/DbModels/PODLExpModel.cs +++ b/MP.Data/DbModels/PODLExpModel.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/PODLModel.cs b/MP.Data/DbModels/PODLModel.cs index 5d660c90..818c5235 100644 --- a/MP.Data/DbModels/PODLModel.cs +++ b/MP.Data/DbModels/PODLModel.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/PzProdModel.cs b/MP.Data/DbModels/PzProdModel.cs index 782f4609..1074bc5c 100644 --- a/MP.Data/DbModels/PzProdModel.cs +++ b/MP.Data/DbModels/PzProdModel.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; #nullable disable // diff --git a/MP.Data/DbModels/RegCheckModel.cs b/MP.Data/DbModels/RegCheckModel.cs index f478495b..772a378c 100644 --- a/MP.Data/DbModels/RegCheckModel.cs +++ b/MP.Data/DbModels/RegCheckModel.cs @@ -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 // diff --git a/MP.Data/DbModels/RegistroControlliModel.cs b/MP.Data/DbModels/RegistroControlliModel.cs index 68358125..c3164062 100644 --- a/MP.Data/DbModels/RegistroControlliModel.cs +++ b/MP.Data/DbModels/RegistroControlliModel.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/RegistroDichiarazioniModel.cs b/MP.Data/DbModels/RegistroDichiarazioniModel.cs index 117bb018..13bdf909 100644 --- a/MP.Data/DbModels/RegistroDichiarazioniModel.cs +++ b/MP.Data/DbModels/RegistroDichiarazioniModel.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/RegistroScartiKitModel.cs b/MP.Data/DbModels/RegistroScartiKitModel.cs index 6b872f50..9d4478b8 100644 --- a/MP.Data/DbModels/RegistroScartiKitModel.cs +++ b/MP.Data/DbModels/RegistroScartiKitModel.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/RemoteRebootLogModel.cs b/MP.Data/DbModels/RemoteRebootLogModel.cs index fbfeec7f..b4728ddf 100644 --- a/MP.Data/DbModels/RemoteRebootLogModel.cs +++ b/MP.Data/DbModels/RemoteRebootLogModel.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/ST_Act.cs b/MP.Data/DbModels/ST_Act.cs index b5d28335..1f84d0a8 100644 --- a/MP.Data/DbModels/ST_Act.cs +++ b/MP.Data/DbModels/ST_Act.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/ST_ActRow.cs b/MP.Data/DbModels/ST_ActRow.cs index 752f4890..bc4f8e55 100644 --- a/MP.Data/DbModels/ST_ActRow.cs +++ b/MP.Data/DbModels/ST_ActRow.cs @@ -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 diff --git a/MP.Data/DbModels/ST_AnagGruppi.cs b/MP.Data/DbModels/ST_AnagGruppi.cs index 451e5060..ce01dbfb 100644 --- a/MP.Data/DbModels/ST_AnagGruppi.cs +++ b/MP.Data/DbModels/ST_AnagGruppi.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/ST_AnagTipi.cs b/MP.Data/DbModels/ST_AnagTipi.cs index 85fb415c..e9e2e873 100644 --- a/MP.Data/DbModels/ST_AnagTipi.cs +++ b/MP.Data/DbModels/ST_AnagTipi.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/ST_Check.cs b/MP.Data/DbModels/ST_Check.cs index ce8985dd..d4ccc293 100644 --- a/MP.Data/DbModels/ST_Check.cs +++ b/MP.Data/DbModels/ST_Check.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/ST_Template.cs b/MP.Data/DbModels/ST_Template.cs index 6efffc79..beec9088 100644 --- a/MP.Data/DbModels/ST_Template.cs +++ b/MP.Data/DbModels/ST_Template.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/ST_TemplateRows.cs b/MP.Data/DbModels/ST_TemplateRows.cs index 701062d4..4958aed1 100644 --- a/MP.Data/DbModels/ST_TemplateRows.cs +++ b/MP.Data/DbModels/ST_TemplateRows.cs @@ -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 diff --git a/MP.Data/DbModels/ScanDataModel.cs b/MP.Data/DbModels/ScanDataModel.cs index 18d5994c..de678ce8 100644 --- a/MP.Data/DbModels/ScanDataModel.cs +++ b/MP.Data/DbModels/ScanDataModel.cs @@ -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; // // This is here so CodeMaid doesn't reorganize this document diff --git a/MP.Data/DbModels/StatODLModel.cs b/MP.Data/DbModels/StatODLModel.cs index 9d879c6c..092fc030 100644 --- a/MP.Data/DbModels/StatODLModel.cs +++ b/MP.Data/DbModels/StatODLModel.cs @@ -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 diff --git a/MP.Data/DbModels/StatoMacchineModel.cs b/MP.Data/DbModels/StatoMacchineModel.cs index 0577b4b4..699b85b9 100644 --- a/MP.Data/DbModels/StatoMacchineModel.cs +++ b/MP.Data/DbModels/StatoMacchineModel.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/StatoProdModel.cs b/MP.Data/DbModels/StatoProdModel.cs index 9eb0e6cc..4bbdf04a 100644 --- a/MP.Data/DbModels/StatoProdModel.cs +++ b/MP.Data/DbModels/StatoProdModel.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/StatsODL.cs b/MP.Data/DbModels/StatsODL.cs index 4cf0a098..f43d77c7 100644 --- a/MP.Data/DbModels/StatsODL.cs +++ b/MP.Data/DbModels/StatsODL.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/TaskExecModel.cs b/MP.Data/DbModels/TaskExecModel.cs index 6cf80a5c..a3ada196 100644 --- a/MP.Data/DbModels/TaskExecModel.cs +++ b/MP.Data/DbModels/TaskExecModel.cs @@ -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 // diff --git a/MP.Data/DbModels/TaskListModel.cs b/MP.Data/DbModels/TaskListModel.cs index d4d6e330..3f446a54 100644 --- a/MP.Data/DbModels/TaskListModel.cs +++ b/MP.Data/DbModels/TaskListModel.cs @@ -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 diff --git a/MP.Data/DbModels/TaskResultModel.cs b/MP.Data/DbModels/TaskResultModel.cs index 98955694..1f721670 100644 --- a/MP.Data/DbModels/TaskResultModel.cs +++ b/MP.Data/DbModels/TaskResultModel.cs @@ -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 // diff --git a/MP.Data/DbModels/TemplateKitModel.cs b/MP.Data/DbModels/TemplateKitModel.cs index 46b990f5..17241428 100644 --- a/MP.Data/DbModels/TemplateKitModel.cs +++ b/MP.Data/DbModels/TemplateKitModel.cs @@ -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 diff --git a/MP.Data/DbModels/TksScoreModel.cs b/MP.Data/DbModels/TksScoreModel.cs index c3a5cc50..d90efb2d 100644 --- a/MP.Data/DbModels/TksScoreModel.cs +++ b/MP.Data/DbModels/TksScoreModel.cs @@ -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; // // This is here so CodeMaid doesn't reorganize this document diff --git a/MP.Data/DbModels/TransizioneIngressiModel.cs b/MP.Data/DbModels/TransizioneIngressiModel.cs index 58144420..aa96eada 100644 --- a/MP.Data/DbModels/TransizioneIngressiModel.cs +++ b/MP.Data/DbModels/TransizioneIngressiModel.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations.Schema; namespace MP.Data.DbModels { diff --git a/MP.Data/DbModels/TransizioneStatiModel.cs b/MP.Data/DbModels/TransizioneStatiModel.cs index b0dd2769..dee2e80e 100644 --- a/MP.Data/DbModels/TransizioneStatiModel.cs +++ b/MP.Data/DbModels/TransizioneStatiModel.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations.Schema; namespace MP.Data.DbModels { diff --git a/MP.Data/DbModels/TurniMaccModel.cs b/MP.Data/DbModels/TurniMaccModel.cs index 11a35a3d..4ee709ea 100644 --- a/MP.Data/DbModels/TurniMaccModel.cs +++ b/MP.Data/DbModels/TurniMaccModel.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/TurniOee.cs b/MP.Data/DbModels/TurniOee.cs index 529e1cef..90587f75 100644 --- a/MP.Data/DbModels/TurniOee.cs +++ b/MP.Data/DbModels/TurniOee.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; diff --git a/MP.Data/DbModels/VocabolarioModel.cs b/MP.Data/DbModels/VocabolarioModel.cs index 3ccc15a4..5ae0843b 100644 --- a/MP.Data/DbModels/VocabolarioModel.cs +++ b/MP.Data/DbModels/VocabolarioModel.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations.Schema; #nullable disable // diff --git a/MP.Data/DbModels/WipSetupKitModel.cs b/MP.Data/DbModels/WipSetupKitModel.cs index 8f7d3cf3..b5cef6e9 100644 --- a/MP.Data/DbModels/WipSetupKitModel.cs +++ b/MP.Data/DbModels/WipSetupKitModel.cs @@ -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; // // This is here so CodeMaid doesn't reorganize this document diff --git a/MP.Data/DbModels/vSelCauScartoModel.cs b/MP.Data/DbModels/vSelCauScartoModel.cs index 82adc351..661ae18c 100644 --- a/MP.Data/DbModels/vSelCauScartoModel.cs +++ b/MP.Data/DbModels/vSelCauScartoModel.cs @@ -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 // diff --git a/MP.Data/DbModels/vSelEventiBCodeModel.cs b/MP.Data/DbModels/vSelEventiBCodeModel.cs index 714afad0..c2830541 100644 --- a/MP.Data/DbModels/vSelEventiBCodeModel.cs +++ b/MP.Data/DbModels/vSelEventiBCodeModel.cs @@ -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 { diff --git a/MP.Data/DbModels/vSelOdlModel.cs b/MP.Data/DbModels/vSelOdlModel.cs index a0a82c21..09f35917 100644 --- a/MP.Data/DbModels/vSelOdlModel.cs +++ b/MP.Data/DbModels/vSelOdlModel.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; #nullable disable // diff --git a/MP.Data/MessagePipe.cs b/MP.Data/MessagePipe.cs index 588428e5..1094cc72 100644 --- a/MP.Data/MessagePipe.cs +++ b/MP.Data/MessagePipe.cs @@ -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; + } + /// /// Invio messaggio sul canale + salvataggio in cache REDIS /// @@ -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 + /// + /// Nome Canale associato al gestore pipeline messaggi + /// + private string _channel = ""; + private bool enableLog = false; private Dictionary numSent = new Dictionary(); - private IConnectionMultiplexer redis; - private IDatabase redisDb; - - #endregion Private Fields - - #region Private Properties /// - /// Canale associato al gestore pipeline messaggi + /// Channel di comunicazione REDIS /// - 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) { diff --git a/MP.Data/Services/BaseServ.cs b/MP.Data/Services/BaseServ.cs index 88efeb72..db80844c 100644 --- a/MP.Data/Services/BaseServ.cs +++ b/MP.Data/Services/BaseServ.cs @@ -16,16 +16,38 @@ namespace MP.Data.Services /// /// Classe di partenza x costruzione servizi di accesso dati + cache /// - 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 result = new Dictionary(); - // 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 /// /// Oggetto per connessione a REDIS /// - protected ConnectionMultiplexer redisConn = null!; + protected IConnectionMultiplexer redisConn = null!; - //ISubscriber sub = redis.GetSubscriber(); + //ISubscriber sub = redisConn.GetSubscriber(); /// /// Oggetto DB redis da impiegare x chiamate R/W /// diff --git a/MP.Data/Services/ExecStatsCollector.cs b/MP.Data/Services/ExecStatsCollector.cs index d8c49143..cd72b5e2 100644 --- a/MP.Data/Services/ExecStatsCollector.cs +++ b/MP.Data/Services/ExecStatsCollector.cs @@ -9,10 +9,15 @@ namespace MP.Data.Services /// /// Gestore statistiche esecuzione processi x analisi timing /// - public class ExecStatsCollector + public class ExecStatsCollector : IDisposable { #region Public Methods + public void Dispose() + { + TrackData.Clear(); + } + /// /// restituisce una stringa da poter emettere in log con il summary degli eventi tracciati ed eventuale reset... /// diff --git a/MP.Data/Services/LandDataService.cs b/MP.Data/Services/LandDataService.cs index bb86cc63..00588e84 100644 --- a/MP.Data/Services/LandDataService.cs +++ b/MP.Data/Services/LandDataService.cs @@ -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 result = new List(); - // 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 result = new List(); - // 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 result = new List(); - // 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 diff --git a/MP.Data/Services/ListSelectDataSrv.cs b/MP.Data/Services/ListSelectDataSrv.cs index e5c8aac5..f536a40f 100644 --- a/MP.Data/Services/ListSelectDataSrv.cs +++ b/MP.Data/Services/ListSelectDataSrv.cs @@ -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 /// /// Classe accesso dati filtrati per operatore /// - 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? result = new List(); - // 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? result = new List(); - // 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; - } - /// /// Pulizia cache Redis (tutta) /// @@ -171,7 +156,7 @@ namespace MP.Data.Services Stopwatch sw = new Stopwatch(); sw.Start(); List? result = new List(); - // 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? result = new List(); - // 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? result = new List(); - // 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 - /// - /// Oggetto per connessione a REDIS - /// - protected ConnectionMultiplexer redisConn = null!; + protected override void Dispose(bool disposing) + { + if (!_disposed) + { + if (disposing) + { + // Free managed resources here + dbController.Dispose(); + } - /// - /// Oggetto DB redis da impiegare x chiamate R/W - /// - 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 /// - /// Esegue flush memoria redis dato pattern + /// Esegue flush memoria redisConn dato pattern /// /// /// diff --git a/MP.Data/Services/MessageService.cs b/MP.Data/Services/MessageService.cs index 37c2e730..808c4693 100644 --- a/MP.Data/Services/MessageService.cs +++ b/MP.Data/Services/MessageService.cs @@ -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 DoLogIn(string decodValue, bool saveOpr) @@ -663,10 +664,10 @@ namespace MP.Data.Services /// /// Oggetto per connessione a REDIS /// - protected ConnectionMultiplexer redisConn = null!; + protected IConnectionMultiplexer redisConn = null!; /// - /// Oggetto DB redis da impiegare x chiamate R/W + /// Oggetto DB redisConn da impiegare x chiamate R/W /// protected IDatabase redisDb = null!; @@ -723,7 +724,7 @@ namespace MP.Data.Services } /// - /// Recupero HashSet redis come Dictionary + /// Recupero HashSet redisConn come Dictionary /// /// /// diff --git a/MP.Data/Services/MonDataFeeder.cs b/MP.Data/Services/MonDataFeeder.cs index 97971dae..15c151a9 100644 --- a/MP.Data/Services/MonDataFeeder.cs +++ b/MP.Data/Services/MonDataFeeder.cs @@ -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(); - } - /// /// Impostazione forzata timer refresh /// @@ -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 diff --git a/MP.Data/Services/OrderDataSrv.cs b/MP.Data/Services/OrderDataSrv.cs index fc6ab539..3461a60e 100644 --- a/MP.Data/Services/OrderDataSrv.cs +++ b/MP.Data/Services/OrderDataSrv.cs @@ -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 /// /// Classe accesso dati ordini /// - 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? result = new List(); - // 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; - } - /// /// Elenco ODL filtrati x articolo e macchina /// @@ -119,7 +103,7 @@ namespace MP.Data.Services Stopwatch sw = new Stopwatch(); sw.Start(); List? result = new List(); - // 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 - /// - /// Oggetto per connessione a REDIS - /// - protected ConnectionMultiplexer redisConn = null!; + protected override void Dispose(bool disposing) + { + if (!_disposed) + { + if (disposing) + { + // Free managed resources here + dbController.Dispose(); + } - /// - /// Oggetto DB redis da impiegare x chiamate R/W - /// - 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 diff --git a/MP.Data/Services/SharedMemService.cs b/MP.Data/Services/SharedMemService.cs index aa64a597..6609ecc1 100644 --- a/MP.Data/Services/SharedMemService.cs +++ b/MP.Data/Services/SharedMemService.cs @@ -9,24 +9,17 @@ namespace MP.Data.Services { public class SharedMemService : BaseServ { + #region Public Constructors + /// /// Init servizio TAB /// /// - public SharedMemService(IConfiguration configuration) : base(configuration) + public SharedMemService(IConfiguration configuration, IConnectionMultiplexer redConn) : base(configuration, redConn) { } - #region Private Fields - - private static Logger Log = LogManager.GetCurrentClassLogger(); - - /// - /// Oggetto vocabolario x uso continuo traduzione - /// - private List ObjVocabolario = new List(); - - #endregion Private Fields + #endregion Public Constructors #region Public Properties @@ -60,16 +53,16 @@ namespace MP.Data.Services /// public Dictionary DictMacchine { get; set; } = new Dictionary(); - /// - /// Dizionario macchine con info multi(int) - /// - public Dictionary DictMacchMulti { get; set; } = new Dictionary(); - /// /// Dizionario macchine con info manual(bool) /// public Dictionary DictMacchManual { get; set; } = new Dictionary(); + /// + /// Dizionario macchine con info multi(int) + /// + public Dictionary DictMacchMulti { get; set; } = new Dictionary(); + /// /// Dizionario Menu /// @@ -106,7 +99,7 @@ namespace MP.Data.Services public List ListStati { get; set; } = new List(); /// - /// Lista completa stati + /// Lista completa lemmi e traduzioni vocabolario /// public List ListVocab { get; set; } = new List(); @@ -117,12 +110,6 @@ namespace MP.Data.Services #endregion Public Properties - #region Private Properties - - private List AllMenuData { get; set; } = new List(); - - #endregion Private Properties - #region Public Methods /// @@ -130,6 +117,7 @@ namespace MP.Data.Services /// public void ClearCache() { +#if false DictMacchine = new Dictionary(); DictMacchMulti = new Dictionary(); DictMenu = new Dictionary>(); @@ -138,6 +126,22 @@ namespace MP.Data.Services DictEventi = new Dictionary(); DictStati = new Dictionary(); DictVocab = new Dictionary(); +#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 AllMenuData { get; set; } = new List(); + + #endregion Private Properties } } \ No newline at end of file diff --git a/MP.Data/Services/StatusData.cs b/MP.Data/Services/StatusData.cs index afdece54..93594364 100644 --- a/MP.Data/Services/StatusData.cs +++ b/MP.Data/Services/StatusData.cs @@ -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!; /// /// Dizionario dei tag configurati per IOB @@ -85,7 +85,7 @@ namespace MP.Data.Services Stopwatch sw = new Stopwatch(); sw.Start(); List? result = new List(); - // 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); } /// @@ -173,7 +170,7 @@ namespace MP.Data.Services string source = "DB"; sw.Start(); List? result = new List(); - // 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? result = new List(); - // 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? result = new List(); - // cerco in redis... + // cerco in redisConn... RedisValue rawData = redisDb.StringGet(Constants.redisMseKey); if (rawData.HasValue && !forceDb) { @@ -353,9 +350,8 @@ namespace MP.Data.Services /// /// Oggetto per connessione a REDIS /// - protected ConnectionMultiplexer redisConn = null!; + protected IConnectionMultiplexer redisConn = null!; - //ISubscriber sub = redis.GetSubscriber(); /// /// Oggetto DB redis da impiegare x chiamate R/W /// @@ -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; /// /// Cache breve durata @@ -398,7 +420,7 @@ namespace MP.Data.Services #region Private Methods /// - /// Esegue flush memoria redis dato pattern + /// Esegue flush memoria redisConn dato pattern /// /// /// diff --git a/MP.Data/Services/TabDataFeeder.cs b/MP.Data/Services/TabDataFeeder.cs index 7189b7d8..25b1633c 100644 --- a/MP.Data/Services/TabDataFeeder.cs +++ b/MP.Data/Services/TabDataFeeder.cs @@ -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); } /// @@ -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 diff --git a/MP.Data/Services/TabDataService.cs b/MP.Data/Services/TabDataService.cs index de1e6e47..e144f6a1 100644 --- a/MP.Data/Services/TabDataService.cs +++ b/MP.Data/Services/TabDataService.cs @@ -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 /// /// - 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? result = new List(); - // 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? result = new List(); - // 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? result = new List(); - // 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? result = new List(); - // 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? result = new List(); - // 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 result = new List(); 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? result = new List(); - // 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); } /// @@ -700,7 +710,7 @@ namespace MP.Data.Services Stopwatch sw = new Stopwatch(); sw.Start(); List? result = new List(); - // 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 result = new List(); - // 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 result = new List(); - // 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? result = new List(); - // 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 - /// - /// Recupero info IOB x TAB (da info registrate IOB-WIN--> MP-IO) - /// - /// - /// - 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($"{rawData}"); - source = "REDIS"; - } - else - { - Log.Error($"Errore: non trovato valore 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 | IdxMacchina: {IdxMacchina}"); - } - sw.Stop(); - Log.Debug($"IobInfo per {IdxMacchina} | {source} | {sw.Elapsed.TotalMilliseconds}ms"); - return result; - } -#endif - /// /// Recupero info IOB x TAB (da info registrate IOB-WIN--> MP-IO) /// @@ -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? result = new List(); - // 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? result = new List(); - // 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 result = new List(); - // 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 result = new List(); - // 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 result = new List(); - // 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? result = new List(); - // 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 - /// - /// Recupero info Machine-IOB x TAB (da info registrate IOB-WIN --> MP-IO) - /// - /// - /// - public Dictionary MachIobConf(string IdxMacchina) - { - string source = "NA"; - Stopwatch sw = new Stopwatch(); - sw.Start(); - Dictionary result = new Dictionary(); - // 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(); - Log.Debug($"Init valore default MachIobConf | IdxMacchina: {IdxMacchina}"); - } - sw.Stop(); - Log.Debug($"MachIobConf per {IdxMacchina} | {source} | {sw.Elapsed.TotalMilliseconds}ms"); - return result; - } - - /// - /// Recupero Conf Yaml Machine-IOB - /// - /// - /// - 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 - /// /// Restitusice elenco KVP dei TASK SALVATI (da passare a IOB-WIN) per l'impianto indicato /// @@ -1707,7 +1611,7 @@ namespace MP.Data.Services { // hard coded dimensione vettore DatiMacchine Dictionary answ = new Dictionary(); - // 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? result = new List(); - // 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 result = new List(); - // 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? result = new List(); - // 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 result = new List(); - // 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? result = new List(); - // 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? result = new List(); - // 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? result = new List(); - // 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? result = new List(); - // 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? result = new List(); - // 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? result = new List(); - // 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? result = new List(); - // 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? result = new List(); - // 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? result = new List(); - // 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? result = new List(); - // 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 /// /// Intera vista v_MSFD /// - /// forza rilettura + save su redis + /// forza rilettura + save su redisConn /// public async Task> VMSFDGetAll(bool doForce = false) { @@ -3765,7 +3669,7 @@ namespace MP.Data.Services Stopwatch sw = new Stopwatch(); sw.Start(); List result = new List(); - // 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? result = new List(); - // 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? result = new List(); - // 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? result = new List(); - // 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? result = new List(); - // 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? result = new List(); - // 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? result = new List(); - // 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 = ""; - - /// - /// Oggetto per connessione a REDIS - /// - protected ConnectionMultiplexer redisConn = null!; - - /// - /// Oggetto DB redis da impiegare x chiamate R/W - /// - protected IDatabase redisDb = null!; - #endregion Protected Fields #region Protected Properties @@ -4092,7 +3984,7 @@ namespace MP.Data.Services #region Private Methods /// - /// Esegue flush memoria redis dato pattern, metodo sincrono + /// Esegue flush memoria redisConn dato pattern, metodo sincrono /// /// /// @@ -4120,7 +4012,7 @@ namespace MP.Data.Services } /// - /// Esegue flush memoria redis dato pattern in async + /// Esegue flush memoria redisConn dato pattern in async /// /// /// @@ -4166,7 +4058,7 @@ namespace MP.Data.Services { // hard coded dimensione vettore DatiMacchine Dictionary answ = new Dictionary(); - // ORA recupero da memoria redis... + // ORA recupero da memoria redisConn... try { var currKey = (RedisKey)exeTaskHash(idxMacchina); @@ -4227,7 +4119,7 @@ namespace MP.Data.Services } /// - /// Recupero HashSet redis come Dictionary + /// Recupero HashSet redisConn come Dictionary /// /// /// diff --git a/MP.Data/Services/TranslateSrv.cs b/MP.Data/Services/TranslateSrv.cs index e1309c26..7f61465d 100644 --- a/MP.Data/Services/TranslateSrv.cs +++ b/MP.Data/Services/TranslateSrv.cs @@ -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 /// /// Classe accesso processi traduzione /// - 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? result = new List(); - // 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; - } - /// /// Pulizia cache Redis (tutta) /// @@ -135,7 +122,7 @@ namespace MP.Data.Services Stopwatch sw = new Stopwatch(); sw.Start(); List? result = new List(); - // 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? result = new List(); - // 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 /// protected static Dictionary DictVocab = new Dictionary(); - /// - /// Oggetto per connessione a REDIS - /// - protected ConnectionMultiplexer redisConn = null!; - - /// - /// Oggetto DB redis da impiegare x chiamate R/W - /// - 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 } /// - /// Esegue flush memoria redis dato pattern + /// Esegue flush memoria redisConn dato pattern /// /// /// diff --git a/MP.TaskMan/Models/TaskExecModel.cs b/MP.TaskMan/Models/TaskExecModel.cs index 8a1c9332..eba64519 100644 --- a/MP.TaskMan/Models/TaskExecModel.cs +++ b/MP.TaskMan/Models/TaskExecModel.cs @@ -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 diff --git a/MP.TaskMan/Models/TaskListModel.cs b/MP.TaskMan/Models/TaskListModel.cs index f27cfff4..b402a2e0 100644 --- a/MP.TaskMan/Models/TaskListModel.cs +++ b/MP.TaskMan/Models/TaskListModel.cs @@ -1,8 +1,5 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using System.Drawing.Printing; using static MP.TaskMan.Objects.Enums; #nullable disable diff --git a/MP.TaskMan/Models/TaskResultModel.cs b/MP.TaskMan/Models/TaskResultModel.cs index bd5534ba..85fcf6d3 100644 --- a/MP.TaskMan/Models/TaskResultModel.cs +++ b/MP.TaskMan/Models/TaskResultModel.cs @@ -1,5 +1,4 @@ -using System.ComponentModel.DataAnnotations; -using System.ComponentModel.DataAnnotations.Schema; +using System.ComponentModel.DataAnnotations.Schema; #nullable disable // diff --git a/MP.TaskMan/Services/TaskService.cs b/MP.TaskMan/Services/TaskService.cs index e55c55a1..ae542b06 100644 --- a/MP.TaskMan/Services/TaskService.cs +++ b/MP.TaskMan/Services/TaskService.cs @@ -28,7 +28,7 @@ namespace MP.TaskMan.Services { _configuration = configuration; - // setup compoenti REDIS + // setup componenti REDIS redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis")); redisDb = redisConn.GetDatabase();