Merge branch 'R_10_00' of http://10.65.20.33/CAMPO/campo into R_10_00
This commit is contained in:
commit
56e8acaecb
@ -288,7 +288,7 @@ END
|
||||
|
||||
BOOLEAN S_SPLITPAY
|
||||
BEGIN
|
||||
PROMPT 1 7 "Assogettato scissione pagamenti art.17 ter DPR 633/72"
|
||||
PROMPT 1 7 "Soggetto a scissione pagamenti art.17 ter DPR 633/72"
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
|
@ -151,9 +151,6 @@ void TMancati_mask::fill()
|
||||
bool first, show, ask = !((show = (first = true)));
|
||||
int fat_no_cod = 0;
|
||||
|
||||
// Disabilito la colonna del codice ufficio
|
||||
docs.enable_column(docs.cid2index(S_UFFICIO), false);
|
||||
|
||||
for (bool okc = rec.move_first(); okc; okc = rec.move_next())
|
||||
{
|
||||
if (!pi.add_status())
|
||||
@ -171,56 +168,19 @@ void TMancati_mask::fill()
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
TToken_string& row = docs.row(-1);
|
||||
row = "";
|
||||
row.add(rec.get(DOC_ANNO).as_int(), 1);
|
||||
row.add(rec.get(DOC_CODNUM).as_string());
|
||||
row.add(rec.get(DOC_TIPODOC).as_string());
|
||||
if (!rec.get(DOC_TIPODOCSDI).is_empty())
|
||||
row.add(rec.get(DOC_TIPODOCSDI).as_string());
|
||||
else
|
||||
row.add(td.tipo_doc_sdi());
|
||||
row.add(rec.get(DOC_NDOC).as_int());
|
||||
row.add(rec.get(DOC_DATADOC).as_date());
|
||||
row.add(rec.get(CFV_CODCF).as_int());
|
||||
row.add(rec.get("20." CLI_RAGSOC).as_string());
|
||||
|
||||
TString rif = get_dest_sdi(rec.get(CFV_TIPOCF).as_string()[0], rec.get(CFV_CODCF).as_int());
|
||||
// Se è ancora vuoto potrebbe essere estero
|
||||
if(rif.empty())
|
||||
{
|
||||
// Segno la riga errata
|
||||
if (first)
|
||||
{
|
||||
first = false;
|
||||
// Abilito la colonna del codice ufficio per segnalare l'errore
|
||||
docs.enable_column(docs.cid2index(S_UFFICIO));
|
||||
}
|
||||
docs.set_back_and_fore_color(COLOR_RED, COLOR_WHITE, rec.current_row(), docs.cid2index(S_UFFICIO));
|
||||
fat_no_cod++;
|
||||
}
|
||||
;
|
||||
row.add(rif);
|
||||
row.add(rec.get("17." CFV_PARIFAMM).as_string());
|
||||
row.add(rec.get("20." CLI_COFI).as_string());
|
||||
|
||||
bool split = rec.get("20." CLI_SPLITPAY).as_bool();
|
||||
if (split)
|
||||
{
|
||||
const long numreg = rec.get(DOC_NUMREG).as_int();
|
||||
if (numreg > 0)
|
||||
{
|
||||
const TRectype& mov = cache().get(LF_MOV, numreg);
|
||||
split = is_split_payment(mov);
|
||||
}
|
||||
}
|
||||
row.add(split ? "X" : " ");
|
||||
|
||||
const bool attach = !rec.get("COLL_GOLEM").is_empty();
|
||||
row.add(attach ? "X" : " ");
|
||||
|
||||
row.add(!td.invio_xml() ? "X" : "");
|
||||
row.add(rec.get("20." CLI_DOCMAIL).as_string()); // Indirizzo email
|
||||
row.add(rec.get("20." CLI_BYMAIL).as_string()); // Consenso invio email
|
||||
}
|
||||
|
||||
docs.force_update();
|
||||
@ -353,9 +313,20 @@ bool TMancati_mask::check_doc_filter(const TDocumentoEsteso& d) const
|
||||
|
||||
class TMancati_app : public TSkeleton_application
|
||||
{
|
||||
int _anno;
|
||||
TString16 _codnum, _tipodoc;
|
||||
long _ndoc, _codcf;
|
||||
char _tipocf;
|
||||
|
||||
void set_next_pdf(const int anno, const TFixed_string& codnum, const TFixed_string& tipodoc, const long ndoc, const long codcf);
|
||||
bool get_next_pdf(int anno, long ditta, const char* codnum, long ndoc, long codcf, TFilename& pdf) const override;
|
||||
bool get_next_mail(TToken_string& to, TToken_string& cc, TToken_string& ccn, TString& subj, TString& text,
|
||||
TToken_string& attach, short& ui) const override;
|
||||
bool get_mail_address(TToken_string& to, TToken_string& cc) const;
|
||||
|
||||
public:
|
||||
virtual bool create();
|
||||
|
||||
virtual bool destroy();
|
||||
virtual void main_loop();
|
||||
|
||||
@ -367,6 +338,27 @@ void TMancati_app::main_loop()
|
||||
TMancati_mask mask;
|
||||
while (mask.run() == K_ENTER)
|
||||
{
|
||||
TString_array& sht = mask.sfield(F_DOCS).rows_array();
|
||||
TFp_mail_sender mail_sender;
|
||||
|
||||
FOR_EACH_ARRAY_ROW(sht, r, riga)
|
||||
{
|
||||
//if (!pi.add_status(1))
|
||||
//break;
|
||||
|
||||
if (riga->starts_with("X"))
|
||||
{
|
||||
const int anno = riga->get_int(mask.sfield(F_DOCS).cid2index(S_ANNO));
|
||||
const long ndoc = riga->get_long(mask.sfield(F_DOCS).cid2index(S_NDOC));
|
||||
const TFixed_string codnum(riga->get(mask.sfield(F_DOCS).cid2index(S_CODNUM)));
|
||||
const TFixed_string tipodoc(riga->get(mask.sfield(F_DOCS).cid2index(S_TIPODOC)));
|
||||
const long codcf = riga->get_long(mask.sfield(F_DOCS).cid2index(S_CLIENTE));
|
||||
|
||||
|
||||
mail_sender.set_doc(anno, ndoc, codnum, tipodoc, codcf);
|
||||
mail_sender.send();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -384,6 +376,112 @@ bool TMancati_app::create()
|
||||
|
||||
}
|
||||
|
||||
void TMancati_app::set_next_pdf(const int anno, const TFixed_string& codnum, const TFixed_string& tipodoc, const long ndoc, const long codcf)
|
||||
{
|
||||
_anno = anno;
|
||||
_codnum = codnum;
|
||||
_ndoc = ndoc;
|
||||
_tipodoc = tipodoc;
|
||||
_tipocf = 'C';
|
||||
_codcf = codcf;
|
||||
}
|
||||
|
||||
bool TMancati_app::get_next_pdf(int anno, long ditta, const char* codnum, long ndoc, long codcf, TFilename& pdf) const
|
||||
{
|
||||
bool ok = false;
|
||||
if (_anno > 0 && _codnum.full() && _ndoc > 0 && _codcf > 0)
|
||||
ok = TSkeleton_application::get_next_pdf(_anno, ditta, _codnum, _ndoc, _codcf, pdf);
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
bool TMancati_app::get_next_mail(TToken_string& to, TToken_string& cc, TToken_string& ccn,
|
||||
TString& subj, TString& text, TToken_string& attach, short& ui) const
|
||||
{
|
||||
bool ok = TApplication::get_next_mail(to, cc, ccn, subj, text, attach, ui);
|
||||
|
||||
if (_ndoc > 0L)
|
||||
{
|
||||
ok = get_mail_address(to, cc);
|
||||
if (ok)
|
||||
{
|
||||
const TDocumento doc('D', _anno, _codnum, _ndoc);
|
||||
doc.riferimento(subj);
|
||||
if (subj.blank())
|
||||
subj = doc.tipo().descrizione();
|
||||
subj << ' ' << _ndoc << TR(" del ") << doc.get(DOC_DATADOC)
|
||||
<< ' ' << prefix().firm().ragione_sociale();
|
||||
|
||||
TString saluti = esc(ini_get_string(CONFIG_USER, "Mail", "Signature"));
|
||||
if (saluti.full())
|
||||
{
|
||||
if (saluti.find('\n') < 0 && fexist(saluti))
|
||||
{
|
||||
TScanner s(saluti);
|
||||
while (!s.eof())
|
||||
text << s.line() << '\n';
|
||||
}
|
||||
else
|
||||
text << saluti << '\n';
|
||||
}
|
||||
else
|
||||
{
|
||||
text << TR("Cordiali Saluti ") << prefix().firm().ragione_sociale();
|
||||
}
|
||||
text.trim();
|
||||
if (to.full())
|
||||
ui &= ~0x1; // No user interface
|
||||
ui |= 0x2; // Query receipt
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TMancati_app::get_mail_address(TToken_string& to, TToken_string& cc) const
|
||||
{
|
||||
if (_tipodoc.full())
|
||||
{
|
||||
const TTipo_documento& tipo = cached_tipodoc(_tipodoc);
|
||||
TFilename report; tipo.mail_print_profile(report);
|
||||
report = report.name_only();
|
||||
|
||||
TString8 clifo; clifo.format("%c%06ld", _tipocf, _codcf);
|
||||
TISAM_recordset contacts("USE MULTIREL\nFROM COD=BACON FIRST=#CLIFO\nTO COD=BACON FIRST=#CLIFO");
|
||||
contacts.set_var("#CLIFO", clifo);
|
||||
|
||||
TToken_string data;
|
||||
for (bool ok = contacts.move_first(); ok; ok = contacts.move_next())
|
||||
{
|
||||
data = contacts.get("DATA").as_string();
|
||||
FOR_EACH_TOKEN(data, tok)
|
||||
{
|
||||
if (_tipodoc.match(tok, true) || report.match(tok, true))
|
||||
{
|
||||
const TRectype& rub = cache().get(LF_CONTACT, contacts.get("SECOND").as_int());
|
||||
TString80 mail = rub.get("MAIL");
|
||||
if (mail.blank())
|
||||
mail = rub.get("MAIL2");
|
||||
if (mail.full())
|
||||
{
|
||||
if (to.blank())
|
||||
to = mail;
|
||||
else
|
||||
cc.add(mail);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (to.blank())
|
||||
{
|
||||
TString8 key; key << _tipocf << '|' << _codcf;
|
||||
to = cache().get(LF_CLIFO, key, CLI_DOCMAIL);
|
||||
}
|
||||
return to.full();
|
||||
}
|
||||
|
||||
bool TMancati_app::destroy()
|
||||
{
|
||||
fp_db().sq_disconnect();
|
||||
|
@ -21,14 +21,10 @@
|
||||
#define S_ANNO 102
|
||||
#define S_CODNUM 103
|
||||
#define S_TIPODOC 104
|
||||
#define S_CODSDI 105
|
||||
#define S_NDOC 106
|
||||
#define S_DATADOC 107
|
||||
#define S_CLIENTE 108
|
||||
#define S_RAGSOC 109
|
||||
#define S_UFFICIO 110
|
||||
#define S_RIFAMM 111
|
||||
#define S_COFI 112
|
||||
#define S_SPLITPAY 113
|
||||
#define S_ATTACH 114
|
||||
#define S_ONLYGEN 115
|
||||
#define S_NDOC 105
|
||||
#define S_DATADOC 106
|
||||
#define S_CLIENTE 107
|
||||
#define S_RAGSOC 108
|
||||
#define S_COFI 109
|
||||
#define S_DOCMAIL 110
|
||||
#define S_BYMAIL 111
|
@ -15,6 +15,14 @@ BEGIN
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
BUTTON DLG_EMAIL 10 2
|
||||
BEGIN
|
||||
PROMPT 5 1 "Mail"
|
||||
PICTURE TOOL_EMAIL
|
||||
MESSAGE EXIT,69
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
#include <helpbar.h>
|
||||
|
||||
ENDPAGE
|
||||
@ -56,17 +64,13 @@ BEGIN
|
||||
ITEM "Anno"
|
||||
ITEM "Cod.\nNum.@4"
|
||||
ITEM "Tipo\nDoc@4"
|
||||
ITEM "Tipo SDI@4"
|
||||
ITEM "Num.\nDoc.@7"
|
||||
ITEM "Data\nDoc.@10"
|
||||
ITEM "Cliente"
|
||||
ITEM "Ragione Sociale@50"
|
||||
ITEM "Codice destinatario@20"
|
||||
ITEM "Riferimento\nAmministrazione@20"
|
||||
ITEM "Codice Fiscale@16"
|
||||
ITEM "Scissione\nPagamenti@9"
|
||||
ITEM "Allegati"
|
||||
ITEM "Solo generazione"
|
||||
ITEM "EMail@50"
|
||||
ITEM "Consenso\ninvio@7"
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
@ -181,18 +185,6 @@ BEGIN
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
LIST S_CODSDI 35
|
||||
BEGIN
|
||||
PROMPT 41 2 "Tipo Doc SDI"
|
||||
ITEM "TD01|TD01 Fattura"
|
||||
ITEM "TD02|TD02 Acconto/Anticipo su fattura"
|
||||
ITEM "TD03|TD03 Acconto/Anticipo su parcella"
|
||||
ITEM "TD04|TD04 Nota di credito"
|
||||
ITEM "TD05|TD05 Nota di debito"
|
||||
ITEM "TD06|TD06 Parcella"
|
||||
ITEM "TD20|TD20 Autofattura"
|
||||
END
|
||||
|
||||
NUMBER S_NDOC 7
|
||||
BEGIN
|
||||
PROMPT 1 3 "Numero "
|
||||
@ -217,39 +209,21 @@ BEGIN
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
STRING S_UFFICIO 50 20
|
||||
BEGIN
|
||||
PROMPT 1 5 ""
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
STRING S_RIFAMM 20
|
||||
BEGIN
|
||||
PROMPT 21 5 ""
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
STRING S_COFI 20
|
||||
BEGIN
|
||||
PROMPT 1 6 ""
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
BOOLEAN S_SPLITPAY
|
||||
STRING S_DOCMAIL 50
|
||||
BEGIN
|
||||
PROMPT 1 7 "Assogettato scissione pagamenti art.17 ter DPR 633/72"
|
||||
PROMPT 1 6 "email"
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
BOOLEAN S_ATTACH
|
||||
BOOLEAN S_BYMAIL
|
||||
BEGIN
|
||||
PROMPT 1 8 "Documenti in allegato"
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
BOOLEAN S_ONLYGEN
|
||||
BEGIN
|
||||
PROMPT 20 8 "Solo generazione"
|
||||
PROMPT 1 7 "Consenso invio email"
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
|
@ -305,5 +305,21 @@ public:
|
||||
|
||||
TFP_righe_custom();
|
||||
};
|
||||
class TFp_mail_sender
|
||||
{
|
||||
int _anno;
|
||||
TString16 _codnum;
|
||||
const TTipo_documento* _tipodoc;
|
||||
long _ndoc, _codcf;
|
||||
|
||||
|
||||
public:
|
||||
void set_doc(const int anno, const long ndoc, const TFixed_string& codnum, const TFixed_string& tipodoc, const long codcf);
|
||||
bool genera_pdf();
|
||||
void send();
|
||||
|
||||
TFp_mail_sender() { }
|
||||
TFp_mail_sender(const int anno, const long ndoc, const TFixed_string& codnum, const TFixed_string& tipodoc, const long codcf)
|
||||
{ set_doc(anno, ndoc, codnum, tipodoc, codcf); }
|
||||
};
|
||||
#endif // __FPLIB_H
|
||||
|
53
src/fp/fplib03.cpp
Normal file
53
src/fp/fplib03.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
#include "fplib.h"
|
||||
#include "execp.h"
|
||||
|
||||
class TExternal_app;
|
||||
|
||||
void TFp_mail_sender::set_doc(const int anno, const long ndoc, const TFixed_string& codnum, const TFixed_string& tipodoc, const long codcf)
|
||||
{
|
||||
_anno = anno;
|
||||
_codnum = codnum;
|
||||
_tipodoc = &cached_tipodoc(tipodoc);
|
||||
_ndoc = ndoc;
|
||||
_codcf = codcf;
|
||||
}
|
||||
|
||||
bool TFp_mail_sender::genera_pdf()
|
||||
{
|
||||
static TString commandline;
|
||||
commandline.cut(0) << "ve1 -2 " << doc.get(DOC_CODNUM) << ' ' << doc.get(DOC_ANNO)
|
||||
<< ' ' << doc.get(DOC_PROVV) << ' ' << doc.get(DOC_NDOC) << " X P 1 D"; // X: stampa su disco, P: provvisorio, 1: 1 copia, D: disabilita archiviazione
|
||||
TExternal_app interattivo(commandline);
|
||||
if (interattivo.run() != NOERR)
|
||||
{
|
||||
TString msgerr = "Fallita generazione PDF documento ";
|
||||
msgerr << doc.get(DOC_CODNUM) << ' ' << doc.get(DOC_ANNO)
|
||||
<< ' ' << doc.get(DOC_PROVV) << ' ' << doc.get(DOC_NDOC);
|
||||
error_box(msgerr);
|
||||
}
|
||||
else
|
||||
{
|
||||
TFilename pdf; pdf.tempdir();
|
||||
pdf << SLASH << doc.get(DOC_ANNO) << '_' << doc.get(DOC_CODNUM) << '_' << doc.get(DOC_NDOC) << ".pdf";
|
||||
if (!pdf.exist() && !yesno_box("Attenzione! Non è stato possibile creare il pdf, continuare?"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!add_row_alleg(pdf, nprogr, paf2600f))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
void TFp_mail_sender::send()
|
||||
{
|
||||
TFilename mail;
|
||||
if (fp_settings().get_allega_fat()) {
|
||||
TString fld_pdf = fp_settings().get_fld_dest_usr(); // Cartella dove ci sono i pdf generati
|
||||
|
||||
//se lo trovo ce l'ho già altrimenti devo generarlo
|
||||
genera_pdf();
|
||||
|
||||
|
||||
|
||||
}
|
||||
_tipodoc->mail_print_profile(mail);
|
||||
}
|
@ -12,6 +12,12 @@ const TDate SSimple_query::sq_get_date(const char * field)
|
||||
return app;
|
||||
}
|
||||
|
||||
const real SSimple_query::sq_get_real(const char * field)
|
||||
{
|
||||
const real app(_rec.get(field));
|
||||
return app;
|
||||
}
|
||||
|
||||
TString SSimple_query::sq_get(const char* field, bool rtrim)
|
||||
{
|
||||
TString fld = _rec.get(field);
|
||||
@ -21,7 +27,7 @@ TString SSimple_query::sq_get(const char* field, bool rtrim)
|
||||
return fld;
|
||||
}
|
||||
|
||||
TString SSimple_query::sq_get(string field, bool rtrim)
|
||||
TString SSimple_query::sq_get(const string& field, const bool rtrim)
|
||||
{
|
||||
return sq_get(field.c_str(), rtrim);
|
||||
}
|
||||
|
@ -74,48 +74,48 @@ public:
|
||||
/**< Costruttore, non inizializza nulla, da caricare successivamente */
|
||||
SSimple_query() = default;
|
||||
/**< Costruttore, Accetta in ingresso dei parametri per la connessione, volendo è anche possibile impostare una query ed eseguirla. Attenzione! Non risponde se la query ha avuto un esito positivo o negativo! */
|
||||
SSimple_query(const char* db, const char* user, const char* pass, TT_driver tipoDb, const char * query = "", const bool ex = false, const bool freezed = false) : _rec(db, user, pass, tipoDb, query, ex, freezed) {}
|
||||
SSimple_query(const char* db, const char* user, const char* pass, const TT_driver tipo_db, const char * query = "", const bool ex = false, const bool freezed = false) : _rec(db, user, pass, tipo_db, query, ex, freezed) {}
|
||||
//SSimpleQuery(const TString& db, const TString& user, const TString& pass, TT_driver tipoDb, const char * query = "", const bool ex = false, const bool freezed = false) : _rec(db, user, pass, tipoDb, query, ex, freezed) {}
|
||||
/**< Distruttore */
|
||||
virtual ~SSimple_query() = default;
|
||||
|
||||
// Connection functions
|
||||
/**< Eseguo la connessione */
|
||||
int sq_connect(const char* db, const char* user, const char* pass, TT_driver tipoDb) { return _rec.connect(db, user, pass, tipoDb); }
|
||||
int sq_connect(const char* db, const char* user, const char* pass, const TT_driver tipo_db) { return _rec.connect(db, user, pass, tipo_db); }
|
||||
/* Mi scollego */
|
||||
void sq_disconnect() { _rec.disconnect(); }
|
||||
/**< Esegue la commit, di default in caso di errore viene chiamato il metodo rollback() */
|
||||
const bool sq_commit(bool autoRoll = true) { return _rec.commit(); }
|
||||
const bool sq_commit(const bool auto_roll = true) { return _rec.commit(auto_roll); }
|
||||
/**< Esegue il rollback all'ultimo commit */
|
||||
const bool sq_rollback() { return _rec.rollback(); }
|
||||
/**< Imposto il tipo di client che utilizzo */
|
||||
void sq_set_client(int client) { _rec.setClient((TT_driver)client); }
|
||||
void sq_set_client(TT_driver client) { _rec.setClient(client); }
|
||||
void sq_set_client(int client) { _rec.set_client(static_cast<TT_driver>(client)); }
|
||||
void sq_set_client(const TT_driver client) { _rec.set_client(client); }
|
||||
// Imposto una opzione generica dellla connessione
|
||||
void sq_set_con_option(const char* opt) { _rec.setConOption(opt); }
|
||||
void sq_set_con_option(const char* opt) { _rec.set_con_option(opt); }
|
||||
/**< Abilito/Disabilito l'autocommit, (disabilitato di default) */
|
||||
void sq_set_autocommit(bool ac) { _rec.setAutocommit(ac); }
|
||||
void sq_set_autocommit(const bool ac) { _rec.set_autocommit(ac); }
|
||||
/** Imposta la visibilità delle transazioni (vedi Funzione) */
|
||||
void sq_set_visibility(isoLvl vis = committed) { _rec.setVisibility(vis); }
|
||||
void sq_set_visibility(const iso_lvl vis = committed) { _rec.set_visibility(vis); }
|
||||
// Getters
|
||||
/** Ritorna se la conessione è connessa */
|
||||
const bool sq_is_connect() const { return _rec.isConnect(); }
|
||||
const bool sq_is_connect() const { return _rec.is_connect(); }
|
||||
/**< Ritorna se la connessione è attiva */
|
||||
const bool sq_is_alive() const { return _rec.isAlive(); }
|
||||
const bool sq_is_alive() const { return _rec.is_alive(); }
|
||||
/** Ritorna la visibilità impostata */
|
||||
const int sq_get_visibility() { return _rec.getVisibility(); }
|
||||
const int sq_get_visibility() { return _rec.get_visibility(); }
|
||||
/**< Ritorna se è attivo l'autocommit, true -> attivo, false -> disattivo o sconosciuto */
|
||||
const bool sq_get_autocommit() { return _rec.getAutocommit(); }
|
||||
const bool sq_get_autocommit() { return _rec.get_autocommit(); }
|
||||
/**< Ritorna il valore dell'opzione specificata */
|
||||
const char* sq_get_option(const char* opt) { return _rec.getOption(opt); }
|
||||
const char* sq_get_option(const char* opt) { return _rec.get_option(opt); }
|
||||
/**< Ritorno la versione del Client che sto utilizzando */
|
||||
const long sq_get_client_v() { return _rec.getClientV(); }
|
||||
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(); }
|
||||
/**< Ritorno la versione del Server che sto utilizzando in formato numerico */
|
||||
const long sq_get_server_vn() { return _rec.getServerVN(); }
|
||||
const long sq_get_server_vn() { return _rec.get_server_vn(); }
|
||||
/**< Ritorno se il recordset è carico */
|
||||
const bool sq_is_loaded() const { return _rec.isLoaded(); }
|
||||
const bool sq_is_loaded() const { return _rec.is_loaded(); }
|
||||
/** Ritorno il numero di elementi nella query */
|
||||
const long sq_items() { return _rec.items(); }
|
||||
|
||||
@ -123,17 +123,17 @@ public:
|
||||
/**< Imposta la query ricevuta come (const char *) nel recordset */
|
||||
const bool sq_set(const char* query) { return _rec.set(query); }
|
||||
/**< Imposta la query ricevuta come (string) nel recordset */
|
||||
const bool sq_set(string query) { return _rec.set(query.c_str()); }
|
||||
const bool sq_set(const string& query) { return _rec.set(query.c_str()); }
|
||||
/**< Imposta la query ricevuta come (TString) nel recordset */
|
||||
const bool sq_set(TString& query) { return _rec.set(static_cast<const char *>(query)); }
|
||||
/**< Esegue la query impostata nel recordset, se viene passato autoF == true esegue anche un comando sqNext() */
|
||||
const bool sq_exec(bool autoF = true) { return _rec.exec(autoF); }
|
||||
/**< Unisce le funzioni sqSet e sqExec, riceve la query come (const char *) */
|
||||
const bool sq_set_exec(const char* query, bool autoF = true) { _rec.set(query); return _rec.exec(autoF); }
|
||||
const bool sq_set_exec(const char* query, const bool auto_f = true) { _rec.set(query); return _rec.exec(auto_f); }
|
||||
/**< Unisce le funzioni sqSet e sqExec, riceve la query come (string) */
|
||||
const bool sq_set_exec(string query, bool autoF = true) { _rec.set(query.c_str()); return _rec.exec(autoF); }
|
||||
const bool sq_set_exec(const string& query, const bool auto_f = true) { _rec.set(query.c_str()); return _rec.exec(auto_f); }
|
||||
/**< Unisce le funzioni sqSet e sqExec, riceve la query come (TString) */
|
||||
const bool sq_set_exec(TString& query, bool autoF = true) { return sq_set_exec(static_cast<const char*>(query), autoF); }
|
||||
const bool sq_set_exec(TString& query, const bool auto_f = true) { return sq_set_exec(static_cast<const char*>(query), auto_f); }
|
||||
/**< Si sposta avanti di un record, in caso di esito negativo valorizza _stringError e _codeError */
|
||||
const bool sq_next() { return _rec.next(); }
|
||||
/**< Si sposta indietro di un record, in caso di esito negativo valorizza _stringError e _codeError */
|
||||
@ -143,9 +143,9 @@ public:
|
||||
/**< Si sposta al primo record, in caso di esito negativo valorizza _stringError e _codeError */
|
||||
const bool sq_last() { return _rec.last(); }
|
||||
/**< Si sposta alla posizione n, in caso di esito negativo valorizza _stringError e _codeError */
|
||||
const bool sq_go(int newPos) { return _rec.go(newPos); }
|
||||
const bool sq_go(const int new_pos) { return _rec.go(new_pos); }
|
||||
/**< Ritorna il numero di righe affette dall'ultima query */
|
||||
const int sq_rows_affected() { return _rec.rowsAffected(); }
|
||||
const int sq_rows_affected() const { return _rec.rows_affected(); }
|
||||
|
||||
|
||||
// Getters
|
||||
@ -168,7 +168,7 @@ public:
|
||||
/**< Ritorna il valore nel campo (field) passato come (const char *) in formato (const char *) */
|
||||
TString sq_get(const char* field, bool rtrim = true);
|
||||
/**< Ritorna il valore nel campo (field) passato come (string) in formato (const char *) */
|
||||
TString sq_get(string field, bool rtrim = true);
|
||||
TString sq_get(const string& field, bool rtrim = true);
|
||||
/**< Ritorna il valore nel campo (field) passato come (TString) in formato (const char *) */
|
||||
TString sq_get(TString& field, bool rtrim = true);
|
||||
/**< Ritorna il valore nel campo (field) in formato (char) */
|
||||
@ -178,11 +178,11 @@ public:
|
||||
|
||||
// Error Getters
|
||||
/**< Ritorno l'ultimo codice errore segnalato in formato /int) */
|
||||
const long sq_get_code_error(bool erase = true) { return _rec.get_code_error(erase); }
|
||||
const long sq_get_code_error(const bool erase = true) { return _rec.get_code_error(erase); }
|
||||
/**< Ritorno l'ultima stringa di errore segnalato in formato (const char *) */
|
||||
const char* sq_get_string_error(bool erase = true) { return _rec.get_string_error(erase); }
|
||||
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(bool erase = true) { return _rec.get_text_error(erase); }
|
||||
const char* sq_get_text_error(const bool erase = true) { return _rec.get_text_error(erase); }
|
||||
};
|
||||
|
||||
#endif
|
@ -9,6 +9,7 @@
|
||||
#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(); }
|
||||
|
||||
/******************************************************************************
|
||||
* TXvt_recordset *
|
||||
@ -84,7 +85,7 @@ const bool TXvt_recordset::checkPermission()
|
||||
{
|
||||
bool err = is_freezed();
|
||||
if (err)
|
||||
setErrorFreezed();
|
||||
set_error_freezed();
|
||||
return !err;
|
||||
}
|
||||
|
||||
@ -94,7 +95,7 @@ const bool TXvt_recordset::checkPermission()
|
||||
* Gestione Connection *
|
||||
**************************************************************************************************/
|
||||
|
||||
int TXvt_recordset::connect(const char* db, const char* user, const char* pass, TT_driver tipoDb)
|
||||
int TXvt_recordset::connect(const char* db, const char* user, const char* pass, TT_driver tipo_db)
|
||||
{
|
||||
if (_con != NULL)
|
||||
{
|
||||
@ -105,7 +106,7 @@ int TXvt_recordset::connect(const char* db, const char* user, const char* pass,
|
||||
SAString dbAddress = db;
|
||||
SAString usr = user;
|
||||
SAString psw = pass;
|
||||
SAClient_t dbDriver = (SAClient_t)tipoDb;
|
||||
SAClient_t dbDriver = (SAClient_t)tipo_db;
|
||||
if (dbAddress.IsEmpty() || usr.IsEmpty())
|
||||
{
|
||||
_code_error = NOT_INITIALIZED;
|
||||
@ -189,22 +190,22 @@ bool TXvt_recordset::rollback()
|
||||
return true;
|
||||
}
|
||||
|
||||
void TXvt_recordset::setClient(TT_driver client)
|
||||
void TXvt_recordset::set_client(TT_driver client)
|
||||
{
|
||||
_CON(_con)->setClient((SAClient_t) client);
|
||||
}
|
||||
|
||||
void TXvt_recordset::setConOption(const char* opt)
|
||||
void TXvt_recordset::set_con_option(const char* opt)
|
||||
{
|
||||
_CON(_con)->setOption(opt);
|
||||
}
|
||||
|
||||
void TXvt_recordset::setAutocommit(bool ac)
|
||||
void TXvt_recordset::set_autocommit(bool ac)
|
||||
{
|
||||
_CON(_con)->setAutoCommit(ac ? SA_AutoCommitOn : SA_AutoCommitOff);
|
||||
}
|
||||
|
||||
void TXvt_recordset::setVisibility(isoLvl vis)
|
||||
void TXvt_recordset::set_visibility(iso_lvl vis)
|
||||
{
|
||||
/* La libreria attuale supporta diversi tipi di visibilità, per mantenere una compatibilità massima
|
||||
* (evitando inutili seghe mentali) consiglio di usare i primi due, di default la classe imposta "Read committed"
|
||||
@ -217,27 +218,27 @@ void TXvt_recordset::setVisibility(isoLvl vis)
|
||||
_CON(_con)->setIsolationLevel((SAIsolationLevel_t)vis);
|
||||
}
|
||||
|
||||
const bool TXvt_recordset::isConnect() const
|
||||
const bool TXvt_recordset::is_connect() const
|
||||
{
|
||||
return _CON(_con)->isConnected();
|
||||
}
|
||||
const bool TXvt_recordset::isAlive() const
|
||||
const bool TXvt_recordset::is_alive() const
|
||||
{
|
||||
return _CON(_con)->isAlive();
|
||||
}
|
||||
int TXvt_recordset::getVisibility()
|
||||
int TXvt_recordset::get_visibility()
|
||||
{
|
||||
return (isoLvl)_CON(_con)->IsolationLevel();
|
||||
return (iso_lvl)_CON(_con)->IsolationLevel();
|
||||
}
|
||||
bool TXvt_recordset::getAutocommit()
|
||||
bool TXvt_recordset::get_autocommit()
|
||||
{
|
||||
return _CON(_con)->AutoCommit() == SA_AutoCommitOn;
|
||||
}
|
||||
const char* TXvt_recordset::getOption(const char* opt)
|
||||
const char* TXvt_recordset::get_option(const char* opt)
|
||||
{
|
||||
return _CON(_con)->Option(opt);
|
||||
}
|
||||
long TXvt_recordset::getClientV()
|
||||
long TXvt_recordset::get_client_v()
|
||||
{
|
||||
return _CON(_con)->ClientVersion();
|
||||
}
|
||||
@ -245,12 +246,12 @@ const char* TXvt_recordset::getServerV()
|
||||
{
|
||||
return _CON(_con)->ServerVersionString();
|
||||
}
|
||||
long TXvt_recordset::getServerVN()
|
||||
long TXvt_recordset::get_server_vn()
|
||||
{
|
||||
return _CON(_con)->ServerVersion();
|
||||
}
|
||||
|
||||
bool TXvt_recordset::isLoaded() const
|
||||
bool TXvt_recordset::is_loaded() const
|
||||
{
|
||||
return _loaded;
|
||||
}
|
||||
@ -331,10 +332,10 @@ bool TXvt_recordset::exec(bool autoF)
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TXvt_recordset::setExec(const char* query, bool autoF)
|
||||
bool TXvt_recordset::set_exec(const char* query, bool auto_f)
|
||||
{
|
||||
set(query);
|
||||
return exec(autoF);
|
||||
return exec(auto_f);
|
||||
}
|
||||
|
||||
bool TXvt_recordset::next()
|
||||
@ -426,18 +427,18 @@ bool TXvt_recordset::last()
|
||||
return fetched;
|
||||
}
|
||||
|
||||
bool TXvt_recordset::go(int newPos)
|
||||
bool TXvt_recordset::go(int new_pos)
|
||||
{
|
||||
// Controllo che la nuova posizione non sia fuori dal limite inferiore (Non so quanto è grande il recordset)
|
||||
bool result = newPos >= 0 ? true : false;
|
||||
bool result = new_pos >= 0 ? true : false;
|
||||
|
||||
// Se la posizione è minore mi sposto indietro
|
||||
while (newPos < _recno && result)
|
||||
while (new_pos < _recno && result)
|
||||
{
|
||||
result = prev();
|
||||
}
|
||||
// Se la posizione è maggiore mi sposto in avanti
|
||||
while (newPos > _recno && result)
|
||||
while (new_pos > _recno && result)
|
||||
{
|
||||
result = next();
|
||||
}
|
||||
@ -451,7 +452,7 @@ bool TXvt_recordset::go(int newPos)
|
||||
return result;
|
||||
}
|
||||
|
||||
const int TXvt_recordset::rowsAffected()
|
||||
const int TXvt_recordset::rows_affected() const
|
||||
{
|
||||
return _RCS(_recset)->RowsAffected();
|
||||
}
|
||||
@ -624,7 +625,7 @@ const char* TXvt_recordset::get_text_error(bool erase)
|
||||
return app;
|
||||
}
|
||||
|
||||
const bool TXvt_recordset::setErrorFreezed()
|
||||
const bool TXvt_recordset::set_error_freezed()
|
||||
{
|
||||
_code_error = ERROR_FREEZED;
|
||||
_string_error = _string_error_full_text = ERROR_FREEZEDS;
|
||||
|
@ -13,8 +13,6 @@
|
||||
|
||||
#define SQLAPIV "SQLAPI++ 4.1.5" // Da tenere aggiornato
|
||||
|
||||
#define CHECK_FREEZED if (is_freezed()) { return setErrorFreezed(); }
|
||||
|
||||
enum TT_driver
|
||||
{
|
||||
//! DBMS client is not specified
|
||||
@ -45,7 +43,7 @@ enum TT_driver
|
||||
TSDB_SQLAnywhere
|
||||
};
|
||||
|
||||
enum isoLvl { unknown = -1, uncommitted, committed, rr, serializable };
|
||||
enum iso_lvl { unknown = -1, uncommitted, committed, rr, serializable };
|
||||
|
||||
#define P_CONN_VOID void *
|
||||
#define P_COMM_VOID void *
|
||||
@ -113,7 +111,7 @@ public:
|
||||
* pass = Angela
|
||||
* driver = TSDB_MSSQL
|
||||
*/
|
||||
int connect(const char* db, const char* user, const char* pass, TT_driver tipoDb);
|
||||
int connect(const char* db, const char* user, const char* pass, TT_driver tipo_db);
|
||||
/* Mi scollego */
|
||||
void disconnect();
|
||||
/**< Esegue la commit, di default in caso di errore viene chiamato il metodo rollback() */
|
||||
@ -124,35 +122,35 @@ public:
|
||||
// Setters
|
||||
|
||||
/**< Imposto il tipo di client che utilizzo */
|
||||
void setClient(TT_driver client);
|
||||
void set_client(TT_driver client);
|
||||
// Imposto una opzione generica dellla connessione
|
||||
void setConOption(const char* opt);
|
||||
void set_con_option(const char* opt);
|
||||
/**< Abilito/Disabilito l'autocommit, (disabilitato di default) */
|
||||
void setAutocommit(bool ac);
|
||||
/** Imposta la visibilità delle transazioni (vedi Funzione) */
|
||||
void setVisibility(isoLvl vis = committed);
|
||||
void set_autocommit(bool ac);
|
||||
/**< Imposta la visibilità delle transazioni (vedi Funzione) */
|
||||
void set_visibility(iso_lvl vis = committed);
|
||||
|
||||
|
||||
// Getters
|
||||
/** Ritorna se la conessione è connessa */
|
||||
const bool isConnect() const;
|
||||
/**< Ritorna se la conessione è connessa */
|
||||
const bool is_connect() const;
|
||||
/**< Ritorna se la connessione è attiva */
|
||||
const bool isAlive() const;
|
||||
/** Ritorna la visibilità impostata */
|
||||
int getVisibility();
|
||||
const bool is_alive() const;
|
||||
/**< Ritorna la visibilità impostata */
|
||||
int get_visibility();
|
||||
/**< Ritorna se è attivo l'autocommit, true -> attivo, false -> disattivo o sconosciuto */
|
||||
bool getAutocommit();
|
||||
bool get_autocommit();
|
||||
/**< Ritorna il valore dell'opzione specificata */
|
||||
const char* getOption(const char* opt);
|
||||
const char* get_option(const char* opt);
|
||||
/**< Ritorno la versione del Client che sto utilizzando */
|
||||
long getClientV();
|
||||
long get_client_v();
|
||||
/**< Ritorno la versione del Server che sto utilizzando */
|
||||
const char* getServerV();
|
||||
/**< Ritorno la versione del Server che sto utilizzando in formato numerico */
|
||||
long getServerVN();
|
||||
long get_server_vn();
|
||||
/**< Ritorno se il recordset è carico */
|
||||
bool isLoaded() const;
|
||||
/** Ritorno il numero di elementi nella query */
|
||||
bool is_loaded() const;
|
||||
/**< Ritorno il numero di elementi nella query */
|
||||
long items();
|
||||
|
||||
/**************************************************************************************************
|
||||
@ -165,7 +163,7 @@ public:
|
||||
/**< Esegue la query impostata nel recordset, se viene passato autoF == true esegue anche un comando Next() */
|
||||
bool exec(bool autoF = true);
|
||||
/**< Unisce le funzioni Set e Exec, riceve la query */
|
||||
bool setExec(const char* query, bool autoF = true);
|
||||
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 */
|
||||
bool next();
|
||||
/**< Si sposta indietro di un record, in caso di esito negativo valorizza _stringError e _codeError */
|
||||
@ -175,9 +173,9 @@ public:
|
||||
/**< Si sposta al primo record, in caso di esito negativo valorizza _stringError e _codeError */
|
||||
bool last();
|
||||
/**< Si sposta alla posizione n, in caso di esito negativo valorizza _stringError e _codeError */
|
||||
bool go(int newPos);
|
||||
bool go(int new_pos);
|
||||
/**< Ritorna il numero di righe affette dall'ultima query */
|
||||
const int rowsAffected();
|
||||
const int rows_affected() const;
|
||||
|
||||
// Getters
|
||||
/**< Ritorna il valore nel campo (field) in formato (int) */
|
||||
@ -223,7 +221,7 @@ public:
|
||||
bool frozen() const { return is_freezed(); }
|
||||
bool not_frozen() const { return !is_freezed(); }
|
||||
/**< Imposta l'errore di record congelato */
|
||||
const bool setErrorFreezed();
|
||||
const bool set_error_freezed();
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user