Patch level : 12.0 1090

Files correlati     : bs0.exe
Commento        :

aggiunto un meccanismo di trace nell'importazione bee store
Interno:
This commit is contained in:
Alessandro Bonazzi 2021-10-20 07:26:56 +02:00
parent c81d72de4d
commit 454f2c2bb4
2 changed files with 62 additions and 23 deletions

View File

@ -644,19 +644,50 @@ bool TTransaction::write_xml()
return ok; return ok;
} }
const char * TTransaction::record_header() const const char * TTransaction::record_header(const char * msg) const
{ {
TString &str = get_tmp_string(2569); TString &str = get_tmp_string(256);
int logicnum = atoi(_executer); const int logicnum = isdigit(_executer[0]) ? atoi(_executer) : table2logic(_executer);
if (logicnum == 0)
logicnum = table2logic(_executer);
TToken_string keyfields(prefix().get_keyexpr(logicnum), '+'); TToken_string keyfields(prefix().get_keyexpr(logicnum), '+');
str = "Record "; if (msg && *msg)
FOR_EACH_STR_TOKEN(keyfields, fld) {
if (fld.full()) TString m(msg);
str << fld << " = " << get(fld, -1, _executer) << " "; int pos;
while ((pos = m.find("#")) >= 0)
{
if (pos > 0)
str << m.left(pos);
int space_pos = m.find(" ", pos);
TString16 fld(m.mid(pos + 1, space_pos - pos - 1));
fld.upper();
if (fld == "KEY")
{
FOR_EACH_STR_TOKEN(keyfields, fld)
if (fld.full())
str << get(fld, -1, _executer) << " ";
}
else
str << get(m.mid(pos + 1, space_pos - pos - 1), -1, _executer);
if (space_pos >= 0)
m.ltrim(space_pos);
else
m.cut(0);
}
if (m.full())
str << m;
}
else
{
str = "Record ";
FOR_EACH_STR_TOKEN(keyfields, fld)
if (fld.full())
str << get(fld, -1, _executer) << " ";
}
return str; return str;
} }
@ -733,9 +764,10 @@ bool file2app(TString & file ,TString& app)
return app.full(); return app.full();
} }
void execute_transactions(TArray & transactions, TLog_report & log, bool interactive, const char * msg) void execute_transactions(TArray & transactions, TLog_report & log, bool interactive, const char * hmsg, const char * msg)
{ {
TString prog_msg(msg); TString prog_msg(msg);
TString header_msg(hmsg);
if (transactions.items() > 0) if (transactions.items() > 0)
{ {
@ -807,17 +839,24 @@ void execute_transactions(TArray & transactions, TLog_report & log, bool interac
TTransaction t(*str); TTransaction t(*str);
TString_array msgs; TString_array msgs;
log.log(0, t.record_header()); log.log(0, t.record_header(header_msg));
t.get_warnings(msgs); if (t.get_warnings(msgs))
FOR_EACH_ARRAY_ROW(msgs, nm, msg)
log.log(1, *msg);
if (t.result_ok())
log.log(0, "Eseguita");
else
{ {
t.get_errors(msgs); FOR_EACH_ARRAY_ROW(msgs, nm, m)
FOR_EACH_ARRAY_ROW(msgs, nm, msg) {
log.log(2, *msg); TString str("Messaggio - "); str << *m;
log.log(1, str);
}
}
if (t.get_errors(msgs))
{
FOR_EACH_ARRAY_ROW(msgs, nm, m)
{
TString str("Errore - "); str << *m;
log.log(2, str);
}
} }
} }
remove_files(filemask, false); remove_files(filemask, false);

View File

@ -149,7 +149,7 @@ public:
const TFilename& name() const { return _file; } const TFilename& name() const { return _file; }
void set_name(const char * name) { _file = name; _file.ext(_type == ini_transaction ? "ini" : "xml"); } void set_name(const char * name) { _file = name; _file.ext(_type == ini_transaction ? "ini" : "xml"); }
const TString & executer() const { return _executer; } const TString & executer() const { return _executer; }
const char * record_header() const; const char * record_header(const char * msg) const;
const TString & get_action() const { return (const char *)get("Action", -1, nullptr); } const TString & get_action() const { return (const char *)get("Action", -1, nullptr); }
char get_mode() const { get("Mode", -1, TRANSACTION_HEADER)[0]; } char get_mode() const { get("Mode", -1, TRANSACTION_HEADER)[0]; }
int get_stop_on_error() const { return get_bool("StopOnError", -1, nullptr) ? 1 : 0; } int get_stop_on_error() const { return get_bool("StopOnError", -1, nullptr) ? 1 : 0; }
@ -186,6 +186,6 @@ public:
virtual ~TTransaction() {} virtual ~TTransaction() {}
}; };
void execute_transactions(TArray & transactions, TLog_report & log, bool interactive = true, const char * msg = nullptr); void execute_transactions(TArray & transactions, TLog_report & log, bool interactive = true, const char * hmsg = nullptr, const char * msg = nullptr);
#endif #endif