From 454f2c2bb455fd61e7b07c1c88e136560953c98f Mon Sep 17 00:00:00 2001 From: Alessandro Bonazzi Date: Wed, 20 Oct 2021 07:26:56 +0200 Subject: [PATCH] Patch level : 12.0 1090 Files correlati : bs0.exe Commento : aggiunto un meccanismo di trace nell'importazione bee store Interno: --- src/include/transaction.cpp | 81 +++++++++++++++++++++++++++---------- src/include/transaction.h | 4 +- 2 files changed, 62 insertions(+), 23 deletions(-) diff --git a/src/include/transaction.cpp b/src/include/transaction.cpp index cb3e6babb..d6648e37d 100644 --- a/src/include/transaction.cpp +++ b/src/include/transaction.cpp @@ -644,19 +644,50 @@ bool TTransaction::write_xml() return ok; } -const char * TTransaction::record_header() const +const char * TTransaction::record_header(const char * msg) const { - TString &str = get_tmp_string(2569); - int logicnum = atoi(_executer); - - if (logicnum == 0) - logicnum = table2logic(_executer); + TString &str = get_tmp_string(256); + const int logicnum = isdigit(_executer[0]) ? atoi(_executer) : table2logic(_executer); TToken_string keyfields(prefix().get_keyexpr(logicnum), '+'); - str = "Record "; - FOR_EACH_STR_TOKEN(keyfields, fld) - if (fld.full()) - str << fld << " = " << get(fld, -1, _executer) << " "; + if (msg && *msg) + { + TString m(msg); + 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; } @@ -733,9 +764,10 @@ bool file2app(TString & file ,TString& app) 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 header_msg(hmsg); if (transactions.items() > 0) { @@ -807,17 +839,24 @@ void execute_transactions(TArray & transactions, TLog_report & log, bool interac TTransaction t(*str); TString_array msgs; - log.log(0, t.record_header()); - t.get_warnings(msgs); - FOR_EACH_ARRAY_ROW(msgs, nm, msg) - log.log(1, *msg); - if (t.result_ok()) - log.log(0, "Eseguita"); - else + log.log(0, t.record_header(header_msg)); + if (t.get_warnings(msgs)) { - t.get_errors(msgs); - FOR_EACH_ARRAY_ROW(msgs, nm, msg) - log.log(2, *msg); + FOR_EACH_ARRAY_ROW(msgs, nm, m) + { + 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); diff --git a/src/include/transaction.h b/src/include/transaction.h index 867f46cf6..3d1975fe5 100644 --- a/src/include/transaction.h +++ b/src/include/transaction.h @@ -149,7 +149,7 @@ public: const TFilename& name() const { return _file; } void set_name(const char * name) { _file = name; _file.ext(_type == ini_transaction ? "ini" : "xml"); } 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); } char get_mode() const { get("Mode", -1, TRANSACTION_HEADER)[0]; } int get_stop_on_error() const { return get_bool("StopOnError", -1, nullptr) ? 1 : 0; } @@ -186,6 +186,6 @@ public: 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