From cf274d21b0d69b9fc231b0c8e06e5da04c12acd1 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Thu, 25 Jan 2024 18:19:03 +0100 Subject: [PATCH] EgtLock 2.6a1 : - aggiunta funzione GetKeyLevelEx con i giorni mancanti alla scadenza dell'assistenza. --- KeyProc.cpp | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/KeyProc.cpp b/KeyProc.cpp index 67ad681..4bba48f 100644 --- a/KeyProc.cpp +++ b/KeyProc.cpp @@ -1,7 +1,7 @@ //---------------------------------------------------------------------------- // EgalTech 2014-2024 //---------------------------------------------------------------------------- -// File : KeyProc.cpp Data : 16.01.23 Versione : 2.6a1 +// File : KeyProc.cpp Data : 24.01.24 Versione : 2.6a1 // Contenuto : Funzioni per la gestione della chiave. // // @@ -10,6 +10,7 @@ // 29.02.16 DS Controllo prodotti con & (and bit a bit). // 12.07.16 DS In recupero opzioni, se chiave ko azzero risultati. // 26.12.20 DS Gestione versione MMmm (vecchie chiavi convertite). +// 24.01.24 DS Aggiunta GetKeyLevelEx con anche giorni scadenza assistenza. // //---------------------------------------------------------------------------- @@ -197,6 +198,41 @@ GetKeyLevel( const string& sKey, int nProd, int nVer, int nLev, return nErr ; } +//---------------------------------------------------------------------------- +int +GetKeyLevelEx( const string& sKey, int nProd, int nVer, int nLev, + int& nKLev, int& nKExpDays, int& nKAssExpDays) +{ + int nKProd, nKVer ; + unsigned int nKOpt1, nKOpt2 ; + int nKOptExpDays ; + int nErr = VerifyKey( sKey, nProd, nVer, nLev, + nKProd, nKVer, nKLev, nKExpDays, + nKOpt1, nKOpt2, nKOptExpDays) ; + if ( nErr != KEY_OK) { + nKLev = 0 ; + nKExpDays = 0 ; + nKAssExpDays = 0 ; + } + else { + // sistemazioni per vecchie gestioni chiavi + // 16xx -> 17xx, 18xx -> 18xx, 19xx -> 19xx, 21xx -> 20xx, 22xx -> 21xx, ... + int nKAssEnd = nKVer + ( nKVer < 1800 ? 100 : ( nKVer < 2000 ? 0 : -100)) ; + // si considera il primo giorno del mese successivo (mesi sono 0-based, con dicembre si va a gennaio anno dopo) + int nKAssEndM = Clamp( nKAssEnd % 100, 1, 12) ; + int nKAssEndY = nKAssEnd / 100 + 100 ; + if ( nKAssEndM == 12) { + nKAssEndM = 0 ; + nKAssEndY += 1 ; + } + struct tm tmAssEnd = { 0, 0, 0, 1, nKAssEndM, nKAssEndY, 0, 0, 0} ; + time_t nClock = mktime( &tmAssEnd) ; + nKAssExpDays = int( nClock / ( 24 * 3600)) ; // (24*3600) secondi in un giorno + nKAssExpDays = min( nKAssExpDays, nKExpDays) ; + } + return nErr ; +} + //---------------------------------------------------------------------------- int GetKeyOptions( const string& sKey, int nProd, int nVer, int nLev,