Patch level : 2.2

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :

Aggiunta qualche cache al programma di invio dati AS/PC


git-svn-id: svn://10.65.10.50/trunk@13424 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2005-10-14 14:21:31 +00:00
parent d07f26d517
commit 2dedf5f983
8 changed files with 257 additions and 298 deletions

View File

@ -418,7 +418,6 @@ bool TInv_cont::create()
_part = new TLocalisamfile (LF_PARTITE); _part = new TLocalisamfile (LF_PARTITE);
_scad = new TLocalisamfile (LF_SCADENZE); _scad = new TLocalisamfile (LF_SCADENZE);
_pagsca = new TLocalisamfile (LF_PAGSCA); _pagsca = new TLocalisamfile (LF_PAGSCA);
_comuni = new TLocalisamfile (LF_COMUNI);
return TSkeleton_application::create(); return TSkeleton_application::create();
} }
@ -436,7 +435,6 @@ bool TInv_cont::destroy()
delete _part; delete _part;
delete _scad; delete _scad;
delete _pagsca; delete _pagsca;
delete _comuni;
return TApplication::destroy(); return TApplication::destroy();
} }
@ -921,27 +919,23 @@ void TInv_cont::crea_marker(TMask& m)
void TInv_cont::aggiorna_marker(TString& token, int pos) void TInv_cont::aggiorna_marker(TString& token, int pos)
{ {
TString str;
_marker = ""; _marker = "";
_marker = firm2dir(0); _marker = firm2dir(0);
_marker << "\\marker"; _marker << "\\marker";
FILE* i; FILE* i = fopen(_marker,"r+t");
const word size = 64; if (i != NULL)
TString buffer(size);
//buffer.spaces();
if ( (i = fopen(_marker,"r+t")) != NULL)
{ {
const word letti = fread((char*)(const char*)buffer,sizeof(char),size,i); const int size = 64;
TString80 buffer;
const word letti = fread(buffer.get_buffer(),sizeof(char),size,i);
buffer.overwrite(token,pos); buffer.overwrite(token,pos);
buffer.cut(64); //Sicurezza: le stringhe dimensionate in realta' sono buffer.cut(size); //Sicurezza: le stringhe dimensionate in realta' sono
//leggermente piu' lunghe della dimensione specificata //leggermente piu' lunghe della dimensione specificata
fseek(i, 0L, SEEK_SET); fseek(i, 0L, SEEK_SET);
const word scritti = fwrite((char*)(const char*)buffer,sizeof(char),size,i); const word scritti = fwrite(buffer,sizeof(char),size,i);
fclose(i); fclose(i);
} }
@ -1076,21 +1070,10 @@ void TInv_cont::crea_record_controllo(TMask& m)
_tras_file.close(); _tras_file.close();
} }
const char* TInv_cont::cerca_provincia(const TString& comcf) const char* TInv_cont::cerca_provincia(const TString& comcf) const
{ {
HIDDEN TString16 TEMP; TString8 k; k << " |" << comcf;
return cache().get(LF_COMUNI, k, COM_PROVCOM);
TLocalisamfile comuni(LF_COMUNI);
comuni.setkey(1);
comuni.zero();
comuni.put(COM_COM, comcf);
if (comuni.read() == NOERR)
TEMP = comuni.get(COM_PROVCOM);
else
TEMP = "";
return TEMP;
} }
bool TInv_cont::invio_tempfile(TMask& m) bool TInv_cont::invio_tempfile(TMask& m)
@ -1179,7 +1162,7 @@ void TInv_cont::causali2tempfile(TString& key, TMask& m)
_caus->first(); _caus->first();
else else
{ {
TString causale (key.mid(0,3)); const TString& causale = key.mid(0,3);
_caus->zero(); _caus->zero();
_caus->put(CAU_CODCAUS, causale); _caus->put(CAU_CODCAUS, causale);
_caus->read(); _caus->read();
@ -1189,7 +1172,7 @@ void TInv_cont::causali2tempfile(TString& key, TMask& m)
{ {
_prog->addstatus(1); _prog->addstatus(1);
TString codcaus = _caus->get(CAU_CODCAUS); const TString4 codcaus = _caus->get(CAU_CODCAUS);
_tcaus->curr() = _caus->curr(); _tcaus->curr() = _caus->curr();
@ -1211,7 +1194,7 @@ void TInv_cont::causali2tempfile(TString& key, TMask& m)
} }
leggi_record_controllo(); leggi_record_controllo();
TString chiave; TString4 chiave;
chiave.format("%3s",(const char*) codcaus); chiave.format("%3s",(const char*) codcaus);
_control_rec.overwrite("W",240); _control_rec.overwrite("W",240);
_control_rec.overwrite(chiave,241); _control_rec.overwrite(chiave,241);
@ -1243,7 +1226,7 @@ void TInv_cont::causali2tempfile(TString& key, TMask& m)
// setta_parametri_record(m,"D"); // setta_parametri_record(m,"D");
} }
void TInv_cont::cancella_righe_causali(TString& codcaus) void TInv_cont::cancella_righe_causali(const TString& codcaus)
{ {
_trcaus->setkey(1); _trcaus->setkey(1);
_trcaus->zero(); _trcaus->zero();
@ -1258,7 +1241,7 @@ void TInv_cont::cancella_righe_causali(TString& codcaus)
} }
} }
void TInv_cont::scrivi_righe_causali(TString& codcaus, char uselab) void TInv_cont::scrivi_righe_causali(const TString& codcaus, char uselab)
{ {
cancella_righe_causali(codcaus); cancella_righe_causali(codcaus);
@ -1368,7 +1351,7 @@ void TInv_cont::clifo2tempfile(TString& key, TMask& m)
void TInv_cont::pcon2tempfile(TString& key, TMask& m) void TInv_cont::pcon2tempfile(TString& key, TMask& m)
{ {
int size = 1024; const int size = 1024;
_tras_file.open(_header); _tras_file.open(_header);

View File

@ -92,8 +92,8 @@ public:
bool invio_tempfile(TMask& m); bool invio_tempfile(TMask& m);
void causali2tempfile(TString& key,TMask& m); void causali2tempfile(TString& key,TMask& m);
void cancella_righe_causali(TString& codcaus); void cancella_righe_causali(const TString& codcaus);
void scrivi_righe_causali(TString& codcaus, char uselab); void scrivi_righe_causali(const TString& codcaus, char uselab);
void clifo2tempfile(TString& key,TMask& m); void clifo2tempfile(TString& key,TMask& m);
void pcon2tempfile(TString& key,TMask& m); void pcon2tempfile(TString& key,TMask& m);
@ -136,8 +136,8 @@ public:
void calcola_totale_record(); void calcola_totale_record();
void scrivi_telefono(TString& app); void scrivi_telefono(TString& app);
const char* cerca_provincia(const TString& comcf); const char* cerca_provincia(const TString& comcf) const;
void cerca_dencom(TString& comcf,TString& dencom); void cerca_dencom(const TString& comcf, TString& dencom) const;
static bool setta_maschera_hnd(TMask_field& f, KEY k); static bool setta_maschera_hnd(TMask_field& f, KEY k);
static bool messaggio_hnd (TMask_field& f, KEY k); static bool messaggio_hnd (TMask_field& f, KEY k);

View File

@ -617,17 +617,10 @@ void TInv_cont::scrivi_telefono(TString& appoggio)
appoggio << tel; appoggio << tel;
} }
void TInv_cont::cerca_dencom(TString& comcf,TString& dencom) void TInv_cont::cerca_dencom(const TString& comcf,TString& dencom) const
{ {
TLocalisamfile comuni(LF_COMUNI); TString8 k; k << " |" << comcf;
dencom = cache().get(LF_COMUNI, k, COM_DENCOM);
comuni.setkey(1);
comuni.zero();
comuni.put(COM_COM, comcf);
if (comuni.read() == NOERR)
dencom = comuni.get(COM_DENCOM);
else
dencom = "";
} }
bool TInv_cont::invio_clifo() bool TInv_cont::invio_clifo()
@ -706,11 +699,11 @@ bool TInv_cont::invio_clifo()
str.format("%-35s", (const char*) indcf); str.format("%-35s", (const char*) indcf);
record.overwrite(str,93); //Indirizzo record.overwrite(str,93); //Indirizzo
TString capcf = _tclifo->get(CLI_CAPCF); const TString8 capcf = _tclifo->get(CLI_CAPCF);
str.format("%05s", (const char*) capcf); str.format("%05s", (const char*) capcf);
record.overwrite(str,128); //Codice di avviamento postale record.overwrite(str,128); //Codice di avviamento postale
TString comcf = _tclifo->get(CLI_COMCF); const TString4 comcf = _tclifo->get(CLI_COMCF);
TString localita; TString localita;
if (comcf.not_empty()) if (comcf.not_empty())
cerca_dencom(comcf,localita); cerca_dencom(comcf,localita);
@ -719,10 +712,7 @@ bool TInv_cont::invio_clifo()
str.format("%-.20s", (const char*) localita); str.format("%-.20s", (const char*) localita);
record.overwrite(str,133); //Localita' record.overwrite(str,133); //Localita'
// TString comcf = _tclifo->get(CLI_COMCF); const TString4 provincia = cerca_provincia(comcf);
TString provincia = "";
if (comcf.not_empty())
provincia = cerca_provincia(comcf);
str.format("%-2s", (const char*) provincia); str.format("%-2s", (const char*) provincia);
record.overwrite(str,153); //Provincia record.overwrite(str,153); //Provincia
@ -1041,32 +1031,22 @@ void TInv_cont::testata_trasfer(long nreg, int nrig, TString& record)
void TInv_cont::sola_iva(TString& record, long nreg) void TInv_cont::sola_iva(TString& record, long nreg)
{ {
TString str;
TLocalisamfile cau (LF_CAUSALI);
TString tipodoc = "";
bool cor = FALSE;
int gruppo = 0; int gruppo = 0;
int conto = 0; int conto = 0;
long sottoc = 0; long sottoc = 0;
cau.setkey(1); const TString4 tipodoc = cache().get(LF_CAUSALI, _codcausm, CAU_TIPODOC);
cau.zero();
cau.put(CAU_CODCAUS, _codcausm);
if (cau.read() == NOERR)
tipodoc = cau.get(CAU_TIPODOC);
const TRectype& tabtpd = cache().get("%TPD", tipodoc); const TRectype& tabtpd = cache().get("%TPD", tipodoc);
cor = tabtpd.get_bool("B0"); const bool cor = tabtpd.get_bool("B0");
if (!cor) if (!cor)
{ {
TLocalisamfile rcaus (LF_RCAUSALI); TLocalisamfile rcaus (LF_RCAUSALI);
rcaus.setkey(1);
rcaus.zero();
rcaus.put(RCA_CODCAUS, _codcausm); rcaus.put(RCA_CODCAUS, _codcausm);
rcaus.read(); rcaus.read();
TString codcau = rcaus.get(RCA_CODCAUS);
const TString& codcau = rcaus.get(RCA_CODCAUS);
if (codcau == _codcausm) if (codcau == _codcausm)
{ {
gruppo = rcaus.get_int (RCA_GRUPPO); gruppo = rcaus.get_int (RCA_GRUPPO);
@ -1077,9 +1057,6 @@ void TInv_cont::sola_iva(TString& record, long nreg)
else else
{ {
TLocalisamfile riva (LF_RMOVIVA); TLocalisamfile riva (LF_RMOVIVA);
riva.setkey(1);
riva.zero();
riva.put(RMI_NUMREG, nreg); riva.put(RMI_NUMREG, nreg);
riva.read(); riva.read();
long nr = riva.get_long(RMI_NUMREG); long nr = riva.get_long(RMI_NUMREG);
@ -1091,6 +1068,7 @@ void TInv_cont::sola_iva(TString& record, long nreg)
} }
} }
TString8 str;
str.format("%02d", gruppo); str.format("%02d", gruppo);
record.overwrite(str,74); //Gruppo di partita record.overwrite(str,74); //Gruppo di partita
str.format("%02d", conto); str.format("%02d", conto);
@ -1114,10 +1092,9 @@ bool TInv_cont::invio_mov_PN()
_tras_file.open(_trasf,TRUE); _tras_file.open(_trasf,TRUE);
TString80 str;
for (_tmov->first(); !_tmov->eof(); _tmov->next()) for (_tmov->first(); !_tmov->eof(); _tmov->next())
{ {
TString str;
_prog->addstatus(1); _prog->addstatus(1);
record.spaces(); record.spaces();
@ -1146,7 +1123,7 @@ bool TInv_cont::invio_mov_PN()
testata_trasfer(nreg,nrig,record); testata_trasfer(nreg,nrig,record);
TString descr = _trmov->get(RMV_DESCR); TString80 descr = _trmov->get(RMV_DESCR);
if (descr.empty()) if (descr.empty())
descr = head_descr; // Se non esiste la descrizione della riga ci mette quella della testata descr = head_descr; // Se non esiste la descrizione della riga ci mette quella della testata
str.format("%-.30s", (const char*) descr); str.format("%-.30s", (const char*) descr);
@ -1164,8 +1141,7 @@ bool TInv_cont::invio_mov_PN()
str.format("%06ld", sottoc); str.format("%06ld", sottoc);
record.overwrite(str,78); //Sottoconto di partita record.overwrite(str,78); //Sottoconto di partita
TString sez = _trmov->get(RMV_SEZIONE); str = _trmov->get(RMV_SEZIONE);
str.format("%s", (const char*) sez);
record.overwrite(str,84); //Sezione importo record.overwrite(str,84); //Sezione importo
int gruppoc = _trmov->get_int(RMV_GRUPPOC); int gruppoc = _trmov->get_int(RMV_GRUPPOC);
@ -1249,7 +1225,7 @@ void TInv_cont::cerca_occasionale()
_ragsococc = _toccas->get(OCC_RAGSOC); _ragsococc = _toccas->get(OCC_RAGSOC);
_indocc = _toccas->get(OCC_INDIR); _indocc = _toccas->get(OCC_INDIR);
_capocc = _toccas->get(OCC_CAP); _capocc = _toccas->get(OCC_CAP);
TString com = _toccas->get(OCC_COM); const TString8 com = _toccas->get(OCC_COM);
cerca_comune_occas(com); cerca_comune_occas(com);
} }
else else