Patch level :2.0 nopatch
Files correlati :dl0.exe Ricompilazione Demo : [ ] Commento :velocizzata la ricerca articoli (sia in ricerca semplice che avanzata); corretta la gestione del campo etichetta nell'importazione dati da discolatio git-svn-id: svn://10.65.10.50/trunk@11064 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
c92db223cd
commit
cfb6cc5441
178
dl/dl0500.cpp
178
dl/dl0500.cpp
@ -87,28 +87,48 @@ bool TRicerca_mask::on_field_event(TOperable_field& o, TField_event e, long joll
|
||||
}
|
||||
|
||||
//-------SKELETON APPLICATION------------------------------------------------------------------------------//
|
||||
|
||||
enum TFilter_type { dl_normal, dl_date, dl_um };
|
||||
enum TFilter_comp { dl_eq, dl_gt, dl_lt, dl_match };
|
||||
|
||||
struct TFilter_exp : public TObject
|
||||
{
|
||||
TFilter_type _type;
|
||||
TString16 _field;
|
||||
TFilter_comp _cmp;
|
||||
TString80 _value;
|
||||
|
||||
TFilter_exp() : _type(dl_normal), _cmp(dl_eq) { }
|
||||
};
|
||||
|
||||
class TRicerca: public TSkeleton_application
|
||||
{
|
||||
TRicerca_mask * _mask;
|
||||
static TMask * _ordmask;
|
||||
bool _barcode, _giac, _titolo, _artista, _compositore, _prezzo, _genere, _tiposupp;
|
||||
|
||||
static TArray _filtro;
|
||||
|
||||
protected:
|
||||
virtual bool create(void);
|
||||
virtual bool destroy(void);
|
||||
virtual void main_loop();
|
||||
|
||||
static void process_link(int id, const char * lnk);
|
||||
static void genera_ordine();
|
||||
static bool fast_filter(const TRelation* rel);
|
||||
|
||||
public:
|
||||
void add_expr_filter(TString& filtro, const char * field, short id, const char * cmp) const;
|
||||
void add_meta_filter(TString& filtro, const char * field, short id) const;
|
||||
void add_range_filter(TString& filtro, const char * field, short fid, short tid = -1) const;
|
||||
void add_expr_filter(const char * field, short id, TFilter_comp cmp) const;
|
||||
void add_meta_filter(const char * field, short id) const;
|
||||
void add_range_filter(const char * field, short fid, short tid = -1) const;
|
||||
|
||||
TRicerca() {}
|
||||
virtual ~TRicerca() {}
|
||||
};
|
||||
|
||||
TArray TRicerca::_filtro;
|
||||
|
||||
// restituisce un riferimento all' applicazione
|
||||
inline TRicerca& app() { return (TRicerca&) main_app();}
|
||||
|
||||
@ -164,45 +184,52 @@ bool TRicerca::destroy()
|
||||
return TSkeleton_application::destroy();
|
||||
}
|
||||
|
||||
//aggiunge effettivamente una espressione ad un filtro
|
||||
void TRicerca::add_expr_filter(TString& filtro, const char * field, short id, const char * cmp) const
|
||||
//aggiunge effettivamente un'espressione ad un filtro
|
||||
void TRicerca::add_expr_filter(const char * field, short id, TFilter_comp cmp) const
|
||||
{
|
||||
TMask_field& fld = _mask->field(id); //prende il campo dalla maschera
|
||||
if (!fld.empty()) //..se non e' vuoto
|
||||
{
|
||||
if (filtro.not_empty()) //distinzione tra filtro vuoto e filtro esistente
|
||||
filtro << "&&";
|
||||
if (fld.class_id() == CLASS_DATE_FIELD) //se e' un campo data deve ANSIzzare il contenuto del campo per aggiungerlo al filtro
|
||||
TFilter_exp* fe = new TFilter_exp;
|
||||
fe->_field = field;
|
||||
fe->_cmp = cmp;
|
||||
//se e' un campo data deve ANSIzzare il contenuto del campo per aggiungerlo al filtro
|
||||
if (fld.class_id() == CLASS_DATE_FIELD)
|
||||
{
|
||||
const TDate data = fld.get();
|
||||
TString8 val = data.string(ANSI);
|
||||
filtro << "(ANSI(" << field << ")" << cmp << val << ")";
|
||||
fe->_type = dl_date;
|
||||
const TDate date = fld.get();
|
||||
fe->_value = date.string(ANSI);
|
||||
}
|
||||
else
|
||||
filtro << "(" << field << cmp << "\"" << fld.get() << "\")"; //aggiunge il contenuto del campo al filtro
|
||||
}
|
||||
else
|
||||
{
|
||||
if (stricmp(field, "UM") == 0)
|
||||
fe->_type = dl_um;
|
||||
fe->_value = fld.get(); //aggiunge il contenuto del campo al filtro
|
||||
}
|
||||
_filtro.add(fe);
|
||||
}
|
||||
}
|
||||
|
||||
//aggiunge ad un filtro una espressione con l'*
|
||||
void TRicerca::add_meta_filter(TString& filtro, const char * field, short id) const
|
||||
void TRicerca::add_meta_filter(const char * field, short id) const
|
||||
{
|
||||
const TString& value = _mask->get(id);
|
||||
const char* cmp = "==";
|
||||
TFilter_comp cmp = dl_eq;
|
||||
if (value.find('*') >= 0 || value.find('?') >= 0)
|
||||
cmp = "?=";
|
||||
add_expr_filter(filtro, field, id, cmp);
|
||||
cmp = dl_match;
|
||||
add_expr_filter(field, id, cmp);
|
||||
}
|
||||
|
||||
//aggiunge ad un filtro un range di valori presi due campi o da uno (se coincidenti)
|
||||
void TRicerca::add_range_filter(TString& filtro, const char * field, short fid, short tid) const
|
||||
void TRicerca::add_range_filter(const char * field, short fid, short tid) const
|
||||
{
|
||||
if (tid > fid)
|
||||
{
|
||||
add_expr_filter(filtro, field, fid, ">=");
|
||||
add_expr_filter(filtro, field, tid, "<=");
|
||||
add_expr_filter(field, fid, dl_gt);
|
||||
add_expr_filter(field, tid, dl_lt);
|
||||
}
|
||||
else
|
||||
add_expr_filter(filtro, field, fid, "==");
|
||||
add_expr_filter(field, fid, dl_eq);
|
||||
}
|
||||
|
||||
//metodo ascetico per generare le righe di uno sheet dalla setlinkhandler (vedi la chiamata + sotto)
|
||||
@ -269,19 +296,6 @@ void TRicerca::genera_ordine()
|
||||
const TRectype test(doc.curr()); //come record di confronto si prende quello corrente
|
||||
doc.put(DOC_NDOC, "9999999");
|
||||
|
||||
/* long ndoc = 1; //metodo per autonumerare il documento (ultimo +1); tolto x' la DL setta a TRUE il flag di..
|
||||
int err = doc.read(_isgreat); //..autonumerazione nelle vendite
|
||||
if (err == NOERR)
|
||||
err = doc.prev();
|
||||
else
|
||||
err = doc.last();
|
||||
if (err == NOERR)
|
||||
{
|
||||
if (doc.curr().compare_key(test,1,1)==0) //confronta la chiave del record appena trovato con quella del
|
||||
ndoc+=doc.get_long(DOC_NDOC); //record campione (test), a meno dell'ultimo campo NDOC
|
||||
}
|
||||
ini.set(DOC_NDOC, ndoc); */ //trovato il primo numero libero documento libero lo scrive nell'ini
|
||||
|
||||
//paragrafi delle righe dell'ordine
|
||||
TSheet_field& sheet = _ordmask->sfield(F_RIGHE);
|
||||
TString80 codart;
|
||||
@ -309,16 +323,50 @@ void TRicerca::genera_ordine()
|
||||
::remove(iniord); //sopprime il file temporaneo
|
||||
}
|
||||
|
||||
static TString16 fast_field;
|
||||
static TString80 fast_value;
|
||||
static bool meta_type;
|
||||
|
||||
static bool fast_filter(const TRelation* rel)
|
||||
bool TRicerca::fast_filter(const TRelation* rel)
|
||||
{
|
||||
const TRectype& rec = rel->curr();
|
||||
if (meta_type)
|
||||
return rec.get(fast_field).match(fast_value);
|
||||
return rec.get(fast_field) == fast_value;
|
||||
for (int i = 0; i < _filtro.items(); i++)
|
||||
{
|
||||
const TFilter_exp& fe = (const TFilter_exp&)_filtro[i];
|
||||
TString80 field_value;
|
||||
switch (fe._type)
|
||||
{
|
||||
case dl_date:
|
||||
{
|
||||
const TDate d = rel->curr().get(fe._field);
|
||||
field_value = d.string(ANSI);
|
||||
}
|
||||
break;
|
||||
case dl_um:
|
||||
{
|
||||
TString80 key = rel->curr().get(ANAMAG_CODART);
|
||||
key << "|1";
|
||||
field_value = cache().get(LF_UMART, key, fe._field);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
field_value = rel->curr().get(fe._field);
|
||||
}
|
||||
switch (fe._cmp)
|
||||
{
|
||||
case dl_lt:
|
||||
if (field_value > fe._value)
|
||||
return FALSE;
|
||||
break;
|
||||
case dl_gt:
|
||||
if (field_value < fe._value)
|
||||
return FALSE;
|
||||
break;
|
||||
case dl_match:
|
||||
if (!field_value.match(fe._value))
|
||||
return FALSE;
|
||||
break;
|
||||
default:
|
||||
if (field_value != fe._value)
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void TRicerca::main_loop()
|
||||
@ -334,6 +382,7 @@ void TRicerca::main_loop()
|
||||
_prezzo = _mask->get_bool(F_P_PREZZO);
|
||||
_genere = _mask->get_bool(F_P_GENERE);
|
||||
_tiposupp = _mask->get_bool(F_P_TIPOSUPPORTO);
|
||||
|
||||
//..e li scrive nel file ini
|
||||
TConfig config("discolat.ini","ADVRES");
|
||||
config.set("BARCODE", _barcode);
|
||||
@ -345,23 +394,19 @@ void TRicerca::main_loop()
|
||||
config.set("GENERE", _genere);
|
||||
config.set("TIPOSUPP", _tiposupp);
|
||||
|
||||
TString16 nomecampo;
|
||||
//laboriosissima costruzione del filtro
|
||||
TString filtro;
|
||||
//laboriosissima costruzione del filtro
|
||||
_filtro.destroy();
|
||||
add_range_filter(ANAMAG_CODART, F_DABARCODE, F_ABARCODE);
|
||||
add_meta_filter(ANAMAG_USER2, F_ARTISTA);
|
||||
add_meta_filter(ANAMAG_DESCR, F_TITOLO);
|
||||
add_meta_filter(ANAMAG_USER3, F_COMPOSITORE);
|
||||
add_meta_filter(ANAMAG_USER4, F_ETICHETTA);
|
||||
|
||||
add_range_filter(filtro, ANAMAG_CODART, F_DABARCODE, F_ABARCODE);
|
||||
|
||||
add_meta_filter(filtro, ANAMAG_DESCR, F_TITOLO);
|
||||
add_meta_filter(filtro, ANAMAG_USER2, F_ARTISTA);
|
||||
add_meta_filter(filtro, ANAMAG_USER3, F_COMPOSITORE);
|
||||
add_meta_filter(filtro, ANAMAG_USER4, F_ETICHETTA);
|
||||
|
||||
add_range_filter(filtro, ANAMAG_GRMERC, F_GENEREMUSICALE);
|
||||
add_range_filter(filtro, ANAMAG_USER5, F_DATAE_INI, F_DATAE_FIN);
|
||||
add_range_filter(filtro, ANAMAG_USER6, F_DATAV_INI, F_DATAV_FIN);
|
||||
add_range_filter(ANAMAG_GRMERC, F_GENEREMUSICALE);
|
||||
add_range_filter(ANAMAG_USER5, F_DATAE_INI, F_DATAE_FIN);
|
||||
add_range_filter(ANAMAG_USER6, F_DATAV_INI, F_DATAV_FIN);
|
||||
//caso sfigato: c'e' il tipo supporto tra i parametri di filtro!
|
||||
nomecampo.format("%d->%s", LF_UMART, "UM");
|
||||
add_range_filter(filtro, nomecampo, F_TIPOSUPPORTO);
|
||||
add_range_filter("UM", F_TIPOSUPPORTO);
|
||||
|
||||
// setta i links presenti nel form (sono gli elementi scritti in blu(b) su bianco(w))
|
||||
// procedimento standard in questi casi
|
||||
@ -370,24 +415,11 @@ void TRicerca::main_loop()
|
||||
arr.add(new TToken_string("Ordina|b|w"));
|
||||
printer().setlinkhandler(process_link);
|
||||
|
||||
|
||||
//dopo il filtrone tocca al cursore x scandire i records
|
||||
TRicerca_form form;
|
||||
//ottimizzazione tempi di ricerca: caso di filtro semplice (senza AND, con ?= o ==)
|
||||
|
||||
if (filtro.find("&&") < 0 && filtro.find('=') > 0)
|
||||
{
|
||||
filtro.strip("()");
|
||||
meta_type = filtro.find("?=") > 0;
|
||||
const int pos = filtro.rfind('=');
|
||||
fast_value = filtro.mid(pos+1);
|
||||
fast_value.strip("\"");
|
||||
fast_field = filtro.left(pos-1);
|
||||
|
||||
form.cursor()->set_filterfunction(fast_filter, !_mask->field(F_TIPOSUPPORTO).empty());
|
||||
}
|
||||
else
|
||||
form.cursor()->setfilter(filtro, !_mask->field(F_TIPOSUPPORTO).empty());
|
||||
form.cursor()->set_filterfunction(fast_filter, FALSE);
|
||||
|
||||
//setta il form columnwise
|
||||
form.find_field('B', odd_page, FF_B_CODART).show(_barcode);
|
||||
|
165
dl/dl0600.cpp
165
dl/dl0600.cpp
@ -181,10 +181,26 @@ bool TIntmag_mask::on_field_event(TOperable_field& o, TField_event e, long jolly
|
||||
}
|
||||
|
||||
//-------SKELETON APPLICATION------------------------------------------------------------------------------//
|
||||
|
||||
enum TFilter_type { dl_normal, dl_date, dl_um };
|
||||
enum TFilter_comp { dl_eq, dl_gt, dl_lt, dl_match };
|
||||
|
||||
struct TFilter_exp : public TObject
|
||||
{
|
||||
TFilter_type _type;
|
||||
TString16 _field;
|
||||
TFilter_comp _cmp;
|
||||
TString80 _value;
|
||||
|
||||
TFilter_exp() : _type(dl_normal), _cmp(dl_eq) { }
|
||||
};
|
||||
|
||||
class TIntmag: public TSkeleton_application
|
||||
{
|
||||
TIntmag_mask * _mask;
|
||||
TIntmag_form * _form;
|
||||
|
||||
static TArray _filtro;
|
||||
|
||||
protected:
|
||||
virtual bool create(void);
|
||||
@ -194,16 +210,20 @@ protected:
|
||||
void print_header();
|
||||
void print_footer();
|
||||
void print_line(const TString& r, const long j);
|
||||
|
||||
static bool fast_filter(const TRelation* rel);
|
||||
|
||||
public:
|
||||
void add_expr_filter(TString& filtro, const char * field, short id, const char * cmp) const;
|
||||
void add_meta_filter(TString& filtro, const char * field, short id) const;
|
||||
void add_range_filter(TString& filtro, const char * field, short fid, short tid = -1) const;
|
||||
void add_expr_filter(const char * field, short id, TFilter_comp cmp) const;
|
||||
void add_meta_filter(const char * field, short id) const;
|
||||
void add_range_filter(const char * field, short fid, short tid = -1) const;
|
||||
|
||||
TIntmag() {}
|
||||
virtual ~TIntmag() {}
|
||||
};
|
||||
|
||||
TArray TIntmag::_filtro;
|
||||
|
||||
// restituisce un riferimento all' applicazione
|
||||
inline TIntmag& app() { return (TIntmag&) main_app();}
|
||||
|
||||
@ -226,97 +246,120 @@ bool TIntmag::destroy()
|
||||
}
|
||||
|
||||
//aggiunge effettivamente una espressione ad un filtro
|
||||
void TIntmag::add_expr_filter(TString& filtro, const char * field, short id, const char * cmp) const
|
||||
void TIntmag::add_expr_filter(const char * field, short id, TFilter_comp cmp) const
|
||||
{
|
||||
TMask_field& fld = _mask->field(id); //prende il campo dalla maschera
|
||||
if (!fld.empty()) //..se non e' vuoto
|
||||
{
|
||||
if (filtro.not_empty()) //distinzione tra filtro vuoto e filtro esistente
|
||||
filtro << "&&";
|
||||
if (fld.class_id() == CLASS_DATE_FIELD) //se e' un campo data deve ANSIzzare il contenuto del campo per aggiungerlo al filtro
|
||||
TFilter_exp* fe = new TFilter_exp;
|
||||
fe->_field = field;
|
||||
fe->_cmp = cmp;
|
||||
//se e' un campo data deve ANSIzzare il contenuto del campo per aggiungerlo al filtro
|
||||
if (fld.class_id() == CLASS_DATE_FIELD)
|
||||
{
|
||||
const TDate data = fld.get();
|
||||
TString8 val = data.string(ANSI);
|
||||
filtro << "(ANSI(" << field << ")" << cmp << val << ")";
|
||||
fe->_type = dl_date;
|
||||
const TDate date = fld.get();
|
||||
fe->_value = date.string(ANSI);
|
||||
}
|
||||
else
|
||||
filtro << "(" << field << cmp << "\"" << fld.get() << "\")"; //aggiunge il contenuto del campo al filtro
|
||||
}
|
||||
else
|
||||
{
|
||||
if (stricmp(field, "UM") == 0)
|
||||
fe->_type = dl_um;
|
||||
fe->_value = fld.get(); //aggiunge il contenuto del campo al filtro
|
||||
}
|
||||
_filtro.add(fe);
|
||||
}
|
||||
}
|
||||
|
||||
//aggiunge ad un filtro una espressione con l'*
|
||||
void TIntmag::add_meta_filter(TString& filtro, const char * field, short id) const
|
||||
{
|
||||
void TIntmag::add_meta_filter(const char * field, short id) const
|
||||
{
|
||||
const TString& value = _mask->get(id);
|
||||
const char* cmp = "==";
|
||||
TFilter_comp cmp = dl_eq;
|
||||
if (value.find('*') >= 0 || value.find('?') >= 0)
|
||||
cmp = "?=";
|
||||
add_expr_filter(filtro, field, id, cmp);
|
||||
cmp = dl_match;
|
||||
add_expr_filter(field, id, cmp);
|
||||
}
|
||||
|
||||
//aggiunge ad un filtro un range di valori presi due campi o da uno (se coincidenti)
|
||||
void TIntmag::add_range_filter(TString& filtro, const char * field, short fid, short tid) const
|
||||
void TIntmag::add_range_filter(const char * field, short fid, short tid) const
|
||||
{
|
||||
if (tid > fid)
|
||||
{
|
||||
add_expr_filter(filtro, field, fid, ">=");
|
||||
add_expr_filter(filtro, field, tid, "<=");
|
||||
add_expr_filter(field, fid, dl_gt);
|
||||
add_expr_filter(field, tid, dl_lt);
|
||||
}
|
||||
else
|
||||
add_expr_filter(filtro, field, fid, "==");
|
||||
add_expr_filter(field, fid, dl_eq);
|
||||
}
|
||||
|
||||
static TString16 fast_field;
|
||||
static TString80 fast_value;
|
||||
static bool meta_type;
|
||||
|
||||
static bool fast_filter(const TRelation* rel)
|
||||
bool TIntmag::fast_filter(const TRelation* rel)
|
||||
{
|
||||
const TRectype& rec = rel->curr();
|
||||
if (meta_type)
|
||||
return rec.get(fast_field).match(fast_value);
|
||||
return rec.get(fast_field) == fast_value;
|
||||
for (int i = 0; i < _filtro.items(); i++)
|
||||
{
|
||||
const TFilter_exp& fe = (const TFilter_exp&)_filtro[i];
|
||||
TString80 field_value;
|
||||
switch (fe._type)
|
||||
{
|
||||
case dl_date:
|
||||
{
|
||||
const TDate d = rel->curr().get(fe._field);
|
||||
field_value = d.string(ANSI);
|
||||
}
|
||||
break;
|
||||
case dl_um:
|
||||
{
|
||||
TString80 key = rel->curr().get(ANAMAG_CODART);
|
||||
key << "|1";
|
||||
field_value = cache().get(LF_UMART, key, fe._field);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
field_value = rel->curr().get(fe._field);
|
||||
}
|
||||
switch (fe._cmp)
|
||||
{
|
||||
case dl_lt:
|
||||
if (field_value > fe._value)
|
||||
return FALSE;
|
||||
break;
|
||||
case dl_gt:
|
||||
if (field_value < fe._value)
|
||||
return FALSE;
|
||||
break;
|
||||
case dl_match:
|
||||
if (!field_value.match(fe._value))
|
||||
return FALSE;
|
||||
break;
|
||||
default:
|
||||
if (field_value != fe._value)
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void TIntmag::main_loop()
|
||||
{
|
||||
while (_mask->run() == K_ENTER)
|
||||
{
|
||||
TString16 nomecampo;
|
||||
//laboriosissima costruzione del filtro
|
||||
TString filtro;
|
||||
//laboriosissima costruzione del filtro
|
||||
_filtro.destroy();
|
||||
add_range_filter(ANAMAG_CODART, F_DABARCODE, F_ABARCODE);
|
||||
add_meta_filter(ANAMAG_USER2, F_ARTISTA);
|
||||
add_meta_filter(ANAMAG_DESCR, F_TITOLO);
|
||||
add_meta_filter(ANAMAG_USER3, F_COMPOSITORE);
|
||||
add_meta_filter(ANAMAG_USER4, F_ETICHETTA);
|
||||
|
||||
add_range_filter(filtro, ANAMAG_CODART, F_DABARCODE, F_ABARCODE);
|
||||
|
||||
add_meta_filter(filtro, ANAMAG_DESCR, F_TITOLO);
|
||||
add_meta_filter(filtro, ANAMAG_USER2, F_ARTISTA);
|
||||
add_meta_filter(filtro, ANAMAG_USER3, F_COMPOSITORE);
|
||||
add_meta_filter(filtro, ANAMAG_USER4, F_ETICHETTA);
|
||||
|
||||
add_range_filter(filtro, ANAMAG_GRMERC, F_GENEREMUSICALE);
|
||||
add_range_filter(filtro, ANAMAG_USER5, F_DATAE_INI, F_DATAE_FIN);
|
||||
add_range_filter(filtro, ANAMAG_USER6, F_DATAV_INI, F_DATAV_FIN);
|
||||
add_range_filter(ANAMAG_GRMERC, F_GENEREMUSICALE);
|
||||
add_range_filter(ANAMAG_USER5, F_DATAE_INI, F_DATAE_FIN);
|
||||
add_range_filter(ANAMAG_USER6, F_DATAV_INI, F_DATAV_FIN);
|
||||
//caso sfigato: c'e' il tipo supporto tra i parametri di filtro!
|
||||
nomecampo.format("%d->%s", LF_UMART, "UM");
|
||||
add_range_filter(filtro, nomecampo, F_TIPOSUPPORTO);
|
||||
add_range_filter("UM", F_TIPOSUPPORTO);
|
||||
|
||||
//dopo il filtrone tocca al cursore x scandire i records
|
||||
TIntmag_form form;
|
||||
//ottimizzazione tempi di ricerca: caso di filtro semplice (senza AND, con ?= o ==)
|
||||
|
||||
if (filtro.find("&&") < 0 && filtro.find('=') > 0 && filtro.find("->") < 0)
|
||||
{
|
||||
filtro.strip("()");
|
||||
meta_type = filtro.find("?=") > 0;
|
||||
const int pos = filtro.rfind('=');
|
||||
fast_value = filtro.mid(pos+1);
|
||||
fast_value.strip("\"");
|
||||
fast_field = filtro.left(pos-1);
|
||||
|
||||
form.cursor()->set_filterfunction(fast_filter, !_mask->field(F_TIPOSUPPORTO).empty());
|
||||
}
|
||||
else
|
||||
form.cursor()->setfilter(filtro, !_mask->field(F_TIPOSUPPORTO).empty());
|
||||
form.cursor()->set_filterfunction(fast_filter, FALSE);
|
||||
|
||||
//procedimento mistico di costruzione del form columnwise
|
||||
const int hh = 5; //altezza header = 5 righe
|
||||
|
@ -37,7 +37,7 @@ protected:
|
||||
real scorpora(const real& lordo, const TRecord_text& rec);
|
||||
|
||||
public:
|
||||
virtual int autosave(TRelation& rel, const TRecord_text& rec);
|
||||
// virtual int autosave(TRelation& rel, const TRecord_text& rec);
|
||||
virtual bool pre_writerel(TRelation& rel,const TRecord_text& rec);
|
||||
void write_supporto(const TRecord_text& rec);
|
||||
void write_listini(const TRecord_text& rec);
|
||||
@ -61,6 +61,7 @@ void TCat2dl_file::set_config(const char * listingr,const char * listven, const
|
||||
_codiva = codiva;
|
||||
}
|
||||
|
||||
/*
|
||||
int TCat2dl_file::autosave(TRelation& rel, const TRecord_text& rec)
|
||||
{
|
||||
const TString& type = rec.type(); //prendo il tracciato record del tipo del record_text
|
||||
@ -82,19 +83,18 @@ int TCat2dl_file::autosave(TRelation& rel, const TRecord_text& rec)
|
||||
preformat_field(field,valore,rel,tr.type());
|
||||
const TRectype& rel_rec = rel.curr(field.file());
|
||||
TFieldtypes tipo_campo = rel_rec.type(field.name());
|
||||
bool vuoto = valore.blank();
|
||||
|
||||
switch(tipo_campo) //in base al tipo di campo formatta i valori seguendo le specifiche del tracciato
|
||||
{
|
||||
case _datefld: //tipo data...
|
||||
{
|
||||
if (real::is_null(valore))
|
||||
{
|
||||
valore.cut(0);
|
||||
vuoto = TRUE;
|
||||
else
|
||||
{
|
||||
TDate data(valore);
|
||||
format_date(data, fpicture(tc), valore);//formatta la data secondo le specifiche del tracciato
|
||||
}
|
||||
TDate data(valore);
|
||||
format_date(data, fpicture(tc), valore);//formatta la data secondo le specifiche del tracciato
|
||||
}
|
||||
break;
|
||||
case _realfld: //tipi numerici
|
||||
@ -102,8 +102,6 @@ int TCat2dl_file::autosave(TRelation& rel, const TRecord_text& rec)
|
||||
case _longfld:
|
||||
{
|
||||
const real numero(valore);
|
||||
vuoto = numero.is_zero();
|
||||
|
||||
valore = numero.string(fpicture(tc));//formatta il numero secondo le specifiche del tracciato
|
||||
|
||||
int length = flength(tc,rel_rec);
|
||||
@ -115,15 +113,12 @@ int TCat2dl_file::autosave(TRelation& rel, const TRecord_text& rec)
|
||||
break;
|
||||
default:
|
||||
valore = format_field(tc, rel.lfile().num(), valore);//formatta il campo secondo le specifiche del record
|
||||
if (valore.blank() && field.name()=="CODIVA") //se il codice iva e' vuoto...
|
||||
valore = _codiva;
|
||||
break;
|
||||
}
|
||||
if (vuoto && field.name()=="CODIVA") //se il codice iva e' vuoto...
|
||||
{
|
||||
valore = _codiva;
|
||||
vuoto = FALSE;
|
||||
}
|
||||
|
||||
if (!vuoto && rel.exist(field.file()))
|
||||
if (rel.exist(field.file()))
|
||||
field.write(valore, rel);//faccio una write sulla relazione del fieldref
|
||||
}
|
||||
}
|
||||
@ -137,9 +132,13 @@ int TCat2dl_file::autosave(TRelation& rel, const TRecord_text& rec)
|
||||
}
|
||||
return err;
|
||||
}
|
||||
*/
|
||||
|
||||
bool TCat2dl_file::pre_writerel(TRelation& rel,const TRecord_text& rec)
|
||||
{
|
||||
if (rel.curr().get("CODIVA").blank())
|
||||
rel.curr().put("CODIVA", _codiva);
|
||||
|
||||
// 1) sistema i tipi di supporto e genere
|
||||
write_supporto(rec);
|
||||
// 2) legge e scrive i dati dei listini: se il listino non esiste lo crea
|
||||
@ -578,10 +577,15 @@ void TCat2dl::transfer()
|
||||
rt += write_time - read_time;
|
||||
wt += clock() - write_time;
|
||||
}
|
||||
ofstream pippo("dl.log");
|
||||
pippo << "records = " << processed_rec << endl;
|
||||
pippo << "time = " << (clock() - start_time)/1000 << endl;
|
||||
pippo << "speed = " << (processed_rec*1000/(clock() - start_time)) << endl;
|
||||
|
||||
const clock_t t = clock() - start_time;
|
||||
if (t > 0)
|
||||
{
|
||||
ofstream pippo("dl.log");
|
||||
pippo << "records = " << processed_rec << endl;
|
||||
pippo << "time = " << t/1000 << endl;
|
||||
pippo << "speed = " << (processed_rec*1000/t) << endl;
|
||||
}
|
||||
|
||||
_trasfile->close();
|
||||
message_box("Operazione terminata");
|
||||
|
Loading…
x
Reference in New Issue
Block a user