campo-sirio/ba/ba1300.cpp
angelo 3275903d6e Aggiunto un programma per il test dell' ISAM.
git-svn-id: svn://10.65.10.50/trunk@288 c028cbd2-c16b-5b4b-a496-9718f37d4682
1994-09-27 08:24:05 +00:00

163 lines
4.6 KiB
C++
Executable File

#include <stdlib.h>
#include <applicat.h>
#include <xvtility.h>
#include <utility.h>
#include <prefix.h>
#include <mask.h>
#include <isam.h>
#include <string.h>
#include <sheet.h>
#include <msksheet.h>
#include <progind.h>
#include <urldefid.h>
#include <validate.h>
#include "ba1.h"
#include "ba1300.h"
#include "ba1300a.h"
class BA1300_application:public TApplication
{
TTestSheet * _testsheet;
TTestProc * _test;
TMask * _mask;
long _firm;
protected:
virtual bool menu(MENU_TAG);
virtual bool create () ;
virtual bool destroy();
virtual bool extended_firm() const { return TRUE; }
public:
BA1300_application() : _testsheet(NULL), _mask(NULL) {}
TTestSheet * get_sheet() {return _testsheet;}
TTestProc * get_test() {return _test;}
TMask * get_mask() {return _mask;}
};
bool BA1300_application::create() // initvar e arrmask
{
_firm = get_firm();
if (argc() > 2)
{
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);
dispatch_e_menu(BAR_ITEM(1));
}
return TRUE ;
}
bool BA1300_application::destroy() // releasev e arrmask
{
if (_firm) set_firm(_firm);
if (_testsheet != NULL) delete _testsheet;
if (_mask != NULL) delete _mask;
return TRUE ;
}
bool BA1300_application::menu(MENU_TAG m)
{
KEY tasto,tastoS;
long numtest;
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("Monitor");
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()))
{
if (get_mask()->get_bool(F_CONTINUO))
get_test()->get_win()->WriteW(33,5,(const char*)TString(20).format("%4ld (CONTINUO)",numtest));
else
get_test()->get_win()->WriteW(33,5,(const char*)TString(20).format("%4ld/%-4ld",numtest,_mask->get_long(F_ITERAZIONI)));
get_test()->set_numt(numtest);
get_test()->do_test_1();
}
if (get_test()->rm_copy())
{ // Funzione di cancellazione da implementare sotto windows
TString base(get_test()->get_base());
get_test()->get_win()->WriteW(33,10,"CANCELLAZIONE COPIE ");
for (int i=0;i<get_sheet()->items();i++)
if (get_sheet()->checked(i))
{
TString nome(get_sheet()->row(i).get(2));
TString fpath;
nome.ltrim(1);
nome.rtrim(4);
fpath << base << nome << ".sta";
remove((const char*)fpath);
fpath.rtrim(4);
fpath << ".sdx";
remove((const char*)fpath);
}
}
delete _test;
}
else
warning_box("No files selected!");
break;
case K_F4:
get_sheet()->sr_status();
while ((tastoS=get_sheet()->run()) == K_F6)
for (int i=0; i<get_sheet()->items();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
message_box("Report not available");
break;
default:
break;
}
} while (tasto != K_ESC);
return xvt_test_menu_tag(BAR_ITEM(2));
}
int ba1300(int argc, char** argv)
{
BA1300_application a;
a.run(argc,argv,"Test dell'ISAM");
return 0;
}