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;
|
||||
TFilename _tmp_dir;
|
||||
TIsamtempfile *_tdoc,*_trdoc;
|
||||
TLocalisamfile *_doc,*_rdoc;
|
||||
|
||||
protected:
|
||||
|
||||
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 delete_tmp_files(bool remove=TRUE);
|
||||
virtual bool create();
|
||||
virtual bool destroy();
|
||||
virtual bool menu(MENU_TAG m);
|
||||
|
||||
static bool state_handler(TMask& m, KEY k);
|
||||
|
||||
public:
|
||||
|
||||
@ -38,44 +40,55 @@ public:
|
||||
~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()
|
||||
{
|
||||
TRecnotype total = 0;
|
||||
TDocumento doc;
|
||||
int err;
|
||||
TDocumento documento;
|
||||
|
||||
err = _doc->lock();
|
||||
TIsamfile doc(LF_DOC,FALSE);
|
||||
TLocalisamfile rdoc(LF_RIGHEDOC);
|
||||
|
||||
doc.open();
|
||||
int err = doc.lock();
|
||||
if (err != NOERR)
|
||||
{
|
||||
error_box("Il file partite non puo' essere bloccato in modo esclusivo."
|
||||
" Nessuna partita cancellata. Errore %d.",err);
|
||||
error_box("Il file documenti non puo' essere bloccato in modo esclusivo."
|
||||
" Nessun documento cancellato. Errore %d.",err);
|
||||
return;
|
||||
}
|
||||
create_tmp_files();
|
||||
_doc->zero();
|
||||
doc.zero();
|
||||
// Scorre il file dei documenti
|
||||
{
|
||||
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;
|
||||
|
||||
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!
|
||||
{ // Memorizza la chiave 1 del documento in un array
|
||||
TToken_string id(30);
|
||||
id = _doc->get("PROVV");
|
||||
id.add(_doc->get("ANNO"));
|
||||
id.add(_doc->get("CODNUM"));
|
||||
id.add(_doc->get("NDOC"));
|
||||
id = doc.get("PROVV");
|
||||
id.add(doc.get("ANNO"));
|
||||
id.add(doc.get("CODNUM"));
|
||||
id.add(doc.get("NDOC"));
|
||||
_to_zap.add(id);
|
||||
err = _tdoc->write(_doc->curr());
|
||||
const int rows = doc.rows();
|
||||
err = _tdoc->write(doc.curr());
|
||||
const int rows = documento.rows();
|
||||
// Memorizza le righe del documento sui file temporanei
|
||||
for (int x=1;err==NOERR && x<=rows;x++)
|
||||
err=_trdoc->write(doc[x]);
|
||||
err=_trdoc->write(documento[x]);
|
||||
total++;
|
||||
}
|
||||
} // end of for
|
||||
@ -96,27 +109,76 @@ void TDeletedoc_app::backup_delete_doc()
|
||||
caption.add_plural(total, "documento");
|
||||
if (!yesno_box(caption))
|
||||
_to_zap.destroy();
|
||||
TProgind pi(total, caption, FALSE, TRUE, 10);
|
||||
const int items = _to_zap.items();
|
||||
for (int i = 0; i < items; i++)
|
||||
{
|
||||
TToken_string& id = (TToken_string&)_to_zap[i];
|
||||
id.restart();
|
||||
const char provv = id.get_char();
|
||||
const int anno = id.get_int();
|
||||
const TString16 codnum = id.get();
|
||||
const long numdoc = id.get_int();
|
||||
doc.read(provv,anno,codnum,numdoc);
|
||||
doc.remove();
|
||||
pi.addstatus(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
TProgind pi(total, caption, FALSE, TRUE, 10);
|
||||
const int items = _to_zap.items();
|
||||
for (int i = 0; i < items; i++)
|
||||
{
|
||||
TToken_string& id = (TToken_string&)_to_zap[i];
|
||||
id.restart();
|
||||
const char provv = id.get_char();
|
||||
const int anno = id.get_int();
|
||||
const TString16 codnum = id.get();
|
||||
const long numdoc = id.get_int();
|
||||
documento.read(provv,anno,codnum,numdoc);
|
||||
documento.remove();
|
||||
pi.addstatus(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
error_box("Errore %d scrivendo sui files temporanei."
|
||||
" La cancellazione dei documenti chiuse non verra' effettuata.",err);
|
||||
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)
|
||||
@ -147,8 +209,6 @@ bool TDeletedoc_app::create()
|
||||
_tmp_dir << "VE";
|
||||
if (!fexist(_tmp_dir)) make_dir(_tmp_dir);
|
||||
_tmp_dir.insert("%"); // Add % sign
|
||||
_doc = new TLocalisamfile(LF_DOC);
|
||||
_rdoc = new TLocalisamfile(LF_RIGHEDOC);
|
||||
dispatch_e_menu(BAR_ITEM(1));
|
||||
return TRUE;
|
||||
}
|
||||
@ -157,8 +217,6 @@ bool TDeletedoc_app::destroy()
|
||||
{
|
||||
_tmp_dir=_tmp_dir.sub(1); // Cut out % sign
|
||||
if (fexist(_tmp_dir)) rmdir(_tmp_dir);
|
||||
delete _doc;
|
||||
delete _rdoc;
|
||||
return TApplication::destroy();
|
||||
}
|
||||
|
||||
@ -174,12 +232,17 @@ bool TDeletedoc_app::menu(MENU_TAG)
|
||||
|
||||
m.set(F_STATUS,_last_std);
|
||||
m.set(F_STADESC,std.get("S0"));
|
||||
m.set_handler(state_handler);
|
||||
|
||||
while (m.run() != K_QUIT)
|
||||
{
|
||||
_unit = m.get(F_UNIT)[0];
|
||||
_desc = m.get(F_DESC);
|
||||
const int scelta = m.get_int(F_OPERAZIONE);
|
||||
if (scelta == 1)
|
||||
backup_delete_doc();
|
||||
else
|
||||
restore_doc();
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -3,5 +3,5 @@
|
||||
#define F_DESC 102
|
||||
#define F_UNIT 103
|
||||
#define F_STADESC 104
|
||||
|
||||
#define F_OPERAZIONE 105
|
||||
|
||||
|
@ -1,29 +1,48 @@
|
||||
#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
|
||||
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"
|
||||
END
|
||||
|
||||
STRING F_STADESC 32
|
||||
BEGIN
|
||||
PROMPT 26 2 ""
|
||||
PROMPT 27 5 ""
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
LIST F_UNIT 2
|
||||
BEGIN
|
||||
PROMPT 2 3 "Unita' di backup "
|
||||
PROMPT 2 6 "Unita' di backup "
|
||||
ITEM "A|A:"
|
||||
ITEM "B|B:"
|
||||
END
|
||||
|
||||
STRING F_DESC 50 35
|
||||
STRING F_DESC 50 36
|
||||
BEGIN
|
||||
PROMPT 2 4 "Descrizione backup "
|
||||
PROMPT 2 7 "Descrizione backup "
|
||||
GROUP 1
|
||||
END
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user