Merge branch 'R_10_00' of http://10.65.20.33/sirio/CAMPO/campo into R_10_00
This commit is contained in:
		
						commit
						ee06dbd5c4
					
				
							
								
								
									
										3
									
								
								cd/test/fp0738.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								cd/test/fp0738.txt
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,3 @@
 | 
			
		||||
fp0.exe
 | 
			
		||||
 | 
			
		||||
Aggiunte info in caso di errori
 | 
			
		||||
							
								
								
									
										19
									
								
								cd/test/fp0738a.ini
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								cd/test/fp0738a.ini
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,19 @@
 | 
			
		||||
[Main]
 | 
			
		||||
Demo=0
 | 
			
		||||
 | 
			
		||||
[fp1]
 | 
			
		||||
File(0) = fp0.exe|X
 | 
			
		||||
Patch = 738
 | 
			
		||||
Versione = 21511200
 | 
			
		||||
 | 
			
		||||
[fp]
 | 
			
		||||
Data = 19-03-2019
 | 
			
		||||
Descrizione = Fattura Elettronica
 | 
			
		||||
Dischi = 1
 | 
			
		||||
Moduli = cg,ve
 | 
			
		||||
OEM = 
 | 
			
		||||
Patch = 738
 | 
			
		||||
PostProcess = 
 | 
			
		||||
PreProcess = 
 | 
			
		||||
Versione = 21511200
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								cd/test/fp0738a1.zip
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								cd/test/fp0738a1.zip
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										4
									
								
								cd/test/sy0738.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								cd/test/sy0738.txt
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,4 @@
 | 
			
		||||
xvaga.dll
 | 
			
		||||
xvtdb.dll
 | 
			
		||||
 | 
			
		||||
Patch di supporto per fp0738
 | 
			
		||||
							
								
								
									
										22
									
								
								cd/test/sy0738a.ini
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								cd/test/sy0738a.ini
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,22 @@
 | 
			
		||||
[Main]
 | 
			
		||||
Demo=0
 | 
			
		||||
 | 
			
		||||
[sy1]
 | 
			
		||||
File(52) = xvaga.dll|X
 | 
			
		||||
File(53) = xvtdb.dll|X
 | 
			
		||||
Patch = 738
 | 
			
		||||
Versione = 21511200
 | 
			
		||||
 | 
			
		||||
[sy]
 | 
			
		||||
Data = 19-03-2019
 | 
			
		||||
Descrizione = Sistema
 | 
			
		||||
Dischi = 1
 | 
			
		||||
Moduli = 
 | 
			
		||||
OEM = 
 | 
			
		||||
Patch = 738
 | 
			
		||||
PostProcess = 
 | 
			
		||||
PreProcess = 
 | 
			
		||||
Prezzo(1) = 
 | 
			
		||||
Prezzo(2) = 
 | 
			
		||||
