Patch level :
Files correlati : Ricompilazione Demo : [ ] Commento : git-svn-id: svn://10.65.10.50/branches/R_10_00@22235 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
3c245f68d4
commit
1d5b4c0a42
@ -69,7 +69,7 @@ class TFile2Txt : public THardy_transaction
|
||||
{
|
||||
|
||||
protected:
|
||||
virtual void elabora(const TMask& mask);
|
||||
virtual void elabora(const TMask& mask, TLog_report& log);
|
||||
virtual TMask* create_mask() const;
|
||||
virtual const char* fake_trans_file() const;
|
||||
|
||||
@ -854,7 +854,7 @@ bool TFile2Txt::genera_ripristino_txt(const TMask& mask)
|
||||
}
|
||||
|
||||
//metodo di alto livello per la gestione delle chiamate
|
||||
void TFile2Txt::elabora(const TMask& mask)
|
||||
void TFile2Txt::elabora(const TMask& mask, TLog_report& log)
|
||||
{
|
||||
// a) stoppa il concentratore
|
||||
chiudi_concentratore();
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <automask.h>
|
||||
#include <config.h>
|
||||
#include <execp.h>
|
||||
#include <progind.h>
|
||||
#include <relation.h>
|
||||
#include <utility.h>
|
||||
|
||||
@ -27,6 +28,33 @@ bool THardy_transaction::is_by_postino() const
|
||||
return (trans.starts_with("/i") || trans.starts_with("-i"));
|
||||
}
|
||||
|
||||
bool THardy_transaction::wait_for_file(const TFilename& filename) const
|
||||
{
|
||||
TString msg;
|
||||
msg << TR("In attesa del file ") << filename;
|
||||
const int time_to_wait = 60;
|
||||
|
||||
TProgind pi(time_to_wait, msg, true, true);
|
||||
|
||||
long last_size = 0L;
|
||||
for (int s = 0; s < 60; s++)
|
||||
{
|
||||
if (!pi.addstatus(1))
|
||||
break;
|
||||
|
||||
xvt_sys_sleep(3000);
|
||||
long size = fsize(filename);
|
||||
if (size == last_size && size > 0)
|
||||
break;
|
||||
last_size = size;
|
||||
}
|
||||
|
||||
if (last_size == 0L && !is_by_postino())
|
||||
return cantread_box(filename);
|
||||
|
||||
return last_size > 0L;
|
||||
}
|
||||
|
||||
void THardy_transaction::chiudi_concentratore()
|
||||
{
|
||||
TFilename bat_chiudi = _conc_path;
|
||||
@ -58,21 +86,7 @@ bool THardy_transaction::scarica_concentratore()
|
||||
TFilename upload = _input_path;
|
||||
upload.add("upload.d");
|
||||
//se trova il file upload.d comincia a fare i test
|
||||
|
||||
long last_size = 0L;
|
||||
for (int s = 0; s < 60; s++)
|
||||
{
|
||||
xvt_sys_sleep(3000);
|
||||
long size = fsize(upload);
|
||||
if (size == last_size && size > 0)
|
||||
break;
|
||||
last_size = size;
|
||||
}
|
||||
|
||||
if (last_size == 0L)
|
||||
return cantread_box(upload);
|
||||
|
||||
return true;
|
||||
return wait_for_file(upload);
|
||||
}
|
||||
|
||||
void THardy_transaction::trasmetti_concentratore()
|
||||
@ -87,6 +101,9 @@ void THardy_transaction::trasmetti_concentratore()
|
||||
void THardy_transaction::main_loop()
|
||||
{
|
||||
TMask* mask = create_mask();
|
||||
TLog_report log(title());
|
||||
log.kill_duplicates();
|
||||
log.log(0, "");
|
||||
|
||||
//sono il server?
|
||||
bool i_am_server = is_server();
|
||||
@ -116,7 +133,12 @@ void THardy_transaction::main_loop()
|
||||
}
|
||||
if (ini.get("Mode", "Transaction")[0] == 'A')
|
||||
{
|
||||
elabora(*mask);
|
||||
elabora(*mask, log);
|
||||
|
||||
//sono il server ma via postino; viene salvato il log in formato txt
|
||||
trans.ext("txt");
|
||||
log.save(trans);
|
||||
|
||||
delete mask;
|
||||
return;
|
||||
}
|
||||
@ -128,15 +150,19 @@ void THardy_transaction::main_loop()
|
||||
{
|
||||
while (mask->run() == K_ENTER)
|
||||
{
|
||||
//se è il server -> esegue le operazioni di elaborazione
|
||||
//se è il server -> esegue le operazioni di elaborazione, viene fatta la preview diretta del log
|
||||
if (i_am_server)
|
||||
elabora(*mask);
|
||||
{
|
||||
log.reset();
|
||||
elabora(*mask, log);
|
||||
log.preview();
|
||||
}
|
||||
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");
|
||||
TFilename trans = _trans_path;
|
||||
trans.add(name());
|
||||
trans.ext("ini");
|
||||
TConfig ini(trans, "Transaction");
|
||||
ini.set("Action", "RUN");
|
||||
ini.set("Mode", "AUTO");
|
||||
ini.set_paragraph(fake_trans_file());
|
||||
@ -147,6 +173,16 @@ void THardy_transaction::main_loop()
|
||||
field->write(ini, fake_trans_file(), f->get());
|
||||
}
|
||||
message_box(TR("Transazione di scarico inviata al server"));
|
||||
//client in interattivo: gli viene spedito il log via file txt e fatta la preview cosi' che l'utente..
|
||||
//..lo possa vedere
|
||||
trans.ext("txt");
|
||||
if (wait_for_file(trans))
|
||||
{
|
||||
TScanner f(trans);
|
||||
log.recordset()->read_from(f);
|
||||
log.preview();
|
||||
trans.fremove();
|
||||
}
|
||||
}
|
||||
}
|
||||
} //if(by_postino(...
|
||||
@ -179,7 +215,7 @@ bool THardy_transaction::create()
|
||||
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);
|
||||
return error_box(FR("Il programma concentratore non si trova nella cartella %s!"), (const char*)_conc_path);
|
||||
|
||||
if (!_trans_path.exist())
|
||||
return error_box(FR("Non esiste la cartella di transazione %s!"), (const char*)_trans_path);
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <applicat.h>
|
||||
#include <mask.h>
|
||||
#include <reputils.h>
|
||||
|
||||
class THardy_transaction : public TSkeleton_application
|
||||
{
|
||||
@ -7,11 +8,12 @@ protected:
|
||||
TFilename _output_path, _input_path, _archive_path, _conc_path, _trans_path;
|
||||
|
||||
protected:
|
||||
virtual void elabora(const TMask& mask) pure;
|
||||
virtual void elabora(const TMask& mask, TLog_report& log) pure;
|
||||
virtual TMask* create_mask() const pure;
|
||||
bool is_server() const;
|
||||
bool is_by_postino() const;
|
||||
virtual const char* fake_trans_file() const pure;
|
||||
bool wait_for_file(const TFilename& filename) const;
|
||||
void chiudi_concentratore();
|
||||
void carica_concentratore();
|
||||
bool scarica_concentratore();
|
||||
|
@ -285,7 +285,7 @@ class TUpload2Campo : public THardy_transaction
|
||||
TAssoc_array _nuovi_clienti;
|
||||
|
||||
protected:
|
||||
virtual void elabora(const TMask& mask);
|
||||
virtual void elabora(const TMask& mask, TLog_report& log);
|
||||
virtual TMask* create_mask() const;
|
||||
const char* fake_trans_file() const;
|
||||
|
||||
@ -1315,7 +1315,7 @@ void TUpload2Campo::elabora_RC(THardy_upload_recordset& recset, TLog_report& log
|
||||
|
||||
|
||||
|
||||
void TUpload2Campo::elabora(const TMask& mask)
|
||||
void TUpload2Campo::elabora(const TMask& mask, TLog_report& log)
|
||||
{
|
||||
// a) stoppa il concentratore
|
||||
chiudi_concentratore();
|
||||
@ -1338,9 +1338,6 @@ void TUpload2Campo::elabora(const TMask& mask)
|
||||
const int n_files_d = list_files(src_files, src_files_list);
|
||||
|
||||
TProgind pi(n_files_d, TR("Acquisizione files in corso..."), true, true);
|
||||
TLog_report log("Segnalazioni su acquisizione");
|
||||
log.kill_duplicates();
|
||||
log.log(0, "");
|
||||
|
||||
//scandisce i files uno ad uno
|
||||
for (int i = 0; i < n_files_d; i++)
|
||||
@ -1444,10 +1441,6 @@ void TUpload2Campo::elabora(const TMask& mask)
|
||||
|
||||
} //for (int i = 0; i < n_files_d;... (giro su tutti i files tipo upload*.d)
|
||||
|
||||
//solo in interattivo e sul server si puo' vedere il log
|
||||
if (!is_by_postino())
|
||||
log.preview();
|
||||
|
||||
} //if (carica)
|
||||
}
|
||||
|
||||
|
@ -1,34 +1,37 @@
|
||||
#include "ha1300a.h"
|
||||
|
||||
PAGE "Importazione dati da file upload" -1 -1 78 7
|
||||
PAGE "Importazione dati da file upload" -1 -1 78 9
|
||||
|
||||
STRING F_INPUT_PATH 256 45
|
||||
STRING F_INPUT_PATH 256 46
|
||||
BEGIN
|
||||
PROMPT 1 1 "Cartella file da importare "
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
STRING F_ARCHIVE_PATH 256 45
|
||||
STRING F_ARCHIVE_PATH 256 46
|
||||
BEGIN
|
||||
PROMPT 1 2 "Cartella di archiviazione "
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
STRING F_CONC_PATH 256 45
|
||||
STRING F_CONC_PATH 256 46
|
||||
BEGIN
|
||||
PROMPT 1 3 "Cartella concentratore "
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
STRING F_TRANS_PATH 256 45
|
||||
STRING F_TRANS_PATH 256 46
|
||||
BEGIN
|
||||
PROMPT 1 4 "Cartella file transazione "
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
BOOLEAN F_DEFINITIVO
|
||||
RADIOBUTTON F_DEFINITIVO 73
|
||||
BEGIN
|
||||
PROMPT 1 6 "Elaborazione definitiva (scrittura sul database)"
|
||||
PROMPT 1 6 "Tipo elaborazione"
|
||||
ITEM "0|Di prova (simulazione)"
|
||||
ITEM "1|Definitiva (scrittura sul database)"
|
||||
FLAGS "Z"
|
||||
FIELD Definitiva
|
||||
END
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user