Merge remote-tracking branch 'origin/R_10_00' into R_10_00

This commit is contained in:
Simone Palacino 2019-06-27 16:45:20 +02:00
commit fc3af2e0d0
30 changed files with 111 additions and 26 deletions

17
lib/.gitignore vendored Normal file
View File

@ -0,0 +1,17 @@
/*.pdb
/*.exp
/*.bsc
/AgaLib.lib
/cb6.lib
/gfm.lib
/pdflib.lib
/vedoc.lib
/vedocext.lib
/xi.lib
/xvaga.lib
/xvapp.lib
/ServerLib.lib
/Uno.lib
/hlw32_mc.lib
/pdflibwrap.lib
/xid.lib

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -743,14 +743,13 @@ bool TDoc2Paf::create()
{
open_files(LF_TAB, LF_TABCOM, LF_TABMOD, LF_ANAG,
LF_CLIFO, LF_CFVEN, LF_CFBAN, LF_NDITTE,
LF_DOC, LF_RIGHEDOC, 0);
LF_DOC, LF_RIGHEDOC, LF_CODCORR, LF_ANAMAG, 0);
TRectype cfven(LF_CFVEN);
const TRectype cfven(LF_CFVEN);
if (cfven.length(CFV_PADESTIN) != 7) // Nuova lunghezza per privati
return error_box(TR("Database non convertito per fatturazione F.P."));
return check_tables() && TSkeleton_application::create();
}
bool TDoc2Paf::destroy()

View File

@ -389,7 +389,8 @@ private:
enum TFP_operator { error, eq, neq, gt, ls, gteq, lseq, and, or };
// Etrattori
static void extract_info(const TString& expr, TString& tabella, TString& campo, TToken_string* search);
static void extract_info(const TString& expr, TString& tabella, TString& campo);
static void extract_info(const TString& expr, TString& tabella, TString& campo, TToken_string& search, int& key);
static bool calc_table(const TString& tabella, int& file);
static void split_condition(const TString& cond, TString& cond_sx, TString& cond_dx, TFP_operator& symb);
static TVariant& get_value(const TRectype& rec, const TString& campo);

View File

@ -51,6 +51,7 @@ bool set_connection(SSimple_query& s)
#endif
return ok;
}
SSimple_query& fp_db()
{
static SSimple_query* db = nullptr;
@ -63,6 +64,7 @@ SSimple_query& fp_db()
}
return *db;
}
bool run_fp_psw_mask()
{
static TMask* m;

View File

@ -255,8 +255,6 @@ TFP_custom_cache::TFP_custom_cache()
}
}
/******************************************************************************
* TFP_expression
*******************************************************************************/
@ -364,7 +362,7 @@ bool TFP_expression::check_condition(const TString& cond, TRiga_documento& rdoc)
}
}
void TFP_expression::extract_info(const TString& expr, TString& tabella, TString& campo, TToken_string* search)
void TFP_expression::extract_info(const TString& expr, TString& tabella, TString& campo)
{
// Prendo la stringa pulita della parte sinistra
TString clean_expr = expr.mid(expr.find('(') + 1);
@ -377,13 +375,38 @@ void TFP_expression::extract_info(const TString& expr, TString& tabella, TString
// Trimmare sempre come se non sapessi fare altro nella vita
tabella.cut(0) << info.remove(0); tabella.trim();
campo.cut(0) << info.remove(0); campo.trim();
if (search != nullptr)
}
void TFP_expression::extract_info(const TString& expr, TString& tabella, TString& campo, TToken_string& search, int& key)
{
// Prendo la stringa pulita della parte sinistra
TString clean_expr = expr.mid(expr.find('(') + 1);
// Tolgo eventuali spazi ai lati
clean_expr.trim();
// Tolgo la virgola finale
clean_expr.rtrim(1);
TToken_string info(clean_expr, ',');
// Trimmare sempre come se non sapessi fare altro nella vita
tabella.cut(0) << info.remove(0); tabella.trim();
if(tabella.contains('.'))
{
// Prendo il resto
search->cut(0) << info;
search->trim();
search->restart();
TToken_string app(tabella, '.');
tabella = app.get();
key = atoi(app.get());
}
else
{
key = 1;
}
campo.cut(0) << info.remove(0); campo.trim();
// Prendo il resto e lo devolvo nella ricerca
search.cut(0) << info;
search.trim();
search.restart();
}
bool TFP_expression::calc_table(const TString& tabella, int& file)
@ -549,17 +572,26 @@ TVariant& TFP_expression::parse_var(const TString& str)
TVariant& TFP_expression::parse_read(const TString& str, TRiga_documento& rdoc)
{
TString tabella, campo;
extract_info(str, tabella, campo, nullptr);
extract_info(str, tabella, campo);
return do_read(tabella, campo, rdoc);
}
TVariant& TFP_expression::do_read(const TString& tabella, const TString& campo, TRiga_documento& rdoc)
{
const TDocumento& doc = rdoc.doc();
// Prima di tutto controllo se è una delle tabelle multitracciato che supporto
if(tabella == "%TIP")
{
return get_value(rdoc.doc().tipo(), campo);
return get_value(doc.tipo(), campo);
}
if(tabella == "%NUM")
{
return get_value(doc.codice_numerazione(), campo);
}
if(tabella == "%CPG")
{
return get_value(cache().get("%CPG", doc.get(DOC_CODPAG)), campo);
}
int file;
@ -568,17 +600,19 @@ TVariant& TFP_expression::do_read(const TString& tabella, const TString& campo,
switch (file)
{
case LF_DOC:
return get_value(rdoc.doc(), campo);
return get_value(doc, campo);
case LF_RIGHEDOC:
return get_value(rdoc, campo);
case LF_CLIFO:
return get_value(rdoc.doc().clifor(), campo);
return get_value(doc.clifor(), campo);
case LF_CFVEN:
return get_value(rdoc.doc().clifor().vendite(), campo);
return get_value(doc.clifor().vendite(), campo);
case LF_LETINT:
return get_value(rdoc.doc().clifor().lettera(), campo);
return get_value(doc.clifor().lettera(), campo);
case LF_ANAMAG:
return get_value(rdoc.articolo(), campo);
case LF_CODCORR:
return get_value(cache().get(LF_CODCORR, rdoc.articolo().codice()), campo);
default:
static TVariant null_var(EMPTY_STRING);
return null_var;
@ -588,10 +622,10 @@ TVariant& TFP_expression::do_read(const TString& tabella, const TString& campo,
TVariant& TFP_expression::parse_search(const TString& str, TRiga_documento& rdoc)
{
TString tabella, campo;
TToken_string input_search, search;
int file;
TToken_string input_search("", ';'), search;
int file, key;
extract_info(str, tabella, campo, &input_search);
extract_info(str, tabella, campo, input_search, key);
const bool multi_table = calc_table(tabella, file);
// Parso ogni singolo token della ricerca
@ -602,10 +636,10 @@ TVariant& TFP_expression::parse_search(const TString& str, TRiga_documento& rdoc
if (multi_table)
{
return get_value(cache().get(tabella, search), campo);
return get_value(cache().get(tabella, search, key), campo);
}
else
{
return get_value(cache().get(file, search), campo);
return get_value(cache().get(file, search, key), campo);
}
}

View File

@ -957,13 +957,42 @@ int TDB_cache::build_table_key(const char* table, const char* key, TToken_string
return file;
}
const TRectype& TDB_cache::get(const char* table, const char* key)
const TRectype& TDB_cache::get(const int file, const char* key_tok, const int key)
{
// Prendo la vecchia chiave
const int old_key = rec_cache(file).key_number();
// Setto la nuova chiave
rec_cache(file).set_key(key);
// Poi chiamo la get normale
const TRectype& app = get(file, key_tok);
// Ripristino la vecchia chiave per mantenere la compatibilità con i metodi vecchi
// non vorrei rischiare che altre applicazioni si basano sulla chiave vecchia
rec_cache(file).set_key(old_key);
return app;
}
const TRectype& TDB_cache::get(const char* table, const char* key_tok)
{
TToken_string tabkey;
const int file = build_table_key(table, key, tabkey);
const int file = build_table_key(table, key_tok, tabkey);
return rec_cache(table).get(tabkey);
}
const TRectype& TDB_cache::get(const char* table, const char* key_tok, const int key)
{
TToken_string tabkey;
const int file = build_table_key(table, key_tok, tabkey);
// Per il giro della vecchia chiave guardare get(const int, const char*, const int)
const int old_key = rec_cache(file).key_number();
rec_cache(table).set_key(key);
const TRectype& app = rec_cache(table).get(tabkey);
rec_cache(file).set_key(old_key);
return app;
}
const TRectype& TDB_cache::get(const TRectype& curr)
{
const int num = curr.num(); // Numero logico del file (o tabella)

View File

@ -184,6 +184,7 @@ public:
int io_result();
const int key_number() const
{ return _key; }
void set_key(const int key) { _key = key; }
bool already_loaded(const char* code) const;
bool already_loaded(long code) const;
@ -263,9 +264,11 @@ public:
void flush(int file) { rec_cache(file).flush(); }
void discard(int file);
const TRectype& get(int file, const char* key_tok, const int key);
const TRectype& get(int file, const char* key_tok) { return rec_cache(file).get(key_tok); }
const TRectype& get(int file, long key) { return rec_cache(file).get(key); }
const TRectype& get(const char* table, const char* key_tok);
const TRectype& get(const char* table, const char* key_tok, const int key);
const TRectype& get(const TRectype& key);
const TRectype& get_rec(int file, char c, long n);