Esportazione su file e uso di file temporaneo
git-svn-id: svn://10.65.10.50/trunk@5334 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
ef2621c2c3
commit
3ae649194c
126
sv/sv1200.cpp
126
sv/sv1200.cpp
@ -2,12 +2,14 @@
|
|||||||
#include <mask.h>
|
#include <mask.h>
|
||||||
#include <progind.h>
|
#include <progind.h>
|
||||||
#include <urldefid.h>
|
#include <urldefid.h>
|
||||||
|
#include <utility.h>
|
||||||
#include <xvtility.h>
|
#include <xvtility.h>
|
||||||
|
|
||||||
#include "../mg/mglib.h"
|
#include "../mg/mglib.h"
|
||||||
#include "sv1.h"
|
#include "sv1.h"
|
||||||
#include "sv1200a.h"
|
#include "sv1200a.h"
|
||||||
#include "sv1200b.h"
|
#include "sv1200b.h"
|
||||||
|
#include "sv1200c.h"
|
||||||
#include "svlib01.h"
|
#include "svlib01.h"
|
||||||
|
|
||||||
#include "svriep.h"
|
#include "svriep.h"
|
||||||
@ -31,6 +33,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#define FORMWIDTH 150
|
#define FORMWIDTH 150
|
||||||
|
#define DEFAULT_OUTFILE "outstat0"
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
// TPeriodo
|
// TPeriodo
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
@ -311,8 +314,7 @@ class TStampa_stat : public TPrint_application
|
|||||||
|
|
||||||
enum { LINEA_DATI='D', LINEA_RAFFRONTI='R', LINEA_TARGET='T'}; // codici per le righe
|
enum { LINEA_DATI='D', LINEA_RAFFRONTI='R', LINEA_TARGET='T'}; // codici per le righe
|
||||||
|
|
||||||
TMask * _msk,*_print_msk;
|
TMask * _msk, *_print_msk,*_export_msk;
|
||||||
|
|
||||||
TStats_agg _stats;
|
TStats_agg _stats;
|
||||||
TFrequenza_colonne _freq;
|
TFrequenza_colonne _freq;
|
||||||
TCodart_livelli* _liv_art;
|
TCodart_livelli* _liv_art;
|
||||||
@ -320,14 +322,14 @@ class TStampa_stat : public TPrint_application
|
|||||||
TRecord_cache *_magazz,*_tipodoc,*_catven,*_zone,*_ums;
|
TRecord_cache *_magazz,*_tipodoc,*_catven,*_zone,*_ums;
|
||||||
TLocalisamfile * _umart,*_anamag,*_clifor,*_agenti;
|
TLocalisamfile * _umart,*_anamag,*_clifor,*_agenti;
|
||||||
|
|
||||||
//TLocalisamfile * _outstat;
|
|
||||||
|
|
||||||
TToken_string _key;
|
TToken_string _key;
|
||||||
TString _last_key;
|
TString _last_key;
|
||||||
TArray _files;
|
TArray _files;
|
||||||
|
|
||||||
bool _ragg_per_um;
|
bool _ragg_per_um;
|
||||||
|
|
||||||
|
// ******************
|
||||||
|
// costruzione file di Output
|
||||||
TStat_cache * _cache; // cache R/W per le statistiche
|
TStat_cache * _cache; // cache R/W per le statistiche
|
||||||
|
|
||||||
int _last_lev_grp, // livello dell'ultimo raggruppamento incontrato
|
int _last_lev_grp, // livello dell'ultimo raggruppamento incontrato
|
||||||
@ -345,28 +347,30 @@ class TStampa_stat : public TPrint_application
|
|||||||
bool _st_totr; // flag stampa totali di riga
|
bool _st_totr; // flag stampa totali di riga
|
||||||
bool _st_totc; // flag stampa totali di colonna
|
bool _st_totc; // flag stampa totali di colonna
|
||||||
static TString s_park; // stringa di lavoro
|
static TString s_park; // stringa di lavoro
|
||||||
|
// ******************
|
||||||
|
// stampa file di Output
|
||||||
TString wrk_row; // stringa di lavoro per le righe di stampa
|
TString wrk_row; // stringa di lavoro per le righe di stampa
|
||||||
|
TRelation * _rel; // relazione per la stampa
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void set_ragg_per_um();
|
|
||||||
|
|
||||||
void put_column(TRectype & statrec,int col,TSVriep_record& curr);
|
void put_column(TRectype & statrec,int col,TSVriep_record& curr);
|
||||||
const real fc_um(TRectype & statrec,const TSVriep_record& rieprec);
|
const real fc_um(TRectype & statrec,const TSVriep_record& rieprec);
|
||||||
void invalid_columns(TRectype & statrec);
|
void invalid_columns(TRectype & statrec);
|
||||||
void standardize_um(TSVriep_record& rieprec, bool force=FALSE);
|
void standardize_um(TSVriep_record& rieprec, bool force=FALSE);
|
||||||
|
|
||||||
void azzera_file();
|
// generazione del file di output
|
||||||
void update_file(const char * key, const char * code,const char tipo, const int level, const int col, TSVriep_record& curr);
|
void set_ragg_per_um();
|
||||||
void genera_file();
|
|
||||||
void esporta_file();
|
|
||||||
|
|
||||||
bool filtro_chiavi(TSVriep_record &curr);
|
bool filtro_chiavi(TSVriep_record &curr);
|
||||||
|
void update_file(const char * key, const char * code,const char tipo, const int level, const int col, TSVriep_record& curr);
|
||||||
|
void genera_file(TLocalisamfile *f);
|
||||||
|
|
||||||
// handler per i campi di maschera
|
// handler per i campi di maschera
|
||||||
static bool chiave_notify(TSheet_field& f, int r, KEY k);
|
static bool chiave_notify(TSheet_field& f, int r, KEY k);
|
||||||
static bool chiave_handler(TMask_field& f, KEY k);
|
static bool chiave_handler(TMask_field& f, KEY k);
|
||||||
static bool campo_handler(TMask_field& f, KEY k);
|
static bool campo_handler(TMask_field& f, KEY k);
|
||||||
|
|
||||||
|
static bool filename_handler(TMask_field& f, KEY k);
|
||||||
static bool codice_handler(TMask_field& f, KEY k);
|
static bool codice_handler(TMask_field& f, KEY k);
|
||||||
static bool multiplo_handler(TMask_field& f, KEY k);
|
static bool multiplo_handler(TMask_field& f, KEY k);
|
||||||
static bool numero_handler(TMask_field& f, KEY k);
|
static bool numero_handler(TMask_field& f, KEY k);
|
||||||
@ -391,7 +395,6 @@ protected:
|
|||||||
virtual void on_config_change();
|
virtual void on_config_change();
|
||||||
|
|
||||||
int handle_levchange(int row,const int level);
|
int handle_levchange(int row,const int level);
|
||||||
int set_header_colonne(int row);
|
|
||||||
int set_rows_colonne(int row, TRectype &strec);
|
int set_rows_colonne(int row, TRectype &strec);
|
||||||
void set_row_atpos(char section,int row,const char * f,int pos);
|
void set_row_atpos(char section,int row,const char * f,int pos);
|
||||||
void reset_grplevels();
|
void reset_grplevels();
|
||||||
@ -420,6 +423,7 @@ protected:
|
|||||||
public:
|
public:
|
||||||
TMask& selmask() { return *_msk; }
|
TMask& selmask() { return *_msk; }
|
||||||
TMask& printmask() { return *_print_msk; }
|
TMask& printmask() { return *_print_msk; }
|
||||||
|
TMask& expmask() { return *_export_msk; }
|
||||||
virtual bool menu(MENU_TAG);
|
virtual bool menu(MENU_TAG);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -474,10 +478,6 @@ bool TStampa_stat::set_print(int i)
|
|||||||
return (ok);
|
return (ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TStampa_stat::set_header_colonne(int row) // to remove
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TStampa_stat::postclose_print()
|
void TStampa_stat::postclose_print()
|
||||||
{
|
{
|
||||||
@ -512,7 +512,7 @@ void TStampa_stat::preprocess_header()
|
|||||||
lastrow=row;
|
lastrow=row;
|
||||||
for (int c=0; c < _numcol; c++) // colonne
|
for (int c=0; c < _numcol; c++) // colonne
|
||||||
{
|
{
|
||||||
if (_st_totr && (((c)%_col_anno)==0 || c== _numcol_dati) )
|
if (_st_totr && c && (((c)%_col_anno)==0 || c== _numcol_dati) )
|
||||||
{
|
{
|
||||||
set_row_atpos('H',row,nome_totale(int(c/_col_anno)),POS_PRIMACOL+c*_largcol+_largcol/2 );
|
set_row_atpos('H',row,nome_totale(int(c/_col_anno)),POS_PRIMACOL+c*_largcol+_largcol/2 );
|
||||||
} else {
|
} else {
|
||||||
@ -562,6 +562,7 @@ const TString& TStampa_stat::nome_colonna1(int c)
|
|||||||
} else {
|
} else {
|
||||||
switch (code_freq)
|
switch (code_freq)
|
||||||
{
|
{
|
||||||
|
case 'A':
|
||||||
default:
|
default:
|
||||||
s_park.format("%d^%s",1+(start+c-1)%lastp,(const char *)char2freqname(code_freq));
|
s_park.format("%d^%s",1+(start+c-1)%lastp,(const char *)char2freqname(code_freq));
|
||||||
}
|
}
|
||||||
@ -592,8 +593,16 @@ const TString& TStampa_stat::nome_colonna2(int c)
|
|||||||
|
|
||||||
const TString& TStampa_stat::nome_totale(int c)
|
const TString& TStampa_stat::nome_totale(int c)
|
||||||
{
|
{
|
||||||
s_park = "Totale ";
|
const char code_freq=selmask().get(F_MULTIPLO)[0];
|
||||||
s_park << c+1;
|
s_park="";
|
||||||
|
{
|
||||||
|
switch (code_freq)
|
||||||
|
{
|
||||||
|
case 'A':
|
||||||
|
default:
|
||||||
|
s_park.format("Totale %d",c);
|
||||||
|
}
|
||||||
|
}
|
||||||
return s_park;
|
return s_park;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -835,7 +844,8 @@ void TStampa_stat::reset_grplevels()
|
|||||||
|
|
||||||
bool TStampa_stat::user_create()
|
bool TStampa_stat::user_create()
|
||||||
{
|
{
|
||||||
_print_msk= NULL;
|
// ************
|
||||||
|
// maschere
|
||||||
_msk = new TMask("sv1200a");
|
_msk = new TMask("sv1200a");
|
||||||
_msk->set_handler(F_CODICE, codice_handler);
|
_msk->set_handler(F_CODICE, codice_handler);
|
||||||
_msk->set_handler(F_MULTIPLO, multiplo_handler);
|
_msk->set_handler(F_MULTIPLO, multiplo_handler);
|
||||||
@ -852,13 +862,13 @@ bool TStampa_stat::user_create()
|
|||||||
|
|
||||||
_print_msk = new TMask("sv1200b");
|
_print_msk = new TMask("sv1200b");
|
||||||
|
|
||||||
|
_export_msk = new TMask("sv1200c");
|
||||||
|
_export_msk->set_handler(F_FILENAME, filename_handler);
|
||||||
|
// ************
|
||||||
// files
|
// files
|
||||||
_files.add(new TLocalisamfile(LF_SVRIEP));
|
_files.add(new TLocalisamfile(LF_SVRIEP));
|
||||||
_files.add(new TLocalisamfile(LF_SVSTAT));
|
_files.add(new TLocalisamfile(LF_SVSTAT));
|
||||||
|
// ************
|
||||||
// cache R/W per le statistiche
|
|
||||||
_cache= new TStat_cache();
|
|
||||||
|
|
||||||
// oggetti per la gestione delle parti del codice
|
// oggetti per la gestione delle parti del codice
|
||||||
_liv_art = new TCodart_livelli;
|
_liv_art = new TCodart_livelli;
|
||||||
_liv_giac = new TCodgiac_livelli;
|
_liv_giac = new TCodgiac_livelli;
|
||||||
@ -873,15 +883,15 @@ bool TStampa_stat::user_create()
|
|||||||
_clifor = new TLocalisamfile(LF_CLIFO);
|
_clifor = new TLocalisamfile(LF_CLIFO);
|
||||||
_agenti = new TLocalisamfile(LF_AGENTI);
|
_agenti = new TLocalisamfile(LF_AGENTI);
|
||||||
|
|
||||||
//_outstat = new TLocalisamfile(LF_SVSTAT);
|
// ************
|
||||||
// cursore di stampa
|
// cursore di stampa
|
||||||
add_file(LF_SVSTAT);
|
add_file(LF_SVSTAT);
|
||||||
add_cursor(new TCursor(new TRelation(LF_SVSTAT)));
|
add_cursor(new TCursor(new TRelation(LF_SVSTAT)));
|
||||||
|
|
||||||
// impone force setpage
|
// cache per l'output
|
||||||
//force_setpage();
|
_cache=NULL;
|
||||||
set_real_picture("");
|
|
||||||
|
|
||||||
|
set_real_picture("");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -889,18 +899,19 @@ bool TStampa_stat::user_destroy()
|
|||||||
{
|
{
|
||||||
delete _msk;
|
delete _msk;
|
||||||
delete _print_msk;
|
delete _print_msk;
|
||||||
|
delete _export_msk;
|
||||||
|
|
||||||
delete _liv_art;
|
delete _liv_art;
|
||||||
delete _liv_giac;
|
delete _liv_giac;
|
||||||
// cancella le cache
|
// cancella le cache
|
||||||
delete _cache;
|
|
||||||
delete _ums;
|
delete _ums;
|
||||||
// cancella i files
|
// cancella i files
|
||||||
delete _umart;
|
delete _umart;
|
||||||
delete _anamag;
|
delete _anamag;
|
||||||
delete _clifor;
|
delete _clifor;
|
||||||
delete _agenti;
|
delete _agenti;
|
||||||
//delete _outstat;
|
|
||||||
|
delete current_cursor()->relation();
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -926,10 +937,21 @@ bool TStampa_stat::menu(MENU_TAG )
|
|||||||
if (k == K_SAVE)
|
if (k == K_SAVE)
|
||||||
{
|
{
|
||||||
set_ragg_per_um();
|
set_ragg_per_um();
|
||||||
genera_file();
|
if (expmask().run()!=K_ESC)
|
||||||
esporta_file();
|
{
|
||||||
|
TFilename fn(expmask().get(F_FILENAME));
|
||||||
|
TIsamtempfile * f=new TIsamtempfile(LF_SVSTAT,fn,TRUE);
|
||||||
|
genera_file(f);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
TFilename fn;
|
||||||
|
fn.temp();
|
||||||
|
fn.insert("%");
|
||||||
|
genera_file(new TIsamtempfile(LF_SVSTAT,fn,TRUE));
|
||||||
set_printmask();
|
set_printmask();
|
||||||
|
TIsamtempfile * f=new TIsamtempfile(LF_SVSTAT,fn,FALSE);
|
||||||
|
f->set_autodel();
|
||||||
|
current_cursor()->relation()->replace(f);
|
||||||
do_print(1);
|
do_print(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1311,7 +1333,7 @@ void TStampa_stat::set_ragg_per_um()
|
|||||||
_ragg_per_um=TRUE;
|
_ragg_per_um=TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TStampa_stat::genera_file()
|
void TStampa_stat::genera_file(TLocalisamfile *f)
|
||||||
{
|
{
|
||||||
|
|
||||||
TString key; // chiave per il record del file statistiche
|
TString key; // chiave per il record del file statistiche
|
||||||
@ -1323,6 +1345,10 @@ void TStampa_stat::genera_file()
|
|||||||
TSheet_field & s_chiave = m.sfield(F_CHIAVE);
|
TSheet_field & s_chiave = m.sfield(F_CHIAVE);
|
||||||
|
|
||||||
|
|
||||||
|
// file di OUTPUT
|
||||||
|
_cache= new TStat_cache(f);
|
||||||
|
|
||||||
|
// file di INPUT
|
||||||
TLocalisamfile riep(LF_SVRIEP);
|
TLocalisamfile riep(LF_SVRIEP);
|
||||||
riep.set_curr(new TSVriep_record);
|
riep.set_curr(new TSVriep_record);
|
||||||
|
|
||||||
@ -1340,8 +1366,7 @@ void TStampa_stat::genera_file()
|
|||||||
TProgind statusbar(date2long(m.get_date(F_DATAFIN),_stats.frequency())-start_status
|
TProgind statusbar(date2long(m.get_date(F_DATAFIN),_stats.frequency())-start_status
|
||||||
, "Creazione del file di output", FALSE, TRUE, 60);
|
, "Creazione del file di output", FALSE, TRUE, 60);
|
||||||
|
|
||||||
azzera_file();
|
_cache->zap();
|
||||||
_cache->clear();
|
|
||||||
|
|
||||||
// **********************
|
// **********************
|
||||||
// ciclo principale: scorre il riepilogo statistiche per anno+periodo
|
// ciclo principale: scorre il riepilogo statistiche per anno+periodo
|
||||||
@ -1396,6 +1421,7 @@ void TStampa_stat::genera_file()
|
|||||||
} // ciclo
|
} // ciclo
|
||||||
statusbar.setstatus(date2long(m.get_date(F_DATAFIN),_stats.frequency())-start_status);
|
statusbar.setstatus(date2long(m.get_date(F_DATAFIN),_stats.frequency())-start_status);
|
||||||
_cache->flush();
|
_cache->flush();
|
||||||
|
delete _cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1429,23 +1455,6 @@ void TStampa_stat::set_printmask()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TStampa_stat::esporta_file()
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
void TStampa_stat::azzera_file()
|
|
||||||
{
|
|
||||||
TLocalisamfile stat(LF_SVSTAT);
|
|
||||||
int err=NOERR;
|
|
||||||
while (err==NOERR)
|
|
||||||
{
|
|
||||||
err=stat.first();
|
|
||||||
if (err==NOERR)
|
|
||||||
err=stat.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const TString& TStampa_stat::partkey_name(const char *lev_code)
|
const TString& TStampa_stat::partkey_name(const char *lev_code)
|
||||||
{
|
{
|
||||||
@ -1799,6 +1808,21 @@ bool TStampa_stat::codice_handler(TMask_field& f, KEY k)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TStampa_stat::filename_handler(TMask_field& f, KEY k)
|
||||||
|
{
|
||||||
|
TFilename fn(f.get());
|
||||||
|
if (k==K_TAB && !fn.empty())
|
||||||
|
{
|
||||||
|
if (!fexist(fn.path()))
|
||||||
|
return f.error_box("Directory %s non trovato",(const char *)fn.path());
|
||||||
|
else
|
||||||
|
if (fexist(fn))
|
||||||
|
return f.yesno_box("File %s esistente: sovrascrivo",(const char *)fn);
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool TStampa_stat::chiave_notify(TSheet_field& s, int r, KEY k)
|
bool TStampa_stat::chiave_notify(TSheet_field& s, int r, KEY k)
|
||||||
{
|
{
|
||||||
bool ok = TRUE;
|
bool ok = TRUE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user