EgtInterface 1.5i1 :
- profondo riordinamento e modifica.
This commit is contained in:
+133
@@ -0,0 +1,133 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
//----------------------------------------------------------------------------
|
||||
// File : API_TscExec.cpp Data : 01.09.14 Versione : 1.5i1
|
||||
// Contenuto : Funzioni esecuzione TSC per API.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 01.09.14 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "API.h"
|
||||
#include "/EgtDev/Include/EInAPI.h"
|
||||
#include "/EgtDev/Include/EGkGdbExecutor.h"
|
||||
#include "/EgtDev/Include/EExExcExecutor.h"
|
||||
#include "/EgtDev/Include/EGrSceExecutor.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EGnStringConverter.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include <string>
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtInitTscExec( int nGseCtx)
|
||||
{
|
||||
// recupero il contesto
|
||||
GseContext* pGseCtx = GetGseContext( nGseCtx) ;
|
||||
// verifico GeomDB
|
||||
if ( pGseCtx == nullptr || pGseCtx->m_pGeomDB == nullptr) {
|
||||
LOG_ERROR( GetLogger(), "GeomDB invalid (EgtInitTscExec)")
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
// eventuale pulizia esecutore e suoi oggetti
|
||||
if ( pGseCtx->m_pTscExec != nullptr) {
|
||||
delete pGseCtx->m_pTscExec ;
|
||||
pGseCtx->m_pTscExec = nullptr ;
|
||||
}
|
||||
|
||||
// creo esecutore
|
||||
PtrOwner<ICmdParser> pCmdParser( CreateCmdParser()) ;
|
||||
if ( IsNull( pCmdParser)) {
|
||||
LOG_ERROR( GetLogger(), "Error in CreateCmdParser")
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
// creo oggetto per esecuzione funzioni di GeomKernel
|
||||
PtrOwner<IGdbExecutor> pGdbExec( CreateGdbExecutor()) ;
|
||||
if ( IsNull( pGdbExec)) {
|
||||
LOG_ERROR( GetLogger(), "Error in CreateGdbExecutor")
|
||||
return FALSE ;
|
||||
}
|
||||
pGdbExec->SetGeomDB( pGseCtx->m_pGeomDB) ;
|
||||
pCmdParser->SetExecutor( Release( pGdbExec)) ;
|
||||
|
||||
// creazione oggetto per esecuzione funzioni di Exchange
|
||||
PtrOwner<IExcExecutor> pExcExec( CreateExcExecutor()) ;
|
||||
if ( IsNull( pExcExec)) {
|
||||
LOG_ERROR( GetLogger(), "Error in CreateExcExecutor")
|
||||
return FALSE ;
|
||||
}
|
||||
pExcExec->SetGeomDB( pGseCtx->m_pGeomDB) ;
|
||||
pCmdParser->AddExecutor( Release( pExcExec)) ;
|
||||
|
||||
// eventuale creazione oggetto per esecuzione funzioni di Scene
|
||||
if ( pGseCtx->m_pScene != nullptr) {
|
||||
PtrOwner<ISceExecutor> pSceExec( CreateSceExecutor()) ;
|
||||
if ( IsNull( pSceExec)) {
|
||||
LOG_ERROR( GetLogger(), "Error in CreateSceExecutor")
|
||||
return FALSE ;
|
||||
}
|
||||
pSceExec->SetScene( pGseCtx->m_pScene) ;
|
||||
pCmdParser->AddExecutor( Release( pSceExec)) ;
|
||||
}
|
||||
|
||||
// completo inizializzazioni
|
||||
pCmdParser->Init() ;
|
||||
pGseCtx->m_pTscExec = Release( pCmdParser) ;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtTscFileExec( int nGseCtx, const wchar_t* wsFilePath)
|
||||
{
|
||||
// verifico TscExecutor
|
||||
GseContext* pGseCtx = GetGseContext( nGseCtx) ;
|
||||
if ( pGseCtx == nullptr || pGseCtx->m_pTscExec == nullptr) {
|
||||
LOG_ERROR( GetLogger(), "TscExecutor invalid (EgtFileExec)")
|
||||
return FALSE ;
|
||||
}
|
||||
// converto nome file
|
||||
string sFilePath = LPSTR( WtoA( wsFilePath)) ;
|
||||
// emetto info
|
||||
string sInfo = "Exec File = " + sFilePath ;
|
||||
LOG_INFO( GetLogger(), sInfo.c_str())
|
||||
|
||||
// imposto il direttorio dello script
|
||||
string sFileDir, sFileName ;
|
||||
SplitLast( sFilePath, "\\", sFileDir, sFileName) ;
|
||||
pGseCtx->m_pTscExec->SetDirReplace( "<TSCDIR>", sFileDir) ;
|
||||
|
||||
// esecuzione script
|
||||
if ( pGseCtx->m_pTscExec->Run( sFilePath))
|
||||
return TRUE ;
|
||||
else
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL
|
||||
__stdcall EgtTscLineExec( int nGseCtx, const wchar_t* wsLine)
|
||||
{
|
||||
// verifico TscExecutor
|
||||
GseContext* pGseCtx = GetGseContext( nGseCtx) ;
|
||||
if ( pGseCtx == nullptr || pGseCtx->m_pTscExec == nullptr) {
|
||||
LOG_ERROR( GetLogger(), "TscExecutor invalid (EgtLineExec)")
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
// eseguo il comando
|
||||
if ( pGseCtx->m_pTscExec->ExecLine( LPSTR( WtoA( wsLine))))
|
||||
return TRUE ;
|
||||
else
|
||||
return FALSE ;
|
||||
}
|
||||
Reference in New Issue
Block a user