104 lines
2.5 KiB
C++
104 lines
2.5 KiB
C++
#include "StdAfx.h"
|
|
#include "CppSQLite3.h"
|
|
#include "FileTransferFiller.h"
|
|
#include "_log.h"
|
|
#include <shlwapi.h>
|
|
|
|
#define MODULO "FileTransferFiller"
|
|
FileTransferFiller *FileTransferFiller::_instance=NULL;
|
|
//*********************************************************************************
|
|
FileTransferFiller::FileTransferFiller(void)
|
|
{
|
|
}
|
|
//*********************************************************************************
|
|
FileTransferFiller::~FileTransferFiller(void)
|
|
{
|
|
}
|
|
//*********************************************************************************
|
|
bool FileTransferFiller::fill( Usuario_conx_0 *user, char *pathRaid )
|
|
{
|
|
if(!db)
|
|
return FALSE;
|
|
std::string sql_select,fuelstate,str,sql_where;
|
|
|
|
sql_select = "SELECT * from clients_file_transfer";
|
|
sql_select=sql_select+" WHERE name = \""+ user->nombre+"\"";
|
|
bool res = false;
|
|
|
|
CppSQLite3Query q = db->execQuery(sql_select.c_str());
|
|
|
|
while (!q.eof() || !res)
|
|
{
|
|
|
|
user->id = q.getIntField("id", -1);
|
|
user->permisos = q.getIntField("permisos", 0);
|
|
user->id = q.getIntField("id", -1);
|
|
|
|
strcpy(user->clave, q.getStringField("clave", ""));
|
|
strcpy(pathRaid, q.getStringField("path_raid", ""));
|
|
|
|
res =true;
|
|
q.nextRow();
|
|
}
|
|
q.finalize();
|
|
return res;
|
|
}
|
|
//*********************************************************************************
|
|
bool FileTransferFiller::getConf( char *ip, int *port )
|
|
{
|
|
if(!db)
|
|
return FALSE;
|
|
std::string sql_select,fuelstate,str,sql_where;
|
|
|
|
sql_select = "SELECT * from conf_file_transfer";
|
|
bool res = false;
|
|
|
|
CppSQLite3Query q = db->execQuery(sql_select.c_str());
|
|
|
|
while (!q.eof() || !res)
|
|
{
|
|
|
|
*port = q.getIntField("port", -1);
|
|
strcpy(ip, q.getStringField("ip", ""));
|
|
res =true;
|
|
q.nextRow();
|
|
}
|
|
q.finalize();
|
|
return res;
|
|
}
|
|
//*********************************************************************************
|
|
FileTransferFiller* FileTransferFiller::Get()
|
|
{
|
|
if(!_instance)
|
|
{
|
|
_instance = new FileTransferFiller();
|
|
if(!_instance->init())
|
|
C_log::log(MODULO, "Error al inicializar db");
|
|
}
|
|
return _instance;
|
|
}
|
|
//*********************************************************************************
|
|
bool FileTransferFiller::init()
|
|
{
|
|
if (!PathFileExists(PATH_DB_FT))
|
|
{
|
|
|
|
C_log::log(MODULO, "Error no se encuentra archivo db: %s",PATH_DB_FT );
|
|
return false;
|
|
}
|
|
try
|
|
{
|
|
db = new CppSQLite3DB();
|
|
db->open(PATH_DB_FT);
|
|
}
|
|
catch (CppSQLite3Exception ex)
|
|
{
|
|
C_log::log(MODULO, "Error al arbrir db: %s",PATH_DB_FT );
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
//*********************************************************************************
|
|
|
|
|