From 97cf10031586722b05d96324a473eb7ad367baa7 Mon Sep 17 00:00:00 2001 From: guy Date: Tue, 23 Dec 2008 09:11:50 +0000 Subject: [PATCH] =?UTF-8?q?Patch=20level=20=20=20=20=20=20=20=20=20:=2010.?= =?UTF-8?q?0=20200=20Files=20correlati=20=20=20=20=20:=20ba1.exe=20Ricompi?= =?UTF-8?q?lazione=20Demo=20:=20[=20]=20Commento=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20:=200001036:=20installazione=20cd=20patch=20180=20I?= =?UTF-8?q?nstallando=20ex=20novo=20ed=20indicando=20una=20societ=C3=A0=20?= =?UTF-8?q?esistente=20di=20dati=20su=20una=20cartella=20diversa=20viene?= =?UTF-8?q?=20segnalato=20l'errore=20ba1.exe=20in=20fase=20di=20conversion?= =?UTF-8?q?e=20archivi,=20richiamando=20da=20manutenzione=20archivi=20la?= =?UTF-8?q?=20conversione=20vengono=20generati=20gli=20errori=20allegati.?= =?UTF-8?q?=20Nell'area=20ftp=20di=20Aga,=20cartella=20Ilaria=20allego=20l?= =?UTF-8?q?'area=20dati=20SIDA=20per=20il=20test.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://10.65.10.50/trunk@17973 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- ba/ba1100.cpp | 183 ++++++++++++++++++++------------------------- ba/ba1100d.uml | 20 ++--- ba/ba1101.cpp | 196 +++++++++++++++++++++++++------------------------ ba/ba1300.cpp | 6 +- ba/ba1700.cpp | 27 +++---- ba/ba8100.cpp | 2 +- 6 files changed, 205 insertions(+), 229 deletions(-) diff --git a/ba/ba1100.cpp b/ba/ba1100.cpp index 664efd299..e2ac89582 100755 --- a/ba/ba1100.cpp +++ b/ba/ba1100.cpp @@ -689,7 +689,8 @@ void TManutenzione_app::edit_riga (long riga_sel, TToken_string& riga) TFilename f_name(d.name()); f_name.ext("dbf"); - if (!f_name.exist()) f.build(eox); + if (!f_name.exist()) + f.build(eox); _browse->dir().get(logicnum, _nolock, _nordir, _sysdirop); } @@ -800,38 +801,38 @@ bool TManutenzione_app::recover(TSystemisamfile& f, int err) void TManutenzione_app::repair_file(int i) { - TString s(_MAX_PATH); + TString s(_MAX_PATH + 50); // Messaggio di log TDir d(i); + const char* n = d.filename(); + if (d.eod() == 0) { - TFilename n(d.filename()); - save_file(n); - remove(n); - n.ext("cdx"); remove(n); - n.ext("fpt"); remove(n); - s.format(FR("File n. %d - %s : eliminato file errato"), i, (const char *)d.filename()); + + TToken_string names; get_table_names(i, names, 0xF); + FOR_EACH_TOKEN(names, name) + xvt_fsys_remove_file(name); + + s.format(FR("File n. %d - %s : eliminato file errato"), i, n); write_log(s, 2); } else { d.get(i, _lock, _nordir, _sysdirop); - TFilename n(d.filename()); save_file(n); - TExternisamfile ef(d.filename()); + TExternisamfile ef(n); const RecDes& rd = ef.curr().rec_des(); TTrec rec; rec.get(i); const int oldreclen = rec.len(); - const int recsize = sizeof(RecDes); rec.rec() = rd; rec.put(i); const int reclen = rec.len(); d.set_len(reclen); d.put(i, _nordir, _sysdirop); - s.format(FR("File n. %d - %s : corretto tracciato da %d a %d bytes"), i, (const char *)d.filename(), oldreclen, reclen); + s.format(FR("File n. %d - %s : corretto tracciato da %d a %d bytes"), i, n, oldreclen, reclen); write_log(s, 1); } } @@ -849,18 +850,18 @@ void TManutenzione_app::update_dir() // in modo da evitare colpe inutili. Noi aggiorniamo solo i tracciati su dir e trc, // ma il file fisico manco lo tocchiamo!! - const TString pref(prefix().name()); - const bool is_com = prefix().is_com(); - if (prefix().get_codditta() <= _history_firm) return; + const TString pref(prefix().name()); + const bool is_com = prefix().is_com(); const int last_new_item = _dirs.last(); //quale è il numero dell'ultimo file nuovo? TDir d(LF_DIR); // equivale a d.get(LF_DIR, _nolock, _nordir, _sysdirop); const int last_curr_item = (int)d.eod(); //quale è il numero dell'ultimo file attualmente presente const int update_items = (last_new_item < last_curr_item) ? last_new_item : last_curr_item; + safely_close_closeable_isamfiles(); // Serve a premettere la chiamata ad fsize() in sicurezza TString prompt(128); if (is_com) @@ -869,13 +870,12 @@ void TManutenzione_app::update_dir() prompt << TR("Aggiornamento ditta") << ' ' << atol(pref) << '.'; TProgind p(update_items ? update_items : 1, prompt, false, true); - p.setstatus(1); int i; - for (i = LF_USER; i <= update_items; i++) { - p.addstatus(1); + if (!p.setstatus(i)) + break; const TDir & ds = (const TDir &) _dirs[i]; const bool is_firm = ds.is_firm(); @@ -919,84 +919,75 @@ void TManutenzione_app::update_dir() { if (old_is_firm && !moveable_file(i) && d.eod() == 0L) { - TFilename n(d.filename()); + const char* n = d.filename(); save_file(n); - remove(n); - n.ext("cdx"); remove(n); - n.ext("fpt"); remove(n); + + TToken_string names; get_table_names(i, names, 0xF); + FOR_EACH_TOKEN(names, name) + xvt_fsys_remove_file(name); TString msg(_MAX_PATH); msg.format(FR("File n. %d - %s : eliminato file non utilizzato"), i, (const char *)d.filename()); write_log(msg, 1); } } - if (i > 2 && is_firm == old_is_firm) + if (i > LF_USER && is_firm == old_is_firm) { - FILE * f = fopen(fs, "r"); - if (f != NULL) + const long size = fsize(fs); + if (flags < 10000L && size > 0L && d.len() > 0) { - fseek(f, 0L, SEEK_END); - const long size = ftell(f); - fclose(f); + TSystemisamfile b(i); + int err = b.is_valid(true); + if ((err == _istrcerr || err == _ispatherr) && (d.eod() == 0) && (size < 4096)) + { + bool kill = true; + //controllo solo all'aga + if (is_power_station()) + kill = yesno_box(FR("Il tracciato record del file %d e' incoerente:\nSi desidera eliminare il file vuoto %s?"), i, (const char*)fs); + if (kill) + { + TToken_string names; get_table_names(i, names, 0xF); + FOR_EACH_TOKEN(names, name) + xvt_fsys_remove_file(name); - if (flags < 10000L && size > 0L && d.len() > 0) + err = NOERR; + // se si decide di eliminare il file con tracciato del cazzo deve tenerne traccia nel log (nel caso di utonti.. + //..è sempre così, perchè kill è sempre true) + TString msg; + msg.format(TR("Eliminato il file %d avente tracciato record incoerente"), i); + write_log(msg, 2); + } + } //if((err==_istrcerr... + + if (err != NOERR && flags < 10000L) { - TSystemisamfile b(i); - int err = b.is_valid(true); - if ((err == _istrcerr) && (d.eod() == 0) && (fsize(d.filename()) < 4096)) - { - bool kill = true; - //controllo solo all'aga - if (is_power_station()) - kill = yesno_box(FR("Il tracciato record del file %d e' incoerente:\nSi desidera eliminare il file vuoto %s?"), i, d.filename()); - if (kill) - { - TFilename n(d.filename()); - save_file(n); - remove(n); - n.ext("cdx"); remove(n); - n.ext("fpt"); remove(n); - err = NOERR; - // se si decide di eliminare il file con tracciato del cazzo deve tenerne traccia nel log (nel caso di utonti.. - //..è sempre così, perchè kill è sempre true) - TString msg; - msg.format(TR("Eliminato il file %d avente tracciato record incoerente"), n); - write_log(msg, 2); - } - } //if((err==_istrcerr... - + if (err == _istrcerr || err == _isbadtrc) + { + repair_file(i); + err = NOERR; + } if (err != NOERR && flags < 10000L) { - if (err == _istrcerr || err == _isbadtrc) - { - repair_file(i); - err = NOERR; - } - if (err != NOERR && flags < 10000L) - { - if (!recover(b, err)) - { - TString msg(_MAX_PATH); - msg.format(TR("Impossibile compattare il file %d - %s : errore n.ro %d"), i, (const char *)d.filename(), err); - write_log(msg, 2); - } - } - } //if(err!=NOERR && flags<10000L.. - } - else - { - if (flags < 10000L && to_create) - { - xvt_fsys_remove_file(d.filename()); - TToken_string idx_names; - get_idx_names(i, idx_names); - FOR_EACH_TOKEN(idx_names, idx_name) - xvt_fsys_remove_file(idx_name); - d.get(i, _nolock, _nordir, _sysdirop); - d.set_eod(0); - d.set_eox(0); - d.put(i, _nordir, _sysdirop); + if (!recover(b, err)) + { + TString msg(_MAX_PATH); + msg.format(TR("Impossibile compattare il file %d - %s : errore n.ro %d"), i, (const char *)d.filename(), err); + write_log(msg, 2); + } } + } //if(err!=NOERR && flags<10000L.. + } + else + { + if (flags < 10000L && to_create) + { + TToken_string names; + get_table_names(i, names, 0xF); + FOR_EACH_TOKEN(names, name) + xvt_fsys_remove_file(name); + d.get(i, _nolock, _nordir, _sysdirop); + d.reset_eox(); + d.put(i, _nordir, _sysdirop); } } } @@ -1030,21 +1021,13 @@ void TManutenzione_app::update_dir() if (fs == fn) { - TTrec wrs; - TTrec wrd; - - wrs.get(i); - - wrd.get(j); // A cosa ca$$o serve ... - wrd = wrs; // ... visto che poi lo sbatto via? - wrd.set_num(j); - + TTrec wrs(i), wrd(j); + wrd = wrs; wrd.set_num(j); // Copia e rinumera wrd.put(j); wrs.zero(); wrs.put(i); - TDir wds(i); - TDir wdd(j); - + + TDir wds(i), wdd(j); wdd.set(wds.name(), wds.eod(), wds.flags(), wds.des(), wds.expr()); wdd.set_eox(wds.eox()); wdd.set_len(wrd.len()); @@ -1068,7 +1051,7 @@ void TManutenzione_app::update_dir() { TToken_string ts(10),td(10); td.cut(0); - get_idx_names(i,ts); // Get index names of current file in current dir + get_table_names(i,ts,0x2); // Get index names of current file in current dir for (int j=1; j<= ts.items() && ok; j++) { const TFilename fsi(ts.get()); @@ -1168,11 +1151,9 @@ void TManutenzione_app::update_dir() //aggiornatore degli EOX EOD ecc. dei files nuovi for (i = last_curr_item + 1; i <= last_new_item; i++) { - TDir d1((TDir &) _dirs[i]); - + TDir d1((const TDir&)_dirs[i]); d1.set_len(0); - d1.set_eox(0); - d1.set_eod(0); + d1.reset_eox(); d1.set_flags(0); d1.put(i, _nordir, _sysdirop); //scrive su dir.gen il nuovo file aggiunto (mettendo numero,eox,eod,flags) } @@ -1180,8 +1161,6 @@ void TManutenzione_app::update_dir() //allinea i valori di eox ed eod (eox non può mai essere < eod!) d.get(LF_DIR, _nolock, _nordir, _sysdirop); d.set_eod(last_new_item); - if (d.eox() < d.eod()) - d.set_eox(d.eod()); d.put(LF_DIR, _nordir, _sysdirop); } @@ -1215,7 +1194,7 @@ void TManutenzione_app::convert_dir() break; const TTrec& rs = (const TTrec&)_recs[i]; // Nuovo tracciato record - const TDir& ds = (const TDir&)_dirs[i]; + const TDir& ds = (const TDir&)_dirs[i]; const long flags = ds.flags(); if (ds.len() > 0) diff --git a/ba/ba1100d.uml b/ba/ba1100d.uml index 12c0c5adc..de639d326 100755 --- a/ba/ba1100d.uml +++ b/ba/ba1100d.uml @@ -10,6 +10,16 @@ BEGIN GROUP 1 END +BUTTON DLG_PRINT 10 2 +BEGIN + PROMPT -25 -1 "" +END + +BUTTON DLG_NULL 2 2 +BEGIN + PROMPT -1 -1 "" +END + BUTTON DLG_IMPORT 10 2 BEGIN PROMPT -45 -1 "~Importa" @@ -26,15 +36,7 @@ BEGIN GROUP 1 END -BUTTON DLG_PRINT 10 2 -BEGIN - PROMPT -25 -1 "" -END - -BUTTON DLG_CANCEL 10 2 -BEGIN - PROMPT -55 -1 "" -END +#include ENDPAGE diff --git a/ba/ba1101.cpp b/ba/ba1101.cpp index c346d80f5..8d7a6c31f 100755 --- a/ba/ba1101.cpp +++ b/ba/ba1101.cpp @@ -31,7 +31,7 @@ TDir_sheet::TDir_sheet(const char* title, bool superprassi, const char* colonne) : TSheet(0, 0, 0, 0, title, colonne, superprassi ? 0xC : 0x8) { add_button(DLG_PRINT, TR("Tracciati"), K_F3, BMP_PRINT); - add_button(-1, "", 0, 1); // Separatore + add_button(DLG_NULL, "", 0); // Separatore if (superprassi) { @@ -39,7 +39,7 @@ TDir_sheet::TDir_sheet(const char* title, bool superprassi, const char* colonne) add_button(DLG_CONVERT, TR("Conversione"), K_F7, 156); if (is_power_station()) add_button(DLG_ADDFILE, TR("Nuovo file"), K_F8, BMP_NEWREC); - add_button(-1, "", 0, 1); // Separatore + add_button(DLG_NULL, "", 0); // Separatore } add_button(DLG_INFO, TR("Info"), K_F2, BMP_INFO); @@ -173,12 +173,13 @@ bool TRec_sheet::key_notify(TSheet_field& f, int r, KEY k) if (k == K_INS) { const int items = f.items(); - if (items >= 8) return FALSE; + if (items >= 8) + return false; } else if (k == K_CTRL + K_INS) f.enable_cell(r, 1, r > 0); - return TRUE; + return true; } void TRec_sheet::save_desc() @@ -310,107 +311,108 @@ void TRec_sheet::edit() save(); return; } - case K_ESC: - if (_descr && (_mask->dirty() || import_dirty)) - { - // Se viene premuto Annulla NON deve salvare le descrizioni! Altrimenti che annulla e'? - // Salva il vecchio file di descrizione con un altro nome... - if (!import_dirty) - fcopy(_descfname,"des.xxx"); - // libera _descr (scrivendo il file) - delete _descr; - _descr = NULL; - // Ripristina il vecchio file e rimuove il file temporaneo - fcopy("des.xxx",_descfname); - } - remove("des.xxx"); - return; - case K_ENTER: - main_app().print(); - break; - case K_F6: - { - TMask m("ba1100f"); - TFilename nf; - nf << 'f' << _dir.num(); - nf.ext("trr"); - m.set(F_NOMEF, nf); - if (m.run() == K_ENTER) + case K_ESC: + if (_descr && (_mask->dirty() || import_dirty)) { - nf = m.get(F_NOMEF); - if (nf.not_empty()) + // Se viene premuto Annulla NON deve salvare le descrizioni! Altrimenti che annulla e'? + // Salva il vecchio file di descrizione con un altro nome... + if (!import_dirty) + fcopy(_descfname,"des.xxx"); + // libera _descr (scrivendo il file) + delete _descr; + _descr = NULL; + // Ripristina il vecchio file e rimuove il file temporaneo + fcopy("des.xxx",_descfname); + } + remove("des.xxx"); + return; + case K_ENTER: + main_app().print(); + break; + case K_F6: + { + TMask m("ba1100f"); + TFilename nf; + nf << 'f' << _dir.num(); + nf.ext("trr"); + m.set(F_NOMEF, nf); + if (m.run() == K_ENTER) { - save_desc(); + nf = m.get(F_NOMEF); + if (nf.not_empty()) { - _rec.set_des(_descr,_tab.upper()); - ofstream out(nf); - out << _rec; - _rec.set_des(); - } - nf.ext("dir"); - ofstream out(nf); - out << _dir; - } - } - } - break; - case K_F7: - { - TMask m("ba1100f"); - TFilename nout(_dir.name()); - - nout.strip("$%"); - nout.ext("trr"); - m.set(F_NOMEF, nout); - if (m.run() == K_ENTER) - { - const TFilename nf(m.get(F_NOMEF)); - if (nf.not_empty()) - { - import_dirty = TRUE; - _rec.set_des(_descr,_tab.upper()); - ifstream in(nf); - in >> _rec; - nfields = _rec.fields(); - fcopy(_descfname,"des.xxx"); // salva il vecchio file di descrizioni - f1.destroy(-1); - - for (int i = 0; i < nfields; i++) - { - f1.row(i) = _rec.fielddef(i); - if (_descr) - f1.row(i).add(_descr->get(_rec.rec().Fd[i].Name)); - else - f1.row(i).add(""); - const TFieldtypes type = (TFieldtypes) f1.row(i).get_int(1); - switch (type) + save_desc(); { - case _datefld : - case _wordfld : - case _charfld : - case _boolfld : - case _memofld: - f1.disable_cell(i, 2); - case _alfafld : - case _intfld : - case _longfld : - case _intzerofld : - case _longzerofld: - f1.disable_cell(i, 3); - default: - break; + _rec.set_des(_descr,_tab.upper()); + ofstream out(nf); + out << _rec; + _rec.set_des(); } + nf.ext("dir"); + ofstream out(nf); + out << _dir; } - nkeys = _rec.keys(); - f2.reset(); - for (int i = 0; i < nkeys; i++) - f2.row(i) = _rec.keydef(i); - f2.disable_cell(0, 1); } } + break; + case K_F7: + { + TMask m("ba1100f"); + TFilename nout(_dir.name()); + + nout.strip("$%"); + nout.ext("trr"); + m.set(F_NOMEF, nout); + if (m.run() == K_ENTER) + { + const TFilename nf(m.get(F_NOMEF)); + if (nf.not_empty()) + { + import_dirty = TRUE; + _rec.set_des(_descr,_tab.upper()); + ifstream in(nf); + in >> _rec; + nfields = _rec.fields(); + fcopy(_descfname,"des.xxx"); // salva il vecchio file di descrizioni + f1.destroy(-1); + + for (int i = 0; i < nfields; i++) + { + f1.row(i) = _rec.fielddef(i); + if (_descr) + f1.row(i).add(_descr->get(_rec.rec().Fd[i].Name)); + else + f1.row(i).add(""); + const TFieldtypes type = (TFieldtypes) f1.row(i).get_int(1); + switch (type) + { + case _datefld : + case _wordfld : + case _charfld : + case _boolfld : + case _memofld: + f1.disable_cell(i, 2); + case _alfafld : + case _intfld : + case _longfld : + case _intzerofld : + case _longzerofld: + f1.disable_cell(i, 3); + default: + break; + } + } + nkeys = _rec.keys(); + f2.reset(); + for (int i = 0; i < nkeys; i++) + f2.row(i) = _rec.keydef(i); + f2.disable_cell(0, 1); + } + } + } + break; + default: + return; // K_QUIT } - break; - default: break; - } } } diff --git a/ba/ba1300.cpp b/ba/ba1300.cpp index 9ed468099..c6c4c27c4 100755 --- a/ba/ba1300.cpp +++ b/ba/ba1300.cpp @@ -96,8 +96,9 @@ void TPackFiles_application::build_sheet() void TPackFiles_application::search_blanks(TSystemisamfile& f) { - // Scorre il file corrente per record cancellando eventuali record vuoti/blank - if (f.open(_excllock, true)) + // Scorre il file corrente per record cancellando eventuali record vuoti/blank + const TIsam_handle h = f.open(_excllock, true); + if (h >= 0) { const long records = f.items(); TString k; @@ -119,6 +120,7 @@ void TPackFiles_application::search_blanks(TSystemisamfile& f) void TPackFiles_application::pack_all() { TProgind p(_selsheet->checked(), TR("Compattazione in corso..."), true, true); + safely_close_closeable_isamfiles(); FOR_EACH_CHECKED_ROW(*_selsheet, k, row) { if (!p.addstatus(1)) diff --git a/ba/ba1700.cpp b/ba/ba1700.cpp index 11036ab49..ccc7627d1 100755 --- a/ba/ba1700.cpp +++ b/ba/ba1700.cpp @@ -345,10 +345,7 @@ bool TInstaller_mask::autoload() TString_array& mask_rows = rows_array(); TString http_server; - TFilename http_path; - - TFilename path; - TFilename ininame; + TFilename http_path, path, ininame; //controla se si e' scelto un path di installazione internet o da disco const bool internet = get_patches_path(path); @@ -357,21 +354,15 @@ bool TInstaller_mask::autoload() { parse_internet_path(http_server, http_path); //controlla il path internet scritto nel campo sulla maschera - make_dir(path); //crea la directory temporanaea di installazione dove depositare e scompattare gli zip + //se si ritrova dei vecchi file nella directory temporanea, la pulisce per evitare casini + ininame = path; ininame.add("*.*"); + TString_array list; + ::list_files(ininame, list); + FOR_EACH_ARRAY_ROW(list, i, row) + xvt_fsys_remove_file(*row); ininame = path; ininame.add(TInstall_ini::default_name()); - - //se si ritrova dei vecchi .ini nella directory temporanea->pulisce la directory temporanea x evitare casini - if (ininame.exist()) //&& yesno_box(TR("Si desidera svuotare la cache dei files scaricati dal sito?"))) domanda del cazzo! - { - TString_array list; - TFilename name = path; name.add("*.*"); - ::list_files(name, list); - - FOR_EACH_ARRAY_ROW(list, i, row) - ::remove(*row); - } if (!ininame.exist()) { TFilename remote_ini = http_path; @@ -1177,15 +1168,15 @@ bool TInstaller_mask::install(const TString& module, int patchlevel) return ok; } - bool TInstaller_mask::get_patches_path(TFilename& path) const { const TEdit_field& www = efield(F_WEB); - path = get(F_WEB); + path = www.get(); if (www.active() && path.full() && is_internet_path(path)) { path.tempdir(); path.add("www"); + make_dir(path); //crea la directory temporanaea di installazione dove depositare e scompattare gli zip return true; } else diff --git a/ba/ba8100.cpp b/ba/ba8100.cpp index 92472eea5..87fc05805 100755 --- a/ba/ba8100.cpp +++ b/ba/ba8100.cpp @@ -287,7 +287,7 @@ void TSelector_app::save_cursor_key(TCursor& cur, TConfig& ini) TString16 para; para << curr.num(); ini.set_paragraph(para); - const RecDes& rd = *curr.rec_des(); + const RecDes& rd = curr.rec_des(); const KeyDes& kd = rd.Ky[0]; for (int i = 0; i < kd.NkFields; i++) {