Patch level :

Files correlati     : sv2.exe
Ricompilazione Demo : [ ]
Commento            :
Ottimizzato ricalcolo statistiche (6x)


git-svn-id: svn://10.65.10.50/branches/R_10_00@22472 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2011-10-31 11:40:02 +00:00
parent 86f42becf9
commit 92aff241e4
2 changed files with 17 additions and 16 deletions

View File

@ -45,8 +45,8 @@ void TRicalcolo_stats::on_config_change()
bool TRicalcolo_stats::kill_stats(const TDate& dfr, const TDate& dto) bool TRicalcolo_stats::kill_stats(const TDate& dfr, const TDate& dto)
{ {
TRelation rel(LF_SVRIEP); TFast_isamfile fdoc(LF_SVRIEP);
TRelation rel(LF_SVRIEP);
TRectype recfrom(LF_SVRIEP), recto(LF_SVRIEP); TRectype recfrom(LF_SVRIEP), recto(LF_SVRIEP);
if (dfr.ok()) if (dfr.ok())
@ -62,7 +62,7 @@ bool TRicalcolo_stats::kill_stats(const TDate& dfr, const TDate& dto)
TCursor cur(&rel, "", 1, &recfrom, &recto); TCursor cur(&rel, "", 1, &recfrom, &recto);
const long items = cur.items(); const long items = cur.items();
TProgind pi(items, TR("Azzeramento statistiche"), FALSE, TRUE); TProgind pi(items, TR("Azzeramento statistiche"), false, true);
cur.freeze(); cur.freeze();
for (cur = 0; cur.pos() < items; ++cur) for (cur = 0; cur.pos() < items; ++cur)
@ -72,11 +72,11 @@ bool TRicalcolo_stats::kill_stats(const TDate& dfr, const TDate& dto)
if (err != NOERR) if (err != NOERR)
{ {
error_box(FR("Errore %d durante l'azzeramento archivi"), err); error_box(FR("Errore %d durante l'azzeramento archivi"), err);
return FALSE; return false;
} }
} }
return TRUE; return true;
} }
void TRicalcolo_stats::calcola_data_minima() void TRicalcolo_stats::calcola_data_minima()
@ -116,6 +116,8 @@ void TRicalcolo_stats::calcola_data_minima()
void TRicalcolo_stats::calc_stats(const TDate& dfr, const TDate& dto) void TRicalcolo_stats::calc_stats(const TDate& dfr, const TDate& dto)
{ {
TFast_isamfile fdoc(LF_DOC);
TRectype recfrom(LF_DOC), recto(LF_DOC); TRectype recfrom(LF_DOC), recto(LF_DOC);
if (dfr.ok()) if (dfr.ok())
{ {
@ -129,16 +131,14 @@ void TRicalcolo_stats::calc_stats(const TDate& dfr, const TDate& dto)
} }
TRelation rel(LF_DOC); TRelation rel(LF_DOC);
const TRectype& curr = rel.curr();
TCursor cur(&rel, "PROVV='D'", 3, &recfrom, &recto); TCursor cur(&rel, "PROVV='D'", 3, &recfrom, &recto);
const long items = cur.items(); const long items = cur.items();
cur.freeze(); cur.freeze();
TProgind pi(items, TR("Ricalcolo statistiche"), FALSE, TRUE); TProgind pi(items, TR("Ricalcolo statistiche"), false, true);
TDocumento* curr = new TDocumento;
cur.file().set_curr(curr);
const TDocumento& doc = *curr;
long records = 0; long records = 0;
_agg.reset(); _agg.reset();
@ -146,10 +146,12 @@ void TRicalcolo_stats::calc_stats(const TDate& dfr, const TDate& dto)
{ {
pi.addstatus(1); pi.addstatus(1);
const TTipo_documento& tipodoc = doc.tipo(); const TTipo_documento& tipodoc = cached_tipodoc(curr.get(DOC_TIPODOC));
if (!tipodoc.statistiche()) if (!tipodoc.statistiche())
continue; continue;
const TDocumento doc(rel.curr());
const bool nota_cr = tipodoc.nota_credito(); const bool nota_cr = tipodoc.nota_credito();
for (int r = doc.physical_rows(); r > 0; r--) for (int r = doc.physical_rows(); r > 0; r--)
{ {
@ -177,7 +179,7 @@ bool TRicalcolo_stats::datein_handler(TMask_field& f, KEY k)
if (inizio < _datamin) if (inizio < _datamin)
return f.error_box(FR("Impossibile effettuare la ricostruzione statistiche\nad una data antecedente il %s"), _datamin.string()); return f.error_box(FR("Impossibile effettuare la ricostruzione statistiche\nad una data antecedente il %s"), _datamin.string());
} }
return TRUE; return true;
} }
void TRicalcolo_stats::main_loop() void TRicalcolo_stats::main_loop()

View File

@ -570,13 +570,12 @@ bool TStats_agg::empty()
bool TStats_agg::update() bool TStats_agg::update()
{ {
test_firm(); test_firm();
bool ok = TRUE; bool ok = TRUE;
TToken_string key(64); TToken_string key(64);
TLocalisamfile stat(LF_SVRIEP); TFast_isamfile stat(LF_SVRIEP);
stat.set_curr(new TSVriep_record); stat.set_curr(new TSVriep_record);
TRectype& curr = stat.curr(); TRectype& curr = stat.curr();