diff --git a/Core/DTO/AuthDataDTO.cs b/Core/DTO/AuthDataDTO.cs new file mode 100644 index 0000000..c88261d --- /dev/null +++ b/Core/DTO/AuthDataDTO.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Core.DTO +{ + // + // This is here so CodeMaid doesn't reorganize this document + // + public class AuthDataDTO + { + /// + /// Master Key + /// + public string MastKey { get; set; } = ""; + + /// + /// Codice Impiego istanza SubLic + /// + public string CodImp { get; set; } = ""; + + /// + /// Chiave SubLic + /// + public string AppKey { get; set; } = ""; + + /// + /// Verifica complessiva validità richiesta: + /// CodApp presente + /// - MainKey oppure CodImp + AppKey presenti + /// + [NotMapped] + public virtual bool IsValid + { + get => (!string.IsNullOrEmpty(MastKey) || (!string.IsNullOrEmpty(CodImp) && !string.IsNullOrEmpty(AppKey))); + } + } +} diff --git a/Core/DTO/ManDeclareDTO.cs b/Core/DTO/ManDeclareDTO.cs new file mode 100644 index 0000000..6c9d951 --- /dev/null +++ b/Core/DTO/ManDeclareDTO.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Core.DTO +{ + // + // This is here so CodeMaid doesn't reorganize this document + // + public class ManDeclareDTO : AuthDataDTO + { + /// + /// Elenco delle CodApp Gestite + /// + public List ListCodApp { get; set; } = new List(); + + /// + /// Verifica complessiva validità richiesta: + /// CodApp presente + /// - MainKey oppure CodImp + AppKey presenti + /// + [NotMapped] + public override bool IsValid + { + get => (ListCodApp != null && ListCodApp.Count > 0) && (!string.IsNullOrEmpty(MastKey) || (!string.IsNullOrEmpty(CodImp) && !string.IsNullOrEmpty(AppKey))); + } + } +} diff --git a/Core/DTO/ReleaseReqDTO.cs b/Core/DTO/ReleaseReqDTO.cs index b0b2d6e..c9f47ab 100644 --- a/Core/DTO/ReleaseReqDTO.cs +++ b/Core/DTO/ReleaseReqDTO.cs @@ -11,28 +11,13 @@ namespace Core.DTO // // This is here so CodeMaid doesn't reorganize this document // - public class ReleaseReqDTO + public class ReleaseReqDTO : AuthDataDTO { /// /// CodApp Richiesta /// public string CodApp { get; set; } = ""; - /// - /// Master Key - /// - public string MastKey { get; set; } = ""; - - /// - /// Codice Impiego istanza SubLic - /// - public string CodImp { get; set; } = ""; - - /// - /// Chiave SubLic - /// - public string AppKey { get; set; } = ""; - /// /// Versione minima richiesta /// @@ -54,7 +39,7 @@ namespace Core.DTO /// - MainKey oppure CodImp + AppKey presenti /// [NotMapped] - public bool IsValid + public override bool IsValid { get => !string.IsNullOrEmpty(CodApp) && (!string.IsNullOrEmpty(MastKey) || (!string.IsNullOrEmpty(CodImp) && !string.IsNullOrEmpty(AppKey))); } diff --git a/LiMan.Api/Controllers/ReleaseController.cs b/LiMan.Api/Controllers/ReleaseController.cs index 9e4bd5b..e383585 100644 --- a/LiMan.Api/Controllers/ReleaseController.cs +++ b/LiMan.Api/Controllers/ReleaseController.cs @@ -142,7 +142,7 @@ namespace LiMan.APi.Controllers NumImp = CurrRequest.NumImp, VersNum = CurrRequest.VersMin }; - dataService.InstallRelUpsert(checkRec); + dataService.InstallRelUpsert(checkRec); // registro infine chiamata await dataService.recordCall(CurrRequest.CodApp, CurrRequest.CodApp, $"POST:api/release/getfilt/ | {CurrRequest.MastKey} | {CurrRequest.CodImp} | {CurrRequest.CodApp}"); } @@ -245,6 +245,24 @@ namespace LiMan.APi.Controllers return result; } + /// + /// Conferma quale sia l'elenco delle app gestite POST api/release/setmanaged + /// + /// Obj ManDeclareDTO con chiavi + elenco app gestite (x eliminare altre) + /// Numero di record eliminati + [HttpPost("setmanaged")] + public async Task SetManaged([FromBody] ManDeclareDTO ManagedApp) + { + int result = 0; + // verifica validità richiesta... + if (CheckReqKeys(ManagedApp)) + { + result = dataService.InstallRelClean(ManagedApp.CodImp, ManagedApp.AppKey, ManagedApp.ListCodApp); + } + await Task.Delay(1); + return result; + } + #endregion Public Methods #region Protected Properties @@ -284,6 +302,23 @@ namespace LiMan.APi.Controllers return answ; } + /// + /// Verifica validità richiesta + /// - dati presenti in chiamata + /// - combinazioni CodApp + chiavi valide/attive + /// + /// + /// + private bool CheckReqKeys(ManDeclareDTO currReq) + { + bool answ = currReq.IsValid; + if (answ) + { + // verifica validità chiavi... TBD!!! + } + return answ; + } + #endregion Private Methods } } \ No newline at end of file diff --git a/LiMan.Api/Data/ApiDataService.cs b/LiMan.Api/Data/ApiDataService.cs index 51d0643..9bd46f8 100644 --- a/LiMan.Api/Data/ApiDataService.cs +++ b/LiMan.Api/Data/ApiDataService.cs @@ -609,6 +609,18 @@ namespace LiMan.APi.Data return answ; } + /// + /// Effettua pulizia record registrazione InstalledRelease eliminando quelli non presenti in elenco + /// + /// CodImpiego + /// Chiave App + /// Elenco app gestite (=da tenere) + /// Num rec eliminati + public int InstallRelClean(string CodImp, string AppKey, List ListCodApp) + { + return dbController.InstallRelClean(CodImp, AppKey, ListCodApp); + } + /// /// Registro su DB il record della licenza attuale relativo alla richiesta di verifica licenza ricevuta /// @@ -924,7 +936,7 @@ namespace LiMan.APi.Data } /// - /// Registro su DB le statistiche delle chiavi in elenco, resettando i vari contatori quando fatto + /// Registro su DB le statistiche delle chiavi in elenco, resettando i vari contatori quando res /// /// Elenco key nel formato {rKeySampleVars}:{codInst}:{codApp}:{targetUrl} public async Task saveStatsToDb(List keyList) diff --git a/LiMan.Api/Resources/ChangeLog.html b/LiMan.Api/Resources/ChangeLog.html index d837d2e..17f836f 100644 --- a/LiMan.Api/Resources/ChangeLog.html +++ b/LiMan.Api/Resources/ChangeLog.html @@ -1,6 +1,6 @@ License Manager -

Versione: 2.1.2501.1319

+

Versione: 2.1.2501.1416


Note di rilascio:
  • diff --git a/LiMan.Api/Resources/VersNum.txt b/LiMan.Api/Resources/VersNum.txt index 814ca86..306c67c 100644 --- a/LiMan.Api/Resources/VersNum.txt +++ b/LiMan.Api/Resources/VersNum.txt @@ -1 +1 @@ -2.1.2501.1319 +2.1.2501.1416 diff --git a/LiMan.Api/Resources/manifest.xml b/LiMan.Api/Resources/manifest.xml index 1b6b25d..8e95456 100644 --- a/LiMan.Api/Resources/manifest.xml +++ b/LiMan.Api/Resources/manifest.xml @@ -1,6 +1,6 @@ - 2.1.2501.1319 + 2.1.2501.1416 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 4c25d44..a6aa9bb 100644 --- a/LiMan.DB/Controllers/DbController.cs +++ b/LiMan.DB/Controllers/DbController.cs @@ -1401,6 +1401,59 @@ namespace LiMan.DB.Controllers return dbResult; } + /// + /// Effettua pulizia record registrazione InstalledRelease eliminando quelli non presenti in elenco + /// + /// CodImpiego + /// Chiave App + /// Elenco app gestite (=da tenere) + /// Num rec eliminati + public int InstallRelClean(string CodImp, string AppKey, List ListCodApp) + { + int numDel = 0; + using (LMDbContext localDbCtx = new LMDbContext(_configuration)) + { + // cerco tutti i record associati con le chiavi richieste + List listRec = localDbCtx + .DbSetInstallRel + .Where(x => x.CodImp == CodImp && x.AppKey == AppKey) + .ToList(); + List list2Del = new List(); + // se ho risultati + if (listRec != null && listRec.Count > 0) + { + // elimino da questo elenco quelli che appartengono all'elenco ricevuto dei dati gestiti + foreach (var item in listRec) + { + if (!ListCodApp.Contains(item.CodApp)) + { + list2Del.Add(item); + } + } + } + + // se ho record da eliminare procedo! + if (list2Del.Count > 0) + { + // altrimenti aggiungo... + localDbCtx + .DbSetInstallRel + .RemoveRange(list2Del); + // salvataggio! + try + { + // salvo + numDel = localDbCtx.SaveChanges(); + } + catch (Exception ex) + { + Log.Error($"Eccezoine in InstallRelClean{Environment.NewLine}{ex}"); + } + } + } + return numDel; + } + /// /// Update/insert record registrazione InstalledRelease applicativo /// @@ -1556,7 +1609,6 @@ namespace LiMan.DB.Controllers .DbSetLicenze .ToList(); - // recupero releases var listAllVers = localDbCtx .DbSetReleases @@ -1642,39 +1694,6 @@ namespace LiMan.DB.Controllers return answ; } - /// - /// Esegue conteggio numero versioni in elenco - /// - /// - /// - protected Dictionary CountRelVers(List listRel) - { - Dictionary answ = new Dictionary(); - if (listRel != null && listRel.Count > 0) - { - answ = listRel - .GroupBy(x => x.VersNumInstall) - .ToDictionary(g => g.Key, g => g.Count()); - } - return answ; - } - /// - /// Esegue conteggio numero versioni in elenco - /// - /// - /// - protected Dictionary CountRelStatus(List listRel) - { - Dictionary answ = new Dictionary(); - if (listRel != null && listRel.Count > 0) - { - answ = listRel - .GroupBy(x => x.UpToDateStatus) - .ToDictionary(g => g.Key, g => g.Count()); - } - return answ; - } - /// /// Effettua refresh del payload della licenza dato info + enigma generato dal client /// @@ -2449,6 +2468,44 @@ namespace LiMan.DB.Controllers #endregion Public Methods + #region Protected Methods + + /// + /// Esegue conteggio numero versioni in elenco + /// + /// + /// + protected Dictionary CountRelStatus(List listRel) + { + Dictionary answ = new Dictionary(); + if (listRel != null && listRel.Count > 0) + { + answ = listRel + .GroupBy(x => x.UpToDateStatus) + .ToDictionary(g => g.Key, g => g.Count()); + } + return answ; + } + + /// + /// Esegue conteggio numero versioni in elenco + /// + /// + /// + protected Dictionary CountRelVers(List listRel) + { + Dictionary answ = new Dictionary(); + if (listRel != null && listRel.Count > 0) + { + answ = listRel + .GroupBy(x => x.VersNumInstall) + .ToDictionary(g => g.Key, g => g.Count()); + } + return answ; + } + + #endregion Protected Methods + #region Private Fields private static IConfiguration _configuration; diff --git a/LiMan.Transfer/Resources/ChangeLog.html b/LiMan.Transfer/Resources/ChangeLog.html index a4296a8..3e08172 100644 --- a/LiMan.Transfer/Resources/ChangeLog.html +++ b/LiMan.Transfer/Resources/ChangeLog.html @@ -1,6 +1,6 @@ License Manager -

    Versione: 2.1.2501.1319

    +

    Versione: 2.1.2501.1416


    Note di rilascio:
      diff --git a/LiMan.Transfer/Resources/VersNum.txt b/LiMan.Transfer/Resources/VersNum.txt index 814ca86..306c67c 100644 --- a/LiMan.Transfer/Resources/VersNum.txt +++ b/LiMan.Transfer/Resources/VersNum.txt @@ -1 +1 @@ -2.1.2501.1319 +2.1.2501.1416 diff --git a/LiMan.Transfer/Resources/manifest.xml b/LiMan.Transfer/Resources/manifest.xml index 2caa934..53cb01b 100644 --- a/LiMan.Transfer/Resources/manifest.xml +++ b/LiMan.Transfer/Resources/manifest.xml @@ -1,6 +1,6 @@ - 2.1.2501.1319 + 2.1.2501.1416 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 fc7de75..1b1ebd1 100644 --- a/LiMan.UI/LiMan.UI.csproj +++ b/LiMan.UI/LiMan.UI.csproj @@ -2,7 +2,7 @@ net6.0 - 2.1.2501.1319 + 2.1.2501.1416 LiMan.UI LiMan.UI diff --git a/LiMan.UI/Resources/ChangeLog.html b/LiMan.UI/Resources/ChangeLog.html index d837d2e..17f836f 100644 --- a/LiMan.UI/Resources/ChangeLog.html +++ b/LiMan.UI/Resources/ChangeLog.html @@ -1,6 +1,6 @@ License Manager -

      Versione: 2.1.2501.1319

      +

      Versione: 2.1.2501.1416


      Note di rilascio:
      • diff --git a/LiMan.UI/Resources/VersNum.txt b/LiMan.UI/Resources/VersNum.txt index 814ca86..306c67c 100644 --- a/LiMan.UI/Resources/VersNum.txt +++ b/LiMan.UI/Resources/VersNum.txt @@ -1 +1 @@ -2.1.2501.1319 +2.1.2501.1416 diff --git a/LiMan.UI/Resources/manifest.xml b/LiMan.UI/Resources/manifest.xml index 1b6b25d..8e95456 100644 --- a/LiMan.UI/Resources/manifest.xml +++ b/LiMan.UI/Resources/manifest.xml @@ -1,6 +1,6 @@ - 2.1.2501.1319 + 2.1.2501.1416 https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.UI.zip https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html false