2001-05-01 08:17:07 +00:00
|
|
|
// Ricezione dati da sistema e da PC
|
1997-01-17 11:02:27 +00:00
|
|
|
|
1997-06-20 08:52:24 +00:00
|
|
|
#include <applicat.h>
|
1996-03-26 09:48:18 +00:00
|
|
|
#include <config.h>
|
|
|
|
#include <mask.h>
|
|
|
|
#include <prefix.h>
|
1997-06-20 08:52:24 +00:00
|
|
|
#include <progind.h>
|
1996-03-26 09:48:18 +00:00
|
|
|
#include <tabutil.h>
|
|
|
|
#include <utility.h>
|
|
|
|
|
|
|
|
#include <nditte.h>
|
|
|
|
|
|
|
|
#include "cg6400.h"
|
1997-06-20 08:52:24 +00:00
|
|
|
#include "cglib04.h"
|
|
|
|
#include "cgsaldac.h"
|
1996-03-26 09:48:18 +00:00
|
|
|
|
1998-03-16 13:51:30 +00:00
|
|
|
class TRic_archivi : public TSkeleton_application
|
1996-03-26 09:48:18 +00:00
|
|
|
{
|
|
|
|
TTransfer_file* _tras_file;
|
|
|
|
TLocalisamfile* _caus;
|
|
|
|
TLocalisamfile* _rcaus;
|
|
|
|
TLocalisamfile* _clifo;
|
|
|
|
TLocalisamfile* _pcon;
|
|
|
|
TLocalisamfile* _mov;
|
|
|
|
TLocalisamfile* _rmov;
|
|
|
|
TLocalisamfile* _rmoviva;
|
|
|
|
TLocalisamfile* _occas;
|
1998-08-25 17:57:12 +00:00
|
|
|
TLocalisamfile* _part;
|
|
|
|
TLocalisamfile* _scad;
|
|
|
|
TLocalisamfile* _pagsca;
|
1996-03-26 09:48:18 +00:00
|
|
|
|
|
|
|
TString80 TEMP;
|
|
|
|
|
|
|
|
char _scelta, _ric_auto;
|
|
|
|
|
|
|
|
int _numtotdisk,_progdisk,_numdisk,_numinv,_numinvp,_nultras;
|
|
|
|
int _stato_ripartenza,_nultras_tab;
|
|
|
|
bool _sequenza,_disketto;
|
|
|
|
bool _prima_volta,_baipassa;
|
2003-05-14 13:12:14 +00:00
|
|
|
TString _nomeid,_nomeidp,_ragsoc_dittar;
|
|
|
|
TFilename _marker,_trasf,_trasfer,_pathname;
|
1996-03-26 09:48:18 +00:00
|
|
|
long _dittainv,_dittainvp,_dittaric,_totrectras,_totrectrasp;
|
|
|
|
TDate _datatras,_datatrasp,_dataultras_tab,_dataultras;
|
|
|
|
TString _sigle_file,_nrec_file,_trasfhard;
|
|
|
|
char _agg_cau,_agg_pcon,_agg_cls,_agg_clifo,_agg_fatatt,_agg_fatpas;
|
|
|
|
|
|
|
|
public:
|
1996-06-04 14:54:43 +00:00
|
|
|
TString _titolo;
|
1996-03-26 09:48:18 +00:00
|
|
|
|
|
|
|
virtual bool create();
|
|
|
|
virtual bool destroy();
|
1998-11-04 18:04:26 +00:00
|
|
|
virtual bool check_autorization() const
|
|
|
|
{return FALSE;}
|
1998-03-16 13:51:30 +00:00
|
|
|
virtual void main_loop();
|
1996-03-26 09:48:18 +00:00
|
|
|
bool leggi_marker();
|
|
|
|
bool leggi_marker_rep();
|
|
|
|
void leggi_trasfer(const char* nome);
|
|
|
|
void ripristina_trasfer();
|
|
|
|
void trasfer2tempfile();
|
|
|
|
long leggi_tabella_tras();
|
1996-06-24 16:51:49 +00:00
|
|
|
void componi_path(TMask*);
|
1996-03-26 09:48:18 +00:00
|
|
|
bool video_ripartenza();
|
|
|
|
void ditta_ricevente();
|
|
|
|
bool ripartenza();
|
|
|
|
bool set_flag();
|
|
|
|
void aggiorna_tabella();
|
|
|
|
int controllo_ripartenza();
|
|
|
|
|
|
|
|
static bool baipassa(TMask& m,KEY k);
|
|
|
|
|
|
|
|
TRic_archivi(char ric_trasfer,char ric_auto = '\0');
|
|
|
|
};
|
|
|
|
|
|
|
|
HIDDEN TRic_archivi& app() { return (TRic_archivi &) main_app(); }
|
|
|
|
|
|
|
|
TRic_archivi::TRic_archivi(char ric_trasfer,char ric_auto) :
|
|
|
|
_scelta(toupper(ric_trasfer)), _ric_auto(toupper(ric_auto))
|
|
|
|
{
|
|
|
|
if (_scelta == 'S')
|
2003-04-08 12:45:26 +00:00
|
|
|
_titolo = TR("Ricezione archivi da sistema");
|
1998-03-16 13:51:30 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
_scelta = 'P';
|
2003-04-08 12:45:26 +00:00
|
|
|
_titolo = TR("Ricezione archivi da PC");
|
1998-03-16 13:51:30 +00:00
|
|
|
}
|
1996-03-26 09:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool TRic_archivi::create()
|
|
|
|
{
|
2003-02-25 14:39:02 +00:00
|
|
|
open_files(LF_TABCOM, 0);
|
1996-03-26 09:48:18 +00:00
|
|
|
_tras_file = new TTransfer_file(_scelta);
|
|
|
|
|
|
|
|
_caus = new TLocalisamfile (LF_CAUSALI);
|
|
|
|
_rcaus = new TLocalisamfile (LF_RCAUSALI);
|
|
|
|
_clifo = new TLocalisamfile (LF_CLIFO);
|
|
|
|
_pcon = new TLocalisamfile (LF_PCON);
|
|
|
|
_mov = new TLocalisamfile (LF_MOV);
|
|
|
|
_rmov = new TLocalisamfile (LF_RMOV);
|
|
|
|
_rmoviva = new TLocalisamfile (LF_RMOVIVA);
|
|
|
|
_occas = new TLocalisamfile (LF_OCCAS);
|
1998-08-25 17:57:12 +00:00
|
|
|
_part = new TLocalisamfile (LF_PARTITE);
|
|
|
|
_scad = new TLocalisamfile (LF_SCADENZE);
|
|
|
|
_pagsca = new TLocalisamfile (LF_PAGSCA);
|
1996-03-26 09:48:18 +00:00
|
|
|
|
|
|
|
_numdisk = 1;
|
|
|
|
_prima_volta = TRUE;
|
|
|
|
_nultras = 0;
|
|
|
|
_nultras_tab = 0;
|
|
|
|
_baipassa = FALSE;
|
|
|
|
|
1999-10-22 10:00:18 +00:00
|
|
|
return TSkeleton_application::create();
|
1996-03-26 09:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool TRic_archivi::destroy()
|
|
|
|
{
|
|
|
|
delete _tras_file;
|
|
|
|
|
|
|
|
delete _caus;
|
|
|
|
delete _rcaus;
|
|
|
|
delete _clifo;
|
|
|
|
delete _pcon;
|
|
|
|
delete _mov;
|
|
|
|
delete _rmov;
|
|
|
|
delete _rmoviva;
|
1996-06-04 14:54:43 +00:00
|
|
|
delete _occas;
|
1998-08-25 17:57:12 +00:00
|
|
|
delete _part;
|
|
|
|
delete _scad;
|
|
|
|
delete _pagsca;
|
1996-03-26 09:48:18 +00:00
|
|
|
|
|
|
|
return TApplication::destroy();
|
|
|
|
}
|
|
|
|
|
1996-06-24 16:51:49 +00:00
|
|
|
void TRic_archivi::componi_path(TMask* msk)
|
1996-03-26 09:48:18 +00:00
|
|
|
{
|
2003-02-25 14:39:02 +00:00
|
|
|
TFilename path = msk->get(F_PATHNAME);
|
1996-03-26 09:48:18 +00:00
|
|
|
|
2003-02-25 14:39:02 +00:00
|
|
|
const TString8 drive = msk->get(F_DRIVE);
|
1998-03-16 13:51:30 +00:00
|
|
|
// Inizio cazzata - da sostituire con _disketto = ::os_is_removable_drive(drive)
|
|
|
|
if (drive == "A:" || drive == "B:")
|
1996-03-26 09:48:18 +00:00
|
|
|
_disketto = TRUE;
|
|
|
|
else
|
|
|
|
_disketto = FALSE;
|
1998-03-16 13:51:30 +00:00
|
|
|
// Fine cazzata
|
1996-03-26 09:48:18 +00:00
|
|
|
|
2003-02-25 14:39:02 +00:00
|
|
|
const int pos = path.find(':');
|
1996-03-26 09:48:18 +00:00
|
|
|
if (pos)
|
|
|
|
path = path.mid(pos+1);
|
|
|
|
|
1999-10-22 10:00:18 +00:00
|
|
|
if (path.not_empty())
|
1996-03-26 09:48:18 +00:00
|
|
|
{
|
|
|
|
_marker << drive << "\\" << path << "\\marker";
|
|
|
|
_trasfer << drive << "\\" << path << "\\trasfer";
|
|
|
|
if (!_disketto)
|
|
|
|
_pathname << drive << "\\" << path;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_marker << drive << "\\marker";
|
|
|
|
_trasfer << drive << "\\trasfer";
|
|
|
|
if (!_disketto)
|
|
|
|
_pathname << drive << "\\";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TRic_archivi::leggi_marker()
|
|
|
|
{
|
2003-05-14 13:12:14 +00:00
|
|
|
if (!_marker.exist())
|
1996-03-26 09:48:18 +00:00
|
|
|
{
|
|
|
|
if (_disketto)
|
2003-04-08 12:45:26 +00:00
|
|
|
return error_box(FR("File marker non presente sul dischetto %d: impossibile proseguire"), _numdisk);
|
1996-03-26 09:48:18 +00:00
|
|
|
else
|
2003-04-08 12:45:26 +00:00
|
|
|
return error_box(FR("File marker non presente in %s: impossibile proseguire"), (const char*)_pathname);
|
1996-03-26 09:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
FILE* i;
|
|
|
|
|
|
|
|
const word size = 64;
|
|
|
|
TString buffer(size);
|
|
|
|
|
|
|
|
if ( (i = fopen(_marker,"r+t")) != NULL)
|
|
|
|
{
|
|
|
|
const word letti = fread((char*)(const char*)buffer,sizeof(char),size,i);
|
|
|
|
|
|
|
|
_progdisk = atoi(buffer.sub(31,33));
|
|
|
|
_numtotdisk = atoi(buffer.sub(29,31));
|
|
|
|
|
1996-07-16 10:08:44 +00:00
|
|
|
if (_numtotdisk == 0)
|
|
|
|
{
|
2003-04-08 12:45:26 +00:00
|
|
|
message_box(TR("Il numero totale dischi su marker non e' significativo: impossibile proseguire"));
|
1996-07-16 10:08:44 +00:00
|
|
|
fclose(i);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
1996-03-26 09:48:18 +00:00
|
|
|
if (_progdisk != _numdisk)
|
|
|
|
{
|
2003-04-08 12:45:26 +00:00
|
|
|
message_box(FR("Il dischetto inserito (%d) non rispecchia la giusta sequenza (%d)"), _numdisk, _progdisk);
|
1996-03-26 09:48:18 +00:00
|
|
|
_sequenza = FALSE;
|
|
|
|
fclose(i);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
_sequenza = TRUE;
|
|
|
|
|
|
|
|
if (letti == 0)
|
1998-05-04 09:34:04 +00:00
|
|
|
{
|
|
|
|
fclose(i);
|
2003-04-08 12:45:26 +00:00
|
|
|
return error_box(TR("Rilevati ERRORI nel file MARKER: impossibile proseguire"));
|
1998-05-04 09:34:04 +00:00
|
|
|
}
|
1996-03-26 09:48:18 +00:00
|
|
|
|
|
|
|
_nomeid = buffer.sub(0,10);
|
|
|
|
_dittainv = atol(buffer.sub(10,14));
|
|
|
|
_totrectras = atol(buffer.sub(23,29));
|
|
|
|
_numinv = atoi(buffer.sub(14,17));
|
2003-02-25 14:39:02 +00:00
|
|
|
|
|
|
|
TString16 tmp = buffer.sub(17,23);
|
1996-03-26 09:48:18 +00:00
|
|
|
_datatras = converti(tmp,FALSE);
|
|
|
|
|
|
|
|
if (_numdisk > 1) //Va fatto solo dal disco 2 in poi
|
|
|
|
if (_nomeid != _nomeidp || _dittainv != _dittainvp || _totrectras != _totrectrasp
|
|
|
|
|| _numinv != _numinvp || _datatras != _datatrasp)
|
2003-04-08 12:45:26 +00:00
|
|
|
return error_box(FR("I dati del marker del disco %d, non corrispondono ai dati del marker del disco 1"), _numdisk);
|
1996-03-26 09:48:18 +00:00
|
|
|
|
|
|
|
_nomeidp = _nomeid;
|
|
|
|
_dittainvp = _dittainv;
|
|
|
|
_totrectrasp = _totrectras;
|
|
|
|
_numinvp = _numinv;
|
|
|
|
_datatrasp = _datatras;
|
|
|
|
|
|
|
|
fclose(i);
|
|
|
|
|
|
|
|
if (_numdisk == 1) // Va fatto solo per il primo disco
|
|
|
|
{
|
|
|
|
_dittaric = leggi_tabella_tras();
|
|
|
|
|
|
|
|
if (_dittaric != 0)
|
|
|
|
{
|
|
|
|
if (!prefix().exist(_dittaric))
|
2003-05-14 13:12:14 +00:00
|
|
|
return error_box(FR("Libreria archivi ditta %ld non presente su disco"), _dittaric);
|
1996-03-26 09:48:18 +00:00
|
|
|
}
|
|
|
|
else
|
2003-04-08 12:45:26 +00:00
|
|
|
return error_box(TR("Codici NON PRESENTI in tabella ricezione: caricarli e riprovare"));
|
1996-03-26 09:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TRic_archivi::leggi_marker_rep()
|
|
|
|
{
|
|
|
|
TString16 tmp;
|
|
|
|
|
2003-05-14 13:12:14 +00:00
|
|
|
if (!_marker.exist())
|
1996-03-26 09:48:18 +00:00
|
|
|
{
|
|
|
|
if (_disketto)
|
2003-04-08 12:45:26 +00:00
|
|
|
return error_box(FR("File marker non presente sul dischetto %d: impossibile proseguire"), _numdisk);
|
1996-03-26 09:48:18 +00:00
|
|
|
else
|
2003-04-08 12:45:26 +00:00
|
|
|
return error_box(FR("File marker non presente in %s: impossibile proseguire"), (const char*)_pathname);
|
1996-03-26 09:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const word size = 64;
|
|
|
|
TString buffer(size);
|
|
|
|
|
1998-05-04 09:34:04 +00:00
|
|
|
FILE* inmark = fopen(_marker,"r");
|
|
|
|
if (inmark != NULL)
|
1996-03-26 09:48:18 +00:00
|
|
|
{
|
1998-05-04 09:34:04 +00:00
|
|
|
const word letti = fread((char*)(const char*)buffer,sizeof(char),size,inmark);
|
|
|
|
fclose(inmark);
|
1996-03-26 09:48:18 +00:00
|
|
|
|
|
|
|
_progdisk = atoi(buffer.sub(34,36));
|
|
|
|
_numtotdisk = atoi(buffer.sub(32,34));
|
|
|
|
|
|
|
|
if (_progdisk != _numdisk)
|
|
|
|
{
|
2003-04-08 12:45:26 +00:00
|
|
|
message_box(FR("Il dischetto inserito (%d) non rispecchia la giusta sequenza (%d)"), _numdisk, _progdisk);
|
1996-03-26 09:48:18 +00:00
|
|
|
_sequenza = FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
_sequenza = TRUE;
|
|
|
|
|
|
|
|
if (letti == 0)
|
2003-04-08 12:45:26 +00:00
|
|
|
return error_box(TR("Rilevati ERRORI nel file MARKER: impossibile proseguire"));
|
1996-03-26 09:48:18 +00:00
|
|
|
|
|
|
|
_nomeid = buffer.sub(0,10);
|
|
|
|
_dittainv = atol(buffer.sub(10,15));
|
|
|
|
_totrectras = atol(buffer.sub(26,32));
|
|
|
|
_numinv = atoi(buffer.sub(15,18));
|
|
|
|
tmp = buffer.sub(18,26);
|
|
|
|
_datatras = converti(tmp,TRUE);
|
|
|
|
|
|
|
|
if (_numdisk > 1) //Va fatto solo dal disco 2 in poi
|
|
|
|
if (_nomeid != _nomeidp || _dittainv != _dittainvp || _totrectras != _totrectrasp
|
|
|
|
|| _numinv != _numinvp || _datatras != _datatrasp)
|
2003-04-08 12:45:26 +00:00
|
|
|
return error_box(FR("I dati del marker del disco %d, non corrispondono ai dati del marker del disco 1"), _numdisk);
|
1996-03-26 09:48:18 +00:00
|
|
|
|
|
|
|
_nomeidp = _nomeid;
|
|
|
|
_dittainvp = _dittainv;
|
|
|
|
_totrectrasp = _totrectras;
|
|
|
|
_numinvp = _numinv;
|
|
|
|
_datatrasp = _datatras;
|
|
|
|
|
|
|
|
if (_numdisk == 1) // Va fatto solo per il primo disco
|
|
|
|
{
|
|
|
|
_dittaric = leggi_tabella_tras();
|
|
|
|
|
|
|
|
if (_dittaric != 0)
|
|
|
|
{
|
|
|
|
if (!prefix().exist(_dittaric))
|
2003-04-08 12:45:26 +00:00
|
|
|
return error_box(FR("Gli archivi della ditta %ld non sono presenti su disco"), _dittaric);
|
1996-03-26 09:48:18 +00:00
|
|
|
}
|
|
|
|
else
|
2003-04-08 12:45:26 +00:00
|
|
|
return error_box(TR("Codici NON PRESENTI in tabella ricezione: caricarli e riprovare"));
|
1996-03-26 09:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-04-08 12:45:26 +00:00
|
|
|
return error_box(FR("Impossibile accedere al file %s"), (const char*)_marker);
|
1996-03-26 09:48:18 +00:00
|
|
|
}
|
|
|
|
|
1998-03-16 13:51:30 +00:00
|
|
|
void TRic_archivi::main_loop()
|
1996-03-26 09:48:18 +00:00
|
|
|
{
|
|
|
|
if (_ric_auto == 'A')
|
|
|
|
{
|
|
|
|
_dittaric = get_firm();
|
|
|
|
_trasf = _tras_file->path(_dittaric);
|
|
|
|
_trasf << "\\trasfer";
|
|
|
|
_tras_file->open(_trasf);
|
|
|
|
|
|
|
|
if (_scelta == 'S')
|
|
|
|
{
|
|
|
|
trasfer2tempfile();
|
|
|
|
_tras_file->close(); // Chiude il trasfer letto dalla directory della ditta
|
1998-02-18 09:44:55 +00:00
|
|
|
::remove(_trasf);
|
1996-03-26 09:48:18 +00:00
|
|
|
TString80 tab = _tras_file->path(_dittaric);
|
|
|
|
TString tabcdx = tab;
|
|
|
|
TString tabdbf = tab;
|
|
|
|
tabcdx << "\\ttab.cdx";
|
|
|
|
tabdbf << "\\ttab.dbf";
|
1998-02-18 09:44:55 +00:00
|
|
|
::remove(tabcdx);
|
|
|
|
::remove(tabdbf);
|
1996-03-26 09:48:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
if (_scelta == 'P')
|
|
|
|
{
|
|
|
|
trasfer2tempfile();
|
|
|
|
_tras_file->close(); // Chiude il trasfer letto dalla directory della ditta
|
1998-02-18 09:44:55 +00:00
|
|
|
::remove(_trasf);
|
1996-03-26 09:48:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (_scelta == 'S')
|
|
|
|
{
|
1998-03-16 13:51:30 +00:00
|
|
|
TMask maskera("cg6400b");
|
|
|
|
TMask* msk = &maskera;
|
|
|
|
|
|
|
|
KEY tasto = msk->run();
|
1996-03-26 09:48:18 +00:00
|
|
|
if (tasto == K_ENTER)
|
|
|
|
{
|
|
|
|
componi_path(msk);
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (_disketto)
|
|
|
|
{
|
1996-06-24 16:51:49 +00:00
|
|
|
char drive = msk->get(F_DRIVE)[0];
|
2003-04-08 12:45:26 +00:00
|
|
|
if (yesno_box(FR("Inserire il dischetto %d nell' unita' %c"), _numdisk,drive))
|
1996-03-26 09:48:18 +00:00
|
|
|
{
|
|
|
|
if (!leggi_marker())
|
1998-03-16 13:51:30 +00:00
|
|
|
return;
|
1996-03-26 09:48:18 +00:00
|
|
|
|
|
|
|
if (_sequenza)
|
|
|
|
{
|
|
|
|
if (video_ripartenza())
|
|
|
|
ripristina_trasfer();
|
|
|
|
else
|
1998-03-16 13:51:30 +00:00
|
|
|
return;
|
1996-03-26 09:48:18 +00:00
|
|
|
_numdisk++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
1998-03-16 13:51:30 +00:00
|
|
|
return;
|
1996-03-26 09:48:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!leggi_marker())
|
1998-03-16 13:51:30 +00:00
|
|
|
return;
|
1996-03-26 09:48:18 +00:00
|
|
|
|
|
|
|
if (_sequenza)
|
|
|
|
{
|
|
|
|
if (video_ripartenza())
|
|
|
|
ripristina_trasfer();
|
|
|
|
else
|
1998-03-16 13:51:30 +00:00
|
|
|
return;
|
1996-03-26 09:48:18 +00:00
|
|
|
_numdisk++;
|
|
|
|
}
|
|
|
|
else
|
1998-03-16 13:51:30 +00:00
|
|
|
return;
|
1996-03-26 09:48:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
while (_numdisk <= _numtotdisk);
|
|
|
|
|
|
|
|
trasfer2tempfile();
|
|
|
|
set_flag();
|
|
|
|
aggiorna_tabella();
|
|
|
|
_tras_file->close(); // Chiude il trasfer letto dalla directory della ditta
|
1998-02-18 09:44:55 +00:00
|
|
|
::remove(_trasf);
|
2000-05-05 15:25:49 +00:00
|
|
|
TFilename tab = _tras_file->path(_dittaric);
|
|
|
|
TFilename tabcdx = tab;
|
|
|
|
TFilename tabdbf = tab;
|
1996-03-26 09:48:18 +00:00
|
|
|
tabcdx << "\\ttab.cdx";
|
|
|
|
tabdbf << "\\ttab.dbf";
|
1998-02-18 09:44:55 +00:00
|
|
|
::remove(tabcdx);
|
|
|
|
::remove(tabdbf);
|
1996-06-24 16:51:49 +00:00
|
|
|
}
|
1996-03-26 09:48:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
if (_scelta == 'P')
|
|
|
|
{
|
1998-03-16 13:51:30 +00:00
|
|
|
TMask maskera("cg6400b");
|
|
|
|
TMask* msk = &maskera;
|
1996-03-26 09:48:18 +00:00
|
|
|
|
1998-03-16 13:51:30 +00:00
|
|
|
KEY tasto = msk->run();
|
1996-03-26 09:48:18 +00:00
|
|
|
|
|
|
|
if (tasto == K_ENTER)
|
|
|
|
{
|
|
|
|
componi_path(msk);
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (_disketto)
|
|
|
|
{
|
1996-06-24 16:51:49 +00:00
|
|
|
char drive = msk->get(F_DRIVE)[0];
|
2003-04-08 12:45:26 +00:00
|
|
|
if (yesno_box(FR("Inserire il dischetto %d nell' unita' %c"), _numdisk,drive))
|
1996-03-26 09:48:18 +00:00
|
|
|
{
|
|
|
|
if (!leggi_marker_rep())
|
1998-03-16 13:51:30 +00:00
|
|
|
return;
|
1996-03-26 09:48:18 +00:00
|
|
|
|
|
|
|
if (_sequenza)
|
|
|
|
{
|
|
|
|
if (video_ripartenza())
|
|
|
|
ripristina_trasfer();
|
|
|
|
else
|
1998-03-16 13:51:30 +00:00
|
|
|
return;
|
1996-03-26 09:48:18 +00:00
|
|
|
_numdisk++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
1998-03-16 13:51:30 +00:00
|
|
|
return;
|
1996-03-26 09:48:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!leggi_marker_rep())
|
1998-03-16 13:51:30 +00:00
|
|
|
return;
|
1996-03-26 09:48:18 +00:00
|
|
|
|
|
|
|
if (_sequenza)
|
|
|
|
{
|
|
|
|
if (video_ripartenza())
|
|
|
|
ripristina_trasfer();
|
|
|
|
else
|
1998-03-16 13:51:30 +00:00
|
|
|
return;
|
1996-03-26 09:48:18 +00:00
|
|
|
_numdisk++;
|
|
|
|
}
|
|
|
|
else
|
1998-03-16 13:51:30 +00:00
|
|
|
return;
|
1996-03-26 09:48:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
while (_numdisk <= _numtotdisk);
|
|
|
|
|
|
|
|
trasfer2tempfile();
|
|
|
|
set_flag();
|
|
|
|
aggiorna_tabella();
|
|
|
|
_tras_file->close(); // Chiude il trasfer letto dalla directory della ditta
|
1998-02-18 09:44:55 +00:00
|
|
|
::remove(_trasf);
|
1996-03-26 09:48:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TRic_archivi::leggi_trasfer(const char* nome)
|
|
|
|
{
|
|
|
|
_nultras = 0;
|
|
|
|
|
|
|
|
_trasf = _tras_file->path(_dittaric);
|
|
|
|
_trasf << nome;
|
|
|
|
|
|
|
|
_tras_file->open(_trasf);
|
|
|
|
|
|
|
|
if (_tras_file->exist())
|
|
|
|
{
|
|
|
|
if (_scelta == 'S')
|
|
|
|
{
|
|
|
|
if (_tras_file->read_control_rec_t())
|
|
|
|
{
|
|
|
|
_nultras = _tras_file->nultras();
|
|
|
|
_dataultras = _tras_file->dataultras();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (_scelta == 'P')
|
|
|
|
{
|
|
|
|
if (_tras_file->read_control_rec())
|
|
|
|
{
|
|
|
|
_nultras = _tras_file->nultras();
|
|
|
|
_dataultras = _tras_file->dataultras();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Questa funzione ritorna:
|
|
|
|
// - 0 se non vengono rilevate condizioni di ripartenza o di trasferimento
|
|
|
|
// non completato.
|
|
|
|
// - 1 se viene rilevato uno stato di RIPARTENZA CON DATI CONTRADDITORI
|
|
|
|
// - 2 se viene rilevato un trasferimento precedente NON COMPLETATO
|
|
|
|
|
|
|
|
int TRic_archivi::controllo_ripartenza()
|
|
|
|
{
|
|
|
|
TString std;
|
|
|
|
bool flag = FALSE;
|
|
|
|
int var = 0;
|
|
|
|
|
1996-09-04 15:32:23 +00:00
|
|
|
set_firm(_dittaric);
|
|
|
|
|
1996-03-26 09:48:18 +00:00
|
|
|
TString trasfer;
|
|
|
|
trasfer = _tras_file->path(_dittaric);
|
|
|
|
trasfer << HEADER;
|
|
|
|
|
|
|
|
_tras_file->open(trasfer);
|
|
|
|
|
|
|
|
TConfig conf(CONFIG_DITTA);
|
|
|
|
std = conf.get("FlStTra");
|
|
|
|
|
|
|
|
if (_tras_file->read_control_rec())
|
|
|
|
flag = TRUE;
|
|
|
|
|
|
|
|
if (std == "" && flag)
|
|
|
|
var = 1;
|
|
|
|
|
|
|
|
if (std == "*" && flag)
|
|
|
|
{
|
|
|
|
TString ult_file = _tras_file->ult_file();
|
|
|
|
TString key = _tras_file->key();
|
|
|
|
if (ult_file != "" || key != "")
|
|
|
|
var = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (std != "" && std != "*")
|
|
|
|
var = 2;
|
|
|
|
|
|
|
|
_tras_file->close();
|
|
|
|
|
|
|
|
return var;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TRic_archivi::ripartenza()
|
|
|
|
{
|
|
|
|
if (_stato_ripartenza == 1)
|
2003-04-08 12:45:26 +00:00
|
|
|
return error_box(TR("Rilevato stato di RIPARTENZA CON DATI CONTRADDITORI: procedura interrotta"));
|
1996-03-26 09:48:18 +00:00
|
|
|
|
|
|
|
if (_stato_ripartenza == 2)
|
2003-04-08 12:45:26 +00:00
|
|
|
return error_box(TR("Trasferimento precedente NON COMPLETATO: completarlo prima di questo"));
|
1996-03-26 09:48:18 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TRic_archivi::video_ripartenza()
|
|
|
|
{
|
|
|
|
TDate dataultras;
|
|
|
|
|
|
|
|
if (_prima_volta)
|
|
|
|
{
|
|
|
|
leggi_trasfer("\\trasfer");
|
|
|
|
|
|
|
|
_prima_volta = FALSE;
|
1998-03-16 13:51:30 +00:00
|
|
|
|
|
|
|
TMask maskera("cg6400a");
|
|
|
|
TMask* msk = &maskera;
|
|
|
|
|
1996-03-26 09:48:18 +00:00
|
|
|
KEY tasto;
|
|
|
|
|
|
|
|
ditta_ricevente();
|
|
|
|
_stato_ripartenza = controllo_ripartenza();
|
|
|
|
|
1996-06-24 16:51:49 +00:00
|
|
|
msk->set(F_NOMEID, _nomeid);
|
|
|
|
msk->set(F_CODDITTAINV, _dittainv);
|
|
|
|
msk->set(F_CODDITTARIC, _dittaric);
|
|
|
|
msk->set(F_RAGSOC, _ragsoc_dittar);
|
|
|
|
msk->set(F_NULTRASDSK, _numinv);
|
1996-03-26 09:48:18 +00:00
|
|
|
TString data1 = _datatras.string();
|
1996-06-24 16:51:49 +00:00
|
|
|
msk->set(F_DATAULTRASDSK, data1);
|
1996-03-26 09:48:18 +00:00
|
|
|
|
|
|
|
if (_nultras != 0)
|
|
|
|
{
|
1996-06-24 16:51:49 +00:00
|
|
|
msk->set(F_NULTRASTAB, _nultras);
|
1996-03-26 09:48:18 +00:00
|
|
|
TString data2 = _dataultras.string();
|
1996-06-24 16:51:49 +00:00
|
|
|
msk->set(F_DATAULTRASTAB, data2);
|
1996-03-26 09:48:18 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1996-06-24 16:51:49 +00:00
|
|
|
msk->set(F_NULTRASTAB, _nultras_tab);
|
1996-03-26 09:48:18 +00:00
|
|
|
TString data2 = _dataultras_tab.string();
|
1996-06-24 16:51:49 +00:00
|
|
|
msk->set(F_DATAULTRASTAB, data2);
|
1996-03-26 09:48:18 +00:00
|
|
|
}
|
|
|
|
|
1998-03-16 13:51:30 +00:00
|
|
|
if (_stato_ripartenza == 0)
|
|
|
|
msk->set(F_STATO, "COMPLETO");
|
1996-03-26 09:48:18 +00:00
|
|
|
else
|
1998-03-16 13:51:30 +00:00
|
|
|
msk->set(F_STATO, "NON COMPLETO");
|
1996-03-26 09:48:18 +00:00
|
|
|
|
|
|
|
if (_numdisk == 1) // Va fatto solo per il primo disco
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
1996-06-24 16:51:49 +00:00
|
|
|
msk->set_handler(baipassa);
|
1996-03-26 09:48:18 +00:00
|
|
|
|
1996-06-24 16:51:49 +00:00
|
|
|
tasto = msk->run();
|
1996-03-26 09:48:18 +00:00
|
|
|
|
|
|
|
if (tasto != K_ENTER)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (_baipassa)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
if (!ripartenza())
|
1996-06-24 16:51:49 +00:00
|
|
|
return FALSE;
|
1996-03-26 09:48:18 +00:00
|
|
|
|
|
|
|
if (_numinv > (_nultras_tab + 1))
|
2003-04-08 12:45:26 +00:00
|
|
|
warning_box(FR("Trasferimento FUORI SEQUENZA: manca un trasferimento intermedio.\n"
|
|
|
|
"Numero invio n. %d, ultimo trasferimento n. %d."), _numinv, _nultras_tab);
|
1996-03-26 09:48:18 +00:00
|
|
|
else
|
|
|
|
if (_numinv < (_nultras_tab +1))
|
2003-04-08 12:45:26 +00:00
|
|
|
warning_box(FR("I dischetti risultano GIA' TRASFERITI.\n"
|
|
|
|
"Numero invio n. %d, ultimo trasferimento n. %d."), _numinv, _nultras_tab);
|
1996-03-26 09:48:18 +00:00
|
|
|
else
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
while (tasto == K_ENTER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TRic_archivi::baipassa(TMask& m,KEY k)
|
|
|
|
{
|
|
|
|
if ( (k == K_SHIFT+K_F7) && (app()._stato_ripartenza == 0) )
|
|
|
|
app()._baipassa = TRUE;
|
2003-02-25 14:39:02 +00:00
|
|
|
|
1996-10-31 16:59:54 +00:00
|
|
|
return TRUE;
|
1996-03-26 09:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TRic_archivi::ripristina_trasfer()
|
|
|
|
{
|
2003-04-08 12:45:26 +00:00
|
|
|
TProgind prg (1,TR("Trasferimento archivi in corso\nPrego attendere"),FALSE, FALSE);
|
1996-03-26 09:48:18 +00:00
|
|
|
|
|
|
|
if (_numdisk == 1)
|
|
|
|
{
|
1996-09-04 15:32:23 +00:00
|
|
|
// set_firm(_dittaric);
|
1996-03-26 09:48:18 +00:00
|
|
|
fcopy(_trasfer,_trasf,FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
fcopy(_trasfer,_trasf,TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TRic_archivi::trasfer2tempfile()
|
|
|
|
{
|
|
|
|
_trasfhard = _tras_file->path(_dittaric);
|
|
|
|
_trasfhard << HEADER;
|
2001-05-01 08:17:07 +00:00
|
|
|
switch (_scelta)
|
|
|
|
{
|
|
|
|
case 'S': _tras_file->fcopytemp(_trasf,_trasfhard); break;
|
|
|
|
case 'P': _tras_file->fcopytemp_PC(_trasf,_trasfhard); break;
|
|
|
|
default: break;
|
|
|
|
}
|
1996-03-26 09:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TRic_archivi::ditta_ricevente()
|
|
|
|
{
|
2001-05-01 08:17:07 +00:00
|
|
|
_ragsoc_dittar = cache().get(LF_NDITTE, _dittaric).get(NDT_RAGSOC);
|
1996-03-26 09:48:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
long TRic_archivi::leggi_tabella_tras()
|
|
|
|
{
|
1997-06-20 08:52:24 +00:00
|
|
|
TString dep(16);
|
1996-03-26 09:48:18 +00:00
|
|
|
long ditta = 0;
|
|
|
|
bool agg_fatatt,agg_fatpas;
|
|
|
|
|
1996-09-02 10:22:15 +00:00
|
|
|
TTable tab_tra ("%TRA");
|
|
|
|
|
|
|
|
tab_tra.zero();
|
1997-06-20 08:52:24 +00:00
|
|
|
dep.format("%10s%05ld", (const char*) _nomeid, _dittainv);
|
2001-05-01 08:17:07 +00:00
|
|
|
tab_tra.put("CODTAB", dep);
|
1996-09-02 10:22:15 +00:00
|
|
|
if (tab_tra.read() == NOERR)
|
1996-03-26 09:48:18 +00:00
|
|
|
{
|
1996-09-02 10:22:15 +00:00
|
|
|
ditta = tab_tra.get_long("I0");
|
|
|
|
_nultras_tab = tab_tra.get_int ("I1");
|
|
|
|
_dataultras_tab = tab_tra.get_date("D0");
|
|
|
|
_agg_cau = tab_tra.get_char("S0");
|
|
|
|
_agg_clifo = tab_tra.get_char("S1");
|
|
|
|
_agg_pcon = tab_tra.get_char("S2");
|
|
|
|
_agg_cls = tab_tra.get_char("S3");
|
|
|
|
agg_fatatt = tab_tra.get_bool("B0");
|
1996-03-26 09:48:18 +00:00
|
|
|
if (agg_fatatt)
|
|
|
|
_agg_fatatt = 'X';
|
|
|
|
else
|
|
|
|
_agg_fatatt = ' ';
|
|
|
|
|
1996-09-02 10:22:15 +00:00
|
|
|
agg_fatpas = tab_tra.get_bool("B1");
|
1996-03-26 09:48:18 +00:00
|
|
|
if (agg_fatpas)
|
|
|
|
_agg_fatpas = 'X';
|
|
|
|
else
|
|
|
|
_agg_fatpas = ' ';
|
|
|
|
}
|
|
|
|
|
|
|
|
return ditta;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TRic_archivi::set_flag()
|
|
|
|
{
|
|
|
|
TString sigla;
|
|
|
|
long nrec;
|
|
|
|
int j;
|
|
|
|
int k = 0;
|
|
|
|
TString flag;
|
|
|
|
TString record;
|
|
|
|
TString ana_com,pcon_cau;
|
|
|
|
TString uselab;
|
|
|
|
bool fatto = TRUE;
|
|
|
|
|
|
|
|
TConfig conf(CONFIG_DITTA);
|
|
|
|
|
|
|
|
ana_com = conf.get("AnCfCm","cg");
|
|
|
|
pcon_cau = conf.get("PcTcCm","cg");
|
|
|
|
|
|
|
|
_tras_file->open(_trasfhard);
|
|
|
|
|
|
|
|
if (_tras_file->exist())
|
|
|
|
{
|
|
|
|
if (_tras_file->read_control_rec())
|
|
|
|
{
|
|
|
|
_nultras = _tras_file->nultras();
|
|
|
|
_dataultras = _tras_file->dataultras();
|
|
|
|
_sigle_file = _tras_file->sigle_file();
|
|
|
|
_nrec_file = _tras_file->nrec_file();
|
|
|
|
record = _tras_file->record();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (j = 0; j < _sigle_file.len(); j++)
|
|
|
|
{
|
|
|
|
sigla = _sigle_file.mid(j,1);
|
|
|
|
nrec = atol(_nrec_file.mid(k,6));
|
|
|
|
|
|
|
|
if (fatto)
|
|
|
|
{
|
|
|
|
if (sigla == "W" || sigla == "P")
|
|
|
|
{
|
|
|
|
if (nrec > 0 && pcon_cau == "")
|
|
|
|
{
|
|
|
|
flag = "T";
|
|
|
|
fatto = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (sigla == "A")
|
|
|
|
{
|
|
|
|
if (nrec > 0 && ana_com == "")
|
|
|
|
{
|
|
|
|
flag = "T";
|
|
|
|
fatto = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (sigla == "Z" || sigla == "U" || sigla == "B")
|
|
|
|
{
|
|
|
|
if (nrec > 0)
|
|
|
|
{
|
|
|
|
flag = "C";
|
|
|
|
fatto = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
flag = "*";
|
|
|
|
fatto = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flag == "T")
|
|
|
|
uselab = sigla;
|
|
|
|
else
|
|
|
|
uselab = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sigla == "W" || sigla == "P")
|
|
|
|
{
|
|
|
|
if (pcon_cau == "X")
|
|
|
|
{
|
|
|
|
_sigle_file.overwrite(" ",j);
|
|
|
|
_nrec_file.overwrite("000000",k);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sigla == "A")
|
|
|
|
{
|
|
|
|
if (ana_com == "X")
|
|
|
|
{
|
|
|
|
_sigle_file.overwrite(" ",j);
|
|
|
|
_nrec_file.overwrite("000000",k);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
k += 6;
|
|
|
|
}
|
|
|
|
|
|
|
|
record.overwrite(_sigle_file,86);
|
|
|
|
record.overwrite(_nrec_file,95);
|
|
|
|
|
|
|
|
TString agg(7);
|
|
|
|
|
|
|
|
agg[0] = _agg_cls;
|
|
|
|
agg[1] = _agg_cau;
|
|
|
|
agg[2] = _agg_clifo;
|
|
|
|
agg[3] = _agg_pcon;
|
|
|
|
agg[4] = _agg_fatatt;
|
|
|
|
agg[5] = _agg_fatpas;
|
|
|
|
agg[6] = '\0';
|
|
|
|
|
|
|
|
record.overwrite(agg,234);
|
|
|
|
record.overwrite(uselab,240);
|
|
|
|
TString str;
|
|
|
|
str.spaces(60);
|
|
|
|
record.overwrite(str,241);
|
|
|
|
|
|
|
|
const int size = 1024;
|
|
|
|
|
|
|
|
if (!_tras_file->write_control_rec(record, size))
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
conf.set("FlStTra", flag);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TRic_archivi::aggiorna_tabella()
|
|
|
|
{
|
2001-05-01 08:17:07 +00:00
|
|
|
TTable tab_tra("%TRA");
|
|
|
|
TString16 dep;
|
1997-06-20 08:52:24 +00:00
|
|
|
dep.format("%10s%05ld", (const char*) _nomeid, _dittainv);
|
2001-05-01 08:17:07 +00:00
|
|
|
tab_tra.put("CODTAB", dep);
|
1996-09-02 10:22:15 +00:00
|
|
|
if (tab_tra.read() == NOERR)
|
1996-03-26 09:48:18 +00:00
|
|
|
{
|
1996-09-02 10:22:15 +00:00
|
|
|
tab_tra.put("I1", (long)_nultras);
|
|
|
|
tab_tra.put("D0", _dataultras);
|
|
|
|
tab_tra.rewrite();
|
1996-03-26 09:48:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int cg6400 (int argc, char* argv[])
|
|
|
|
{
|
|
|
|
char p3 = '\0';
|
|
|
|
|
|
|
|
if (argc > 4)
|
|
|
|
p3 = *argv[3];
|
|
|
|
|
1996-06-24 16:51:49 +00:00
|
|
|
TRic_archivi* main_app = new TRic_archivi(*argv[2],p3);
|
|
|
|
main_app->run(argc, argv,main_app->_titolo);
|
|
|
|
delete main_app;
|
1996-03-26 09:48:18 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|