Patch level :10.0
Files correlati : Ricompilazione Demo : [ ] Commento : prima implementazione del programma per il cliente commercialista di Sicuri git-svn-id: svn://10.65.10.50/trunk@20228 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
2b2e0c54fe
commit
f4b7e6acd0
15
ps/pg0067.cpp
Executable file
15
ps/pg0067.cpp
Executable file
@ -0,0 +1,15 @@
|
||||
#include <xvt.h>
|
||||
|
||||
#include "pg0067.h"
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
const int r = (argc > 1) ? argv[1][1]-'0' : -1;
|
||||
|
||||
switch (r)
|
||||
{
|
||||
case 0: pg0067100(argc, argv); break; // distributore di F24 bancari
|
||||
default: break;
|
||||
}
|
||||
return 0;
|
||||
}
|
1
ps/pg0067.h
Executable file
1
ps/pg0067.h
Executable file
@ -0,0 +1 @@
|
||||
int pg0067100(int, char**);
|
182
ps/pg0067100.cpp
Executable file
182
ps/pg0067100.cpp
Executable file
@ -0,0 +1,182 @@
|
||||
#include <applicat.h>
|
||||
#include <automask.h>
|
||||
#include <modaut.h>
|
||||
#include <progind.h>
|
||||
#include <reputils.h>
|
||||
#include <utility.h>
|
||||
|
||||
#include "pg0067100a.h"
|
||||
|
||||
|
||||
///////////////////////////////////////////////
|
||||
// MASCHERA
|
||||
///////////////////////////////////////////////
|
||||
class TDistribuzione_f24_mask : public TAutomask
|
||||
{
|
||||
protected:
|
||||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||
public:
|
||||
TDistribuzione_f24_mask();
|
||||
};
|
||||
|
||||
TDistribuzione_f24_mask::TDistribuzione_f24_mask() : TAutomask("pg0067100a")
|
||||
{
|
||||
}
|
||||
|
||||
bool TDistribuzione_f24_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||
{
|
||||
/*switch(o.dlg())
|
||||
{
|
||||
default:
|
||||
break;
|
||||
}*/
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////
|
||||
// APPLICAZIONE
|
||||
/////////////////////////////////////////////
|
||||
//Ridistributore di F24 per il computer
|
||||
class TDistribuzione_f24 : public TSkeleton_application
|
||||
{
|
||||
TDistribuzione_f24_mask* _mask;
|
||||
|
||||
virtual bool check_autorization() const {return false;}
|
||||
|
||||
protected:
|
||||
virtual const char * extra_modules() const {return "cg";}
|
||||
virtual bool create();
|
||||
|
||||
void elabora();
|
||||
|
||||
public:
|
||||
virtual void main_loop();
|
||||
};
|
||||
|
||||
void TDistribuzione_f24::elabora()
|
||||
{
|
||||
TFilename src_files = _mask->get(F_PATH_SRC);
|
||||
src_files.add("*.pdf");
|
||||
TString_array src_files_list;
|
||||
//dalla cartella origine prende tutti i files .pdf e crea una simpatica lista
|
||||
const int n_files_pdf = list_files(src_files, src_files_list);
|
||||
|
||||
const TString& dst_root_path = _mask->get(F_PATH_DST);
|
||||
const bool delete_src_files = _mask->get_bool(F_ERASE_TRANSFERRED);
|
||||
|
||||
//scansione dello string_array per il trasferimento (con tanto di progind e log)
|
||||
TProgind pi(n_files_pdf, TR("Trasferimento F24 in corso..."), true, true);
|
||||
TLog_report log("ERRORI DI TRASFERIMENTO");
|
||||
|
||||
TToken_string curr_tok_file(_MAX_PATH, '_');
|
||||
|
||||
for (int i = 0; i < n_files_pdf; i++)
|
||||
{
|
||||
if (!pi.addstatus(1))
|
||||
break;
|
||||
|
||||
//file in formato filename e token_string (per prendere i pezzi)
|
||||
const TFilename curr_fname = src_files_list.row(i);
|
||||
curr_tok_file = curr_fname.name_only();
|
||||
|
||||
//anno e relativo controllo
|
||||
const int anno = curr_tok_file.get_int(0);
|
||||
if (anno < 2000)
|
||||
{
|
||||
TString msg;
|
||||
msg.format("File %s ha ANNO errato", (const char*)curr_tok_file);
|
||||
log.log(1, msg);
|
||||
continue;
|
||||
}
|
||||
|
||||
//piva e relativo controllo
|
||||
const TString16 piva = curr_tok_file.get(3);
|
||||
if (piva.len() < 11)
|
||||
{
|
||||
TString msg;
|
||||
msg.format("File %s ha P.IVA o C.F. errato", (const char*)curr_tok_file);
|
||||
log.log(1, msg);
|
||||
continue;
|
||||
}
|
||||
|
||||
//controllo della cartella di destinazione
|
||||
TFilename dst_file = dst_root_path;
|
||||
dst_file.add(piva);
|
||||
TString4 str_anno;
|
||||
str_anno << anno;
|
||||
dst_file.add(str_anno);
|
||||
const bool crea_dir = make_dir(dst_file);
|
||||
//non riesce a crearla! deve dare errore di grave livello!
|
||||
if (!crea_dir)
|
||||
{
|
||||
TString msg;
|
||||
msg.format("Impossibile creare la cartella %s !", dst_file);
|
||||
log.log(2, msg);
|
||||
continue;
|
||||
}
|
||||
|
||||
//se invece crea/trova la cartella -> copia il file
|
||||
dst_file.add(curr_fname.name());
|
||||
|
||||
const bool copia_riuscita = fcopy(curr_fname, dst_file);
|
||||
if (!copia_riuscita)
|
||||
{
|
||||
TString msg;
|
||||
msg.format("Impossibile copiare il file %s !", curr_fname.name());
|
||||
log.log(2, msg);
|
||||
continue;
|
||||
}
|
||||
|
||||
//controllo dell'avvenuta copia e della correttezza del file destinazione
|
||||
//controllo sulle dimensioni
|
||||
const long src_size = fsize(curr_fname);
|
||||
const long dst_size = fsize(dst_file);
|
||||
|
||||
if (src_size != dst_size)
|
||||
{
|
||||
TString msg;
|
||||
msg.format("Copia del file %s non completata !", curr_fname.name());
|
||||
log.log(2, msg);
|
||||
continue;
|
||||
}
|
||||
|
||||
//eliminazione del file sorgente
|
||||
if (delete_src_files)
|
||||
{
|
||||
const bool src_file_removed = remove_file(curr_fname);
|
||||
if (!src_file_removed)
|
||||
{
|
||||
TString msg;
|
||||
msg.format("Impossibile eliminare il file origine %s ", curr_fname.name());
|
||||
log.log(1, msg);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool TDistribuzione_f24::create()
|
||||
{
|
||||
//se non ha la CG non può proseguire
|
||||
if (!has_module(CGAUT))
|
||||
return error_box(TR("Modulo non autorizzato"));
|
||||
|
||||
return TSkeleton_application::create();
|
||||
}
|
||||
|
||||
void TDistribuzione_f24::main_loop()
|
||||
{
|
||||
_mask = new TDistribuzione_f24_mask;
|
||||
if (_mask->run() != K_QUIT)
|
||||
elabora();
|
||||
delete _mask;
|
||||
_mask = NULL;
|
||||
}
|
||||
|
||||
int pg0067100 (int argc, char **argv)
|
||||
{
|
||||
TDistribuzione_f24 a;
|
||||
a.run(argc,argv, TR("Spostamento F24"));
|
||||
return true;
|
||||
}
|
3
ps/pg0067100a.h
Executable file
3
ps/pg0067100a.h
Executable file
@ -0,0 +1,3 @@
|
||||
#define F_PATH_SRC 101
|
||||
#define F_PATH_DST 102
|
||||
#define F_ERASE_TRANSFERRED 103
|
40
ps/pg0067100a.uml
Executable file
40
ps/pg0067100a.uml
Executable file
@ -0,0 +1,40 @@
|
||||
#include "pg0067100a.h"
|
||||
|
||||
PAGE "Trasferimento F24" -1 -1 78 6
|
||||
|
||||
STRING F_PATH_SRC 255 45
|
||||
BEGIN
|
||||
PROMPT 1 1 "Cartella di origine "
|
||||
DSELECT
|
||||
FLAGS "M"
|
||||
CHECKTYPE REQUIRED
|
||||
WARNING "Selezionare una cartella valida!"
|
||||
END
|
||||
|
||||
STRING F_PATH_DST 255 45
|
||||
BEGIN
|
||||
PROMPT 1 2 "Cartella di destinazione "
|
||||
DSELECT
|
||||
FLAGS "M"
|
||||
CHECKTYPE REQUIRED
|
||||
WARNING "Selezionare una cartella valida!"
|
||||
END
|
||||
|
||||
BOOLEAN F_ERASE_TRANSFERRED
|
||||
BEGIN
|
||||
PROMPT 1 4 "Eliminare i file di origine dopo la copia"
|
||||
END
|
||||
|
||||
STRING DLG_PROFILE 50
|
||||
BEGIN
|
||||
PROMPT 1 -1 "Profilo "
|
||||
PSELECT
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
TOOLBAR "" 0 0 0 2
|
||||
#include <elabar.h>
|
||||
ENDPAGE
|
||||
|
||||
ENDMASK
|
Loading…
x
Reference in New Issue
Block a user