Files
TestEGr/TestEGr.cpp
T
Dario Sassi 427ac04c4d TestEGr 1.6c6 :
- aggiornamento per codici di protezione.
2015-03-30 06:55:33 +00:00

156 lines
4.9 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2013-2014
//----------------------------------------------------------------------------
// File : TestEGr.cpp Data : 29.01.14 Versione : 1.5a1
// Contenuto : Implementazione della classe applicazione test grafica.
//
//
//
// Modifiche : 29.01.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "TestEGr.h"
#include "TestEGrDlg.h"
#include "/EgtDev/Include/EGkDllMain.h"
#include "/EgtDev/Include/ENkDllMain.h"
#include "/EgtDev/Include/EGnDllMain.h"
#include "/EgtDev/Include/EExDllMain.h"
#include "/EgtDev/Include/EGrDllMain.h"
#include "/EgtDev/Include/EgnGetModuleVer.h"
#include "/EgtDev/Include/EGnStringConverter.h"
#include "/EgtDev/Include/EgtIniFile.h"
#include "/EgtDev/Include/EgtLogger.h"
#include <fstream>
//----------------------------------------------------------------------------
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
//--------------------------- Define -----------------------------------------
#if defined( _WIN64) && defined( NDEBUG)
#define STR_EXE "TestEGrR64.exe"
#elif defined( _WIN64)
#define STR_EXE "TestEGrD64.exe"
#elif defined( _WIN32) && defined( NDEBUG)
#define STR_EXE "TestEGrR32.exe"
#else
#define STR_EXE "TestEGrD32.exe"
#endif
using namespace std ;
using namespace egtlogger ;
//----------------------------------------------------------------------------
// The one and only CTestEGrApp object
CTestEGrApp theApp ;
//----------------------------------------------------------------------------
BEGIN_MESSAGE_MAP( CTestEGrApp, CWinApp)
ON_COMMAND( ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()
//----------------------------------------------------------------------------
CTestEGrApp::CTestEGrApp( void)
{
}
//----------------------------------------------------------------------------
BOOL
CTestEGrApp::InitInstance( void)
{
// CommonControls initialize
INITCOMMONCONTROLSEX InitCtrls ;
InitCtrls.dwSize = sizeof( InitCtrls) ;
InitCtrls.dwICC = ICC_WIN95_CLASSES ;
InitCommonControlsEx( &InitCtrls) ;
CWinApp::InitInstance() ;
AfxEnableControlContainer() ;
// recupero il direttorio del programma e lo imposto come corrente
string sDir ;
GetModuleDirectory( NULL, sDir) ;
SetCurrentDirectory( stringtoW( sDir)) ;
// costruisco path file INI
string sFileIni= sDir + "\\TestEGr.ini" ;
wchar_t* p = _wcsdup( stringtoW( sFileIni)) ;
free( (void*) m_pszProfileName) ;
m_pszProfileName = p ;
// livello di debug
int nDebug = GetPrivateProfileInt( "General", "Debug", 0, m_pszProfileName) ;
// inizializzazioni del logger generale
Logger logGen( ( nDebug > 0 ? LL_DEBUG : LL_INFO), "TestEGr") ;
logGen.AddOutputStream( new ofstream( "TestEgr.log"), true) ;
SetEGnLogger( &logGen) ;
SetENkLogger( &logGen) ;
SetEGkLogger( &logGen) ;
SetEExLogger( &logGen) ;
SetEGrLogger( &logGen) ;
// imposto la chiave di protezione
string sKey = GetPrivateProfileStringUtf8( "General", "Key", "", m_pszProfileName) ;
SetEGkKey( sKey) ;
SetEGrKey( sKey) ;
SetEExKey( sKey) ;
// inizializzo il font manager
string sNfeFontDir = GetPrivateProfileStringUtf8( "GeomDB", "NfeFontDir", "", m_pszProfileName) ;
string sDefaultFont = GetPrivateProfileStringUtf8( "GeomDB", "DefaultFont", "", m_pszProfileName) ;
InitFontManager( sNfeFontDir, sDefaultFont) ;
// inizio programma
LOG_DATETIME( &logGen, " Start")
// versione del programma
LOG_INFO( &logGen, GetExeNameVer().c_str())
// versione delle librerie
LOG_INFO( &logGen, GetEGnVersion())
LOG_INFO( &logGen, GetENkVersion())
LOG_INFO( &logGen, GetEGkVersion())
LOG_INFO( &logGen, GetEExVersion())
LOG_INFO( &logGen, GetEGrVersion())
// inizializzazione logger dei comandi
Logger logCmd( LL_INFO, "TestEGr") ;
logCmd.AddOutputStream( new ofstream( "TestEgr.tsc"), true) ;
LOG_INFO( &logCmd, ( "// " + CurrDateTime()).c_str()) ;
// gestione linea di comando
string sFileToOpen ;
CCommandLineInfo cmdInfo ;
ParseCommandLine( cmdInfo) ;
if ( cmdInfo.m_nShellCommand == CCommandLineInfo::FileOpen)
sFileToOpen = WtoA( cmdInfo.m_strFileName) ;
// Dialog interface
CTestEGrDlg dlg( sFileToOpen, &logGen, &logCmd) ;
m_pMainWnd = &dlg ;
dlg.DoModal() ;
// fine programma
LOG_INFO( &logCmd, "// EXIT") ;
LOG_DATETIME( &logGen, " End")
// Exit application with FALSE
return FALSE ;
}
//----------------------------------------------------------------------------
string
GetExeNameVer( void)
{
string sVer ;
GetModuleVersion( NULL, sVer) ;
return string( STR_EXE " ver." + sVer) ;
}