Versione = 21511200
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								cd/test/sy0738a1.zip
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								cd/test/sy0738a1.zip
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							@ -103,7 +103,7 @@ bool check_tables()
 | 
			
		||||
					s.erase(0, limiter);
 | 
			
		||||
					if(!fp_db().sq_set_exec(query) || !fp_db().sq_commit())
 | 
			
		||||
					{
 | 
			
		||||
						fatal_box("Impossibile eseguire/salvare la query:\n%s\n%s", query.c_str(), fp_db().sq_get_string_error());
 | 
			
		||||
						fatal_box("Impossibile eseguire/salvare la query:\n%s\n%s", query.c_str(), fp_db().sq_get_token_text_error(1));
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
@ -808,7 +808,7 @@ bool TDoc_fp::insert(TPaf_record& p)
 | 
			
		||||
		ok = p.insert();
 | 
			
		||||
		if (!ok)
 | 
			
		||||
		{
 | 
			
		||||
			log(2, fp_db().sq_get_string_error());
 | 
			
		||||
			log(2, fp_db().sq_get_token_text_error(1));
 | 
			
		||||
			log(2, p.insert_string());
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@ -827,7 +827,7 @@ bool TDoc_fp::remove(TPaf_record& p)
 | 
			
		||||
		ok = p.remove();
 | 
			
		||||
		if (!ok)
 | 
			
		||||
		{
 | 
			
		||||
			log(2, fp_db().sq_get_string_error());
 | 
			
		||||
			log(2, fp_db().sq_get_token_text_error(1));
 | 
			
		||||
			log(2, p.remove_string());
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@ -844,7 +844,7 @@ bool TDoc_fp::save_paf()
 | 
			
		||||
		ok = fp_db().sq_set_exec(query);
 | 
			
		||||
		if (!ok)
 | 
			
		||||
		{
 | 
			
		||||
			log(2, fp_db().sq_get_string_error());
 | 
			
		||||
			log(2, fp_db().sq_get_token_text_error(1));
 | 
			
		||||
			log(2, query.c_str());
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@ -1073,7 +1073,7 @@ const int TDoc_fp::commit()
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			r = -1;
 | 
			
		||||
			log(2, fp_db().sq_get_string_error());
 | 
			
		||||
			log(2, fp_db().sq_get_token_text_error(1));
 | 
			
		||||
			log(2, "UPDATE PAF0100F SET P1_GESTIONE = 'P' WHERE P1_GESTIONE = 'D'");
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -95,6 +95,12 @@ TFieldtypes SSimple_query::sq_get_type_field(const unsigned column) const
 | 
			
		||||
	return _nullfld;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char* SSimple_query::sq_get_token_text_error(const int token, const bool erase)
 | 
			
		||||
{
 | 
			
		||||
	TToken_string errors(sq_get_text_error(erase), '\n');
 | 
			
		||||
	return errors.get(token);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TDB_recordset::reset()
 | 
			
		||||
{
 | 
			
		||||
	_current_row = -1;
 | 
			
		||||
 | 
			
		||||
@ -105,7 +105,7 @@ public:
 | 
			
		||||
	/**< Ritorno la versione del Client che sto utilizzando */
 | 
			
		||||
	const long sq_get_client_v() { return _rec.get_client_v(); }
 | 
			
		||||
	/**< Ritorno la versione del Server che sto utilizzando */
 | 
			
		||||
	const char* sq_get_server_v() { return _rec.getServerV(); }
 | 
			
		||||
	const char* sq_get_server_v() { return _rec.get_server_v(); }
 | 
			
		||||
	/**< Ritorno la versione del Server che sto utilizzando in formato numerico */
 | 
			
		||||
	const long sq_get_server_vn() { return _rec.get_server_vn(); }
 | 
			
		||||
	/**< Ritorno se il recordset è carico */
 | 
			
		||||
@ -187,6 +187,7 @@ public:
 | 
			
		||||
	const char*		sq_get_string_error(const bool erase = true) { return _rec.get_string_error(erase); }
 | 
			
		||||
	/**< Ritorno l'ultima stringa di errore segnalato in formato (const char *) */
 | 
			
		||||
	const char*		sq_get_text_error(const bool erase = true) { return _rec.get_text_error(erase); }
 | 
			
		||||
	const char*		sq_get_token_text_error(const int token, const bool erase = true);
 | 
			
		||||
 | 
			
		||||
	// Gestione freeze
 | 
			
		||||
	/**< Controlla se il cursore è bloccato */
 | 
			
		||||
 | 
			
		||||
@ -6,7 +6,7 @@
 | 
			
		||||
#define _RCS(a) ((SACommand *)a)
 | 
			
		||||
#define _ERR(a) ((SAException *)a)
 | 
			
		||||
 | 
			
		||||
#define _CPY_STR(from,to) (to = strdup(from));
 | 
			
		||||
#define _CPY_STR(from,to) (to = _strdup(from));
 | 
			
		||||
#define _GET_ERROR(from,to) _CPY_STR(from,to)
 | 
			
		||||
 | 
			
		||||
#define CHECK_FREEZED 	if (is_freezed()) { return set_error_freezed(); }
 | 
			
		||||
@ -33,17 +33,16 @@ TXvt_recordset::TXvt_recordset() : _freezed(false)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
TXvt_recordset::TXvt_recordset(const char* db, const char* user, const char* pass, TT_driver tipoDb, const char * query, const bool ex, const bool freezed)
 | 
			
		||||
	: _db(db), _usr(user), _psw(pass), _drv(tipoDb), _freezed(false)
 | 
			
		||||
TXvt_recordset::TXvt_recordset(const char* db, const char* user, const char* pass, const TT_driver tipo_db, const char * query, const bool ex, const bool freezed)
 | 
			
		||||
	: _db(db), _usr(user), _psw(pass), _drv(tipo_db), _query(""), _recno(0), _freezed(false), _loaded(false)
 | 
			
		||||
{
 | 
			
		||||
	_con = new SAConnection;
 | 
			
		||||
	if(connect(db, user, pass, tipoDb) == NOERR)
 | 
			
		||||
	if(connect(db, user, pass, tipo_db) == NOERR)
 | 
			
		||||
	{
 | 
			
		||||
		try
 | 
			
		||||
		{
 | 
			
		||||
			_recset = new SACommand;
 | 
			
		||||
			_RCS(_recset)->setConnection(_CON(_con));
 | 
			
		||||
			// if (query[0] != '\0')
 | 
			
		||||
			if (query && *query)
 | 
			
		||||
			{
 | 
			
		||||
				set(query);
 | 
			
		||||
@ -110,33 +109,8 @@ TT_driver TXvt_recordset::str_to_driver(const char* tipo_db)
 | 
			
		||||
	return tipoDb_driver;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int strcmp_ins(const char* str1, const char* str2)
 | 
			
		||||
{
 | 
			
		||||
	int len1 = strlen(str1) + 1;
 | 
			
		||||
	int len2 = strlen(str2) + 1;
 | 
			
		||||
	char * str1_up = new char[len1];
 | 
			
		||||
	char * str2_up = new char[len2];
 | 
			
		||||
 | 
			
		||||
	strcpy_s(str1_up, len1, str1);
 | 
			
		||||
	strcpy_s(str2_up, len2, str2);
 | 
			
		||||
 | 
			
		||||
	char *p = str1_up;
 | 
			
		||||
	char *q = str2_up;
 | 
			
		||||
	while (*p != '\0')
 | 
			
		||||
	{
 | 
			
		||||
		*p = toupper(*p);
 | 
			
		||||
		p++;
 | 
			
		||||
	}
 | 
			
		||||
	while (*q != '\0')
 | 
			
		||||
	{
 | 
			
		||||
		*q = toupper(*q);
 | 
			
		||||
		q++;
 | 
			
		||||
	}
 | 
			
		||||
	return strcmp(str1_up, str2_up);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TXvt_recordset::TXvt_recordset(const char* db, const char* user, const char* pass, const char* tipoDb,
 | 
			
		||||
	const char* query, const bool ex, const bool freezed) : TXvt_recordset(db, user, pass, str_to_driver(tipoDb), query, ex, freezed)
 | 
			
		||||
TXvt_recordset::TXvt_recordset(const char* db, const char* user, const char* pass, const char* tipo_db,
 | 
			
		||||
	const char* query, const bool ex, const bool freezed) : TXvt_recordset(db, user, pass, str_to_driver(tipo_db), query, ex, freezed)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -156,9 +130,9 @@ TXvt_recordset::~TXvt_recordset()
 | 
			
		||||
 | 
			
		||||
/* PRIVATE FUNCTIONS **************************************************************************************************/
 | 
			
		||||
 | 
			
		||||
const bool TXvt_recordset::checkPermission()
 | 
			
		||||
const bool TXvt_recordset::check_permission()
 | 
			
		||||
{
 | 
			
		||||
	bool err = is_freezed();
 | 
			
		||||
	const bool err = is_freezed();
 | 
			
		||||
	if (err)
 | 
			
		||||
		set_error_freezed();
 | 
			
		||||
	return !err; 
 | 
			
		||||
@ -172,17 +146,17 @@ const bool TXvt_recordset::checkPermission()
 | 
			
		||||
 | 
			
		||||
int TXvt_recordset::connect(const char* db, const char* user, const char* pass, TT_driver tipo_db)
 | 
			
		||||
{
 | 
			
		||||
	if (_con != NULL)
 | 
			
		||||
	if (_con != nullptr)
 | 
			
		||||
	{
 | 
			
		||||
		// Se è già connesso lo scollego
 | 
			
		||||
		if (_CON(_con)->isConnected())
 | 
			
		||||
			_CON(_con)->Disconnect();
 | 
			
		||||
 | 
			
		||||
		SAString dbAddress = db;
 | 
			
		||||
		SAString db_address = db;
 | 
			
		||||
		SAString usr = user;
 | 
			
		||||
		SAString psw = pass;
 | 
			
		||||
		SAClient_t dbDriver = (SAClient_t)tipo_db;
 | 
			
		||||
		if (dbAddress.IsEmpty() || usr.IsEmpty())
 | 
			
		||||
		const SAString psw = pass;
 | 
			
		||||
		const SAClient_t db_driver = static_cast<SAClient_t>(tipo_db);
 | 
			
		||||
		if (db_address.IsEmpty() || usr.IsEmpty())
 | 
			
		||||
		{
 | 
			
		||||
			_code_error		= NOT_INITIALIZED;
 | 
			
		||||
			_string_error	= NOT_INITIALIZEDS;
 | 
			
		||||
@ -192,7 +166,7 @@ int TXvt_recordset::connect(const char* db, const char* user, const char* pass,
 | 
			
		||||
			try
 | 
			
		||||
			{
 | 
			
		||||
				// Mi collego
 | 
			
		||||
				_CON(_con)->Connect(dbAddress, usr, psw, dbDriver);
 | 
			
		||||
				_CON(_con)->Connect(db_address, usr, psw, db_driver);
 | 
			
		||||
				// Imposto che non si possono vedere i record non committati
 | 
			
		||||
				_CON(_con)->setIsolationLevel(SA_ReadCommitted);
 | 
			
		||||
				_CPY_STR(db, _db);
 | 
			
		||||
@ -231,7 +205,7 @@ void TXvt_recordset::disconnect()
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool TXvt_recordset::commit(bool autoRoll)
 | 
			
		||||
bool TXvt_recordset::commit(const bool auto_roll)
 | 
			
		||||
{
 | 
			
		||||
	CHECK_FREEZED
 | 
			
		||||
	try
 | 
			
		||||
@ -240,7 +214,7 @@ bool TXvt_recordset::commit(bool autoRoll)
 | 
			
		||||
	}
 | 
			
		||||
	catch (SAException &x)
 | 
			
		||||
	{
 | 
			
		||||
		if (autoRoll)
 | 
			
		||||
		if (auto_roll)
 | 
			
		||||
		{
 | 
			
		||||
			rollback();
 | 
			
		||||
		}
 | 
			
		||||
@ -269,17 +243,17 @@ bool TXvt_recordset::rollback()
 | 
			
		||||
	return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TXvt_recordset::set_client(TT_driver client) 
 | 
			
		||||
void TXvt_recordset::set_client(TT_driver client) const
 | 
			
		||||
{ 
 | 
			
		||||
	_CON(_con)->setClient((SAClient_t) client); 
 | 
			
		||||
	_CON(_con)->setClient(static_cast<SAClient_t>(client)); 
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TXvt_recordset::set_con_option(const char* opt) 
 | 
			
		||||
void TXvt_recordset::set_con_option(const char* opt) const
 | 
			
		||||
{ 
 | 
			
		||||
	_CON(_con)->setOption(opt); 
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void TXvt_recordset::set_autocommit(bool ac)
 | 
			
		||||
void TXvt_recordset::set_autocommit(const bool ac) const
 | 
			
		||||
{
 | 
			
		||||
	_CON(_con)->setAutoCommit(ac ? SA_AutoCommitOn : SA_AutoCommitOff);
 | 
			
		||||
}
 | 
			
		||||
@ -294,7 +268,7 @@ void TXvt_recordset::set_visibility(iso_lvl vis)
 | 
			
		||||
	 *	2 -> Repeatable read.
 | 
			
		||||
	 *	3 -> Serializable.
 | 
			
		||||
	 */
 | 
			
		||||
	_CON(_con)->setIsolationLevel((SAIsolationLevel_t)vis);
 | 
			
		||||
	_CON(_con)->setIsolationLevel(static_cast<SAIsolationLevel_t>(vis));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const bool TXvt_recordset::is_connect() const 
 | 
			
		||||
@ -305,27 +279,27 @@ const bool TXvt_recordset::is_alive() const
 | 
			
		||||
{ 
 | 
			
		||||
	return _CON(_con)->isAlive(); 
 | 
			
		||||
}
 | 
			
		||||
int  TXvt_recordset::get_visibility() 
 | 
			
		||||
int  TXvt_recordset::get_visibility() const
 | 
			
		||||
{ 
 | 
			
		||||
	return (iso_lvl)_CON(_con)->IsolationLevel(); 
 | 
			
		||||
	return static_cast<iso_lvl>(_CON(_con)->IsolationLevel()); 
 | 
			
		||||
}
 | 
			
		||||
bool TXvt_recordset::get_autocommit() 
 | 
			
		||||
bool TXvt_recordset::get_autocommit() const
 | 
			
		||||
{ 
 | 
			
		||||
	return _CON(_con)->AutoCommit() == SA_AutoCommitOn; 
 | 
			
		||||
}
 | 
			
		||||
const char* TXvt_recordset::get_option(const char* opt) 
 | 
			
		||||
const char* TXvt_recordset::get_option(const char* opt) const
 | 
			
		||||
{
 | 
			
		||||
	return _CON(_con)->Option(opt); 
 | 
			
		||||
}
 | 
			
		||||
long TXvt_recordset::get_client_v() 
 | 
			
		||||
long TXvt_recordset::get_client_v() const
 | 
			
		||||
{ 
 | 
			
		||||
	return _CON(_con)->ClientVersion(); 
 | 
			
		||||
}
 | 
			
		||||
const char* TXvt_recordset::getServerV() 
 | 
			
		||||
const char* TXvt_recordset::get_server_v() const
 | 
			
		||||
{ 
 | 
			
		||||
	return _CON(_con)->ServerVersionString(); 
 | 
			
		||||
}
 | 
			
		||||
long TXvt_recordset::get_server_vn() 
 | 
			
		||||
long TXvt_recordset::get_server_vn() const
 | 
			
		||||
{ 
 | 
			
		||||
	return _CON(_con)->ServerVersion(); 
 | 
			
		||||
}
 | 
			
		||||
@ -340,12 +314,12 @@ long TXvt_recordset::items()
 | 
			
		||||
	// Per non creare casini utilizzo una funzione apposita che mi ritorna il numero
 | 
			
		||||
	P_CONN_VOID conn = new SAConnection;
 | 
			
		||||
	SAString q;
 | 
			
		||||
	long items = -1;
 | 
			
		||||
	long items = DEFAULT_ERR_NUMBER;
 | 
			
		||||
 | 
			
		||||
	// Connetto la nuova istanza
 | 
			
		||||
	try
 | 
			
		||||
	{
 | 
			
		||||
		_CON(conn)->Connect(_db, _usr, _psw, (SAClient_t)_drv);
 | 
			
		||||
		_CON(conn)->Connect(_db, _usr, _psw, static_cast<SAClient_t>(_drv));
 | 
			
		||||
		items = xvt_rcs_get_items(conn, _query);
 | 
			
		||||
		if (conn != _con)
 | 
			
		||||
			delete conn;
 | 
			
		||||
@ -395,7 +369,7 @@ bool TXvt_recordset::set(const char* query)
 | 
			
		||||
	return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool TXvt_recordset::exec(bool autoF)
 | 
			
		||||
bool TXvt_recordset::exec(const bool auto_f)
 | 
			
		||||
{
 | 
			
		||||
	CHECK_FREEZED
 | 
			
		||||
	bool ok = false;
 | 
			
		||||
@ -403,10 +377,10 @@ bool TXvt_recordset::exec(bool autoF)
 | 
			
		||||
	{
 | 
			
		||||
		_RCS(_recset)->Execute();
 | 
			
		||||
		_loaded = true;
 | 
			
		||||
		_recno = -1;
 | 
			
		||||
		_recno = DEFAULT_ERR_NUMBER;
 | 
			
		||||
		// Se trovo almeno un "select" faccio l'autofetch
 | 
			
		||||
		SAString s = _RCS(_recset)->CommandText(); s.MakeUpper();
 | 
			
		||||
		ok = s.Find("SELECT") != SIZE_MAX && autoF ? next() : true;
 | 
			
		||||
		ok = s.Find("SELECT") != SIZE_MAX && auto_f ? next() : true;
 | 
			
		||||
	}
 | 
			
		||||
	catch (SAException &x)
 | 
			
		||||
	{
 | 
			
		||||
@ -418,7 +392,7 @@ bool TXvt_recordset::exec(bool autoF)
 | 
			
		||||
	return ok;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool TXvt_recordset::set_exec(const char* query, bool auto_f)	
 | 
			
		||||
bool TXvt_recordset::set_exec(const char* query, const bool auto_f)	
 | 
			
		||||
{ 
 | 
			
		||||
	set(query); 
 | 
			
		||||
	return exec(auto_f); 
 | 
			
		||||
@ -487,14 +461,6 @@ bool TXvt_recordset::first()
 | 
			
		||||
 | 
			
		||||
bool TXvt_recordset::last()
 | 
			
		||||
{
 | 
			
		||||
	/* La vita sarebbe molto bella se potessi chiamare la funzione FetchLast(), 
 | 
			
		||||
	// siccome non so la posizione del record eseguo ciclicamente Next
 | 
			
		||||
	// _RCS(_recset)->FetchLast();
 | 
			
		||||
	while (Next())
 | 
			
		||||
	{
 | 
			
		||||
		_recno++;
 | 
			
		||||
	}
 | 
			
		||||
	*/
 | 
			
		||||
	bool fetched = false;
 | 
			
		||||
	try
 | 
			
		||||
	{
 | 
			
		||||
@ -513,10 +479,10 @@ bool TXvt_recordset::last()
 | 
			
		||||
	return fetched;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool TXvt_recordset::go(int new_pos)
 | 
			
		||||
bool TXvt_recordset::go(const int new_pos)
 | 
			
		||||
{
 | 
			
		||||
	// Controllo che la nuova posizione non sia fuori dal limite inferiore (Non so quanto è grande il recordset)
 | 
			
		||||
	bool result = new_pos >= 0 ? true : false;
 | 
			
		||||
	bool result = new_pos >= 0;
 | 
			
		||||
	
 | 
			
		||||
	// Se la posizione è minore mi sposto indietro
 | 
			
		||||
	while (new_pos < _recno && result)
 | 
			
		||||
@ -528,13 +494,7 @@ bool TXvt_recordset::go(int new_pos)
 | 
			
		||||
	{
 | 
			
		||||
		result = next();
 | 
			
		||||
	}
 | 
			
		||||
	/*
 | 
			
		||||
	// Controllo finale per prevenire errori
 | 
			
		||||
	if (newPos == _recno)
 | 
			
		||||
		return true;
 | 
			
		||||
	else
 | 
			
		||||
		return false;
 | 
			
		||||
	*/
 | 
			
		||||
 | 
			
		||||
	return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -554,7 +514,7 @@ int TXvt_recordset::get_int(const char* field)
 | 
			
		||||
		_code_error =		x.ErrNativeCode();
 | 
			
		||||
		_GET_ERROR(x.ErrMessage(), _string_error);
 | 
			
		||||
		_GET_ERROR(x.ErrText(), _string_error_full_text);
 | 
			
		||||
		return -1;
 | 
			
		||||
		return DEFAULT_ERR_NUMBER;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -569,7 +529,7 @@ short TXvt_recordset::get_short(const char* field)
 | 
			
		||||
		_code_error =		x.ErrNativeCode();
 | 
			
		||||
		_GET_ERROR(x.ErrMessage(), _string_error);
 | 
			
		||||
		_GET_ERROR(x.ErrText(), _string_error_full_text);
 | 
			
		||||
		return -1;
 | 
			
		||||
		return DEFAULT_ERR_NUMBER;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -584,7 +544,7 @@ long TXvt_recordset::get_long(const char* field)
 | 
			
		||||
		_code_error =		x.ErrNativeCode();
 | 
			
		||||
		_GET_ERROR(x.ErrMessage(), _string_error);
 | 
			
		||||
		_GET_ERROR(x.ErrText(), _string_error_full_text);
 | 
			
		||||
		return -1;
 | 
			
		||||
		return DEFAULT_ERR_NUMBER;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -599,7 +559,7 @@ double TXvt_recordset::get_double(const char* field)
 | 
			
		||||
		_code_error =		x.ErrNativeCode();
 | 
			
		||||
		_GET_ERROR(x.ErrMessage(), _string_error);
 | 
			
		||||
		_GET_ERROR(x.ErrText(), _string_error_full_text);
 | 
			
		||||
		return -1;
 | 
			
		||||
		return DEFAULT_ERR_NUMBER;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -617,12 +577,7 @@ bool TXvt_recordset::get_bool(const char* field)
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
/*
 | 
			
		||||
real TXvt_recordset::GetReal(const char * field)
 | 
			
		||||
{
 | 
			
		||||
	return Get(field);
 | 
			
		||||
}
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
const char* TXvt_recordset::get_date(const char * field)
 | 
			
		||||
{
 | 
			
		||||
	try
 | 
			
		||||
@ -637,7 +592,7 @@ const char* TXvt_recordset::get_date(const char * field)
 | 
			
		||||
		_code_error =		x.ErrNativeCode();
 | 
			
		||||
		_GET_ERROR(x.ErrMessage(), _string_error);
 | 
			
		||||
		_GET_ERROR(x.ErrText(), _string_error_full_text);
 | 
			
		||||
		return NULL;
 | 
			
		||||
		return DEFAULT_ERR_STRING;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -656,7 +611,7 @@ const char* TXvt_recordset::get(const char* field)
 | 
			
		||||
		_code_error =		x.ErrNativeCode();
 | 
			
		||||
		_GET_ERROR(x.ErrMessage(), _string_error);
 | 
			
		||||
		_GET_ERROR(x.ErrText(), _string_error_full_text);
 | 
			
		||||
		return "";
 | 
			
		||||
		return DEFAULT_ERR_STRING;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -673,7 +628,7 @@ const char* TXvt_recordset::get(unsigned int field)
 | 
			
		||||
		_code_error = x.ErrNativeCode();
 | 
			
		||||
		_GET_ERROR(x.ErrMessage(), _string_error);
 | 
			
		||||
		_GET_ERROR(x.ErrText(), _string_error_full_text);
 | 
			
		||||
		return '\0';
 | 
			
		||||
		return DEFAULT_ERR_STRING;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -688,7 +643,7 @@ char TXvt_recordset::get_char(const char* field)
 | 
			
		||||
		_code_error =		x.ErrNativeCode();
 | 
			
		||||
		_GET_ERROR(x.ErrMessage(), _string_error);
 | 
			
		||||
		_GET_ERROR(x.ErrText(), _string_error_full_text);
 | 
			
		||||
		return '\0';
 | 
			
		||||
		return DEFAULT_ERR_CHAR;
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -753,9 +708,9 @@ const char* TXvt_recordset::get_type_field(const unsigned column) const
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
long TXvt_recordset::get_code_error(bool erase)
 | 
			
		||||
long TXvt_recordset::get_code_error(const bool erase)
 | 
			
		||||
{
 | 
			
		||||
	long app = _code_error; 
 | 
			
		||||
	const long app = _code_error; 
 | 
			
		||||
	if (erase)
 | 
			
		||||
		_code_error = NOERR;
 | 
			
		||||
	return app;
 | 
			
		||||
 | 
			
		||||
@ -62,19 +62,19 @@ protected:
 | 
			
		||||
	/**< Oggetto della connessione																*/
 | 
			
		||||
	P_CONN_VOID				_con;
 | 
			
		||||
	/**< Database																									*/
 | 
			
		||||
	const char* _db;
 | 
			
		||||
	const char*				_db;
 | 
			
		||||
	/**< Utente																										*/
 | 
			
		||||
	const char* _usr;
 | 
			
		||||
	const char*				_usr;
 | 
			
		||||
	/**< Password																									*/
 | 
			
		||||
	const char* _psw;
 | 
			
		||||
	const char*				_psw;
 | 
			
		||||
	/**< Driver																										*/
 | 
			
		||||
	TT_driver		_drv;
 | 
			
		||||
	TT_driver					_drv;
 | 
			
		||||
	/**< Query																										*/
 | 
			
		||||
	const char* _query;
 | 
			
		||||
	const char*				_query{};
 | 
			
		||||
	/**< Ultima stringa con codice di errore ricevuto							*/
 | 
			
		||||
	char*				_string_error;
 | 
			
		||||
	const char*					_string_error;
 | 
			
		||||
	/**< Ultima stringa con codice di errore ricevuto full text		*/
 | 
			
		||||
	char*				_string_error_full_text;
 | 
			
		||||
	const char*					_string_error_full_text;
 | 
			
		||||
	/**< Ultimo codice di errore ricevuto													*/
 | 
			
		||||
	long							_code_error;
 | 
			
		||||
	/**< Numero record corrente																		*/
 | 
			
		||||
@ -84,7 +84,7 @@ protected:
 | 
			
		||||
	/**< Indica se il cursore è caricato													*/
 | 
			
		||||
	bool							_loaded;
 | 
			
		||||
 | 
			
		||||
	const bool checkPermission();
 | 
			
		||||
	const bool check_permission();
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
	// Disabilito il copy constructor
 | 
			
		||||
@ -94,10 +94,10 @@ public:
 | 
			
		||||
	/**< Costruttore, crea un oggetto vuoto, PERICOLOSO!! Ricordarsi di inizializzarlo opportunamente con il metodo connect() e set() */
 | 
			
		||||
	TXvt_recordset();
 | 
			
		||||
	/**< Costruttore, crea un oggetto dai parametri di connessione passati */
 | 
			
		||||
	TXvt_recordset(const char* db, const char* user, const char* pass, TT_driver tipoDb, const char * query = "", const bool ex = false, const bool freezed = false);
 | 
			
		||||
	TXvt_recordset(const char* db, const char* user, const char* pass, TT_driver tipo_db, const char * query = "", const bool ex = false, const bool freezed = false);
 | 
			
		||||
	static TT_driver str_to_driver(const char* tipo_db);
 | 
			
		||||
	/**< Costruttore, crea un oggetto dai parametri di connessione passati, chiama costruttore con TT_driver */
 | 
			
		||||
	TXvt_recordset(const char* db, const char* user, const char* pass, const char* tipoDb, const char * query = "", const bool ex = false, const bool freezed = false);
 | 
			
		||||
	TXvt_recordset(const char* db, const char* user, const char* pass, const char* tipo_db, const char * query = "", const bool ex = false, const bool freezed = false);
 | 
			
		||||
	/**< Distruttore */
 | 
			
		||||
	~TXvt_recordset();
 | 
			
		||||
 | 
			
		||||
@ -118,18 +118,18 @@ public:
 | 
			
		||||
	/* Mi scollego */
 | 
			
		||||
	void disconnect();
 | 
			
		||||
	/**< Esegue la commit, di default in caso di errore viene chiamato il metodo rollback() */
 | 
			
		||||
	bool commit(bool autoRoll = true);
 | 
			
		||||
	bool commit(bool auto_roll = true);
 | 
			
		||||
	/**< Esegue il rollback all'ultimo commit */
 | 
			
		||||
	bool rollback();
 | 
			
		||||
 | 
			
		||||
	// Setters
 | 
			
		||||
 | 
			
		||||
	/**< Imposto il tipo di client che utilizzo */
 | 
			
		||||
	void set_client(TT_driver client);
 | 
			
		||||
	void set_client(TT_driver client) const;
 | 
			
		||||
	// Imposto una opzione generica dellla connessione
 | 
			
		||||
	void set_con_option(const char* opt);
 | 
			
		||||
	void set_con_option(const char* opt) const;
 | 
			
		||||
	/**< Abilito/Disabilito l'autocommit, (disabilitato di default) */
 | 
			
		||||
	void set_autocommit(bool ac);
 | 
			
		||||
	void set_autocommit(bool ac) const;
 | 
			
		||||
	/**< Imposta la visibilità delle transazioni (vedi Funzione) */
 | 
			
		||||
	void set_visibility(iso_lvl vis = committed);
 | 
			
		||||
	
 | 
			
		||||
@ -140,17 +140,17 @@ public:
 | 
			
		||||
	/**< Ritorna se la connessione è attiva */
 | 
			
		||||
	const bool is_alive() const;
 | 
			
		||||
	/**< Ritorna la visibilità impostata */
 | 
			
		||||
	int  get_visibility();
 | 
			
		||||
	int  get_visibility() const;
 | 
			
		||||
	/**< Ritorna se è attivo l'autocommit, true -> attivo, false -> disattivo o sconosciuto */
 | 
			
		||||
	bool get_autocommit();
 | 
			
		||||
	bool get_autocommit() const;
 | 
			
		||||
	/**< Ritorna il valore dell'opzione specificata */
 | 
			
		||||
	const char* get_option(const char* opt);
 | 
			
		||||
	const char* get_option(const char* opt) const;
 | 
			
		||||
	/**< Ritorno la versione del Client che sto utilizzando */
 | 
			
		||||
	long get_client_v();
 | 
			
		||||
	long get_client_v() const;
 | 
			
		||||
	/**< Ritorno la versione del Server che sto utilizzando */
 | 
			
		||||
	const char* getServerV();
 | 
			
		||||
	const char* get_server_v() const;
 | 
			
		||||
	/**< Ritorno la versione del Server che sto utilizzando in formato numerico */
 | 
			
		||||
	long get_server_vn();
 | 
			
		||||
	long get_server_vn() const;
 | 
			
		||||
	/**< Ritorno se il recordset è carico */
 | 
			
		||||
	bool is_loaded() const;
 | 
			
		||||
	/**< Ritorno il numero di elementi nella query */
 | 
			
		||||
@ -164,7 +164,7 @@ public:
 | 
			
		||||
	/**< Imposta la query ricevuta nel recordset */
 | 
			
		||||
	bool set(const char* query);
 | 
			
		||||
	/**< Esegue la query impostata nel recordset, se viene passato autoF == true esegue anche un comando Next() */
 | 
			
		||||
	bool exec(bool autoF = true);
 | 
			
		||||
	bool exec(bool auto_f = true);
 | 
			
		||||
	/**< Unisce le funzioni Set e Exec, riceve la query */
 | 
			
		||||
	bool set_exec(const char* query, bool auto_f = true);
 | 
			
		||||
	/**< Si sposta avanti di un record, in caso di esito negativo valorizza _stringError e _codeError */
 | 
			
		||||
 | 
			
		||||
@ -5,3 +5,6 @@
 | 
			
		||||
#define NOT_INITIALIZEDS "ERROR: Recordset not initialized"
 | 
			
		||||
#define ERROR_FREEZED		-883
 | 
			
		||||
#define ERROR_FREEZEDS	"ERROR: Recordset on ice"
 | 
			
		||||
#define DEFAULT_ERR_NUMBER -19
 | 
			
		||||
#define DEFAULT_ERR_STRING ""
 | 
			
		||||
#define DEFAULT_ERR_CHAR '\0'
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user