prefix.cpp Nuova gestione handles isam

printapp.cpp Risolti conflitti su buffer della setrow
printer.cpp  Risolti conflitti sul numero di colonne stampabili
recarray.cpp Tolte tutte le ::format inutili
relapp.cpp   Risolti conflitti
relapp.h     Cambiato prototipo della funzione get_next_key()
             VERY IMPORTANTE: la token stringa della chiave viene ora
             passata come parametro e non ritornata dalla funzione


git-svn-id: svn://10.65.10.50/trunk@6586 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1998-05-04 07:57:56 +00:00
parent 075c25a23b
commit 5ef993980d
6 changed files with 67 additions and 53 deletions

View File

@ -291,6 +291,11 @@ int TFile_info::open_low(bool exclusive, bool index)
_filedes.EOX = d.eox() = n;
d.put(num(),_dir,_sysdirop);
}
if (index)
err = DB_tagselect(_handle, _last_key = 1);
else
_last_key = 0;
}
else
{
@ -306,6 +311,7 @@ int TFile_info::close_low()
{
DB_close(_handle);
_handle = -1;
_last_key = -1;
}
else
{
@ -520,16 +526,20 @@ bool TFile_manager::close_oldest()
{
int oldest = 0;
clock_t age = 0;
_open_files = 0; // Intanto ricalcolo il numero di file veramente aperti
for (int n = _fileinfo.last(); n > 0; n = _fileinfo.pred(n))
{
TFile_info& i = (TFile_info&)_fileinfo[n];
if (i.is_open() && !i.is_locked() && !i.is_exclusive())
if (i.is_open())
{
if (oldest == 0 || i.last_access() < age)
_open_files++;
if (!i.is_locked() && !i.is_exclusive())
{
oldest = n;
age = i.last_access();
if (oldest == 0 || i.last_access() < age)
{
oldest = n;
age = i.last_access();
}
}
}
}
@ -583,9 +593,12 @@ int TFile_manager::close(TIsam_handle& name)
TFile_info* i = (TFile_info*)_fileinfo.objptr(name);
if (i != NULL)
{
const bool was_open = i->is_open();
err = i->close();
if (err == NOERR && i->ref_count() == 0)
{
if (was_open && !i->is_open())
_open_files--;
if (name >= LF_EXTERNAL)
{
_fileinfo.remove(name);
@ -728,7 +741,7 @@ TFile_manager::TFile_manager()
: _open_files(0)
{
TConfig prawin(CONFIG_INSTALL, "Main");
_max_open_files = prawin.get_int("MaxHandles", NULL, 16);
_max_open_files = prawin.get_int("MaxHandles", NULL, -1, 16);
if (_max_open_files < 8)
_max_open_files = 8;
else
@ -845,15 +858,16 @@ void TPrefix::set(
bool TPrefix::exist(long codditta) const
{
CHECKD(codditta > 0, "Solo le ditte con codice maggiore di zero possono esistere : codice ", codditta);
TFilename s(firm2dir(codditta));
s.add("dir.gen");
if (s.exist())
if (codditta > 0L && codditta < 100000L)
{
s = s.path();
s.add("trc.gen");
return s.exist();
TFilename s(firm2dir(codditta));
s.add("dir.gen");
if (s.exist())
{
s = s.path();
s.add("trc.gen");
return s.exist();
}
}
return FALSE;
}

View File

@ -32,9 +32,9 @@ const word RECNO_FLAG = 0x0800;
const word BOOLEAN_FLAG = 0x1000;
const word IGNORE_FILL = 0x2000;
// =============================================================
///////////////////////////////////////////////////////////
// print token containers
// =============================================================
///////////////////////////////////////////////////////////
class _Transfield:public TObject
{
@ -436,9 +436,9 @@ TString& fill_str (TString & t, char f)
return t;
}
// ========================================================
///////////////////////////////////////////////////////////
// Printapp code at last
// ========================================================
///////////////////////////////////////////////////////////
void TPrint_application::select_cursor (int c)
{
@ -691,7 +691,6 @@ void TPrint_application::set_row (
r--;
char digbuf[10];
TString bigbuf(256);
char* strbuf = bigbuf.get_buffer();

View File

@ -1073,6 +1073,7 @@ TPrinter::TPrinter()
_formlen = 66;
_formwidth = 0;
_frompage = 0;
_topage = 0xffff;
_hwformfeed = FALSE;
@ -1181,10 +1182,10 @@ void TPrinter::read_configuration(
break;
}
if (xvt_print_is_valid(_print_rcd))
{
set_win_formlen();
}
else
{
init_formlen();
}
else
{
error_box("Attenzione: la stampante corrente non e' valida.\n"
"Si prega di selezionare e registrare una nuova stampante.");
@ -1707,7 +1708,6 @@ bool TPrinter::set()
}
mask.set(MSK_PRINTERS, pn1.get(_curprn));
// set_win_formlen(); // Update dimensions
}
else
beep ();

View File

@ -402,14 +402,14 @@ int TRecord_array::remove() const
TFile_cache::TFile_cache(TLocalisamfile *f , int key)
: _file(NULL), _key(key)
{
_code.format("%d", f->num());
_code << f->num();
init_file(f);
}
TFile_cache::TFile_cache(int num, int key)
: _file(NULL), _key(key)
{
_code.format("%d", num);
_code << num;
}
TFile_cache::TFile_cache(const char* tab, int key)
@ -574,9 +574,11 @@ const TString& TDecoder::decode(const char* code)
const TString& TDecoder::decode(long code)
{
TString16 c;
char c[16];
if (code > 0)
c << code;
sprintf(c, "%ld", code);
else
c[0] = '\0';
return decode(c);
}
@ -584,7 +586,7 @@ const TString& TDecoder::decode(long code)
// TRecord_cache
///////////////////////////////////////////////////////////
TRecord_cache::TRecord_cache(TLocalisamfile *f, int key )
TRecord_cache::TRecord_cache(TLocalisamfile *f, int key)
: TFile_cache(f, key)
{ }

View File

@ -237,7 +237,12 @@ bool TRelation_application::autonum(
TMask* m, // @parm Maschera a cui applicare l'autonumerazione
bool rec) // @parm Indica se registrare la chiave anche sul record corrente
{
TToken_string k(get_next_key());
TToken_string k;
if (!get_next_key(k))
{
NFCHECK("La 'const char* get_next_key()' verra' sostituita dalla 'bool get_next_key(TToken_string&)'");
k = get_next_key();
}
if (!rec && !m->query_mode())
m->reset();
@ -254,7 +259,10 @@ bool TRelation_application::autonum(
if (rec)
((TEditable_field&)f).autosave(*get_relation());
if (_renum_message.empty() || f.in_key(1))
_renum_message.format("Il documento e' stato registrato con :\n %s = %s", (const char *) f.prompt(), (const char *) f.get());
{
_renum_message = "Il documento e' stato registrato con:\n";
_renum_message << f.prompt() << " = " << f.get();
}
}
return k.not_empty();
}
@ -1023,28 +1031,16 @@ void TRelation_application::main_loop()
if (_transaction.not_empty())
{
TConfig ini(_ini, "Transaction");
int err = NOERR;
if (_recins >= 0)
{
ini.set("Result", "OK");
ini.set("Error", "0");
edit_mask2ini();
}
if (_curr_transaction.not_empty())
{
TConfig ini(_trans_ini.row(_trans_counter), "Transaction");
if (_recins >= 0)
{
ini.set("Result", "OK");
ini.set("Error", "0");
edit_mask2ini();
}
else
{
const int err = get_relation()->status();
ini.set("Result", err == NOERR ? "CANCEL" : "ERROR");
ini.set("Error", err);
}
else
{
err = get_relation()->status();
ini.set("Result", err == NOERR ? "CANCEL" : "ERROR");
}
_trans_counter++;
} while ( _trans_counter < _ntransactions);
@ -1263,12 +1259,13 @@ bool TRelation_application::load_transaction()
_curr_trans_mode = cnf.get("Mode")[0];
long firm = cnf.get_long("Firm");
if (firm > 0)
if (firm > 0 && firm != get_firm())
{
bool ok = set_firm(firm);
_mask->on_firm_change();
if (!ok)
error_box("Ditta inesistente: %ld", firm);
if (ok)
_mask->on_firm_change();
else
error_box("La ditta %ld non esiste", firm);
}
if (_curr_transaction == "RUN")
@ -1307,7 +1304,7 @@ void TRelation_application::ini2mask(TConfig& ini, TMask& m, bool query)
TMask_field& campo = m.fld(f);
if (campo.field())
{
if (!query || campo.in_key(1))
if (!query || campo.in_key(0))
{
str = campo.field()->read(ini, defpar);
if (str.not_empty())

View File

@ -175,6 +175,8 @@ protected:
// return format("%d<pipe>%s", F_NUM, get_relation()-<gt>items());
virtual const char* get_next_key()
{ return ""; }
virtual bool get_next_key(TToken_string& key)
{ return FALSE; }
// @cmember Richiede se il record corrente e' protetto (non cancellabile)
virtual bool protected_record(TRectype&)