git-svn-id: svn://10.65.10.50/branches/R_10_00@22218 c028cbd2-c16b-5b4b-a496-9718f37d4682
120 lines
3.3 KiB
C++
Executable File
120 lines
3.3 KiB
C++
Executable File
#include <automask.h>
|
|
#include <config.h>
|
|
#include <relation.h>
|
|
|
|
#include "ha1250.h"
|
|
|
|
|
|
bool THardy_transaction::is_server() const
|
|
{
|
|
bool i_am_server = false;
|
|
TConfig config(CONFIG_INSTALL, "Main");
|
|
const int type = config.get_int("Type");
|
|
if (type == 2)
|
|
{
|
|
const TFilename study = config.get("Study");
|
|
if (xvt_fsys_is_fixed_drive(study))
|
|
i_am_server = true;
|
|
}
|
|
return i_am_server;
|
|
}
|
|
|
|
|
|
void THardy_transaction::main_loop()
|
|
{
|
|
TMask* mask = create_mask();
|
|
|
|
//sono il server?
|
|
bool i_am_server = is_server();
|
|
|
|
TFilename trans = argv(2);
|
|
if (trans.starts_with("/i") || trans.starts_with("-i"))
|
|
{
|
|
//se sono il server eseguo subito l'elaborazione
|
|
if (i_am_server)
|
|
{
|
|
//legge i files da trasferire
|
|
trans.ltrim(2);
|
|
TConfig ini(trans, fake_trans_file());
|
|
FOR_EACH_MASK_FIELD(*mask, i, f)
|
|
{
|
|
const TFieldref* field = f->field();
|
|
if (field != NULL)
|
|
{
|
|
const char* val = field->read(ini, fake_trans_file());
|
|
if (val && *val)
|
|
{
|
|
f->set(val);
|
|
f->on_hit();
|
|
}
|
|
}
|
|
}
|
|
if (ini.get("Mode", "Transaction")[0] == 'A')
|
|
{
|
|
elabora(*mask);
|
|
delete mask;
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
error_box(TR("Le transazioni possono essere eseguite solo dal server!"));
|
|
}
|
|
|
|
while (mask->run() == K_ENTER)
|
|
{
|
|
//se è il server -> esegue le operazioni di elaborazione
|
|
if (i_am_server)
|
|
elabora(*mask);
|
|
else //senno' prepara il .ini per l'elaborazione postinica
|
|
{
|
|
TFilename lista_files = _trans_path;
|
|
lista_files.add(name());
|
|
lista_files.ext("ini");
|
|
TConfig ini(lista_files, "Transaction");
|
|
ini.set("Action", "RUN");
|
|
ini.set("Mode", "AUTO");
|
|
ini.set_paragraph(fake_trans_file());
|
|
FOR_EACH_MASK_FIELD(*mask, i, f)
|
|
{
|
|
const TFieldref* field = f->field();
|
|
if (field != NULL && f->active())
|
|
field->write(ini, fake_trans_file(), f->get());
|
|
}
|
|
message_box(TR("Transazione di scarico inviata al server"));
|
|
}
|
|
}
|
|
delete mask;
|
|
}
|
|
|
|
|
|
bool THardy_transaction::create()
|
|
{
|
|
TConfig config(CONFIG_DITTA, "ha");
|
|
_output_path = config.get("OutputPath");
|
|
_input_path = config.get("InputPath");
|
|
_archive_path = config.get("ArchivePath");
|
|
_conc_path = config.get("ConcentratorePath");
|
|
_trans_path = config.get("TransactionPath");
|
|
|
|
if (!_output_path.exist())
|
|
return error_box(FR("Non esiste la cartella di destinazione %s!"), (const char*)_output_path);
|
|
|
|
if (!_input_path.exist())
|
|
return error_box(FR("Non esiste la cartella di upload %s!"), (const char*)_input_path);
|
|
|
|
if (!_archive_path.exist())
|
|
return error_box(FR("Non esiste la cartella di archiviazione dei files processati &s!"), (const char*)_archive_path);
|
|
|
|
if (!_conc_path.exist())
|
|
return error_box(FR("Non esiste la cartella del concentratore %s!"), (const char*)_conc_path);
|
|
|
|
TFilename conc_prog_path = _conc_path;
|
|
conc_prog_path.add("ProgettoConcentratore.exe");
|
|
if (!conc_prog_path.exist())
|
|
return error_box(FR("Il programma concentratore non si trova nella cartella %s!"), _conc_path);
|
|
|
|
if (!_trans_path.exist())
|
|
return error_box(FR("Non esiste la cartella di transazione %s!"), (const char*)_trans_path);
|
|
|
|
return TSkeleton_application::create();
|
|
} |