Aggiunta la funzione di ripristino documenti.
git-svn-id: svn://10.65.10.50/trunk@3539 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
aa45f91009
commit
615ddcc124
135
ve/ve5100.cpp
135
ve/ve5100.cpp
@ -21,16 +21,18 @@ class TDeletedoc_app : public TApplication
|
|||||||
char _unit;
|
char _unit;
|
||||||
TFilename _tmp_dir;
|
TFilename _tmp_dir;
|
||||||
TIsamtempfile *_tdoc,*_trdoc;
|
TIsamtempfile *_tdoc,*_trdoc;
|
||||||
TLocalisamfile *_doc,*_rdoc;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void backup_delete_doc(); // Backup e cancellazione dei documenti da eliminare
|
void backup_delete_doc(); // Backup e cancellazione dei documenti da eliminare
|
||||||
|
void restore_doc(); // Ripristino documenti da disco
|
||||||
void create_tmp_files(bool create=TRUE);
|
void create_tmp_files(bool create=TRUE);
|
||||||
void delete_tmp_files(bool remove=TRUE);
|
void delete_tmp_files(bool remove=TRUE);
|
||||||
virtual bool create();
|
virtual bool create();
|
||||||
virtual bool destroy();
|
virtual bool destroy();
|
||||||
virtual bool menu(MENU_TAG m);
|
virtual bool menu(MENU_TAG m);
|
||||||
|
|
||||||
|
static bool state_handler(TMask& m, KEY k);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -38,44 +40,55 @@ public:
|
|||||||
~TDeletedoc_app() {};
|
~TDeletedoc_app() {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool TDeletedoc_app::state_handler(TMask& m, KEY k)
|
||||||
|
{
|
||||||
|
if (k == K_SHIFT + K_F7)
|
||||||
|
m.enable(F_STATUS);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
void TDeletedoc_app::backup_delete_doc()
|
void TDeletedoc_app::backup_delete_doc()
|
||||||
{
|
{
|
||||||
TRecnotype total = 0;
|
TRecnotype total = 0;
|
||||||
TDocumento doc;
|
TDocumento documento;
|
||||||
int err;
|
|
||||||
|
|
||||||
err = _doc->lock();
|
TIsamfile doc(LF_DOC,FALSE);
|
||||||
|
TLocalisamfile rdoc(LF_RIGHEDOC);
|
||||||
|
|
||||||
|
doc.open();
|
||||||
|
int err = doc.lock();
|
||||||
if (err != NOERR)
|
if (err != NOERR)
|
||||||
{
|
{
|
||||||
error_box("Il file partite non puo' essere bloccato in modo esclusivo."
|
error_box("Il file documenti non puo' essere bloccato in modo esclusivo."
|
||||||
" Nessuna partita cancellata. Errore %d.",err);
|
" Nessun documento cancellato. Errore %d.",err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
create_tmp_files();
|
create_tmp_files();
|
||||||
_doc->zero();
|
doc.zero();
|
||||||
// Scorre il file dei documenti
|
// Scorre il file dei documenti
|
||||||
{
|
{
|
||||||
TProgind p(10, "Ricerca e copia dei documenti da eliminare...", TRUE, FALSE, 10);
|
TProgind p(10, "Ricerca e copia dei documenti da eliminare...", TRUE, FALSE, 10);
|
||||||
for (_doc->first();_doc->good() && !p.iscancelled();_doc->read(_isgreat))
|
for (doc.first();doc.good() && !p.iscancelled();doc.read(_isgreat))
|
||||||
{
|
{
|
||||||
doc.read(_doc->curr());
|
documento.read(doc.curr());
|
||||||
bool to_delete = TRUE;
|
bool to_delete = TRUE;
|
||||||
|
|
||||||
if (_doc->get("STATO") != _last_std) to_delete = FALSE;
|
if (doc.get("STATO") != _last_std) to_delete = FALSE;
|
||||||
|
|
||||||
if (to_delete && !p.iscancelled()) // Se TRUE il puo' essere eliminato!
|
if (to_delete && !p.iscancelled()) // Se TRUE il puo' essere eliminato!
|
||||||
{ // Memorizza la chiave 1 del documento in un array
|
{ // Memorizza la chiave 1 del documento in un array
|
||||||
TToken_string id(30);
|
TToken_string id(30);
|
||||||
id = _doc->get("PROVV");
|
id = doc.get("PROVV");
|
||||||
id.add(_doc->get("ANNO"));
|
id.add(doc.get("ANNO"));
|
||||||
id.add(_doc->get("CODNUM"));
|
id.add(doc.get("CODNUM"));
|
||||||
id.add(_doc->get("NDOC"));
|
id.add(doc.get("NDOC"));
|
||||||
_to_zap.add(id);
|
_to_zap.add(id);
|
||||||
err = _tdoc->write(_doc->curr());
|
err = _tdoc->write(doc.curr());
|
||||||
const int rows = doc.rows();
|
const int rows = documento.rows();
|
||||||
// Memorizza le righe del documento sui file temporanei
|
// Memorizza le righe del documento sui file temporanei
|
||||||
for (int x=1;err==NOERR && x<=rows;x++)
|
for (int x=1;err==NOERR && x<=rows;x++)
|
||||||
err=_trdoc->write(doc[x]);
|
err=_trdoc->write(documento[x]);
|
||||||
total++;
|
total++;
|
||||||
}
|
}
|
||||||
} // end of for
|
} // end of for
|
||||||
@ -96,27 +109,76 @@ void TDeletedoc_app::backup_delete_doc()
|
|||||||
caption.add_plural(total, "documento");
|
caption.add_plural(total, "documento");
|
||||||
if (!yesno_box(caption))
|
if (!yesno_box(caption))
|
||||||
_to_zap.destroy();
|
_to_zap.destroy();
|
||||||
TProgind pi(total, caption, FALSE, TRUE, 10);
|
else
|
||||||
const int items = _to_zap.items();
|
{
|
||||||
for (int i = 0; i < items; i++)
|
TProgind pi(total, caption, FALSE, TRUE, 10);
|
||||||
{
|
const int items = _to_zap.items();
|
||||||
TToken_string& id = (TToken_string&)_to_zap[i];
|
for (int i = 0; i < items; i++)
|
||||||
id.restart();
|
{
|
||||||
const char provv = id.get_char();
|
TToken_string& id = (TToken_string&)_to_zap[i];
|
||||||
const int anno = id.get_int();
|
id.restart();
|
||||||
const TString16 codnum = id.get();
|
const char provv = id.get_char();
|
||||||
const long numdoc = id.get_int();
|
const int anno = id.get_int();
|
||||||
doc.read(provv,anno,codnum,numdoc);
|
const TString16 codnum = id.get();
|
||||||
doc.remove();
|
const long numdoc = id.get_int();
|
||||||
pi.addstatus(1);
|
documento.read(provv,anno,codnum,numdoc);
|
||||||
}
|
documento.remove();
|
||||||
|
pi.addstatus(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
error_box("Errore %d scrivendo sui files temporanei."
|
error_box("Errore %d scrivendo sui files temporanei."
|
||||||
" La cancellazione dei documenti chiuse non verra' effettuata.",err);
|
" La cancellazione dei documenti chiuse non verra' effettuata.",err);
|
||||||
delete_tmp_files(); // Physical remove of tmp files
|
delete_tmp_files(); // Physical remove of tmp files
|
||||||
_doc->unlock();
|
doc.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TDeletedoc_app::restore_doc()
|
||||||
|
{
|
||||||
|
TIsamfile doc(LF_DOC,FALSE);
|
||||||
|
TLocalisamfile rdoc(LF_RIGHEDOC);
|
||||||
|
|
||||||
|
doc.open();
|
||||||
|
int err = doc.lock();
|
||||||
|
if (err != NOERR)
|
||||||
|
{
|
||||||
|
error_box("Il file documenti non puo' essere bloccato in modo esclusivo."
|
||||||
|
" Nessuna documento ripristinato. Errore %d.",err);
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
const char* dir =& _tmp_dir[1]; // Cut out % sign
|
||||||
|
if (_arc.restore(dir,_unit,FALSE,FALSE))
|
||||||
|
{
|
||||||
|
create_tmp_files(FALSE); // In realta' ci sono gia'
|
||||||
|
const TRecnotype items = _tdoc->items() + _trdoc->items();
|
||||||
|
TProgind pi(items, "Ripristino documenti eliminati", FALSE, TRUE, 10);
|
||||||
|
|
||||||
|
for (_tdoc->first();_tdoc->good() && err==NOERR;_tdoc->next())
|
||||||
|
{
|
||||||
|
if ((err=doc.write(_tdoc->curr())) == _isreinsert)
|
||||||
|
err=doc.rewrite(_tdoc->curr());
|
||||||
|
pi.addstatus(1);
|
||||||
|
}
|
||||||
|
if (err != NOERR)
|
||||||
|
error_box("Errore %d ripristinando il file DOCUMENTI.",err);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (_trdoc->first();_trdoc->good() && err==NOERR;_trdoc->next())
|
||||||
|
{
|
||||||
|
if ((err=rdoc.write(_trdoc->curr())) == _isreinsert)
|
||||||
|
err=rdoc.rewrite(_trdoc->curr());
|
||||||
|
pi.addstatus(1);
|
||||||
|
}
|
||||||
|
if (err != NOERR)
|
||||||
|
error_box("Errore %d ripristinando il file RIGHE DOCUMENTI.",err);
|
||||||
|
}
|
||||||
|
delete_tmp_files(); // Removes tmp files!
|
||||||
|
}
|
||||||
|
else
|
||||||
|
error_box("Errore nel ripristino dei file da dischetto. Nessuna documento ripristinato.");
|
||||||
|
doc.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TDeletedoc_app::create_tmp_files(bool create)
|
void TDeletedoc_app::create_tmp_files(bool create)
|
||||||
@ -147,8 +209,6 @@ bool TDeletedoc_app::create()
|
|||||||
_tmp_dir << "VE";
|
_tmp_dir << "VE";
|
||||||
if (!fexist(_tmp_dir)) make_dir(_tmp_dir);
|
if (!fexist(_tmp_dir)) make_dir(_tmp_dir);
|
||||||
_tmp_dir.insert("%"); // Add % sign
|
_tmp_dir.insert("%"); // Add % sign
|
||||||
_doc = new TLocalisamfile(LF_DOC);
|
|
||||||
_rdoc = new TLocalisamfile(LF_RIGHEDOC);
|
|
||||||
dispatch_e_menu(BAR_ITEM(1));
|
dispatch_e_menu(BAR_ITEM(1));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -157,8 +217,6 @@ bool TDeletedoc_app::destroy()
|
|||||||
{
|
{
|
||||||
_tmp_dir=_tmp_dir.sub(1); // Cut out % sign
|
_tmp_dir=_tmp_dir.sub(1); // Cut out % sign
|
||||||
if (fexist(_tmp_dir)) rmdir(_tmp_dir);
|
if (fexist(_tmp_dir)) rmdir(_tmp_dir);
|
||||||
delete _doc;
|
|
||||||
delete _rdoc;
|
|
||||||
return TApplication::destroy();
|
return TApplication::destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,12 +232,17 @@ bool TDeletedoc_app::menu(MENU_TAG)
|
|||||||
|
|
||||||
m.set(F_STATUS,_last_std);
|
m.set(F_STATUS,_last_std);
|
||||||
m.set(F_STADESC,std.get("S0"));
|
m.set(F_STADESC,std.get("S0"));
|
||||||
|
m.set_handler(state_handler);
|
||||||
|
|
||||||
while (m.run() != K_QUIT)
|
while (m.run() != K_QUIT)
|
||||||
{
|
{
|
||||||
_unit = m.get(F_UNIT)[0];
|
_unit = m.get(F_UNIT)[0];
|
||||||
_desc = m.get(F_DESC);
|
_desc = m.get(F_DESC);
|
||||||
|
const int scelta = m.get_int(F_OPERAZIONE);
|
||||||
|
if (scelta == 1)
|
||||||
backup_delete_doc();
|
backup_delete_doc();
|
||||||
|
else
|
||||||
|
restore_doc();
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -3,5 +3,5 @@
|
|||||||
#define F_DESC 102
|
#define F_DESC 102
|
||||||
#define F_UNIT 103
|
#define F_UNIT 103
|
||||||
#define F_STADESC 104
|
#define F_STADESC 104
|
||||||
|
#define F_OPERAZIONE 105
|
||||||
|
|
||||||
|
@ -1,29 +1,48 @@
|
|||||||
#include "ve5100a.h"
|
#include "ve5100a.h"
|
||||||
|
|
||||||
PAGE "Eliminazione documenti" -1 -1 60 8
|
PAGE "Eliminazione documenti" -1 -1 62 11
|
||||||
|
|
||||||
|
RADIOBUTTON F_OPERAZIONE 28
|
||||||
|
BEGIN
|
||||||
|
PROMPT 1 1 "Operazione da eseguire"
|
||||||
|
ITEM "1|Eliminazione documenti"
|
||||||
|
MESSAGE ENABLE,F_DESC
|
||||||
|
ITEM "2|Ripristino documenti"
|
||||||
|
MESSAGE DISABLE,F_DESC
|
||||||
|
HELP "Scegli l'operazione da eseguire"
|
||||||
|
END
|
||||||
|
|
||||||
|
|
||||||
STRING F_STATUS 1
|
STRING F_STATUS 1
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 2 2 "Stato eliminabile "
|
PROMPT 2 5 "Stato eliminabile "
|
||||||
|
USE %STD
|
||||||
|
INPUT CODTAB F_STATUS
|
||||||
|
DISPLAY "Stato documento" CODTAB
|
||||||
|
DISPLAY "Descrizione@50" S0
|
||||||
|
OUTPUT F_STATUS CODTAB
|
||||||
|
OUTPUT F_STADESC S0
|
||||||
|
CHECKTYPE REQUIRED
|
||||||
|
WARNING "Stato documento obbligatorio"
|
||||||
FLAGS "D"
|
FLAGS "D"
|
||||||
END
|
END
|
||||||
|
|
||||||
STRING F_STADESC 32
|
STRING F_STADESC 32
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 26 2 ""
|
PROMPT 27 5 ""
|
||||||
FLAGS "D"
|
FLAGS "D"
|
||||||
END
|
END
|
||||||
|
|
||||||
LIST F_UNIT 2
|
LIST F_UNIT 2
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 2 3 "Unita' di backup "
|
PROMPT 2 6 "Unita' di backup "
|
||||||
ITEM "A|A:"
|
ITEM "A|A:"
|
||||||
ITEM "B|B:"
|
ITEM "B|B:"
|
||||||
END
|
END
|
||||||
|
|
||||||
STRING F_DESC 50 35
|
STRING F_DESC 50 36
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 2 4 "Descrizione backup "
|
PROMPT 2 7 "Descrizione backup "
|
||||||
GROUP 1
|
GROUP 1
|
||||||
END
|
END
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user