Aggiunto il recovery della conversione in caso di interruzione programma.
Aggiunto display memoria libera nelle progress indicator. git-svn-id: svn://10.65.10.50/trunk@2858 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
44bc94a92c
commit
fc9258bb9e
@ -14,6 +14,11 @@
|
||||
#include <extcdecl.h>
|
||||
#include <execp.h>
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
#define STRICT
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include "ba1.h"
|
||||
#include "ba1100.h"
|
||||
|
||||
@ -29,11 +34,14 @@ struct direct
|
||||
#include <dos.h>
|
||||
#endif
|
||||
|
||||
#define History_file "conv.his"
|
||||
|
||||
class TManutenzione_app : public TApplication
|
||||
{
|
||||
TDir_sheet* _browse;
|
||||
TMask* _mask;
|
||||
long _firm;
|
||||
long _history_firm;
|
||||
TRec_sheet* _rec;
|
||||
|
||||
protected:
|
||||
@ -50,6 +58,9 @@ protected:
|
||||
virtual void print();
|
||||
virtual void do_print(TPrinter & p, TRec_sheet & r);
|
||||
const char* dumpfilename(const FileDes& dep) const;
|
||||
void open_history();
|
||||
void put_history(const char* firm);
|
||||
void close_history();
|
||||
|
||||
public:
|
||||
|
||||
@ -327,6 +338,39 @@ void TManutenzione_app::insert_riga (long riga_sel, TToken_string& riga)
|
||||
_browse->set_items(_browse->dir()->eod());
|
||||
_browse->dir()->put(LF_DIR);
|
||||
}
|
||||
}
|
||||
|
||||
void TManutenzione_app::open_history()
|
||||
{
|
||||
FILE *fp = fopen(History_file,"r");
|
||||
if (fp != NULL)
|
||||
{
|
||||
char line[16];
|
||||
fgets(line,16,fp);
|
||||
line[strlen(line) -1] = '\0';
|
||||
if (strlen(line)==0) _history_firm = -1;
|
||||
else
|
||||
_history_firm = atol(line);
|
||||
}
|
||||
else
|
||||
{
|
||||
fopen(History_file,"w");
|
||||
_history_firm = -1;
|
||||
}
|
||||
fclose (fp);
|
||||
}
|
||||
|
||||
void TManutenzione_app::put_history(const char* firm)
|
||||
{
|
||||
FILE * fp = fopen(History_file,"w");
|
||||
fprintf(fp,"%s\n",firm);
|
||||
fclose (fp);
|
||||
}
|
||||
|
||||
void TManutenzione_app::close_history()
|
||||
{
|
||||
// Se la conversione non ha rilevato errori rimuove il file di history.
|
||||
remove(History_file);
|
||||
}
|
||||
|
||||
const char* TManutenzione_app::dumpfilename(const FileDes& dep) const
|
||||
@ -515,10 +559,14 @@ void TManutenzione_app::update_dir()
|
||||
{
|
||||
const TString pref(prefix().name());
|
||||
const bool is_com = prefix().is_com();
|
||||
TString desc(256), s(256);
|
||||
|
||||
if (prefix().get_codditta() <= _history_firm)
|
||||
return;
|
||||
|
||||
prefix().set("");
|
||||
|
||||
|
||||
TString desc(256), s(256);
|
||||
TDir d;
|
||||
d.get(LF_DIR);
|
||||
const int orig_items = (int)d.eod();
|
||||
@ -530,7 +578,10 @@ void TManutenzione_app::update_dir()
|
||||
|
||||
s = "Aggiornamento direttorio ";
|
||||
if (is_com) s << "comune";
|
||||
else s << " della ditta " << atol (pref);
|
||||
else s << " della ditta " << atol (pref) <<".";
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
s << " Memoria libera: " << (long)GetFreeSpace(0) << " bytes.";
|
||||
#endif
|
||||
|
||||
TProgind p(items ? items : 1, s, FALSE, TRUE, 70);
|
||||
p.setstatus(1);
|
||||
@ -728,24 +779,31 @@ void TManutenzione_app::update_dir()
|
||||
d.eod() = orig_items;
|
||||
if (d.eox() < d.eod())
|
||||
d.eox() = d.eod();
|
||||
d.put(LF_DIR, _nordir, _sysdirop);
|
||||
d.put(LF_DIR, _nordir, _sysdirop);
|
||||
}
|
||||
|
||||
void TManutenzione_app::convert_dir()
|
||||
{
|
||||
{
|
||||
const TString pref(prefix().name());
|
||||
const bool is_com = prefix().is_com();
|
||||
|
||||
TDir d;
|
||||
TTrec r;
|
||||
|
||||
if (prefix().get_codditta() <= _history_firm)
|
||||
return;
|
||||
|
||||
d.get(LF_DIR);
|
||||
const int items = (int)d.eod();
|
||||
|
||||
TString s(256);
|
||||
s = "Aggiornamento archivi ";
|
||||
if (is_com) s << "comuni";
|
||||
else s << " della ditta " << atol (pref);
|
||||
else s << " della ditta " << atol (pref) << ".";
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
s << " Memoria libera: " << (long)GetFreeSpace(0) << " bytes.";
|
||||
#endif
|
||||
|
||||
TProgind p(items ? items : 1, s, FALSE, TRUE, 70);
|
||||
p.setstatus(1);
|
||||
@ -802,6 +860,7 @@ void TManutenzione_app::convert_dir()
|
||||
d.get(LF_DIR, _nolock, _nordir, _sysdirop);
|
||||
d.flags() = level;
|
||||
d.put(LF_DIR, _nordir, _sysdirop);
|
||||
put_history(pref);
|
||||
}
|
||||
|
||||
void TManutenzione_app::update()
|
||||
@ -841,6 +900,7 @@ void TManutenzione_app::update()
|
||||
if (!ok)
|
||||
return;
|
||||
|
||||
open_history();
|
||||
long firm = get_firm();
|
||||
TString pref;
|
||||
if (firm == 0) pref = prefix().name();
|
||||
@ -861,12 +921,23 @@ void TManutenzione_app::update()
|
||||
TSystemisamfile ditte(LF_NDITTE);
|
||||
ditte.open();
|
||||
|
||||
TString80 s("Conversione archivi ditte.");
|
||||
|
||||
#if XVT_OS == XVT_OS_WIN
|
||||
s << " Memoria libera: " << (long)GetFreeSpace(0) << " bytes.";
|
||||
#endif
|
||||
|
||||
TProgind p(ditte.items() ? ditte.items() : 1, s, TRUE, TRUE, 70);
|
||||
|
||||
p.setstatus(1);
|
||||
|
||||
for (ditte.first(); !ditte.eof(); ditte.next())
|
||||
{
|
||||
p.addstatus(1);
|
||||
const long codditta = ditte.get_long("CODDITTA");
|
||||
const TRecnotype rec = ditte.recno();
|
||||
|
||||
if (prefix().exist(codditta))
|
||||
if (codditta > _history_firm && prefix().exist(codditta))
|
||||
{
|
||||
ditte.close();
|
||||
set_firm(codditta);
|
||||
@ -896,7 +967,7 @@ void TManutenzione_app::update()
|
||||
utenti.rewrite();
|
||||
}
|
||||
utenti.close();
|
||||
|
||||
close_history();
|
||||
end_wait();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user