Patch level :
Files correlati :ha1.exe Ricompilazione Demo : [ ] Commento : Migliorata generazione del file di carico.txt in modo append git-svn-id: svn://10.65.10.50/branches/R_10_00@22453 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
37b49c465c
commit
37f9d93ce5
@ -2,6 +2,7 @@
|
||||
#include <automask.h>
|
||||
#include <execp.h>
|
||||
#include <progind.h>
|
||||
#include <utility.h>
|
||||
|
||||
#include <comuni.h>
|
||||
#include <scadenze.h>
|
||||
@ -88,30 +89,79 @@ protected:
|
||||
|
||||
void fill_anagrafica_cliente(const TISAM_recordset& archivio_clienti,
|
||||
TEsporta_clienti_recordset& clienti, const bool is_fatt = false);
|
||||
|
||||
bool genera_nomi_output(const char* nome, TFilename& txt, TFilename& tmp) const;
|
||||
bool salva_recordset(TRecordset& recset, const char* nome) const;
|
||||
bool accoda_recordset(TRecordset& recset, const char* nome) const;
|
||||
public:
|
||||
};
|
||||
|
||||
bool TFile2Txt::genera_nomi_output(const char* nome, TFilename& txt, TFilename& tmp) const
|
||||
{
|
||||
txt = _output_path;
|
||||
txt.add(nome);
|
||||
txt.ext("txt");
|
||||
txt.lower();
|
||||
|
||||
tmp = txt;
|
||||
tmp.ext("tmp");
|
||||
|
||||
return txt.exist();
|
||||
}
|
||||
|
||||
|
||||
bool TFile2Txt::salva_recordset(TRecordset& recset, const char* nome) const
|
||||
{
|
||||
TFilename output_path;
|
||||
output_path = _output_path;
|
||||
output_path.add(nome);
|
||||
output_path.ext(".tmp");
|
||||
output_path.lower();
|
||||
bool ok = recset.save_as(output_path, fmt_text);
|
||||
TFilename txt_path, tmp_path;
|
||||
genera_nomi_output(nome, txt_path, tmp_path);
|
||||
const bool ok = recset.save_as(tmp_path, fmt_text);
|
||||
if (ok)
|
||||
{
|
||||
TFilename txt_path = output_path;
|
||||
txt_path.ext("txt");
|
||||
txt_path.fremove(); // Cancello nome.txt (potrebbe esistere)
|
||||
::rename(output_path, txt_path); // rinomino nome.tmp in nome.txt
|
||||
txt_path.fremove(); // Cancello nome.txt (potrebbe esistere)
|
||||
::rename(tmp_path, txt_path); // rinomino nome.tmp in nome.txt
|
||||
}
|
||||
else
|
||||
cantwrite_box(output_path);
|
||||
cantwrite_box(tmp_path);
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TFile2Txt::accoda_recordset(TRecordset& recset, const char* nome) const
|
||||
{
|
||||
TFilename txt_path, tmp_path;
|
||||
const bool append = genera_nomi_output(nome, txt_path, tmp_path);
|
||||
bool ok = true;
|
||||
|
||||
if (append)
|
||||
{
|
||||
// Rinomino il file di destinazione per evitare interferenze dal concentratore
|
||||
::rename(txt_path, tmp_path);
|
||||
|
||||
TFilename local_path;
|
||||
local_path.tempdir();
|
||||
local_path.add(nome);
|
||||
local_path.ext(".txt");
|
||||
local_path.lower();
|
||||
ok = recset.save_as(local_path, fmt_text);
|
||||
if (ok)
|
||||
{
|
||||
ok = ::fcopy(local_path, tmp_path, true, false);
|
||||
if (!ok)
|
||||
cantwrite_box(tmp_path);
|
||||
local_path.fremove();
|
||||
}
|
||||
else
|
||||
cantwrite_box(local_path);
|
||||
|
||||
// Ripristino il nome del file di destinazione
|
||||
::rename(tmp_path, txt_path);
|
||||
}
|
||||
else
|
||||
ok = salva_recordset(recset, nome);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
bool TFile2Txt::genera_agenti_txt()
|
||||
{
|
||||
//AS400 recordset da riempire (da lui nascerà il .txt)
|
||||
@ -776,7 +826,7 @@ bool TFile2Txt::genera_carico_txt(const TMask& mask)
|
||||
carico.set("CodiceLotto", archivio_rdoc.get(RDOC_LIVELLO));
|
||||
}
|
||||
|
||||
return salva_recordset(carico, "carico");
|
||||
return accoda_recordset(carico, "carico");
|
||||
}
|
||||
|
||||
bool TFile2Txt::genera_ripristino_txt(const TMask& mask)
|
||||
|
@ -1490,6 +1490,6 @@ const char* TUpload2Campo::fake_trans_file() const
|
||||
int ha1300(int argc, char* argv[])
|
||||
{
|
||||
TUpload2Campo a;
|
||||
a.run(argc, argv, "Importazione dati da file");
|
||||
a.run(argc, argv, TR("Importazione dati da file"));
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user