//---------------------------------------------------------------------------- // EgalTech 2013-2014 //---------------------------------------------------------------------------- // File : TestEGk.cpp Data : 04.04.14 Versione : 1.5d2 // Contenuto : Programma di test della libreria EgtGeomKernel. // // // // Modifiche : 20.11.13 DS Creazione modulo. // 04.04.14 DS Agg. esecutore di Exchange. // // //---------------------------------------------------------------------------- //--------------------------- Include ---------------------------------------- #include "stdafx.h" #include "/EgtDev/Include/EGnDllMain.h" #include "/EgtDev/Include/EGnGetModuleVer.h" #include "/EgtDev/Include/EGnStringUtils.h" #include "/EgtDev/Include/EGnCmdParser.h" #include "/EgtDev/Include/ENkDllMain.h" #include "/EgtDev/Include/EGkDllMain.h" #include "/EgtDev/Include/EGkGeomDB.h" #include "/EgtDev/Include/EGkGdbExecutor.h" #include "/EgtDev/Include/EExDllMain.h" #include "/EgtDev/Include/EExExcExecutor.h" #include "/EgtDev/Include/EgtPointerOwner.h" #include "/EgtDev/Include/EgtLogger.h" #include "/EgtDev/Include/EgtIniFile.h" #include "/EgtDev/Include/EgtStringConverter.h" #include //--------------------------- Define ----------------------------------------- #if defined( _WIN64) #if defined( NDEBUG) #define STR_EXE "TestEGkR64.exe" #else #define STR_EXE "TestEGkD64.exe" #endif #elif defined( _WIN32) #if defined( NDEBUG) #define STR_EXE "TestEGkR32.exe" #else #define STR_EXE "TestEGkD32.exe" #endif #endif using namespace std ; using namespace egtlogger ; //---------------------------------------------------------------------------- int wmain( int argc, wchar_t* argv[]) { // se debug, imposto stampe memory leaks all'uscita #ifdef _DEBUG _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF) ; #endif // recupero il direttorio del programma e costruisco path file INI e LIC string sExeDir ; GetModuleDirectory( NULL, sExeDir) ; string sFileIni = sExeDir + "\\TestEgk.ini" ; string sFileLic = sExeDir + "\\TestEgk.lic" ; // verifico se dati separati da programmi string sRootFile = sExeDir + "\\DataRoot.ini" ; string sDataRoot = GetPrivateProfileStringUtf8( "Data", "DataRoot", "", sRootFile.c_str()) ; if ( ! sDataRoot.empty()) { sFileIni = sDataRoot + "\\Config\\TestEgk.ini" ; sFileLic = sDataRoot + "\\Config\\TestEgk.lic" ; } // imposto direttorio di lavoro SetCurrentDirectory( sExeDir) ; // nome file di comandi string sIn ; if ( argc >= 2) sIn = LPSTR( WtoA( argv[1])) ; else sIn = GetPrivateProfileStringUtf8( "General", "Batch", "In.btsc", sFileIni.c_str()) ; // livello di debug int nDebug = GetPrivateProfileInt( "General", "Debug", 0, sFileIni.c_str()) ; // file di log string sLog = GetPrivateProfileStringUtf8( "General", "Log", "TestEgk.log", sFileIni.c_str()) ; // inizializzazioni del logger Logger logger( ( nDebug > 0 ? LL_DEBUG : LL_INFO), "TestEGk") ; logger.AddOutputStream( cout, false, LL_INFO) ; logger.AddOutputStream( new(nothrow) ofstream( sLog), true) ; // inizio programma LOG_DATETIME( &logger, " Start Test") // versione del programma { string sVer ; GetModuleVersion( NULL, sVer) ; LOG_INFO( &logger, string( STR_EXE " v." + sVer).c_str()) } // versione delle librerie LOG_INFO( &logger, GetEGnVersion()) LOG_INFO( &logger, GetENkVersion()) LOG_INFO( &logger, GetEGkVersion()) LOG_INFO( &logger, GetEExVersion()) // passo logger alle librerie SetEGnLogger( &logger) ; SetENkLogger( &logger) ; SetEGkLogger( &logger) ; SetEExLogger( &logger) ; // leggo e imposto la chiave di protezione string sKey = GetPrivateProfileStringUtf8( "Licence", "Key", "", sFileLic.c_str()) ; SetEGkKey( sKey) ; SetEExKey( sKey) ; // inizializzo il font manager string sNfeFontDir = GetPrivateProfileStringUtf8( "General", "NfeFontDir", "", sFileIni.c_str()) ; string sDefaultFont = GetPrivateProfileStringUtf8( "General", "DefaultFont", "", sFileIni.c_str()) ; InitFontManager( sNfeFontDir, sDefaultFont) ; // nessun errore int nErr = 0 ; // esecuzione script PtrOwner pGdb( CreateGeomDB()) ; PtrOwner pGdbExec( CreateGdbExecutor()) ; PtrOwner pExcExec( CreateExcExecutor()) ; PtrOwner pCmdParser( CreateCmdParser()) ; // controllo validità oggetti if ( IsNull( pGdb)) { LOG_ERROR( &logger, "Error in CreateGeomDB") nErr = 1 ; goto END ; } if ( IsNull( pGdbExec)) { LOG_ERROR( &logger, "Error in CreateGdbExecutor") nErr = 1 ; goto END ; } if ( IsNull( pExcExec)) { LOG_ERROR( &logger, "Error in CreateExcExecutor") nErr = 1 ; goto END ; } if ( IsNull( pCmdParser)) { LOG_ERROR( &logger, "Error in CreateCmdParser") nErr = 1 ; goto END ; } // inizializzazioni pGdb->Init() ; pGdbExec->SetGeomDB( Get( pGdb)) ; pExcExec->SetGeomDB( Get( pGdb)) ; pCmdParser->SetExecutor( Release( pGdbExec)) ; pCmdParser->AddExecutor( Release( pExcExec)) ; if ( ! pCmdParser->Init( )) { LOG_ERROR( &logger, "Error on Parser.Init") nErr = 2 ; goto END ; } // esecuzione comandi if ( ! pCmdParser->Run( sIn)) { nErr = 3 ; goto END ; } END : // fine programma LOG_DATETIME( &logger, " End Test") return nErr ; }