Patch level : 10.0 1154
Files correlati : fe0.exe fe0300a.msk Ricompilazione Demo : [ ] Commento : Prima versione del programma per sommare più file spesometro git-svn-id: svn://10.65.10.50/branches/R_10_00@22493 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
dc3092d224
commit
0bc5bd8846
165
fe/fe0300.cpp
165
fe/fe0300.cpp
@ -1,6 +1,8 @@
|
||||
#include <applicat.h>
|
||||
#include <automask.h>
|
||||
#include <utility.h>
|
||||
|
||||
#include "felib.h"
|
||||
#include "fe0100a.h"
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -11,21 +13,180 @@ class TSomma_spesometro_msk : public TAutomask
|
||||
{
|
||||
protected:
|
||||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||
void elabora(const TString_array& a, const TFilename& n) const;
|
||||
|
||||
bool str2fname(const TString& name, TFilename& n) const;
|
||||
bool row2fname(const TToken_string& row, TFilename& n) const;
|
||||
void enable_buttons();
|
||||
|
||||
public:
|
||||
TSomma_spesometro_msk() : TAutomask("fe0300a") { load_profile(); }
|
||||
~TSomma_spesometro_msk() { save_profile(); }
|
||||
};
|
||||
|
||||
bool TSomma_spesometro_msk::str2fname(const TString& name, TFilename& n) const
|
||||
{
|
||||
if (name.blank() || name.len() < 4)
|
||||
return false;
|
||||
|
||||
if (name.full() && name[1] != ':')
|
||||
{
|
||||
n = get(F_OUTFOLDER);
|
||||
n.add(name);
|
||||
}
|
||||
else
|
||||
n = name;
|
||||
n.replace('/', '\\');
|
||||
return n.exist();
|
||||
}
|
||||
|
||||
bool TSomma_spesometro_msk::row2fname(const TToken_string& row, TFilename& n) const
|
||||
{
|
||||
TString80 name; row.get(0, name);
|
||||
return str2fname(name, n);
|
||||
}
|
||||
|
||||
void TSomma_spesometro_msk::elabora(const TString_array& infiles, const TFilename& outfile) const
|
||||
{
|
||||
int anno = 2010;
|
||||
|
||||
TFilename n;
|
||||
if (row2fname(infiles.row(0), n))
|
||||
{
|
||||
const TDati_rilevanti_set s(n);
|
||||
anno = s.anno();
|
||||
}
|
||||
|
||||
TDati_rilevanti_set outset(anno);
|
||||
outset.add_header(*this);
|
||||
|
||||
FOR_EACH_ARRAY_ROW(infiles, r, row) if (row2fname(*row, n))
|
||||
{
|
||||
const int len = outset.record_length();
|
||||
ifstream s(n, ios::binary);
|
||||
TString row(len);
|
||||
while (!s.eof())
|
||||
{
|
||||
s.read(row.get_buffer(), len);
|
||||
if (row[0] != '0' && row[0] != '9')
|
||||
outset.new_rec(row);
|
||||
}
|
||||
}
|
||||
|
||||
outset.add_footer();
|
||||
outset.sort();
|
||||
outset.save_as(outfile);
|
||||
|
||||
if (outset.items() > 15000)
|
||||
{
|
||||
outset.split(outfile);
|
||||
const int n = (outset.items()-1) / 15000 + 1;
|
||||
warning_box(FR("E' stato generato il file %s, separato in %d parti da 15000 record."), (const char*)outfile, n);
|
||||
}
|
||||
else
|
||||
message_box(FR("E' stato generato il file %s"), (const char*)outfile);
|
||||
|
||||
TDati_rilevanti_rep rep(outfile);
|
||||
rep.preview();
|
||||
}
|
||||
|
||||
void TSomma_spesometro_msk::enable_buttons()
|
||||
{
|
||||
const TSheet_field& righe = sfield(F_RIGHE);
|
||||
enable(DLG_ELABORA, !righe.empty());
|
||||
|
||||
TFilename n;
|
||||
enable(DLG_PREVIEW, str2fname(get(F_OUTFILE), n));
|
||||
}
|
||||
|
||||
bool TSomma_spesometro_msk::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||
{
|
||||
switch (o.dlg())
|
||||
{
|
||||
case F_OUTFOLDER:
|
||||
if (e == fe_init || e == fe_modify)
|
||||
case DLG_ELABORA:
|
||||
if (e == fe_button && check_fields())
|
||||
{
|
||||
TFilename n;
|
||||
str2fname(get(F_OUTFILE), n);
|
||||
TSheet_field& righe = sfield(F_RIGHE);
|
||||
TString_array& a = righe.rows_array();
|
||||
if (!a.empty() && n.full())
|
||||
{
|
||||
elabora(a, n);
|
||||
enable_buttons();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DLG_USER:
|
||||
if (e == fe_button)
|
||||
{
|
||||
TFilename fn;
|
||||
if (str2fname(o.mask().get(101), fn))
|
||||
{
|
||||
TDati_rilevanti_rep rep(fn);
|
||||
rep.preview();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DLG_PREVIEW:
|
||||
if (e == fe_button)
|
||||
{
|
||||
TFilename fn;
|
||||
if (str2fname(get(F_OUTFILE), fn))
|
||||
{
|
||||
TDati_rilevanti_rep rep(fn);
|
||||
rep.preview();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case F_OUTFOLDER:
|
||||
if ((e == fe_init || e == fe_modify) && !o.empty())
|
||||
{
|
||||
TSheet_field& righe = sfield(F_RIGHE);
|
||||
TFilename dir = o.get(); dir.add("Spe*.txt");
|
||||
TString_array& a = righe.rows_array();
|
||||
a.destroy();
|
||||
list_files(dir, a);
|
||||
TFilename fn;
|
||||
FOR_EACH_ARRAY_ROW(a, r, row)
|
||||
{
|
||||
fn = row->get(0);
|
||||
*row = fn.name();
|
||||
row->add(fsize(fn) / 1800);
|
||||
const time_t t = xvt_fsys_file_attr(fn, XVT_FILE_ATTR_MTIME);
|
||||
if (t > 0)
|
||||
{
|
||||
const struct tm& lt = *localtime(&t);
|
||||
const TDate d(lt.tm_mday, lt.tm_mon, 1900+lt.tm_year);
|
||||
row->add(d);
|
||||
TString8 ora; ora.format("%02d:%02d:%02d", lt.tm_hour, lt.tm_min, lt.tm_sec);
|
||||
row->add(ora);
|
||||
}
|
||||
}
|
||||
|
||||
// Elimina dalla lista il file di output
|
||||
if (str2fname(get(F_OUTFILE), fn))
|
||||
{
|
||||
TFilename fr;
|
||||
FOR_EACH_ARRAY_ROW(a, r, row)
|
||||
{
|
||||
row2fname(*row, fr);
|
||||
if (fr.compare(fn, -1, true) == 0)
|
||||
{
|
||||
a.destroy(r, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
righe.force_update();
|
||||
enable_buttons();
|
||||
}
|
||||
break;
|
||||
case F_RIGHE:
|
||||
if (e == se_query_add || e == se_query_del)
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
116
fe/fe0300a.uml
116
fe/fe0300a.uml
@ -2,55 +2,32 @@
|
||||
|
||||
TOOLBAR "topbar" 0 0 0 2
|
||||
|
||||
BUTTON DLG_OK 2 2
|
||||
BUTTON DLG_ELABORA 2 2
|
||||
BEGIN
|
||||
PROMPT 1 1 "Elabora"
|
||||
PICTURE TOOL_ELABORA
|
||||
END
|
||||
|
||||
BUTTON DLG_PREVIEW 10 2
|
||||
BEGIN
|
||||
PROMPT 1 2 "Anteprima"
|
||||
PICTURE TOOL_PREVIEW
|
||||
END
|
||||
|
||||
#include <helpbar.h>
|
||||
|
||||
ENDPAGE
|
||||
|
||||
PAGE "Somma file spesometro" 0 2 0 0
|
||||
|
||||
GROUPBOX DLG_NULL 78 4
|
||||
BEGIN
|
||||
PROMPT 1 1 "@bParametri di elaborazione "
|
||||
END
|
||||
|
||||
STRING F_OUTFOLDER 255 50
|
||||
BEGIN
|
||||
PROMPT 2 2 "Cartella "
|
||||
DSELECT
|
||||
CHECKTYPE REQUIRED
|
||||
WARNING "Specificare una cartella di destinazione valida"
|
||||
END
|
||||
|
||||
STRING F_OUTFILE 255 50
|
||||
BEGIN
|
||||
PROMPT 2 3 "File "
|
||||
FSELECT "*.txt"
|
||||
CHECKTYPE REQUIRED
|
||||
WARNING "Specificare un file di destinazione valido"
|
||||
END
|
||||
|
||||
TREELIST F_RIGHE 78 10
|
||||
BEGIN
|
||||
PROMPT 1 5 ""
|
||||
DISPLAY "Nome@50" NAME
|
||||
DISPLAY "Dimensioni" SIZE
|
||||
DISPLAY "Data@10" DATE
|
||||
END
|
||||
|
||||
GROUPBOX DLG_NULL 78 6
|
||||
BEGIN
|
||||
PROMPT 1 16 "@bDati del soggetto che assume l'impegno alla presentazione telematica"
|
||||
PROMPT 1 0 "@bDati del soggetto che assume l'impegno alla presentazione telematica"
|
||||
END
|
||||
|
||||
LIST F_INTER_COM 1 20
|
||||
BEGIN
|
||||
PROMPT 2 17 "Comunicazione predisposta da "
|
||||
PROMPT 2 1 "Comunicazione predisposta da "
|
||||
ITEM "|"
|
||||
ITEM "1|contribuente"
|
||||
ITEM "2|chi effettua l'invio"
|
||||
@ -58,21 +35,90 @@ END
|
||||
|
||||
STRING F_INTER_COFI 16
|
||||
BEGIN
|
||||
PROMPT 2 18 "Codice fiscale dell'intermediario "
|
||||
PROMPT 2 2 "Codice fiscale dell'intermediario "
|
||||
FLAGS "U"
|
||||
VALIDATE CF_FUNC 1 F_INTER_COFI
|
||||
END
|
||||
|
||||
NUMBER F_INTER_CAF 5
|
||||
BEGIN
|
||||
PROMPT 2 19 "Numero iscrizione all'albo C.A.F. "
|
||||
PROMPT 2 3 "Numero iscrizione all'albo C.A.F. "
|
||||
END
|
||||
|
||||
DATE F_INTER_DATE
|
||||
BEGIN
|
||||
PROMPT 2 20 "Data dell'impegno alla trasmissione "
|
||||
PROMPT 2 4 "Data dell'impegno alla trasmissione "
|
||||
END
|
||||
|
||||
GROUPBOX DLG_NULL 78 4
|
||||
BEGIN
|
||||
PROMPT 1 6 "@bParametri di elaborazione "
|
||||
END
|
||||
|
||||
STRING F_OUTFOLDER 255 62
|
||||
BEGIN
|
||||
PROMPT 2 7 "Cartella "
|
||||
DSELECT
|
||||
CHECKTYPE REQUIRED
|
||||
WARNING "Specificare una cartella di destinazione valida"
|
||||
END
|
||||
|
||||
STRING F_OUTFILE 255 62
|
||||
BEGIN
|
||||
PROMPT 2 8 "File "
|
||||
FSELECT "*.txt"
|
||||
CHECKTYPE REQUIRED
|
||||
WARNING "Specificare un file di destinazione valido"
|
||||
END
|
||||
|
||||
SPREADSHEET F_RIGHE 78 0
|
||||
BEGIN
|
||||
PROMPT 1 10 ""
|
||||
ITEM "Nome@40"
|
||||
ITEM "N. Record"
|
||||
ITEM "Data@10"
|
||||
ITEM "Ora@8"
|
||||
FLAGS "D"
|
||||
DEFAULT "*"
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
ENDMASK
|
||||
|
||||
PAGE "Riga" -1 -1 60 7
|
||||
|
||||
STRING 101 260 50
|
||||
BEGIN
|
||||
PROMPT 1 1 "Nome "
|
||||
END
|
||||
|
||||
NUMBER 102 5
|
||||
BEGIN
|
||||
PROMPT 1 2 "Numero di record "
|
||||
END
|
||||
|
||||
DATE 103
|
||||
BEGIN
|
||||
PROMPT 30 2 "Data "
|
||||
END
|
||||
|
||||
STRING 104 8
|
||||
BEGIN
|
||||
PROMPT 52 2 ""
|
||||
END
|
||||
|
||||
BUTTON DLG_USER 10 2
|
||||
BEGIN
|
||||
PROMPT -12 -1 "Anteprima"
|
||||
END
|
||||
|
||||
BUTTON DLG_CANCEL 10 2
|
||||
BEGIN
|
||||
PROMPT -22 -1 ""
|
||||
PICTURE BMP_OK
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
ENDMASK
|
@ -178,6 +178,12 @@ bool TAnagrafica::init(const TRectype& rec)
|
||||
return _tipo == 'F' || _tipo == 'G';
|
||||
}
|
||||
|
||||
bool TAnagrafica::init(int num, const TString& codice)
|
||||
{ return init(cache().get(num, codice)); }
|
||||
|
||||
bool TAnagrafica::init(int num, long codice)
|
||||
{ return init(cache().get(num, codice)); }
|
||||
|
||||
bool TAnagrafica::init(int num, char tipo, long codice)
|
||||
{
|
||||
TString16 key; key << tipo << '|' << codice;
|
||||
|
@ -1,6 +1,10 @@
|
||||
#ifndef __FELIB_H__
|
||||
#define __FELIB_H__
|
||||
|
||||
#ifndef __ISAM_H__
|
||||
#include <isam.h>
|
||||
#endif
|
||||
|
||||
#ifndef __TEXTSET_H__
|
||||
#include <textset.h>
|
||||
#endif
|
||||
@ -48,8 +52,8 @@ public:
|
||||
const TString& indirizzo_residenza() const { return _ind_res; }
|
||||
|
||||
bool init(const TRectype& rec);
|
||||
bool init(int num, const TString& codice) { return init(cache().get(num, codice)); }
|
||||
bool init(int num, long codice) { return init(cache().get(num, codice)); }
|
||||
bool init(int num, const TString& codice);
|
||||
bool init(int num, long codice);
|
||||
bool init(int num, char tipo, long codice);
|
||||
bool init(char tipocf, long codice, const TString& ocfpi);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user