diff --git a/LiMan.Api/Resources/ChangeLog.html b/LiMan.Api/Resources/ChangeLog.html
index ae5f198..06e5f24 100644
--- a/LiMan.Api/Resources/ChangeLog.html
+++ b/LiMan.Api/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
License Manager
- Versione: 2.1.2512.0316
+ Versione: 2.1.2512.0317
Note di rilascio:
-
diff --git a/LiMan.Api/Resources/VersNum.txt b/LiMan.Api/Resources/VersNum.txt
index d9cf67f..df42a90 100644
--- a/LiMan.Api/Resources/VersNum.txt
+++ b/LiMan.Api/Resources/VersNum.txt
@@ -1 +1 @@
-2.1.2512.0316
+2.1.2512.0317
diff --git a/LiMan.Api/Resources/manifest.xml b/LiMan.Api/Resources/manifest.xml
index 59dddb7..7f20c0e 100644
--- a/LiMan.Api/Resources/manifest.xml
+++ b/LiMan.Api/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 2.1.2512.0316
+ 2.1.2512.0317
https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.UI.zip
https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html
false
diff --git a/LiMan.DB/Controllers/DbController.cs b/LiMan.DB/Controllers/DbController.cs
index aa627bd..8afd7b0 100644
--- a/LiMan.DB/Controllers/DbController.cs
+++ b/LiMan.DB/Controllers/DbController.cs
@@ -16,6 +16,7 @@ using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
+using System.Threading.Channels;
using System.Threading.Tasks;
using static Core.Enum;
@@ -32,8 +33,6 @@ namespace LiMan.DB.Controllers
#endregion Public Constructors
- #region Public Methods
-
#if false
///
/// Upsert record applicativo
@@ -74,9 +73,11 @@ namespace LiMan.DB.Controllers
}
}
return fatto;
- }
+ }
#endif
+ #region Public Methods
+
///
/// Verifica se una applcazione abbia record correlati...
///
@@ -255,27 +256,6 @@ namespace LiMan.DB.Controllers
return fatto;
}
- ///
- /// Lista attivazioni x licenza
- ///
- ///
- ///
- public List AttivazioniGetByLic(int idxLic)
- {
- List dbResult = new List();
- using (LMDbContext localDbCtx = new LMDbContext(_configuration))
- {
- DateTime oggi = DateTime.Today;
- var rawRes = localDbCtx
- .DbSetSubLicenze
- .Where(x => x.IdxLic == idxLic)
- .OrderBy(o => o.VetoUnlock)
- .ToList();
- dbResult = rawRes != null ? rawRes : dbResult;
- }
- return dbResult;
- }
-
///
/// Lista attivazioni dati cod identificativi CodImp e AppKey
///
@@ -297,6 +277,27 @@ namespace LiMan.DB.Controllers
return dbResult;
}
+ ///
+ /// Lista attivazioni x licenza
+ ///
+ ///
+ ///
+ public List AttivazioniGetByLic(int idxLic)
+ {
+ List dbResult = new List();
+ using (LMDbContext localDbCtx = new LMDbContext(_configuration))
+ {
+ DateTime oggi = DateTime.Today;
+ var rawRes = localDbCtx
+ .DbSetSubLicenze
+ .Where(x => x.IdxLic == idxLic)
+ .OrderBy(o => o.VetoUnlock)
+ .ToList();
+ dbResult = rawRes != null ? rawRes : dbResult;
+ }
+ return dbResult;
+ }
+
///
/// Elimino le licenze con veto scaduto
///
@@ -741,6 +742,90 @@ namespace LiMan.DB.Controllers
return answ;
}
+ ///
+ /// Verifica e ripulisce eventuali vecchie SubLic rimaste senza riferimento
+ ///
+ ///
+ ///
+ public async Task CheckCleanOldSubLic(InstalledReleasesModel upRec)
+ {
+ bool fatto = false;
+
+ using (LMDbContext localDbCtx = new LMDbContext(_configuration))
+ {
+ // cerco idxSublic da info...
+ SubLicenzaModel recIst = localDbCtx
+ .DbSetSubLicenze
+ .FirstOrDefault(x => x.Chiave == upRec.AppKey);
+ // se non fosse giusto CodImpiego e veto scaduto...
+ if (!recIst.CodImpiego.Equals(upRec.CodApp))
+ {
+ // log disuguaglianza chiave
+ Log.Info($"CheckOldSubLic | Mismatch licenza SubLic | CodApp: {upRec.CodApp} | AppKey: {upRec.AppKey} | App.CodImp: {upRec.CodImp} | Db.CodImp: {recIst.CodImpiego}");
+
+ // aggiorno CodImp se non bloccato...
+ if (recIst.VetoUnlock <= DateTime.Now)
+ {
+ // salvo record variazione licenza
+ LogCodImp recLogCodImp = new LogCodImp()
+ {
+ IdxLic = recIst.IdxLic,
+ IdxSubLic = recIst.IdxSubLic,
+ CodApp = upRec.CodApp,
+ CodImpOld = recIst.CodImpiego,
+ CodImpNew = upRec.CodImp,
+ DtMod = DateTime.Now
+ };
+ localDbCtx
+ .DbSetLogCodImp
+ .Add(recLogCodImp);
+
+ // elimino righe vecchie
+ var list2rem = localDbCtx
+ .DbSetInstallRel
+ .Where(x => x.CodApp == upRec.CodApp && x.CodImp == recIst.CodImpiego && x.AppKey == upRec.AppKey)
+ .ToList();
+ if (list2rem != null && list2rem.Count > 0)
+ {
+ // loggo i record che vado ad eliminare
+ var sb = new StringBuilder();
+ sb.AppendLine("---------- Eliminazione SubLic scadute ----------");
+ foreach (var item in list2rem)
+ {
+ sb.AppendLine($"Eliminazione SubLic scaduta | IdxInstall: {item.IdxInstall} | CodImp: {item.CodImp} | Vers: {item.VersNum} | NumImp: {item.NumImp} | LastCheck: {item.DtCheck}");
+ }
+ sb.AppendLine("---------- Fine Elenco ----------");
+ Log.Info(sb.ToString());
+
+ // elimino
+ localDbCtx
+ .DbSetInstallRel
+ .RemoveRange(list2rem);
+ }
+
+ // registro nuovo CodImpiego
+ recIst.CodImpiego = upRec.CodImp;
+ localDbCtx.Entry(recIst).State = EntityState.Modified;
+ // salvataggio!
+ try
+ {
+ // salvo
+ var res = await localDbCtx.SaveChangesAsync();
+ fatto = res != 0;
+ }
+ catch (Exception ex)
+ {
+ Log.Error($"Eccezione in CheckOldSubLic | IdxLic: {upRec.IdxLic} | CodApp: {upRec.CodApp} | VersNum: {upRec.VersNum} {Environment.NewLine}{ex}");
+ }
+
+ // log update codImpiego
+ Log.Info($"CheckOldSubLic | Aggiornamento SubLicenza | CodImp Aggiornato | CodApp: {upRec.CodApp} | AppKey: {upRec.AppKey} | App.CodImp: {upRec.CodImp} | Db.CodImp: {recIst.CodImpiego}");
+ }
+ }
+ }
+ return fatto;
+ }
+
public bool DbForceMigrate()
{
bool answ = false;
@@ -1571,7 +1656,6 @@ namespace LiMan.DB.Controllers
.DbSetInstallRelHist
.Add(item);
}
-
}
// salvataggio!
try
@@ -1620,7 +1704,7 @@ namespace LiMan.DB.Controllers
if (currRec.IdxSubLic == 0)
{
// cerco idxSublic da info...
- var recIst = localDbCtx
+ SubLicenzaModel recIst = localDbCtx
.DbSetSubLicenze
.FirstOrDefault(x => x.Chiave == upRec.AppKey && x.CodImpiego == upRec.CodImp);
if (recIst != null)
diff --git a/LiMan.DB/Services/CommonDataServices.cs b/LiMan.DB/Services/CommonDataServices.cs
index dac3860..56dbb4b 100644
--- a/LiMan.DB/Services/CommonDataServices.cs
+++ b/LiMan.DB/Services/CommonDataServices.cs
@@ -1217,6 +1217,11 @@ namespace LiMan.DB.Services
public bool InstallRelUpsert(InstalledReleasesModel upRec)
{
bool fatto = dbController.InstallRelUpsert(upRec);
+ // se ok fa verifica sublicenze...
+ if (fatto)
+ {
+ dbController.CheckCleanOldSubLic(upRec);
+ }
return fatto;
}
diff --git a/LiMan.Transfer/Resources/ChangeLog.html b/LiMan.Transfer/Resources/ChangeLog.html
index 98118a2..b2aaa59 100644
--- a/LiMan.Transfer/Resources/ChangeLog.html
+++ b/LiMan.Transfer/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
License Manager
-
Versione: 2.1.2512.0316
+ Versione: 2.1.2512.0317
Note di rilascio:
diff --git a/LiMan.Transfer/Resources/VersNum.txt b/LiMan.Transfer/Resources/VersNum.txt
index d9cf67f..df42a90 100644
--- a/LiMan.Transfer/Resources/VersNum.txt
+++ b/LiMan.Transfer/Resources/VersNum.txt
@@ -1 +1 @@
-2.1.2512.0316
+2.1.2512.0317
diff --git a/LiMan.Transfer/Resources/manifest.xml b/LiMan.Transfer/Resources/manifest.xml
index 0158efa..99f546e 100644
--- a/LiMan.Transfer/Resources/manifest.xml
+++ b/LiMan.Transfer/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 2.1.2512.0316
+ 2.1.2512.0317
https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.Transfer.zip
https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html
false
diff --git a/LiMan.UI/LiMan.UI.csproj b/LiMan.UI/LiMan.UI.csproj
index a53d873..8b1499a 100644
--- a/LiMan.UI/LiMan.UI.csproj
+++ b/LiMan.UI/LiMan.UI.csproj
@@ -2,7 +2,7 @@
net6.0
- 2.1.2512.0316
+ 2.1.2512.0317
LiMan.UI
LiMan.UI
diff --git a/LiMan.UI/Resources/ChangeLog.html b/LiMan.UI/Resources/ChangeLog.html
index ae5f198..06e5f24 100644
--- a/LiMan.UI/Resources/ChangeLog.html
+++ b/LiMan.UI/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
License Manager
-
Versione: 2.1.2512.0316
+ Versione: 2.1.2512.0317
Note di rilascio:
-
diff --git a/LiMan.UI/Resources/VersNum.txt b/LiMan.UI/Resources/VersNum.txt
index d9cf67f..df42a90 100644
--- a/LiMan.UI/Resources/VersNum.txt
+++ b/LiMan.UI/Resources/VersNum.txt
@@ -1 +1 @@
-2.1.2512.0316
+2.1.2512.0317
diff --git a/LiMan.UI/Resources/manifest.xml b/LiMan.UI/Resources/manifest.xml
index 59dddb7..7f20c0e 100644
--- a/LiMan.UI/Resources/manifest.xml
+++ b/LiMan.UI/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 2.1.2512.0316
+ 2.1.2512.0317
https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.UI.zip
https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html
false