diff --git a/LiMan.Api/Controllers/AttivazioniController.cs b/LiMan.Api/Controllers/AttivazioniController.cs index 4cc5520..d2a0137 100644 --- a/LiMan.Api/Controllers/AttivazioniController.cs +++ b/LiMan.Api/Controllers/AttivazioniController.cs @@ -17,15 +17,16 @@ namespace LiMan.APi.Controllers [ApiController] public class AttivazioniController : ControllerBase { + #region Private Fields + /// /// Classe per logging /// private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); - /// - /// Dataservice x accesso DB - /// - protected ApiDataService _DataService { get; set; } + #endregion Private Fields + + #region Public Constructors /// /// Init generico @@ -37,6 +38,30 @@ namespace LiMan.APi.Controllers Log.Info("Avviata classe AttivazioniController"); } + #endregion Public Constructors + + #region Protected Properties + + /// + /// Dataservice x accesso DB + /// + protected ApiDataService _DataService { get; set; } + + #endregion Protected Properties + + #region Public Methods + + /// + /// Eliminazione di un set di attivazioni (SE SCADUTE) + /// + // DELETE api/attivazioni + [HttpDelete()] + public async Task Delete([FromBody] UserLicenseRequest CurrRequest) + { + bool done = await _DataService.AttivazioniDelete(CurrRequest.MasterKey, CurrRequest.ParamDict); + return done; + } + /// /// Recupero record di sub licenza (con chiavi anonimizzate) /// @@ -52,22 +77,6 @@ namespace LiMan.APi.Controllers return result; } - /// - /// Verifica recupero un record di sub licenza - /// - /// Licenza MASTER - /// Codice univoco impiego licenza - /// - // GET api/attivazioni/verifica/5 - [HttpGet("verifica")] - public async Task VerificaImpiego(string chiave, string CodImpiego) - { - DB.DTO.AttivazioneDTO result = new DB.DTO.AttivazioneDTO(); - var dbResult = await _DataService.AttivazioneSearch(chiave, CodImpiego, false); - result = (dbResult != null) ? dbResult : result; - return result; - } - /// /// Richiesta attivazione di una lista di chiavi di licenza sub /// @@ -85,19 +94,6 @@ namespace LiMan.APi.Controllers return currData; } - /// - /// Eliminazione di un attivazione (SE SCADUTA) - /// - /// Id della licenza SUB da eliminare - /// Licenza MASTER - // DELETE api/attivazioni/5 - [HttpDelete("{id}")] - public async Task Delete(int id, string chiave) - { - bool done = await _DataService.AttivazioniDelete(chiave, id); - return done; - } - /// /// Eliminazione di TUTTE le attivazioni SCADUTE /// @@ -110,14 +106,31 @@ namespace LiMan.APi.Controllers return done; } + /// + /// Verifica recupero un record di sub licenza + /// + /// Licenza MASTER + /// Codice univoco impiego licenza + /// + // GET api/attivazioni/verifica/5 + [HttpGet("verifica")] + public async Task VerificaImpiego(string chiave, string CodImpiego) + { + DB.DTO.AttivazioneDTO result = new DB.DTO.AttivazioneDTO(); + var dbResult = await _DataService.AttivazioneSearch(chiave, CodImpiego, false); + result = (dbResult != null) ? dbResult : result; + return result; + } + + #endregion Public Methods #if false // PUT api/attivazioni/5 [HttpPut("{id}")] public void Put(int id, [FromBody] string value) { - } + } #endif } -} +} \ No newline at end of file diff --git a/LiMan.Api/Data/ApiDataService.cs b/LiMan.Api/Data/ApiDataService.cs index 2e2990d..fed3d31 100644 --- a/LiMan.Api/Data/ApiDataService.cs +++ b/LiMan.Api/Data/ApiDataService.cs @@ -77,27 +77,27 @@ namespace LiMan.APi.Data return await Task.FromResult(dbResult); } + /// - /// Effettua registrazione (se possibile) delle licenze indicate dall'elenco codici di impiego indicati + /// Elenco licenze dato cliente /// - /// Codice Licenza Master - /// Elenco codici impiego (key) + valori in formato dizionari - /// Numero giorni x scadenza veto modifica + /// Licenza MASTER + /// Codice Impiego licenza + /// Indica se nascondere i dati sensibili /// - /// - public async Task AttivazioniTryAdd(string MasterKey, Dictionary ParamDict, int DayVeto) + public async Task AttivazioneSearch(string Chiave, string CodImpiego, bool HideData) { - bool taskDone = false; + DB.DTO.AttivazioneDTO dbResult = new DB.DTO.AttivazioneDTO(); Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); - taskDone = dbController.AttivazioniTryAdd(MasterKey, ParamDict, DayVeto); + dbResult = dbController.GetAttivazione(Chiave, CodImpiego, HideData); stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; - Log.Trace($"Effettuata scrittura + rilettura da DB per AttivazioniTryAdd: {ts.TotalMilliseconds} ms"); + Log.Trace($"Effettuata lettura da DB per AttivazioniSearch: {ts.TotalMilliseconds} ms"); - return await Task.FromResult(taskDone); + return await Task.FromResult(dbResult); } /// @@ -146,35 +146,13 @@ namespace LiMan.APi.Data return await Task.FromResult(dbResult); } - /// - /// Elenco licenze dato cliente - /// - /// Licenza MASTER - /// Codice Impiego licenza - /// Indica se nascondere i dati sensibili - /// - public async Task AttivazioneSearch(string Chiave, string CodImpiego, bool HideData) - { - DB.DTO.AttivazioneDTO dbResult = new DB.DTO.AttivazioneDTO(); - - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - - dbResult = dbController.GetAttivazione(Chiave, CodImpiego, HideData); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Trace($"Effettuata lettura da DB per AttivazioniSearch: {ts.TotalMilliseconds} ms"); - - return await Task.FromResult(dbResult); - } - /// /// Elimina un Attivaizone /// /// Licenza Master - /// ID della sub licenza da eliminare + /// Elenco delle attivazioni da eliminare /// - public async Task AttivazioniDelete(string MasterKey, int IdxSubLic) + public async Task AttivazioniDelete(string MasterKey, Dictionary ParamDict) { bool answ = false; @@ -184,7 +162,7 @@ namespace LiMan.APi.Data var licenza = dbController.GetLicenza(MasterKey); if (licenza != null) { - answ = dbController.AttivazioniDelete(IdxSubLic, MasterKey); + answ = dbController.AttivazioniDelete(ParamDict, MasterKey); } stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; @@ -192,6 +170,7 @@ namespace LiMan.APi.Data return await Task.FromResult(answ); } + /// /// Elimina attivaizoni con veto scaduto /// @@ -215,7 +194,29 @@ namespace LiMan.APi.Data return await Task.FromResult(answ); } - + + /// + /// Effettua registrazione (se possibile) delle licenze indicate dall'elenco codici di impiego indicati + /// + /// Codice Licenza Master + /// Elenco codici impiego (key) + valori in formato dizionari + /// Numero giorni x scadenza veto modifica + /// + /// + public async Task AttivazioniTryAdd(string MasterKey, Dictionary ParamDict, int DayVeto) + { + bool taskDone = false; + + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + + taskDone = dbController.AttivazioniTryAdd(MasterKey, ParamDict, DayVeto); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"Effettuata scrittura + rilettura da DB per AttivazioniTryAdd: {ts.TotalMilliseconds} ms"); + + return await Task.FromResult(taskDone); + } /// /// Dispose classe diff --git a/LiMan.Api/LiMan.APi.xml b/LiMan.Api/LiMan.APi.xml index c3a78e2..b02e3e6 100644 --- a/LiMan.Api/LiMan.APi.xml +++ b/LiMan.Api/LiMan.APi.xml @@ -44,17 +44,22 @@ Classe per logging - - - Dataservice x accesso DB - - Init generico + + + Dataservice x accesso DB + + + + + Eliminazione di un set di attivazioni (SE SCADUTE) + + Recupero record di sub licenza (con chiavi anonimizzate) @@ -62,6 +67,18 @@ Licenza MASTER + + + Richiesta attivazione di una lista di chiavi di licenza sub + + Obj Richiesta con licenza MASTER + Elenco codici impiego (key) + valori in formato dizionari + + + + Eliminazione di TUTTE le attivazioni SCADUTE + + Licenza MASTER + Verifica recupero un record di sub licenza @@ -70,25 +87,6 @@ Codice univoco impiego licenza - - - Richiesta attivazione di una lista di chiavi di licenza sub - - Obj Richiesta con licenza MASTER + Elenco codici impiego (key) + valori in formato dizionari - - - - Eliminazione di un attivazione (SE SCADUTA) - - Id della licenza SUB da eliminare - Licenza MASTER - - - - Eliminazione di TUTTE le attivazioni SCADUTE - - Licenza MASTER - Controller livello INSTALLAZIONI @@ -170,15 +168,14 @@ Indica se nascondere i dati sensibili - + - Effettua registrazione (se possibile) delle licenze indicate dall'elenco codici di impiego indicati + Elenco licenze dato cliente - Codice Licenza Master - Elenco codici impiego (key) + valori in formato dizionari - Numero giorni x scadenza veto modifica + Licenza MASTER + Codice Impiego licenza + Indica se nascondere i dati sensibili - @@ -196,21 +193,12 @@ Indica se nascondere i dati sensibili - - - Elenco licenze dato cliente - - Licenza MASTER - Codice Impiego licenza - Indica se nascondere i dati sensibili - - - + Elimina un Attivaizone Licenza Master - ID della sub licenza da eliminare + Elenco delle attivazioni da eliminare @@ -220,6 +208,16 @@ Licenza Master + + + Effettua registrazione (se possibile) delle licenze indicate dall'elenco codici di impiego indicati + + Codice Licenza Master + Elenco codici impiego (key) + valori in formato dizionari + Numero giorni x scadenza veto modifica + + + Dispose classe diff --git a/LiMan.Api/Properties/PublishProfiles/IIS01.pubxml.user b/LiMan.Api/Properties/PublishProfiles/IIS01.pubxml.user index ea4ea25..5551d00 100644 --- a/LiMan.Api/Properties/PublishProfiles/IIS01.pubxml.user +++ b/LiMan.Api/Properties/PublishProfiles/IIS01.pubxml.user @@ -7,6 +7,6 @@ by editing this MSBuild file. In order to learn more about this please visit htt AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAk75miMJLMkCTEelQutKpbwAAAAACAAAAAAADZgAAwAAAABAAAAA7RC2yFYQ+sbph7Gm3hrEMAAAAAASAAACgAAAAEAAAAFhL9j1HkRjMaqEESfncpZcYAAAAIMz57CMDX9ZLAPLwms1/yHQTf/r/v74FFAAAAB6WaNF8er6HZmelU4da+AsQFSC5 - True|2021-11-06T10:19:02.9085307Z;True|2021-11-06T11:18:28.0387848+01:00;True|2021-11-06T09:53:17.1717596+01:00;True|2021-10-21T17:47:07.5800856+02:00;True|2021-10-21T17:45:53.9877689+02:00;True|2021-10-21T17:45:26.3424924+02:00;True|2021-10-21T17:44:04.8901686+02:00;True|2021-10-21T17:12:38.0143120+02:00;True|2021-10-21T12:48:27.8969428+02:00;True|2021-10-21T12:45:17.7896250+02:00;True|2021-10-21T12:44:18.8941191+02:00;True|2021-10-21T08:48:23.1235907+02:00;True|2021-10-21T08:48:18.3291685+02:00;True|2021-10-15T11:33:23.1161895+02:00;True|2021-10-15T11:26:37.7646366+02:00;True|2021-10-15T11:26:08.9411561+02:00;True|2021-10-15T11:25:36.6377010+02:00;True|2021-10-15T11:25:15.7375383+02:00;True|2021-10-15T11:20:26.4607123+02:00;True|2021-10-15T11:13:33.8524245+02:00;False|2021-10-15T10:30:42.4253422+02:00;False|2021-10-15T10:27:43.8339493+02:00;False|2021-10-15T10:23:05.0864739+02:00;False|2021-10-15T10:22:43.2958457+02:00;False|2021-10-15T10:22:15.0954116+02:00;True|2021-10-15T10:15:10.5127570+02:00;False|2021-10-15T10:13:53.0299219+02:00;False|2021-10-15T08:58:38.3028788+02:00;False|2021-10-15T08:47:48.5789826+02:00;False|2021-10-14T19:32:56.5281204+02:00;False|2021-10-14T19:31:10.1629370+02:00;True|2021-05-26T19:49:30.0427896+02:00;False|2021-05-26T19:49:14.9065510+02:00;True|2021-05-25T17:48:33.3901785+02:00;True|2021-05-25T17:46:09.2063020+02:00;True|2021-05-25T17:42:47.8167539+02:00;True|2021-05-25T17:22:03.1877438+02:00;True|2021-05-25T17:21:05.1565775+02:00;True|2021-05-25T16:26:34.1426996+02:00;True|2021-05-25T16:14:28.2842402+02:00;True|2021-05-25T15:02:11.7131495+02:00; + True|2021-11-08T11:34:27.5881363Z;True|2021-11-08T12:34:19.3151235+01:00;True|2021-11-06T11:19:02.9085307+01:00;True|2021-11-06T11:18:28.0387848+01:00;True|2021-11-06T09:53:17.1717596+01:00;True|2021-10-21T17:47:07.5800856+02:00;True|2021-10-21T17:45:53.9877689+02:00;True|2021-10-21T17:45:26.3424924+02:00;True|2021-10-21T17:44:04.8901686+02:00;True|2021-10-21T17:12:38.0143120+02:00;True|2021-10-21T12:48:27.8969428+02:00;True|2021-10-21T12:45:17.7896250+02:00;True|2021-10-21T12:44:18.8941191+02:00;True|2021-10-21T08:48:23.1235907+02:00;True|2021-10-21T08:48:18.3291685+02:00;True|2021-10-15T11:33:23.1161895+02:00;True|2021-10-15T11:26:37.7646366+02:00;True|2021-10-15T11:26:08.9411561+02:00;True|2021-10-15T11:25:36.6377010+02:00;True|2021-10-15T11:25:15.7375383+02:00;True|2021-10-15T11:20:26.4607123+02:00;True|2021-10-15T11:13:33.8524245+02:00;False|2021-10-15T10:30:42.4253422+02:00;False|2021-10-15T10:27:43.8339493+02:00;False|2021-10-15T10:23:05.0864739+02:00;False|2021-10-15T10:22:43.2958457+02:00;False|2021-10-15T10:22:15.0954116+02:00;True|2021-10-15T10:15:10.5127570+02:00;False|2021-10-15T10:13:53.0299219+02:00;False|2021-10-15T08:58:38.3028788+02:00;False|2021-10-15T08:47:48.5789826+02:00;False|2021-10-14T19:32:56.5281204+02:00;False|2021-10-14T19:31:10.1629370+02:00;True|2021-05-26T19:49:30.0427896+02:00;False|2021-05-26T19:49:14.9065510+02:00;True|2021-05-25T17:48:33.3901785+02:00;True|2021-05-25T17:46:09.2063020+02:00;True|2021-05-25T17:42:47.8167539+02:00;True|2021-05-25T17:22:03.1877438+02:00;True|2021-05-25T17:21:05.1565775+02:00;True|2021-05-25T16:26:34.1426996+02:00;True|2021-05-25T16:14:28.2842402+02:00;True|2021-05-25T15:02:11.7131495+02:00; \ No newline at end of file diff --git a/LiMan.Api/Properties/PublishProfiles/IIS02.pubxml.user b/LiMan.Api/Properties/PublishProfiles/IIS02.pubxml.user index 473927a..388769e 100644 --- a/LiMan.Api/Properties/PublishProfiles/IIS02.pubxml.user +++ b/LiMan.Api/Properties/PublishProfiles/IIS02.pubxml.user @@ -7,6 +7,6 @@ by editing this MSBuild file. In order to learn more about this please visit htt AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAk75miMJLMkCTEelQutKpbwAAAAACAAAAAAADZgAAwAAAABAAAAA7RC2yFYQ+sbph7Gm3hrEMAAAAAASAAACgAAAAEAAAAFhL9j1HkRjMaqEESfncpZcYAAAAIMz57CMDX9ZLAPLwms1/yHQTf/r/v74FFAAAAB6WaNF8er6HZmelU4da+AsQFSC5 - True|2021-11-06T10:18:52.0560366Z;True|2021-11-06T11:18:39.5514277+01:00;True|2021-10-21T17:10:41.5356616+02:00;True|2021-10-21T17:09:53.6684540+02:00;True|2021-10-21T12:51:53.0071793+02:00;True|2021-10-21T12:50:27.0123409+02:00;True|2021-10-21T08:48:42.2014540+02:00;True|2021-10-21T08:48:38.0576948+02:00;True|2021-10-21T08:48:31.5097766+02:00;True|2021-10-15T10:15:10.5127570+02:00;False|2021-10-15T10:13:53.0299219+02:00;False|2021-10-15T08:58:38.3028788+02:00;False|2021-10-15T08:47:48.5789826+02:00;False|2021-10-14T19:32:56.5281204+02:00;False|2021-10-14T19:31:10.1629370+02:00;True|2021-05-26T19:49:30.0427896+02:00;False|2021-05-26T19:49:14.9065510+02:00;True|2021-05-25T17:48:33.3901785+02:00;True|2021-05-25T17:46:09.2063020+02:00;True|2021-05-25T17:42:47.8167539+02:00;True|2021-05-25T17:22:03.1877438+02:00;True|2021-05-25T17:21:05.1565775+02:00;True|2021-05-25T16:26:34.1426996+02:00;True|2021-05-25T16:14:28.2842402+02:00;True|2021-05-25T15:02:11.7131495+02:00; + True|2021-11-08T11:35:03.8241794Z;True|2021-11-08T12:34:36.4622795+01:00;True|2021-11-06T11:18:52.0560366+01:00;True|2021-11-06T11:18:39.5514277+01:00;True|2021-10-21T17:10:41.5356616+02:00;True|2021-10-21T17:09:53.6684540+02:00;True|2021-10-21T12:51:53.0071793+02:00;True|2021-10-21T12:50:27.0123409+02:00;True|2021-10-21T08:48:42.2014540+02:00;True|2021-10-21T08:48:38.0576948+02:00;True|2021-10-21T08:48:31.5097766+02:00;True|2021-10-15T10:15:10.5127570+02:00;False|2021-10-15T10:13:53.0299219+02:00;False|2021-10-15T08:58:38.3028788+02:00;False|2021-10-15T08:47:48.5789826+02:00;False|2021-10-14T19:32:56.5281204+02:00;False|2021-10-14T19:31:10.1629370+02:00;True|2021-05-26T19:49:30.0427896+02:00;False|2021-05-26T19:49:14.9065510+02:00;True|2021-05-25T17:48:33.3901785+02:00;True|2021-05-25T17:46:09.2063020+02:00;True|2021-05-25T17:42:47.8167539+02:00;True|2021-05-25T17:22:03.1877438+02:00;True|2021-05-25T17:21:05.1565775+02:00;True|2021-05-25T16:26:34.1426996+02:00;True|2021-05-25T16:14:28.2842402+02:00;True|2021-05-25T15:02:11.7131495+02:00; \ No newline at end of file diff --git a/LiMan.DB/Controllers/DbController.cs b/LiMan.DB/Controllers/DbController.cs index 29be4b2..8f88c1d 100644 --- a/LiMan.DB/Controllers/DbController.cs +++ b/LiMan.DB/Controllers/DbController.cs @@ -31,122 +31,40 @@ namespace LiMan.DB.Controllers #region Public Methods - public bool DbForceMigrate() - { - bool answ = false; - using (LMDbContext localDbCtx = new LMDbContext(_configuration)) - { - try - { - localDbCtx.DbForceMigrate(); - answ = true; - } - catch (Exception exc) - { - Log.Error($"Eccezione in DbForceMigrate"); - } - } - return answ; - } - - public void Dispose() - { - // Clear database context - //Log.Info("Dispose di GWMSController"); - } - - /// - /// Recupero da DB le attivazioni richieste - /// - /// Idx Licenza - /// Indica se generare rand parametri sensibili - public List GetAttivazioniByLic(int IdxLic, bool hideData) - { - List dbResult = new List(); - LicenzaModel mainLic = new LicenzaModel(); - using (LMDbContext localDbCtx = new LMDbContext(_configuration)) - { - DateTime oggi = DateTime.Today; - int stdIdxLic = 0; - - // generazione stringhe casuali.... - // https://jonathancrozier.com/blog/how-to-generate-a-random-string-with-c-sharp - StringBuilder sbRandChiave = new StringBuilder(); - string stdChiave = ""; - - if (hideData) - { - int numChar = 80; - Random random = new Random(); - - // idxLic - stdIdxLic = random.Next(50000, 100000); - - // chiave random - for (int i = 0; i < numChar; i++) - { - // Generate floating point numbers - double myFloat = random.NextDouble(); - // Generate the char using below logic - var myChar = Convert.ToChar(Convert.ToInt32(Math.Floor(25 * myFloat) + 65)); - sbRandChiave.Append(myChar); - } - stdChiave = $"{sbRandChiave}"; - } - else - { - // recupero se c'è licenza master - mainLic = localDbCtx - .DbSetLicenze - .Where(x => x.IdxLic == IdxLic) - .FirstOrDefault(); - } - - // calcolo DTO Attivazione - dbResult = localDbCtx - .DbSetSubLicenze - .Where(x => x.IdxLic == IdxLic) - .Select(x => new AttivazioneDTO() - { - IdxLic = hideData ? stdIdxLic : x.IdxLic, - IdxSubLic = x.IdxSubLic, - CodImpiego = x.CodImpiego, - CodApp = mainLic.CodApp, - CodInst = mainLic.CodInst, - Descrizione = mainLic.Descrizione, - Tipo = x.Tipo, - Chiave = hideData ? stdChiave : x.Chiave, - VetoUnlock = x.VetoUnlock - }) - .ToList(); - } - return dbResult; - } - /// /// Elimino una licenza da quelle attivate (SE scaduto veto) /// - /// Idx Licenza + /// Dizionario delle Licenze da eliminare /// Chiave Master - public bool AttivazioniDelete(int IdxSubLic, string MasterKey) + public bool AttivazioniDelete(Dictionary ParamDict, string MasterKey) { bool fatto = false; LicenzaModel mainLic = new LicenzaModel(); using (LMDbContext localDbCtx = new LMDbContext(_configuration)) { DateTime oggi = DateTime.Today; + List items2del = new List(); + // ciclo x ogni licenze a vedere SE sia eliminabile... + foreach (var item in ParamDict) + { + // calcolo DTO Attivazione + var itemsTgt = localDbCtx + .DbSetSubLicenze + .Where(x => x.CodImpiego == item.Key && x.Chiave == item.Value && x.LicenzaNav.Chiave == MasterKey && x.VetoUnlock < oggi) + .ToList(); + // se trovate aggiungo ad elenco... + if (itemsTgt != null && itemsTgt.Count > 0) + { + items2del.AddRange(itemsTgt); + } + } - // calcolo DTO Attivazione - var item2Del = localDbCtx - .DbSetSubLicenze - .Where(x => x.IdxSubLic == IdxSubLic && x.LicenzaNav.Chiave == MasterKey && x.VetoUnlock < oggi) - .ToList(); // se ho qualcosa procedo... - if (item2Del != null && item2Del.Count > 0) + if (items2del != null && items2del.Count > 0) { localDbCtx .DbSetSubLicenze - .RemoveRange(item2Del); + .RemoveRange(items2del); // salvo localDbCtx.SaveChanges(); fatto = true; @@ -238,68 +156,28 @@ namespace LiMan.DB.Controllers return answ; } - public AttivazioneDTO GetAttivazione(string Chiave, string CodImpiego, bool hideData) + public bool DbForceMigrate() { - AttivazioneDTO dbResult = new AttivazioneDTO(); - LicenzaModel mainLic = new LicenzaModel(); + bool answ = false; using (LMDbContext localDbCtx = new LMDbContext(_configuration)) { - DateTime oggi = DateTime.Today; - int stdIdxLic = 0; - - // generazione stringhe casuali.... - // https://jonathancrozier.com/blog/how-to-generate-a-random-string-with-c-sharp - StringBuilder sbRandChiave = new StringBuilder(); - string stdChiave = ""; - - if (hideData) + try { - int numChar = 80; - Random random = new Random(); - - // idxLic - stdIdxLic = random.Next(50000, 100000); - - // chiave random - for (int i = 0; i < numChar; i++) - { - // Generate floating point numbers - double myFloat = random.NextDouble(); - // Generate the char using below logic - var myChar = Convert.ToChar(Convert.ToInt32(Math.Floor(25 * myFloat) + 65)); - sbRandChiave.Append(myChar); - } - stdChiave = $"{sbRandChiave}"; + localDbCtx.DbForceMigrate(); + answ = true; } - else + catch (Exception exc) { - // recupero se c'è licenza master - mainLic = localDbCtx - .DbSetLicenze - .Where(x => x.Chiave == Chiave) - .FirstOrDefault(); + Log.Error($"Eccezione in DbForceMigrate"); } - - // calcolo DTO applicativi - dbResult = localDbCtx - .DbSetSubLicenze - .Where(x => x.LicenzaNav.Chiave == Chiave && x.CodImpiego == CodImpiego) - .OrderBy(o => o.VetoUnlock) - .Select(x => new AttivazioneDTO() - { - IdxLic = hideData ? stdIdxLic : x.IdxLic, - IdxSubLic = x.IdxSubLic, - CodImpiego = x.CodImpiego, - CodApp = mainLic.CodApp, - CodInst = mainLic.CodInst, - Descrizione = mainLic.Descrizione, - Tipo = x.Tipo, - Chiave = hideData ? stdChiave : x.Chiave, - VetoUnlock = x.VetoUnlock - }) - .FirstOrDefault(); } - return dbResult; + return answ; + } + + public void Dispose() + { + // Clear database context + //Log.Info("Dispose di GWMSController"); } public List GetApplicativiFilt(bool OnlyActive, string CodApp, string CodInst, bool hideData) @@ -411,6 +289,138 @@ namespace LiMan.DB.Controllers return dbResult; } + public AttivazioneDTO GetAttivazione(string Chiave, string CodImpiego, bool hideData) + { + AttivazioneDTO dbResult = new AttivazioneDTO(); + LicenzaModel mainLic = new LicenzaModel(); + using (LMDbContext localDbCtx = new LMDbContext(_configuration)) + { + DateTime oggi = DateTime.Today; + int stdIdxLic = 0; + + // generazione stringhe casuali.... + // https://jonathancrozier.com/blog/how-to-generate-a-random-string-with-c-sharp + StringBuilder sbRandChiave = new StringBuilder(); + string stdChiave = ""; + + if (hideData) + { + int numChar = 80; + Random random = new Random(); + + // idxLic + stdIdxLic = random.Next(50000, 100000); + + // chiave random + for (int i = 0; i < numChar; i++) + { + // Generate floating point numbers + double myFloat = random.NextDouble(); + // Generate the char using below logic + var myChar = Convert.ToChar(Convert.ToInt32(Math.Floor(25 * myFloat) + 65)); + sbRandChiave.Append(myChar); + } + stdChiave = $"{sbRandChiave}"; + } + else + { + // recupero se c'è licenza master + mainLic = localDbCtx + .DbSetLicenze + .Where(x => x.Chiave == Chiave) + .FirstOrDefault(); + } + + // calcolo DTO applicativi + dbResult = localDbCtx + .DbSetSubLicenze + .Where(x => x.LicenzaNav.Chiave == Chiave && x.CodImpiego == CodImpiego) + .OrderBy(o => o.VetoUnlock) + .Select(x => new AttivazioneDTO() + { + IdxLic = hideData ? stdIdxLic : x.IdxLic, + IdxSubLic = x.IdxSubLic, + CodImpiego = x.CodImpiego, + CodApp = mainLic.CodApp, + CodInst = mainLic.CodInst, + Descrizione = mainLic.Descrizione, + Tipo = x.Tipo, + Chiave = hideData ? stdChiave : x.Chiave, + VetoUnlock = x.VetoUnlock + }) + .FirstOrDefault(); + } + return dbResult; + } + + /// + /// Recupero da DB le attivazioni richieste + /// + /// Idx Licenza + /// Indica se generare rand parametri sensibili + public List GetAttivazioniByLic(int IdxLic, bool hideData) + { + List dbResult = new List(); + LicenzaModel mainLic = new LicenzaModel(); + using (LMDbContext localDbCtx = new LMDbContext(_configuration)) + { + DateTime oggi = DateTime.Today; + int stdIdxLic = 0; + + // generazione stringhe casuali.... + // https://jonathancrozier.com/blog/how-to-generate-a-random-string-with-c-sharp + StringBuilder sbRandChiave = new StringBuilder(); + string stdChiave = ""; + + if (hideData) + { + int numChar = 80; + Random random = new Random(); + + // idxLic + stdIdxLic = random.Next(50000, 100000); + + // chiave random + for (int i = 0; i < numChar; i++) + { + // Generate floating point numbers + double myFloat = random.NextDouble(); + // Generate the char using below logic + var myChar = Convert.ToChar(Convert.ToInt32(Math.Floor(25 * myFloat) + 65)); + sbRandChiave.Append(myChar); + } + stdChiave = $"{sbRandChiave}"; + } + else + { + // recupero se c'è licenza master + mainLic = localDbCtx + .DbSetLicenze + .Where(x => x.IdxLic == IdxLic) + .FirstOrDefault(); + } + + // calcolo DTO Attivazione + dbResult = localDbCtx + .DbSetSubLicenze + .Where(x => x.IdxLic == IdxLic) + .Select(x => new AttivazioneDTO() + { + IdxLic = hideData ? stdIdxLic : x.IdxLic, + IdxSubLic = x.IdxSubLic, + CodImpiego = x.CodImpiego, + CodApp = mainLic.CodApp, + CodInst = mainLic.CodInst, + Descrizione = mainLic.Descrizione, + Tipo = x.Tipo, + Chiave = hideData ? stdChiave : x.Chiave, + VetoUnlock = x.VetoUnlock + }) + .ToList(); + } + return dbResult; + } + public List GetInstallazioni() { List dbResult = new List(); @@ -435,6 +445,7 @@ namespace LiMan.DB.Controllers } return dbResult; } + public LicenzaModel GetLicenza(string MasterKey) { LicenzaModel dbResult = new LicenzaModel(); diff --git a/LiMan.UI/LiMan.UI.csproj b/LiMan.UI/LiMan.UI.csproj index 365a102..f76e295 100644 --- a/LiMan.UI/LiMan.UI.csproj +++ b/LiMan.UI/LiMan.UI.csproj @@ -2,7 +2,7 @@ net5.0 - 1.1.2111.0612 + 1.1.2111.0812 LiMan.UI LiMan.UI diff --git a/LiMan.UI/Resources/ChangeLog.html b/LiMan.UI/Resources/ChangeLog.html index c2743ff..1588f34 100644 --- a/LiMan.UI/Resources/ChangeLog.html +++ b/LiMan.UI/Resources/ChangeLog.html @@ -1,6 +1,6 @@ License Manager -

Versione: 1.1.2111.0612

+

Versione: 1.1.2111.0812


Note di rilascio:
    diff --git a/LiMan.UI/Resources/VersNum.txt b/LiMan.UI/Resources/VersNum.txt index 1c92755..31bfc0f 100644 --- a/LiMan.UI/Resources/VersNum.txt +++ b/LiMan.UI/Resources/VersNum.txt @@ -1 +1 @@ -1.1.2111.0612 +1.1.2111.0812 diff --git a/LiMan.UI/Resources/manifest.xml b/LiMan.UI/Resources/manifest.xml index 0f7db41..ecf2c07 100644 --- a/LiMan.UI/Resources/manifest.xml +++ b/LiMan.UI/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.1.2111.0612 + 1.1.2111.0812 https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/LiMan.UI.zip https://nexus.steamware.net/repository/SWS/LiMan/stable/LAST/ChangeLog.html false