Patch level : 12.00 1388
Files correlati : cg0.exe ve0.exe Commento: Trasformazione occasionali in clienti/fornitori
This commit is contained in:
parent
e78fe413cb
commit
f2633c1a29
@ -1,3 +1,4 @@
|
||||
#include <applicat.h>
|
||||
#include <array.h>
|
||||
#include <config.h>
|
||||
#include <execp.h>
|
||||
@ -6,6 +7,7 @@
|
||||
#include <strings.h>
|
||||
#include <transaction.h>
|
||||
#include <utility.h>
|
||||
#include <strings.h>
|
||||
#include <tabutil.h>
|
||||
#include <tabmod.h>
|
||||
#include <xml.h>
|
||||
@ -556,15 +558,19 @@ void TTransaction::write_ini_row_para(TConfig & cnf, const TString & rowkey, boo
|
||||
TAssoc_array & row = *((TAssoc_array *)_rows.objptr(rowkey));
|
||||
|
||||
cnf.set_paragraph(rowkey);
|
||||
|
||||
row.get_keys(arr);
|
||||
|
||||
FOR_EACH_ARRAY_ROW(arr, r1, str)
|
||||
{
|
||||
int index = get_varkey_index(*str);
|
||||
const TString name = get_varkey_name(*str);
|
||||
if (arr.items() > 0)
|
||||
{
|
||||
FOR_EACH_ARRAY_ROW(arr, r1, str)
|
||||
{
|
||||
int index = get_varkey_index(*str);
|
||||
const TString name = get_varkey_name(*str);
|
||||
|
||||
cnf.set(name, *((TString *)row.objptr(*str)), nullptr, true, index);
|
||||
}
|
||||
cnf.set(name, *((TString *)row.objptr(*str)), nullptr, true, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool TTransaction::write_ini()
|
||||
@ -577,9 +583,10 @@ bool TTransaction::write_ini()
|
||||
TConfig cnf(_file, "Transaction");
|
||||
TString_array row_arr;
|
||||
|
||||
_head.get_keys(arr);
|
||||
|
||||
cnf.set("Version", "2.0");
|
||||
cnf.set("Executer", _executer);
|
||||
_head.get_keys(arr);
|
||||
FOR_EACH_ARRAY_ROW(arr, r, str)
|
||||
{
|
||||
int index = get_varkey_index(*str);
|
||||
@ -588,7 +595,6 @@ bool TTransaction::write_ini()
|
||||
cnf.set(name, *((TString *)_head.objptr(*str)), nullptr, true, index);
|
||||
}
|
||||
_rows.get_keys(row_arr);
|
||||
write_ini_row_para(cnf, _executer);
|
||||
row_arr.sort();
|
||||
FOR_EACH_ARRAY_ROW(row_arr, r1, rowkey)
|
||||
write_ini_row_para(cnf, *rowkey, false);
|
||||
@ -711,6 +717,34 @@ bool TTransaction::get_warnings(TString_array & warnings) const
|
||||
return warnings.items() > 0;
|
||||
}
|
||||
|
||||
bool TTransaction::set_user(const char * u)
|
||||
{
|
||||
const char * wrk_user = u != nullptr ? u : user();
|
||||
|
||||
return set("User", wrk_user, -1, nullptr);
|
||||
}
|
||||
|
||||
bool TTransaction::set_hostname(const char * h)
|
||||
{
|
||||
const char * wrk_host = h != nullptr ? h : get_hostname();
|
||||
|
||||
return set("HostName", wrk_host, -1, nullptr);
|
||||
}
|
||||
|
||||
bool TTransaction::set_version()
|
||||
{
|
||||
int year, release, tag, patch;
|
||||
|
||||
if (main_app().get_version_info(year, release, tag, patch))
|
||||
{
|
||||
TString80 ver;
|
||||
ver.format("%d %d.%d-%d", year, release, tag, patch);
|
||||
set("Version", ver, -1, nullptr);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TTransaction::read()
|
||||
{
|
||||
if (_type == ini_transaction)
|
||||
@ -764,6 +798,68 @@ bool file2app(TString & file ,TString& app)
|
||||
return app.full();
|
||||
}
|
||||
|
||||
bool TTransaction::execute(bool interactive)
|
||||
{
|
||||
TString table = executer();
|
||||
int logicnum = atoi(table);
|
||||
TFilename pref = name();
|
||||
bool ok = false;
|
||||
|
||||
if (table.full())
|
||||
{
|
||||
TString app;
|
||||
|
||||
if (file2app(table, app))
|
||||
{
|
||||
app << (interactive ? " -i" : " -b") << pref;
|
||||
app << " -u" << user();
|
||||
|
||||
TExternal_app cmd(app);
|
||||
|
||||
TRACE("Esecuzione transazione");
|
||||
ok = cmd.run() == NOERR;
|
||||
TRACE("Fine esecuzione transazione");
|
||||
if (!interactive)
|
||||
{
|
||||
TLog_report log;
|
||||
TString_array msgs;
|
||||
|
||||
TRACE("Aggiornamento log");
|
||||
read();
|
||||
log.log(0, record_header("Transazione"));
|
||||
if (get_warnings(msgs))
|
||||
{
|
||||
FOR_EACH_ARRAY_ROW(msgs, nm, m)
|
||||
{
|
||||
TString str("Messaggio - "); str << *m;
|
||||
|
||||
log.log(1, str);
|
||||
}
|
||||
}
|
||||
if (get_errors(msgs))
|
||||
{
|
||||
FOR_EACH_ARRAY_ROW(msgs, nm, m)
|
||||
{
|
||||
TString str("Errore - "); str << *m;
|
||||
|
||||
log.log(2, str);
|
||||
}
|
||||
}
|
||||
if (log.full())
|
||||
log.preview();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TString msg(TR("Esecutore sconosciuto per le transazioni sul file "));
|
||||
|
||||
msg << (logicnum == 0) ? table : prefix().description(logicnum);
|
||||
error_box(msg);
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
void execute_transactions(TArray & transactions, TLog_report & log, bool interactive, const char * hmsg, const char * msg)
|
||||
{
|
||||
TString prog_msg(msg);
|
||||
|
@ -142,7 +142,7 @@ public:
|
||||
|
||||
// @cmember Elimina tutte le variabili
|
||||
void remove_all();
|
||||
// @cmember nouva transazione
|
||||
// @cmember nuova transazione
|
||||
void new_transaction(const char* file) { set_name(file); remove_all(); }
|
||||
|
||||
// @cmember Ritorna il nome del file di configurazione
|
||||
@ -168,10 +168,14 @@ public:
|
||||
bool set_stop_on_error(bool val) { return set("StopOnError", val ? 1 : 0, -1, nullptr); }
|
||||
bool set_caller(const TString & caller) { return set("From", caller, -1, nullptr); }
|
||||
bool set_firm(int firm) { return set("Firm", firm, -1, nullptr); }
|
||||
const char * ext() const { return _type == ini_transaction ? "ini" : "xml"; }
|
||||
bool set_user(const char * u = nullptr);
|
||||
bool set_hostname(const char * h = nullptr);
|
||||
bool set_version();
|
||||
const char * ext() const { return _type == ini_transaction ? "ini" : "xml"; }
|
||||
|
||||
bool read();
|
||||
bool write();
|
||||
bool execute(bool interactive = true);
|
||||
|
||||
TTransaction & operator= (const TTransaction & t) { return copy(t); }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user