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 <extcdecl.h>
|
||||||
#include <execp.h>
|
#include <execp.h>
|
||||||
|
|
||||||
|
#if XVT_OS == XVT_OS_WIN
|
||||||
|
#define STRICT
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "ba1.h"
|
#include "ba1.h"
|
||||||
#include "ba1100.h"
|
#include "ba1100.h"
|
||||||
|
|
||||||
@ -29,11 +34,14 @@ struct direct
|
|||||||
#include <dos.h>
|
#include <dos.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define History_file "conv.his"
|
||||||
|
|
||||||
class TManutenzione_app : public TApplication
|
class TManutenzione_app : public TApplication
|
||||||
{
|
{
|
||||||
TDir_sheet* _browse;
|
TDir_sheet* _browse;
|
||||||
TMask* _mask;
|
TMask* _mask;
|
||||||
long _firm;
|
long _firm;
|
||||||
|
long _history_firm;
|
||||||
TRec_sheet* _rec;
|
TRec_sheet* _rec;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -50,6 +58,9 @@ protected:
|
|||||||
virtual void print();
|
virtual void print();
|
||||||
virtual void do_print(TPrinter & p, TRec_sheet & r);
|
virtual void do_print(TPrinter & p, TRec_sheet & r);
|
||||||
const char* dumpfilename(const FileDes& dep) const;
|
const char* dumpfilename(const FileDes& dep) const;
|
||||||
|
void open_history();
|
||||||
|
void put_history(const char* firm);
|
||||||
|
void close_history();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -329,6 +340,39 @@ void TManutenzione_app::insert_riga (long riga_sel, TToken_string& riga)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
const char* TManutenzione_app::dumpfilename(const FileDes& dep) const
|
||||||
{
|
{
|
||||||
TFilename n; n.tempdir();
|
TFilename n; n.tempdir();
|
||||||
@ -515,10 +559,14 @@ void TManutenzione_app::update_dir()
|
|||||||
{
|
{
|
||||||
const TString pref(prefix().name());
|
const TString pref(prefix().name());
|
||||||
const bool is_com = prefix().is_com();
|
const bool is_com = prefix().is_com();
|
||||||
TString desc(256), s(256);
|
|
||||||
|
if (prefix().get_codditta() <= _history_firm)
|
||||||
|
return;
|
||||||
|
|
||||||
prefix().set("");
|
prefix().set("");
|
||||||
|
|
||||||
|
|
||||||
|
TString desc(256), s(256);
|
||||||
TDir d;
|
TDir d;
|
||||||
d.get(LF_DIR);
|
d.get(LF_DIR);
|
||||||
const int orig_items = (int)d.eod();
|
const int orig_items = (int)d.eod();
|
||||||
@ -530,7 +578,10 @@ void TManutenzione_app::update_dir()
|
|||||||
|
|
||||||
s = "Aggiornamento direttorio ";
|
s = "Aggiornamento direttorio ";
|
||||||
if (is_com) s << "comune";
|
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);
|
TProgind p(items ? items : 1, s, FALSE, TRUE, 70);
|
||||||
p.setstatus(1);
|
p.setstatus(1);
|
||||||
@ -739,13 +790,20 @@ void TManutenzione_app::convert_dir()
|
|||||||
TDir d;
|
TDir d;
|
||||||
TTrec r;
|
TTrec r;
|
||||||
|
|
||||||
|
if (prefix().get_codditta() <= _history_firm)
|
||||||
|
return;
|
||||||
|
|
||||||
d.get(LF_DIR);
|
d.get(LF_DIR);
|
||||||
const int items = (int)d.eod();
|
const int items = (int)d.eod();
|
||||||
|
|
||||||
TString s(256);
|
TString s(256);
|
||||||
s = "Aggiornamento archivi ";
|
s = "Aggiornamento archivi ";
|
||||||
if (is_com) s << "comuni";
|
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);
|
TProgind p(items ? items : 1, s, FALSE, TRUE, 70);
|
||||||
p.setstatus(1);
|
p.setstatus(1);
|
||||||
@ -802,6 +860,7 @@ void TManutenzione_app::convert_dir()
|
|||||||
d.get(LF_DIR, _nolock, _nordir, _sysdirop);
|
d.get(LF_DIR, _nolock, _nordir, _sysdirop);
|
||||||
d.flags() = level;
|
d.flags() = level;
|
||||||
d.put(LF_DIR, _nordir, _sysdirop);
|
d.put(LF_DIR, _nordir, _sysdirop);
|
||||||
|
put_history(pref);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TManutenzione_app::update()
|
void TManutenzione_app::update()
|
||||||
@ -841,6 +900,7 @@ void TManutenzione_app::update()
|
|||||||
if (!ok)
|
if (!ok)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
open_history();
|
||||||
long firm = get_firm();
|
long firm = get_firm();
|
||||||
TString pref;
|
TString pref;
|
||||||
if (firm == 0) pref = prefix().name();
|
if (firm == 0) pref = prefix().name();
|
||||||
@ -861,12 +921,23 @@ void TManutenzione_app::update()
|
|||||||
TSystemisamfile ditte(LF_NDITTE);
|
TSystemisamfile ditte(LF_NDITTE);
|
||||||
ditte.open();
|
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())
|
for (ditte.first(); !ditte.eof(); ditte.next())
|
||||||
{
|
{
|
||||||
|
p.addstatus(1);
|
||||||
const long codditta = ditte.get_long("CODDITTA");
|
const long codditta = ditte.get_long("CODDITTA");
|
||||||
const TRecnotype rec = ditte.recno();
|
const TRecnotype rec = ditte.recno();
|
||||||
|
|
||||||
if (prefix().exist(codditta))
|
if (codditta > _history_firm && prefix().exist(codditta))
|
||||||
{
|
{
|
||||||
ditte.close();
|
ditte.close();
|
||||||
set_firm(codditta);
|
set_firm(codditta);
|
||||||
@ -896,7 +967,7 @@ void TManutenzione_app::update()
|
|||||||
utenti.rewrite();
|
utenti.rewrite();
|
||||||
}
|
}
|
||||||
utenti.close();
|
utenti.close();
|
||||||
|
close_history();
|
||||||
end_wait();
|
end_wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user