diff --git a/ba/ba1.url b/ba/ba1.url index 62f6a6974..2c8a729e2 100755 --- a/ba/ba1.url +++ b/ba/ba1.url @@ -18,8 +18,6 @@ MENUBAR MENU_BAR(2) MENU MENU_BAR(2) SUBMENU MENU_FILE "~File" - ITEM BAR_ITEM(1) "~Test" - ITEM BAR_ITEM(2) "~Debug" /* ba1 -3 */ MENUBAR MENU_BAR(3) diff --git a/ba/ba1300.cpp b/ba/ba1300.cpp index 2e7fe6d94..cf82df8aa 100755 --- a/ba/ba1300.cpp +++ b/ba/ba1300.cpp @@ -1,211 +1,173 @@ -#include - #include +#include #include -#include -#include +#include #include #include #include -#include #include "ba1.h" -#include "ba1300.h" -#include "ba1300a.h" -class BA1300_application:public TApplication +class TPackFiles_application:public TApplication { - TTestSheet * _testsheet; - TTestProc * _test, - * _debug; - TMask * _mask; - long _firm; + TArray_sheet * _selsheet; + long _firm; protected: virtual bool menu(MENU_TAG); virtual bool create () ; virtual bool destroy(); virtual bool extended_firm() const { return TRUE; } - + void build_sheet(); public: - BA1300_application() : _testsheet(NULL), _mask(NULL) {} - TTestSheet * get_sheet() {return _testsheet;} - TTestProc * get_test() {return _test;} - TMask * get_mask() {return _mask;} - TString_array& field_sheet(TMask *); - + TPackFiles_application() : _selsheet(NULL), _firm(0) {} + ~TPackFiles_application() {}; }; -HIDDEN bool seq_handler(TMask_field& f, KEY key) -{ - if (key==K_ENTER) - if (!fexist((const char*)f.get())) - { - warning_box("File inesistente"); - return FALSE; - } - return TRUE; -} - -bool BA1300_application::create() // initvar e arrmask +bool TPackFiles_application::create() // initvar e arrmask { TApplication::create(); - _firm = get_firm(); - - if (argc() > 2) - { + if (!set_firm()) return FALSE; - } - else - { - _mask = new TMask ("ba1300a"); // Maschera principale - set_firm(); - _testsheet = new TTestSheet("Selezione Files") ; - get_sheet()->add_button(DLG_RESET,"~Reset",K_F6); - } + const bool is_prassi = user() == "PRASSI"; + _selsheet = new TArray_sheet(-1, -1, -4, -4, "Selezione files", + is_prassi ? + "@1|N.@5|Nome@20|EOD@7|EOX@7|Lung. |Descrizione@43|Flags@7" : + "N.@5|Nome@20|EOD@7|EOX@7|Lung. |Descrizione@43|Flags@7", + is_prassi ? 0 : 0x10); + dispatch_e_menu(BAR_ITEM(1)); return TRUE ; } -bool BA1300_application::destroy() // releasev e arrmask +bool TPackFiles_application::destroy() { if (_firm) set_firm(_firm); - if (_testsheet != NULL) delete _testsheet; - if (_mask != NULL) delete _mask; + if (_selsheet != NULL) delete _selsheet; return TApplication::destroy() ; } -TString_array& BA1300_application::field_sheet(TMask * m) +void TPackFiles_application::build_sheet() { - TEdit_field& f = m->efield(F_FILE); - return f.sheet()->rows_array(); + _selsheet->destroy(); + TDir cdir; + cdir.get(LF_DIR,_nolock,_nordir,_sysdirop); + const bool is_prassi = user() == "PRASSI"; + const int nitems = (int)cdir.eod(); + for (int i = 0; i < nitems; i++) // fill sheet + { + TToken_string riga(128); + cdir.get(i+1,_nolock,_nordir,_sysdirop); + if (is_prassi) + riga.add(""); + riga.add(i+1); + riga.add(cdir.name()); + riga.add(cdir.eod()); + riga.add(cdir.eox()); + riga.add((int)cdir.len()); + riga.add(cdir.des()); + riga.add(cdir.flags()); + _selsheet->add(riga); + } } -bool BA1300_application::menu(MENU_TAG m) +bool TPackFiles_application::menu(MENU_TAG m) { - KEY tasto,tastoS; - long numtest; - TMask *msk; - TDir *cdir; - - disable_menu_item(M_FILE_NEW); - switch (m) + KEY tasto; + + do { - case BAR_ITEM(2): - { - msk = new TMask("ba1300b"); - cdir = new TDir; - cdir->get(LF_DIR,_nolock,_nordir,_sysdirop); - const int nitems=(int)cdir->eod(); - for (int i=0; irun()) { - TToken_string riga(128); - riga.cut(0); - cdir->get(i+1,_nolock,_nordir,_sysdirop); - riga=format("%3d",i+1); - riga.add(cdir->name()); - riga.add(format("%ld",cdir->eod())); - riga.add(format("%ld",cdir->eox())); - riga.add(format("%u",cdir->len())); - riga.add(cdir->des()); - field_sheet(msk).add(riga); - } - msk->set_handler(F_SEQUENZA,seq_handler); - if (msk->run()==K_ENTER) - { - _debug = new TTestProc; - _debug->set_file(msk->get_int(F_FILE)); - _debug->load_random(msk->get(F_SEQUENZA)); - if (!_debug->stopped()) - _debug->do_debug(); - else - warning_box("File di sequenza non valido"); - delete _debug; - } - delete msk; - delete cdir; - } - break; - case BAR_ITEM(1): - do { - switch(tasto=get_mask()->run()) - { - case K_ENTER: - if (get_sheet()->checked()>0 && (get_mask()->get_long(F_ITERAZIONI)>0 || get_mask()->get_bool(F_CONTINUO))) - { - _test = new TTestProc; - get_test()->set_sheet(get_sheet()); - get_test()->set_rmc(); - get_test()->get_win()->set_color(COLOR_BLACK,COLOR_WHITE); - get_test()->get_win()->clear(COLOR_WHITE); - get_test()->get_win()->set_caption("Verifica di stabilita'"); - get_test()->get_win()->WriteW(10,5,"Test N. :"); - get_test()->get_win()->WriteW(10,7,"Nome File :"); - get_test()->get_win()->WriteW(10,9,"Record cancellati :"); - get_test()->get_win()->WriteW(10,10,"Operazione in corso :"); - get_test()->get_win()->WriteW(10,12,"Tempo trascorso :"); - get_test()->get_win()->WriteW(10,13,"Tempo stimato :"); - get_test()->get_win()->WriteW(10,15,"Ultimo Errore :"); - numtest=0; - while (((++numtest)<=get_mask()->get_long(F_ITERAZIONI) || get_mask()->get_bool(F_CONTINUO)) && (!get_test()->stopped())) + case K_ENTER: + if (_selsheet->checked()>0) { - if (get_mask()->get_bool(F_CONTINUO)) - get_test()->get_win()->WriteW(33,5,format("%4ld (CONTINUO)",numtest)); - else - get_test()->get_win()->WriteW(33,5,format("%4ld/%-4ld",numtest,_mask->get_long(F_ITERAZIONI))); - get_test()->set_numt(numtest); - get_test()->do_test_1(); + int status; + const long items = _selsheet->items(); + bool retry,present; + TFilename f_name,d_name; + TString cmd; + TDir d; + for (int i = 2; i<=items; i++) // Skip LF_DIR + { + if (!_selsheet->checked(i-1)) + continue; + d.get(i); + const long flags = d.flags(); + const int module = abs((int)flags); + if (flags >= 10000L) + continue; // Skip files with flags over 10000 + TSystemisamfile f(i); + + f_name = d.name(); + f_name.ext("dbf"); + retry = FALSE; + present = access(f_name,0) == 0; + do + { + status = NOERR; + if (present) // Se il file c'e' prova a compattarlo + { + if (f.packfile() == NOERR) + f.packindex(); + status = f.status(); + if (status == -60) // Se ritorna -60 allora il file e' aperto da qualcuno + retry = yesno_box("Il file %s non puo' essere compattato perche' aperto da altre applicazioni. Riprovare?",(const char*) f_name); + } + } while (retry); // Ci riprovo ! + + if (!present || status == -60) + { + if (!present && d.len() > 0 && has_module(module,CHK_DONGLE))// Se il file non esiste lo costruisce + f.build(0L); + + continue; // Se il file non esiste e non si ha il modulo abilitato evita inutili controlli + } // Se le pack() hanno ritornato -60 ma il file esiste, allora prosegue con il prossimo + if (status != NOERR && + yesno_box("Rilevato l'errore %d cercando di compattare il file %s." + " Si desidera scaricarlo e ricaricarlo?",status,(const char*)f_name)) + { + // Dump the file, Zap it and Reload it. + d_name = ""; + d_name.temp("fdump"); + if (f.dump(d_name,0) == NOERR) // Dump + { + // Zap + d.get(i,_nolock, _nordir,_sysdirop); + bool is_com = d.is_com(); + d.get(i,_nolock, is_com ? _comdir : _nordir); + d.eod() = 0L; + d.put(i, is_com ? _comdir : _nordir); + if (f.pack() == NOERR) + if (f.load(d_name) == NOERR) // Reload + unlink(f_name); + else + error_box("Impossibile ricaricare %s. Errore %d",(const char*) d_name, f.status()); + else + error_box("Impossibile azzerare %s. Errore %d",(const char*) f_name, f.status()); + } + else + error_box("Impossibile scaricare %s. Errore %d",(const char*) d_name, f.status()); + } + } } - if (get_test()->rm_copy()) - { - get_test()->get_win()->WriteW(33,10,"CANCELLAZIONE COPIE "); - for (int i=0;iitems();i++) - if (get_sheet()->checked(i)) - get_test()->remove_copy(i+1); - } - delete _test; - } - else - warning_box("Nessun file selezionato"); - break; - case K_F4: - get_sheet()->sr_status(); - while ((tastoS=get_sheet()->run()) == K_F6) - for (int i=0; iitems();i++) - get_sheet()->uncheck(i); - if (tastoS == K_ESC) - get_sheet()->sr_status(FALSE); - else - { // Cannot select first two files. - get_sheet()->uncheck(0); - get_sheet()->uncheck(1); - } - break; - case K_F5: - if (fexist((const char*)TString(20).format("test%creport.txt",Separator))) - { - TTestReport rep_win("Report"); - rep_win.load_report(); - rep_win.run(); - } else - warning_box("Report non disponibile"); - break; - default: - break; + else + warning_box("Nessun file selezionato"); + break; + default: + break; } } while (tasto != K_ESC); - break; -} - enable_menu_item(M_FILE_NEW); - return xvt_test_menu_tag(BAR_ITEM(2)); + return FALSE; } int ba1300(int argc, char** argv) { - BA1300_application a; - a.run(argc,argv,"Test dell'ISAM"); + TPackFiles_application a; + a.run(argc,argv,"Compatta files"); return 0; } diff --git a/ba/ba1300.h b/ba/ba1300.h deleted file mode 100755 index 916536b62..000000000 --- a/ba/ba1300.h +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef __BA1300_H -#define __BA1300_H - -#include "ba1100.h" - -#if XVT_OS == XVT_OS_WIN -#define Separator '\\' -#else -#define Separator '/' -#endif - -//////////////////////////////////////// -// Here defining classes // -//////////////////////////////////////// - -class TTestSheet : public TDir_sheet -{ - TBit_array _oldstatus; // Previous status of selected files -protected: - void get_row(long n, TToken_string& r); - -public: - void sr_status(bool save=TRUE); - - TTestSheet(const char* titolo, byte bottoni = 0x0); - virtual ~TTestSheet() ; -}; - -class TTestFile : public TBaseisamfile -{ -public: - TTestFile(int ln,bool lt=TRUE) : TBaseisamfile(ln,lt) {} - virtual ~TTestFile() {} - int close() {return _close();} - int open(unsigned int mode = _manulock) {return _open(mode);} - const char * file_name() const {return filename();} -}; - -class TTestWin : public TIndwin -{ -protected: - virtual void update() {update_text();} - virtual void handler(WINDOW w, EVENT *e); - void update_text() {set_mode(M_COPY); check_stop();} -public: - void WriteW(short x, short y, const char* line) {stringat(x,y,line);update_text();do_events();} - TTestWin(); - ~TTestWin() {}; -}; - -class TTestProc -{ - TTestSheet * _sheet; // Sheet with files selected - TTestFile * _workf; // working file - TTestWin * _win; // Output window - long * _randseq; // Random sequence - long _ntest; // number of test in progress - int _nfile; // number of file being tested - long _kriminal; // number of record incriminated (Debug) - int _nkeys; // # of keys defined for current file - bool _block; // is test blocked ? - bool _rmc; // Remove copies at the end of test ? -protected: - void do_random(long eod); - void filecopy(bool save=TRUE); - void DumpReport(int err, long i, long x, int key); - long sumop(const long n) {return ((n+1)*(n/2)+(n%2)*((n+1)/2));} - int ctrl_keys(); - bool show_mess(int, int, long, long, int); - const char * fmttime(const long); -public: - TTestProc(); - ~TTestProc(); - const char* get_base(); - void do_test_1(); - void do_test_2(); - void do_debug(); - void remove_copy(int n); - void load_random(const TString& st); - bool stopped() {return _block;} - bool rm_copy() {return _rmc;} - void set_rmc(bool a=FALSE) {_rmc = a;} - long num_test() {return _ntest;} - void set_numt(const long num) { _ntest = num;} - int num_file() {return _nfile;} - void set_file(int n) {_nfile=n;} - long number(const long n) {return _randseq[n];} - void set_sheet (TTestSheet * sh) {_sheet=sh;} - TTestSheet * get_isheet() {return _sheet;} - TTestWin * get_win() {return _win;} -}; - -class TTestReport : public TScroll_window -{ - TArray _report; -protected: - virtual void update(); - virtual bool on_key(KEY); -public: - TTestReport(const char* title); - ~TTestReport() {}; - void load_report(); - TString& get_row(int n) {return (TString&)_report[n];} -}; -#endif diff --git a/ba/ba1300a.h b/ba/ba1300a.h deleted file mode 100755 index 4a131bf40..000000000 --- a/ba/ba1300a.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef __BA1300A_H -#define __BA1300A_H - - -#define F_CONTINUO 101 -#define F_ITERAZIONI 102 -#define F_LABEL 103 -#define DLG_FILES 104 -#define DLG_REPORT 105 -#define DLG_TEST 106 - -#define DLG_RESET 201 // Reset button for sheet mask - -#define F_FILE 101 -#define F_NOMEFILE 102 -#define F_SEQUENZA 103 - -#endif diff --git a/ba/ba1300a.uml b/ba/ba1300a.uml deleted file mode 100755 index 9f8cb60e2..000000000 --- a/ba/ba1300a.uml +++ /dev/null @@ -1,54 +0,0 @@ -#include -#include -#include "ba1300a.h" - -PAGE "Selezione principale" -1 -1 44 9 - -GROUPBOX DLG_NULL 20 5 -BEGIN - PROMPT 1 1 "Opzioni" -END - -BOOLEAN F_CONTINUO -BEGIN - PROMPT 2 2 " Continuo" - MESSAGE TRUE DISABLE,F_ITERAZIONI|RESET,F_ITERAZIONI - MESSAGE FALSE ENABLE,F_ITERAZIONI - HELP "Tipo di test da svolgere" -END - -NUMBER F_ITERAZIONI 3 -BEGIN - PROMPT 2 4 "" - HELP "Numero di iterazioni del test" -END - -TEXT F_LABEL -BEGIN - PROMPT 9 4 "Iterazioni" -END - -BUTTON DLG_FILES 10 2 -BEGIN - PROMPT 29 1 "~Files" - MESSAGE EXIT,K_F4 -END - -BUTTON DLG_REPORT 10 2 -BEGIN - PROMPT 29 3 "~Report" - MESSAGE EXIT,K_F5 -END - -BUTTON DLG_TEST 10 2 -BEGIN - PROMPT 29 5 "~Test" - MESSAGE EXIT,K_ENTER -END - -BUTTON DLG_CANCEL 10 2 -BEGIN - PROMPT 29 7 "" -END -ENDMASK - diff --git a/ba/ba1300b.uml b/ba/ba1300b.uml deleted file mode 100755 index 65e64e6c2..000000000 --- a/ba/ba1300b.uml +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include -#include "ba1300a.h" - -PAGE "Debugging" -1 -1 42 8 - -NUMBER F_FILE 3 -BEGIN - PROMPT 2 1 "Numero file " - SHEET "N.@5|Nome@20|EOD@7|EOX@7|Lung. |Descrizione@43" - INPUT F_FILE - OUTPUT F_FILE - HELP "Numero del file da esaminare" -END - -STRING F_SEQUENZA 20 -BEGIN - PROMPT 2 3 "File Random " - HELP "Nome del file della sequenza" -END - -BUTTON DLG_OK 10 2 -BEGIN - PROMPT -12 6 "" -END - -BUTTON DLG_CANCEL 10 2 -BEGIN - PROMPT -22 6 "" -END - -ENDMASK - diff --git a/ba/ba1301.cpp b/ba/ba1301.cpp deleted file mode 100755 index 5b9001da2..000000000 --- a/ba/ba1301.cpp +++ /dev/null @@ -1,601 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if XVT_OS!=XVT_OS_SCOUNIX -#include -#endif - -#include "ba1300.h" - -extern "C" { - void cgettime(char *); -} - -TTestSheet::TTestSheet(const char* titolo, byte bottoni) -:TDir_sheet(titolo, bottoni, "@1|N.@5|Nome@20|EOD@7|EOX@7|Lung. |Descrizione@43|Flags@7") -{} - -TTestSheet::~TTestSheet() -{} - -void TTestSheet::get_row(long n, TToken_string& l) - -{ - dir()->get((int)n,_nolock,_nordir,_sysdirop); - l.cut(0); - l.add(""); - l.add(n); // Numero progressivo del file - l.add(dir()->name()); - const TRecnotype eod = dir()->eod(); - l.add(eod); - const TRecnotype eox = dir()->eox(); - l.add(eox); - const word len = dir()->len(); - l.add(format("%u", len)); - l.add(dir()->des()); - l.add(format("%ld", dir()->flags())); -} - -void TTestSheet::sr_status(bool save) -{ - for (int i=0; i>1; - cbits++; - } - scale=(unsigned int)0x8000; - for (i=1;i<=(long)cbits;i++) - { - scale=scale>>1; - scale |= 0x8000; - } - // Extracts "random" seed from time - time(&tloc); - parm=(unsigned int)(tloc & 0x0000FFFF); - srand(parm); - // Mix array... - for (i=0;i>1; - if (((long) rnd)>=eod) // Difficile che accada... - rnd=(unsigned int) eod-1; - com=_randseq[i]; - _randseq[i]=_randseq[(long)rnd]; - _randseq[(long)rnd]=com; - } -} - -int TTestProc::ctrl_keys() -{ - int err=1; - - for (int nk=1;nk<=_nkeys;nk++) - { - _workf->setkey(nk); - if ((err=_workf->first())==NOERR) - return NOERR; - } - return err; -} - -void TTestProc::do_test_1() -{ - bool FoundError; - long i,EOD; - int err; - time_t inix,finix; - - _nfile=0; - while ((_nfile++ <= get_isheet()->items()) && !_block) - { - EOD=get_isheet()->row(_nfile-1).get_long(3); - if (get_isheet()->checked(_nfile-1) && EOD > 0) - { - get_win()->WriteW(33,7,(const char*)TString(18).format("%-18s",get_isheet()->row(_nfile-1).get(2))); - get_win()->WriteW(33,12,"000:00:00"); - get_win()->WriteW(33,13,"000:00:00"); - if (_ntest == 1) - { - TSystemisamfile f(_nfile); - get_win()->WriteW(33,10,"COMPATTAMENTO "); - if ((f.packfile(FALSE)!=NOERR)||(f.packindex(FALSE) != NOERR)) - error_box("Errore in compattamento file %d",_nfile); - get_win()->WriteW(33,10,"COPIA DI SICUREZZA "); - filecopy(); - set_rmc(TRUE); - } // If it was test # 1 - _workf = new TTestFile(_nfile); - time(&inix); - if (_workf->open(_excllock) == NOERR) - { - TTrec r; - r.get(_nfile); - _nkeys=r.keys(); - FoundError=FALSE; - i=0; - EOD=_workf->eod(); - get_win()->WriteW(33,9,(const char*)TString(14).format(" 0/%-7ld",EOD)); - get_win()->WriteW(33,10,"TEST1 (cisreadrec-cisdelete)"); - _randseq = new long[EOD]; - do_random(EOD); - while (!FoundError && ireadat(number(i++)))==NOERR) - err=_workf->remove(); - if (err!=NOERR) - FoundError=TRUE; - if (get_win()->iscancelled()) - _block=TRUE; - if ((i%20)==0) - get_win()->WriteW(33,9,(const char*)TString(20).format("%7ld/%-7ld",i,EOD)); - time(&finix); - get_win()->WriteW(33,12,(const char*)TString(10).format("%s",fmttime(finix-inix))); - if (((finix-inix)%3)==0) - { - long com=((finix-inix)*EOD)/(i+1); - get_win()->WriteW(33,13,(const char*)TString(10).format("%s",fmttime(com))); - } - } - if (!_block && ((ctrl_keys()==NOERR) || FoundError)) - do_test_2(); - _workf->close(); - get_win()->WriteW(33,10,"RIPRISTINO ARCHIVI "); - filecopy(FALSE); //restore copies - if (_randseq!=NULL) - delete _randseq; - } // If it was open - if (_workf != NULL) - delete _workf; - } // If it was selected - } // While test is in progress -} - -void TTestProc::do_test_2() -{ - time_t alpha,omega; - long i=0,j; - int err=NOERR; - - get_win()->WriteW(33,10,"TEST2: RIPRISTINO ARCHIVI "); - _workf->close(); - filecopy(FALSE); - if (_workf->open(_excllock) == NOERR) - { - long EOD=_workf->eod(); - long optot=sumop(EOD); - long optr=1; - - get_win()->WriteW(33,10,"TEST2 (cisreadrec-cisdelete)"); - time(&alpha); - while (!_block && ireadat(number(i)); - err=_workf->remove(); - j=i+1; - get_win()->WriteW(33,10,"TEST2: CONTROLLO CHIAVI "); - get_win()->WriteW(33,9,(const char*)TString(20).format("%7ld/%-7ld",j,EOD)); - while (!_block && jiscancelled()) _block=TRUE; - time(&omega); - get_win()->WriteW(33,12,(const char*)TString(10).format("%s",fmttime(omega-alpha))); - if ((omega-alpha)%3==0) - get_win()->WriteW(33,13,(const char*)TString(10).format("%s",fmttime(((omega-alpha)*optot)/optr))); - err=_workf->readat(number(j)); - optr++; - int k=1; - while (k<=_nkeys && err==NOERR) - { - TTrec r; - r.get(_nfile); - TToken_string def(r.keydef(k-1)); - - _workf->setkey(k); - err=_workf->read(); - if (def.get_char(1)=='X') // if keys are duplicated - { - TString ksaved(_workf->curr().key(k)); - bool Fnd=FALSE; - - while (err==NOERR && !Fnd && ksaved==_workf->curr().key(k)) - if (_workf->recno()==number(j)) - Fnd=TRUE; - else - err=_workf->next(); - } - if (err!=NOERR || number(j)!=_workf->recno()) - { - get_win()->WriteW(33,10,"Trovati errori scrittura report"); - DumpReport(err,i,j,k); - if (err==NOERR) - err=999; //errore fittizio, tanto per farlo uscire - } - k++; - } - j++; - } - get_win()->WriteW(33,10,"TEST2 (cisreadrec-cisdelete) "); - i++; - } - } -} - -void TTestProc::DumpReport(int err, long i, long x, int key) -{ - static rnum=0; - char ora[12] = "08-08-1883"; - TString RandomFile,ReportFile; - FILE * fp; - - get_win()->WriteW(33,15,(const char*)TString(35).format("File nr. %d Test nr. %ld",_nfile,_ntest)); - - if (!fexist("test")) // create directory -#if XVT_OS==XVT_OS_SCOUNIX - mkdir("test",0777); -#else -#ifdef __WATCOMC__ - mkdir("test"); -#else - _mkdir("test"); -#endif -#endif - RandomFile.format("test%crnd%d.dat",Separator,rnum++); - if ((fp=fopen((const char*)RandomFile,"w"))!=NULL) - { - for (int j=0;j<_workf->eod();j++) - if (j==i) - fprintf(fp,"%9ld*\n",number(j)); - else - fprintf(fp,"%9ld \n",number(j)); - fclose(fp); - } - ReportFile.format("test%creport.txt",Separator); - if ((fp=fopen((const char*)ReportFile,"a"))!=NULL) - { - fprintf(fp,"REPORT sulla verifica della stabilita' dell'ISAM\n"); - fprintf(fp,"------\n"); - fprintf(fp,"\n"); - fprintf(fp,"Eseguito il : %s Alle : %s\n",(const char*)TDate(TODAY),ora); - fprintf(fp,"\n"); - fprintf(fp,"File nr. : %4d %s\n",_nfile,get_isheet()->row(_nfile-1).get(2)); - fprintf(fp,"File Random : %s\n",(const char*)RandomFile); - fprintf(fp,"Nr. Record cancellato: %5ld Nr. Record letto: %5ld\n",number(i),number(x)); - fprintf(fp,"Nr. Chiave elaborata: %3d\n",key); - if (err!=NOERR) - fprintf(fp,"Errore generato dal record letto: %d\n",err); - else - fprintf(fp,"Errore generato dal record letto: Numero di record non corretto.\n\n"); - fprintf(fp,"------\n\n\n"); - fclose(fp); - } -} - -void TTestProc::load_random(const TString& st) -{ - FILE *fp; - char c; - - _kriminal=0; - if ((fp=fopen((const char*)st,"r"))!=NULL) - { - TDir d; - d.get(_nfile,_nolock,_nordir,_sysdirop); - _randseq = new long[d.eod()]; - for (long i=0;id.eod()) - { - _block=TRUE; - break; - } - } - } -} - -void TTestProc::do_debug() -{ - TDir d; - - d.get(_nfile,_nolock,_nordir,_sysdirop); - get_win()->set_color(COLOR_BLACK,COLOR_WHITE); - get_win()->clear(COLOR_WHITE); - get_win()->set_caption("Ricerca dell'errore"); - get_win()->WriteW(8,5,(const char*)TString(25).format("File numero : %4d\t\t\t%s",_nfile,(const char*)d.name())); - get_win()->WriteW(8,7,"Record Cancellati :"); - get_win()->WriteW(8,9,"Operazione in corso : COPIA DI SICUREZZA"); - get_win()->WriteW(8,11,"Record cancellato :"); - get_win()->WriteW(8,12,"Record letto :"); - get_win()->WriteW(8,14,"Errore rilevato :"); - - filecopy(); // Backup copies. Must be placed here - // otherwise I get a "File already open error" - _workf = new TTestFile(_nfile); - if (_workf->open(_excllock) == NOERR) - { - TTrec r; - r.get(_nfile); - _nkeys=r.keys(); - long i=0,j; - int k,err=NOERR; - bool step=FALSE; - get_win()->WriteW(30,9,"Cancello fino al Kriminale..."); - while (!stopped() && i<_workf->eod() && err==NOERR) - { - if (number(i)==_kriminal) - step=TRUE; // Put here a Break Point to debug step by step - err=_workf->readat(number(i)); - if (err!=NOERR || step) - _block=show_mess(1,err,number(i),number(i),0); - err=_workf->remove(); - if (err!=NOERR || step) - _block=show_mess(2,err,number(i),number(i),0); - j=i+1; - get_win()->WriteW(30,9,"TEST 2: CONTROLLO CHIAVI "); - get_win()->WriteW(30,7,(const char*)TString(20).format("%5ld/%-5ld",j,_workf->eod())); - get_win()->WriteW(30,11,(const char*)TString(10).format("%5ld",number(i))); - while (!stopped() && j<_workf->eod() && err==NOERR) - { - if (get_win()->iscancelled()) - _block=TRUE; - err=_workf->readat(number(j)); - if (err!=NOERR || step) - _block=show_mess(3,err,number(j),number(j),0); - get_win()->WriteW(30,12,(const char*)TString(10).format("%5ld",number(j))); - k=1; - while (k<=_nkeys && err==NOERR && !stopped()) - { - TToken_string def(r.keydef(k-1)); - - _workf->setkey(k); - err=_workf->read(); - if (err!=NOERR || step) - _block=show_mess(4,err,number(j),_workf->recno(),k); - if (def.get_char(1)=='X') // if keys are duplicated - { - TString ksaved(_workf->curr().key(k)); - bool Fnd=FALSE; - - while (!stopped() && err==NOERR && !Fnd && ksaved==_workf->curr().key(k)) - if (_workf->recno()==number(j)) - Fnd=TRUE; - else - { - err=_workf->next(); - if (err!=NOERR || step) - _block=show_mess(5,err,number(j),_workf->recno(),k); - } - } // if keys are duplicated - if (err!=NOERR || number(j)!=_workf->recno()) - { - _block=show_mess(6,err,number(j),number(j),0); - err=999; // So it will exit - } - k++; - } - j++; - } - get_win()->WriteW(30,9,"Cisreadrec -- Cisdelete "); - i++; - } - _workf->close(); - } - get_win()->WriteW(30,9,"RIPRISTINO ARCHIVIO "); - filecopy(FALSE); // Restore copies - get_win()->WriteW(30,9,"CANCELLAZIONE COPIE "); - remove_copy(_nfile); // Delete backup copies - - // Free pointers - if (_workf!=NULL) - delete _workf; - if (_randseq != NULL) - delete _randseq; -} - -bool TTestProc::show_mess(int act, int err, long n1, long n2, int k) -{ - switch (act) - { - case 1: - get_win()->WriteW(30,9,(const char*)TString(42).format("Eseguita la readrec per rec. # %ld",n1)); - get_win()->WriteW(30,11,(const char*)TString(40).spaces()); - break; - case 2: - get_win()->WriteW(30,9,(const char*)TString(42).format("Eseguita la delete per rec. # %ld",n1)); - get_win()->WriteW(30,11,(const char*)TString(10).format("%5ld",n1)); - break; - case 3: - get_win()->WriteW(30,9,(const char*)TString(42).format("Eseguita la readrec per contr. chiavi")); - get_win()->WriteW(30,12,(const char*)TString(10).format("%5ld ",n1)); - break; - case 4: - get_win()->WriteW(30,9,(const char*)TString(42).format("Eseguita la start con chiave %d ",k)); - get_win()->WriteW(30,12,(const char*)TString(15).format("%5ld (%ld)",n1,n2)); - break; - case 5: - get_win()->WriteW(30,9,(const char*)TString(42).format("Eseguita la next per chiavi doppie ")); - get_win()->WriteW(30,12,(const char*)TString(15).format("%5ld (%ld)",n1,n2)); - break; - case 6: - get_win()->WriteW(30,9,(const char*)TString(42).format("Record %ld non trovato nelle chiavi duplicate ",n1)); - break; - } - get_win()->WriteW(30,14,(const char*)TString(5).format("%5d",err)); - KEY tasto=get_win()->run(); - return (tasto == K_ESC); -} - -TTestProc::TTestProc() -: _block(FALSE), _ntest(0), _nfile(0), _randseq(NULL), _rmc(FALSE), _workf(NULL), _sheet(NULL), _win(NULL) -{ - _win = new TTestWin; -} - -TTestProc::~TTestProc() -{ - if (_win != NULL) - delete _win; -} - -TTestWin::TTestWin() -:TIndwin(1L,"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n",TRUE,FALSE,70) -{} - -void TTestWin::handler(WINDOW w, EVENT *e) -{ - switch (e->type) - { - case E_CHAR: - if (e->v.chr.ch == K_ENTER) - stop_run(K_ENTER); - break; - default: - break; - } - TIndwin::handler(w,e); -} - -TTestReport::TTestReport(const char* title) -{ - WINDOW parent=TASK_WIN; - long flags=WSF_CLOSE | WSF_SIZE | WSF_VSCROLL | WSF_HSCROLL; - WIN_TYPE wt=W_DOC; - create(6,2,68,20,title,flags,wt,parent); - set_color(COLOR_BLACK,COLOR_WHITE); -} - -void TTestReport::load_report() -{ - FILE *fp; - char line[256]; - - fp=fopen((const char *)TString(20).format("test%creport.txt",Separator),"r"); - while (fgets(line,256,fp)!=NULL) - { - TString element(line); - _report.add(element); - } - fclose(fp); - set_scroll_max(80,_report.items()); -} - -void TTestReport::update() -{ - for (int i=0; i<_report.items(); i++) - stringat(1,i+1,(const char*)get_row(i)); -} - -bool TTestReport::on_key(KEY key) -{ - switch (key) - { - case K_ESC: - stop_run(key); - break; - default: - break; - } - return TScroll_window::on_key(key); -} diff --git a/ba/ba3.cpp b/ba/ba3.cpp index ae910908b..0d9bb4ac4 100755 --- a/ba/ba3.cpp +++ b/ba/ba3.cpp @@ -35,6 +35,6 @@ int main(int argc, char** argv) default: error_box(usage, argv[0]) ; break; } - + exit(0); return rt ; } diff --git a/ba/ba3800.cpp b/ba/ba3800.cpp index 5d76131a3..7efa5b70e 100755 --- a/ba/ba3800.cpp +++ b/ba/ba3800.cpp @@ -1830,10 +1830,13 @@ bool BA3800_application::user_destroy() int ba3800 (int argc, char* argv[]) { - - BA3800_application a(*argv[2]); - - a.run(argc, argv, "Stampa Tabella IV Direttiva CEE"); + if (argc > 3) + { + BA3800_application a(*argv[2]); + a.run(argc, argv, "Stampa Tabella IV Direttiva CEE"); + } + else + error_box("Usage: BA3 -7 {D|S}"); return 0; } diff --git a/ba/ba4300.cpp b/ba/ba4300.cpp index effdc8644..f41b60389 100755 --- a/ba/ba4300.cpp +++ b/ba/ba4300.cpp @@ -83,6 +83,7 @@ public: virtual TRelation* get_relation() const { return _rel;} virtual int rewrite(const TMask& m); virtual int write(const TMask& m); + virtual bool remove(); virtual ~TDitte_application() {} }; @@ -333,6 +334,19 @@ int TDitte_application::rewrite(const TMask& m) return err; } +bool TDitte_application::remove() +{ + // Removes all activities + const long firm = _msk->get_long(FLD_GD1_CODDITTA); + _attiv->zero(); + TRecfield att_firm(_attiv->curr(),"CODDITTA"); + att_firm = firm; + for (_attiv->read(_isgteq);_attiv->good() && firm == (long)att_firm; _attiv->next()) + _attiv->remove(); + // Removes firm + return TRelation_application::remove(); +} + void TDitte_application::init_query_mode(TMask& m) { if (filtered()) diff --git a/ba/prassi.mnu b/ba/prassi.mnu index 555af71c6..c0bacdf6e 100755 --- a/ba/prassi.mnu +++ b/ba/prassi.mnu @@ -150,6 +150,7 @@ 14|Ripristino indici libro unico|cg5 -4 inl 15|Manutenzione|4 15|Archivi|ba1 +15|Compatta tutti i files|ba1 -2 15|Utenti|ba1 -3 15|Attivazione|ba1 -4 15|Backup|ba2 -1