Patch level : 12.0 1186
Files correlati : xvaga.dll Commento: Le cache di file si aggiornano meglio, abbiamo aggiornato la data di modifica dei file ad ogni srittura cion la nuova funzione xvt_fsys_set_file_time in xvaga. le relapp per default aggiornano le cache di file
This commit is contained in:
parent
6bdaecf6f1
commit
caa96b90e2
@ -956,7 +956,7 @@ int TBaseisamfile::_write(const TRectype& rec)
|
|||||||
if (rec.has_memo())
|
if (rec.has_memo())
|
||||||
((TRectype&)rec).write_memo(_isam_handle, _recno );
|
((TRectype&)rec).write_memo(_isam_handle, _recno );
|
||||||
rec_cache(_logicnum).notify_change();
|
rec_cache(_logicnum).notify_change();
|
||||||
|
xvt_fsys_set_file_time(filename(), nullptr, nullptr, xvt_time_now());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_lasterr = get_error(_lasterr);
|
_lasterr = get_error(_lasterr);
|
||||||
@ -1016,6 +1016,7 @@ int TBaseisamfile::_rewrite(const TRectype& rec)
|
|||||||
{
|
{
|
||||||
memcpy(DB_getrecord(fhnd), rec.string(), len);
|
memcpy(DB_getrecord(fhnd), rec.string(), len);
|
||||||
_lasterr = DB_rewrite(fhnd);
|
_lasterr = DB_rewrite(fhnd);
|
||||||
|
xvt_fsys_set_file_time(filename(), nullptr, nullptr, xvt_time_now());
|
||||||
if (_lasterr == NOERR)
|
if (_lasterr == NOERR)
|
||||||
rec_cache(_logicnum).notify_change();
|
rec_cache(_logicnum).notify_change();
|
||||||
else
|
else
|
||||||
@ -3801,7 +3802,9 @@ const TString& TRectype::get(const char* fieldname) const
|
|||||||
if (orig)
|
if (orig)
|
||||||
{
|
{
|
||||||
CHECKD(orig >= LF_EXTERNAL || orig == num(), "Invalid isam handle ", orig);
|
CHECKD(orig >= LF_EXTERNAL || orig == num(), "Invalid isam handle ", orig);
|
||||||
|
|
||||||
TCodeb_handle cb_handle = prefix().get_handle(orig, -1);
|
TCodeb_handle cb_handle = prefix().get_handle(orig, -1);
|
||||||
|
|
||||||
CHECKD(cb_handle >= 0, "Can't read memo from file ", orig);
|
CHECKD(cb_handle >= 0, "Can't read memo from file ", orig);
|
||||||
if (DB_recno(cb_handle) != _memo_data->recno())
|
if (DB_recno(cb_handle) != _memo_data->recno())
|
||||||
DB_go(cb_handle, _memo_data->recno());
|
DB_go(cb_handle, _memo_data->recno());
|
||||||
@ -3910,7 +3913,7 @@ void TRectype::put_str(const char* fieldname, const char* val)
|
|||||||
const int nf = findfld(&recd, fieldname);
|
const int nf = findfld(&recd, fieldname);
|
||||||
if (nf == FIELDERR)
|
if (nf == FIELDERR)
|
||||||
{
|
{
|
||||||
unknown_field(fieldname);
|
unknown_field(fieldname);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3937,6 +3940,7 @@ void TRectype::put_str(const char* fieldname, const char* val)
|
|||||||
__putfieldbuff(fd.Len, fd.Dec, ft, val, _rec + fd.RecOff);
|
__putfieldbuff(fd.Len, fd.Dec, ft, val, _rec + fd.RecOff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
setempty(FALSE);
|
setempty(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3959,7 +3963,7 @@ void TRectype::zero(const char* fieldname)
|
|||||||
const RecDes& recd = rec_des();
|
const RecDes& recd = rec_des();
|
||||||
const int nf = findfld(&recd, fieldname);
|
const int nf = findfld(&recd, fieldname);
|
||||||
if (nf == FIELDERR)
|
if (nf == FIELDERR)
|
||||||
unknown_field(fieldname);
|
unknown_field(fieldname);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const int recoff = recd.Fd[nf].RecOff;
|
const int recoff = recd.Fd[nf].RecOff;
|
||||||
@ -3974,7 +3978,7 @@ void TRectype::zero(const char* fieldname)
|
|||||||
__putfieldbuff(len, dec, _datefld, "", p);
|
__putfieldbuff(len, dec, _datefld, "", p);
|
||||||
break;
|
break;
|
||||||
case _memofld:
|
case _memofld:
|
||||||
__putfieldbuff(len, dec, _memofld, "", p);
|
__putfieldbuff(len, dec, _memofld, "", p);
|
||||||
_memo_data->add("", nf);
|
_memo_data->add("", nf);
|
||||||
_memo_data->set_dirty(nf);
|
_memo_data->set_dirty(nf);
|
||||||
break;
|
break;
|
||||||
|
@ -94,7 +94,7 @@ void TRecord_array::set_key(TRectype* r)
|
|||||||
const RecDes& recd = r->rec_des(); // Descrizione del record della testata
|
const RecDes& recd = r->rec_des(); // Descrizione del record della testata
|
||||||
const KeyDes& kd = recd.Ky[0]; // Elenco dei campi della chiave 1
|
const KeyDes& kd = recd.Ky[0]; // Elenco dei campi della chiave 1
|
||||||
|
|
||||||
// Copia tutti i campi chiave, tranne l'ultimo, in tutti i records
|
// Copia tutti i campi chiave, tranne l'ultimo, in tutti i records
|
||||||
TString80 val;
|
TString80 val;
|
||||||
for (int i = kd.NkFields-2; i >= 0; i--)
|
for (int i = kd.NkFields-2; i >= 0; i--)
|
||||||
{
|
{
|
||||||
@ -546,6 +546,7 @@ int TRecord_array::remove() const
|
|||||||
|
|
||||||
unsigned long TFile_cache::_hits = 0;
|
unsigned long TFile_cache::_hits = 0;
|
||||||
unsigned long TFile_cache::_misses = 0;
|
unsigned long TFile_cache::_misses = 0;
|
||||||
|
bool TFile_cache::_global_test_changes = false;
|
||||||
|
|
||||||
void TFile_cache::stats(unsigned long& h, unsigned long& m)
|
void TFile_cache::stats(unsigned long& h, unsigned long& m)
|
||||||
{
|
{
|
||||||
@ -661,11 +662,11 @@ void TFile_cache::test_firm()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_test_changes && !_changed && _file != NULL)
|
if (check_changes() && !_changed && _file != nullptr)
|
||||||
{
|
{
|
||||||
// Non controllare troppo spesso la data del file nei programmi batch: aspetta almeno 2 secondi!
|
// Non controllare troppo spesso la data del file nei programmi batch: aspetta almeno 2 secondi!
|
||||||
const unsigned long now = clock();
|
const unsigned long now = clock();
|
||||||
if (now > _last_file_test + 2500)
|
if (now > _last_file_test + (_global_test_changes ? 0 : 2500))
|
||||||
{
|
{
|
||||||
TFilename n = prefix().get_filename(_file->num()); n.ext("dbf");
|
TFilename n = prefix().get_filename(_file->num()); n.ext("dbf");
|
||||||
FILE_SPEC fs; xvt_fsys_convert_str_to_fspec(n, &fs);
|
FILE_SPEC fs; xvt_fsys_convert_str_to_fspec(n, &fs);
|
||||||
@ -677,7 +678,7 @@ void TFile_cache::test_firm()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool flush_needed = _test_changes && _changed && _file != NULL;
|
const bool flush_needed = check_changes() && _changed && _file != NULL;
|
||||||
|
|
||||||
if (flush_needed)
|
if (flush_needed)
|
||||||
{
|
{
|
||||||
@ -720,7 +721,7 @@ const TObject& TFile_cache::query(const char* code)
|
|||||||
|
|
||||||
TObject* obj = _cache.objptr(_code);
|
TObject* obj = _cache.objptr(_code);
|
||||||
|
|
||||||
if (obj == NULL)
|
if (obj == nullptr)
|
||||||
{
|
{
|
||||||
TLocalisamfile& f = file();
|
TLocalisamfile& f = file();
|
||||||
TRectype& curr = f.curr();
|
TRectype& curr = f.curr();
|
||||||
@ -760,10 +761,7 @@ const TObject& TFile_cache::query(const char* code)
|
|||||||
_misses++;
|
_misses++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
_hits++;
|
_hits++;
|
||||||
}
|
|
||||||
|
|
||||||
return *obj;
|
return *obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,6 +157,7 @@ public:
|
|||||||
class TFile_cache : public TObject
|
class TFile_cache : public TObject
|
||||||
{
|
{
|
||||||
static unsigned long _hits, _misses;
|
static unsigned long _hits, _misses;
|
||||||
|
static bool _global_test_changes;
|
||||||
|
|
||||||
TToken_string _code;
|
TToken_string _code;
|
||||||
TString8 _filecode; // Codice tabella es: %STA, &AUT, LVCAU
|
TString8 _filecode; // Codice tabella es: %STA, &AUT, LVCAU
|
||||||
@ -200,6 +201,8 @@ public:
|
|||||||
|
|
||||||
void set_items_limit(long l) { _limit = l; }
|
void set_items_limit(long l) { _limit = l; }
|
||||||
void test_file_changes(bool t = TRUE) { _test_changes = t; }
|
void test_file_changes(bool t = TRUE) { _test_changes = t; }
|
||||||
|
static void global_file_changes(bool t = TRUE) { _global_test_changes = t; }
|
||||||
|
bool check_changes() const { return _global_test_changes || _test_changes; }
|
||||||
void notify_change();
|
void notify_change();
|
||||||
|
|
||||||
static void stats(unsigned long& hits, unsigned long& misses);
|
static void stats(unsigned long& hits, unsigned long& misses);
|
||||||
|
@ -214,6 +214,7 @@ void TRelation_application::set_find_button()
|
|||||||
|
|
||||||
bool TRelation_application::create()
|
bool TRelation_application::create()
|
||||||
{
|
{
|
||||||
|
TFile_cache::global_file_changes(true);
|
||||||
bool ok = user_create();
|
bool ok = user_create();
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
@ -811,6 +812,7 @@ int TRelation_application::delete_mode()
|
|||||||
TToken_string fldlist = brw->get_input_field_names();
|
TToken_string fldlist = brw->get_input_field_names();
|
||||||
TString80 str;
|
TString80 str;
|
||||||
int fi = 0;
|
int fi = 0;
|
||||||
|
|
||||||
for (TString80 tok = inplist.get(fi); tok.not_empty(); tok = inplist.get(), fi++)
|
for (TString80 tok = inplist.get(fi); tok.not_empty(); tok = inplist.get(), fi++)
|
||||||
{
|
{
|
||||||
const TString16 fn = fldlist.get(fi);
|
const TString16 fn = fldlist.get(fi);
|
||||||
@ -890,6 +892,7 @@ int TRelation_application::delete_mode()
|
|||||||
TWait_cursor hourglass;
|
TWait_cursor hourglass;
|
||||||
long skipped = 0; // Record non cancellati perche' protetti
|
long skipped = 0; // Record non cancellati perche' protetti
|
||||||
cur.freeze(TRUE); // Congelo il cursore altrimenti si riaggiorna troppo
|
cur.freeze(TRUE); // Congelo il cursore altrimenti si riaggiorna troppo
|
||||||
|
batch(true);
|
||||||
for (long pos = sht.items()-1; deleting > 0; pos--)
|
for (long pos = sht.items()-1; deleting > 0; pos--)
|
||||||
{
|
{
|
||||||
if (sht.checked(pos))
|
if (sht.checked(pos))
|
||||||
@ -919,7 +922,8 @@ int TRelation_application::delete_mode()
|
|||||||
deleting--;
|
deleting--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cur.freeze(false);
|
batch(false);
|
||||||
|
cur.freeze(false);
|
||||||
set_limits(); // Riaggiorno il numero del primo/ultimo record
|
set_limits(); // Riaggiorno il numero del primo/ultimo record
|
||||||
|
|
||||||
if (skipped > 0)
|
if (skipped > 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user