Patch level : 10.0
Files correlati : lv Ricompilazione Demo : [ ] Commento : Corretta cache sulle tabelle di modulo Aumentata lunghezza massima del nome del produttore da 50 a 255 caratteri git-svn-id: svn://10.65.10.50/trunk@17198 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
49f97904ae
commit
602827b7ea
@ -1,12 +1,9 @@
|
||||
#include <prefix.h>
|
||||
#include <recarray.h>
|
||||
#include <tabmod.h>
|
||||
#include <tabutil.h>
|
||||
#include <user.h>
|
||||
|
||||
#include <user.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TRecord_Array
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -465,7 +462,7 @@ void TFile_cache::construct(int key)
|
||||
_changed = false;
|
||||
}
|
||||
|
||||
TFile_cache::TFile_cache(TLocalisamfile *f , int key)
|
||||
TFile_cache::TFile_cache(TLocalisamfile* f , int key)
|
||||
{
|
||||
construct(key);
|
||||
_filecode << f->num();
|
||||
@ -473,7 +470,7 @@ TFile_cache::TFile_cache(TLocalisamfile *f , int key)
|
||||
}
|
||||
|
||||
TFile_cache::TFile_cache(int num, int key)
|
||||
: _key(key)
|
||||
: _key(key)
|
||||
{
|
||||
construct(key);
|
||||
_filecode << num;
|
||||
@ -512,7 +509,10 @@ void TFile_cache::init_file(TLocalisamfile* f)
|
||||
int logicnum = atoi(_filecode);
|
||||
if (logicnum == 0)
|
||||
{
|
||||
_file = new TTable(_filecode);
|
||||
if (_filecode == '&')
|
||||
_file = new TModule_table(_filecode);
|
||||
else
|
||||
_file = new TTable(_filecode);
|
||||
logicnum = _file->num();
|
||||
}
|
||||
else
|
||||
@ -599,16 +599,17 @@ const TObject& TFile_cache::query(const char* code)
|
||||
{
|
||||
TLocalisamfile& f = file();
|
||||
TRectype& curr = f.curr();
|
||||
if (_code.not_empty())
|
||||
if (_code.full())
|
||||
{
|
||||
const RecDes* recd = curr.rec_des(); // Descrizione del record della testata
|
||||
const KeyDes& kd = recd->Ky[_key-1]; // Elenco dei campi della chiave
|
||||
for (int i = f.tab() ? 1 : 0; i < kd.NkFields; i++) // Riempie la chiave selezionata
|
||||
const int fi = f.tab() ? 1 : (f.num() == LF_TABMOD ? 2 : 0);
|
||||
for (int i = fi; i < kd.NkFields; i++) // Riempie la chiave selezionata
|
||||
{
|
||||
const int nf = kd.FieldSeq[i] % MaxFields;
|
||||
const RecFieldDes& rf = recd->Fd[nf];
|
||||
const char* val = _code.get();
|
||||
if (val)
|
||||
if (val && *val)
|
||||
curr.put(rf.Name, val);
|
||||
else
|
||||
curr.zero(rf.Name);
|
||||
@ -619,14 +620,14 @@ const TObject& TFile_cache::query(const char* code)
|
||||
_error = _iskeyerr;
|
||||
switch (_error)
|
||||
{
|
||||
case NOERR:
|
||||
break;
|
||||
case _iskeynotfound:
|
||||
case _iseof:
|
||||
case _isemptyfile:
|
||||
default:
|
||||
curr.zero();
|
||||
break;
|
||||
case NOERR:
|
||||
break;
|
||||
case _iskeynotfound:
|
||||
case _iseof:
|
||||
case _isemptyfile:
|
||||
default:
|
||||
curr.zero();
|
||||
break;
|
||||
}
|
||||
obj = rec2obj(curr);
|
||||
_cache.add(_code, obj);
|
||||
@ -792,24 +793,39 @@ TRecord_cache& TDB_cache::rec_cache(int file)
|
||||
return *rc;
|
||||
}
|
||||
|
||||
int TDB_cache::build_table_key(const char* table, const char* key, TToken_string& k) const
|
||||
{
|
||||
int file = LF_TAB;
|
||||
if (!isalnum(*table)) // gestisco i casi come %IVA e &AUT
|
||||
{
|
||||
switch (*table)
|
||||
{
|
||||
case '%': file = LF_TABCOM; break;
|
||||
case '^': file = LF_TABGEN; break;
|
||||
case '&': file = LF_TABMOD; break;
|
||||
case '$':
|
||||
default : file = LF_TAB; break;
|
||||
}
|
||||
table++; // Skippa il primo carattere speciale
|
||||
}
|
||||
k = table;
|
||||
k.add(key);
|
||||
return file;
|
||||
}
|
||||
|
||||
const TRectype& TDB_cache::get(const char* table, const char* key)
|
||||
{
|
||||
CHECKS(table && *table, "Invalid Table code ", table);
|
||||
int file = LF_TAB;
|
||||
if (*table == '%')
|
||||
{
|
||||
file = LF_TABCOM;
|
||||
table++;
|
||||
}
|
||||
TString80 tabkey;
|
||||
tabkey.format("%s|%s", table, key);
|
||||
|
||||
TToken_string tabkey;
|
||||
const int file = build_table_key(table, key, tabkey);
|
||||
return get(file, tabkey);
|
||||
}
|
||||
|
||||
const TRectype& TDB_cache::get(const TRectype& curr)
|
||||
{
|
||||
const int num = curr.num();
|
||||
if (num == LF_TAB || num == LF_TABCOM)
|
||||
if (num == LF_TAB || num == LF_TABCOM || num == LF_TABGEN || num == LF_TABMOD)
|
||||
return get(curr.get("COD"), curr.get("CODTAB"));
|
||||
|
||||
const RecDes& recd = *curr.rec_des(); // Descrizione del record della testata
|
||||
@ -833,14 +849,8 @@ bool TDB_cache::discard(const char *table, const char* key)
|
||||
{
|
||||
CHECK(table && *table, "Invalid Table code");
|
||||
|
||||
int file = LF_TAB;
|
||||
if (*table == '%')
|
||||
{
|
||||
file = LF_TABCOM;
|
||||
table++;
|
||||
}
|
||||
TString80 tabkey;
|
||||
tabkey << table << '|' << key;
|
||||
TToken_string tabkey;
|
||||
const int file = build_table_key(table, key, tabkey);
|
||||
return rec_cache(file).discard(tabkey);
|
||||
}
|
||||
|
||||
@ -879,7 +889,7 @@ const TString_array& user_and_groups()
|
||||
if (_uag.empty() || _uag.row(0) != user())
|
||||
{
|
||||
_uag.destroy();
|
||||
_uag.add(user()); // Inserisco l'utente stesso come primo
|
||||
_uag.add(user()); // Inserisco l'utente corrente come primo
|
||||
if (prefix_valid()) // Costruisce lista dei gruppi solo se possibile
|
||||
{
|
||||
TLocalisamfile user(LF_USER);
|
||||
|
@ -228,7 +228,7 @@ public:
|
||||
virtual const TRectype& get(const char* chiave);
|
||||
|
||||
// @cmember ritorna il campo (chiama get(chiave))
|
||||
const TString& get(const char* chiave, const char* campo);
|
||||
const TString& get(const char* chiave, const char* campo);
|
||||
// @cmember ritorna il record con una determinata chiave numerica
|
||||
const TRectype& get(long chiave);
|
||||
const TString& get(long chiave, const char* campo);
|
||||
@ -242,6 +242,9 @@ public:
|
||||
|
||||
class TDB_cache : public TArray
|
||||
{
|
||||
protected:
|
||||
int build_table_key(const char* table, const char* key, TToken_string& k) const;
|
||||
|
||||
public:
|
||||
TRecord_cache& rec_cache(int file);
|
||||
|
||||
|
@ -528,7 +528,7 @@ const char * encode(
|
||||
|
||||
// @xref <f decode>
|
||||
{
|
||||
char* tmp = get_tmp_string(50).get_buffer();
|
||||
char* tmp = get_tmp_string(255).get_buffer();
|
||||
int i;
|
||||
for (i = 0; data[i]; i++)
|
||||
tmp[i] = data[i] + (i < 8 ? encryption_key[i] : data[i - 8]);
|
||||
@ -546,7 +546,7 @@ const char * decode(
|
||||
|
||||
// @xref <f encode>
|
||||
{
|
||||
char* tmp = get_tmp_string(50).get_buffer();
|
||||
char* tmp = get_tmp_string(255).get_buffer();
|
||||
int i;
|
||||
|
||||
for (i = 0; data[i]; i++)
|
||||
|
Loading…
x
Reference in New Issue
Block a user