diff --git a/ba/ba1200.cpp b/ba/ba1200.cpp index 9b6f581e7..61ac05cd3 100755 --- a/ba/ba1200.cpp +++ b/ba/ba1200.cpp @@ -7,13 +7,15 @@ #include #include +#include + class TProfiler_mask : public TMask { public: TProfiler_mask(); }; -TProfiler_mask::TProfiler_mask() : TMask(TR("Test"), 1, 60, 9) +TProfiler_mask::TProfiler_mask() : TMask(TR("Test"), 1, 60, 14) { add_button_tool(DLG_OK, PR("Elabora"), TOOL_ELABORA); add_button_tool(DLG_INFO, PR("Info"), TOOL_INFO); @@ -26,8 +28,9 @@ TProfiler_mask::TProfiler_mask() : TMask(TR("Test"), 1, 60, 9) codes.add(2); items.add(TR("Lettura cursore su chiave primaria")); codes.add(3); items.add(TR("Lettura cursore con ordinamento fuori chiave")); codes.add(4); items.add(TR("Lettura causale con cache")); - codes.add(5); items.add(TR("Creazione e cancellazione records")); - codes.add(6); items.add(TR("Creazione e cancellazione records in modo esclusivo")); + codes.add(5); items.add(TR("Lettura causale senza cache")); + codes.add(6); items.add(TR("Creazione e cancellazione records")); + codes.add(7); items.add(TR("Creazione e cancellazione records in modo esclusivo")); add_radio(101, 0, TR("@bSelezione test"), 1, 1, 58, codes, items); add_number(102, 0, PR("Numero di iterazioni"), 1, 0, 3, "U"); @@ -53,6 +56,7 @@ protected: bool test4(TLog_report& log); bool test5(TLog_report& log); bool test6(TLog_report& log); + bool test7(TLog_report& log); public: bool test(int n, TLog_report& log); @@ -217,18 +221,19 @@ bool TTest_application::test4(TLog_report& log) start = start_timer(); for (int i = 0; i < times; i++) { - for (long j = 0; j < 10000; j++) - { - cod.format(" |%c%03d", 'A'+rand()%8, rand() % 1000); - cache().get(LF_COMUNI, cod); - r++; - } if (!p.addstatus(1)) { log.log(1, TR("Interrotto dall'utente")); ok = false; break; } + for (long j = 0; j < 10000; j++) + { + const int rn = rand(); + cod.format(" |%c%03d", 'A'+(rn%2), rn % 1000); + cache().get(LF_COMUNI, cod); + r++; + } } } @@ -241,6 +246,46 @@ bool TTest_application::test4(TLog_report& log) } bool TTest_application::test5(TLog_report& log) +{ + bool ok = true; + long r = 0; + srand(r); + TString8 cod; + + clock_t start; + { + const int times = 10; + TProgind p(times, TR("Lettura casuale senza cache"), TRUE, TRUE); + TLocalisamfile f(LF_COMUNI); + start = start_timer(); + for (int i = 0; i < times; i++) + { + if (!p.addstatus(1)) + { + log.log(1, TR("Interrotto dall'utente")); + ok = false; + break; + } + for (long j = 0; j < 10000; j++) + { + const int rn = rand(); + cod.format("%c%03d", 'A'+(rn%2), rn % 1000); + f.put(COM_COM, cod); + f.read(); + r++; + } + } + } + + const clock_t t = clock() - start; + TString msg; + msg.format("Lettura casuale di %ld records in %ld msec - %lg records per sec", + r, t, 1000.0*r/t); + log.log(0, msg); + return ok; +} + +bool TTest_application::test6(TLog_report& log) { bool ok = true; TString msg; @@ -294,7 +339,7 @@ bool TTest_application::test5(TLog_report& log) return ok; } -bool TTest_application::test6(TLog_report& log) +bool TTest_application::test7(TLog_report& log) { bool ok = true; TString msg; @@ -368,6 +413,7 @@ bool TTest_application::test(int n, TLog_report& log) case 4: ok = test4(log); break; case 5: ok = test5(log); break; case 6: ok = test6(log); break; + case 7: ok = test7(log); break; default: ok = false; break; } return ok; diff --git a/ba/ba1700.cpp b/ba/ba1700.cpp index f14ac4016..3b4e8ec07 100755 --- a/ba/ba1700.cpp +++ b/ba/ba1700.cpp @@ -449,7 +449,7 @@ bool TInstaller_mask::autoload() TString http_server; TFilename http_path, path, ininame; - //controla se si e' scelto un path di installazione internet o da disco + //controlla se si e' scelto un path di installazione internet o da disco const bool internet = get_patches_path(path); //se e' un aggiornamento via internet... if (internet) @@ -570,7 +570,7 @@ bool TInstaller_mask::autoload() if (internet) //internet patches { - TProgind pi(1, TR("Controllo lista aggiornamenti"), false); //progind NON bloccabile: causa errore impossibile! + TProgind pi(1, TR("Controllo lista aggiornamenti"), false); // progind NON bloccabile: causa errore impossibile! http_dir(http_server, http_path, modules); pi.setmax(modules.items()); pi.set_text(TR("Download lista aggiornamenti")); @@ -581,6 +581,7 @@ bool TInstaller_mask::autoload() TString& str = modules.row(i); if (str.ends_with("a.ini", true)) { + /* Triste nescessita': si rischia di non caricare nessuna patch const TString& module = str.left(2); const int patch = atoi(str.mid(2, 4)); const int mypatch = ini_get_int(CONFIG_GENERAL, module, "Patch"); @@ -589,6 +590,7 @@ bool TInstaller_mask::autoload() modules.destroy(i); continue; // Non fare il download delle patch inutili } + */ TFilename remote = http_path; remote << str; @@ -1551,7 +1553,7 @@ void TInstaller_mask::install_selection() const int oldpatch = row->get_int(C_CURRPATCH); pi.set_text(format(FR("Installazione modulo '%s'"), (const char*)modesc)); - if (version2year(newver) < 2009) + if (version2year(newver) < 2012) { error_box(FR("Il modulo '%s' non ha una versione valida."), (const char*)modesc); continue; @@ -1570,7 +1572,7 @@ void TInstaller_mask::install_selection() if (!is_patch && cmp > 0) { TString256 msg; - msg.format(FR("Si desidera ritornare alla versione %s.%d del modulo '%s' ?\nAttenzione: non e' garantito il corretto\nfunzionamento di tutti i programmi!"), (const char*)newver, newpatch, (const char*)modesc); + msg.format(FR("Si desidera ritornare alla versione %s.%d del modulo '%s' ?\nAttenzione: non è garantito il corretto\nfunzionamento di tutti i programmi!"), (const char*)newver, newpatch, (const char*)modesc); ok = noyes_box(msg); } @@ -1772,7 +1774,7 @@ bool TInstaller_mask::install_handler(TMask_field& fld, KEY key) if (some) _curr_mask->install_selection(); else - error_box(TR("Selezionare uno o piu' moduli da installare.")); + error_box(TR("Selezionare uno o più moduli da installare.")); } return true; } diff --git a/ba/ba2800.cpp b/ba/ba2800.cpp index ebb7be78d..e3b44984d 100644 --- a/ba/ba2800.cpp +++ b/ba/ba2800.cpp @@ -219,6 +219,7 @@ private: protected: virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); + bool on_sheet_event(TSheet_field& s, TField_event e, long jolly); bool fill_sheet(); void merge_sheet(); void save_sheet(); @@ -644,7 +645,9 @@ bool Tdninst_mask::fill_sheet() s.force_update(); - enable(DLG_ELABORA, !s.empty()); + const bool on = !s.empty(); + enable(DLG_ELABORA, on); + enable(DLG_SAVEREC, on); return true; } @@ -825,7 +828,57 @@ void Tdninst_mask::save_sheet() } } -static word _last_serno; +bool Tdninst_mask::on_sheet_event(TSheet_field& s, TField_event e, long jolly) +{ + static word _last_serno = 0; + + switch (e) + { + case se_query_add: // Lascio aggiungere una riga alla volta + { + TToken_string& r = s.row(s.items()-1); + _last_serno = r.get_int(0); + if (_last_serno > 0) + { + char str[8] = ""; + xvt_dm_post_string_prompt(TR("Inserire il numero di serie"), str, sizeof(str)); + _last_serno = atoi(str); + if (_last_serno > 0) + { + FOR_EACH_SHEET_ROW(s, r, row) + { + if (row->get_int(0) == _last_serno) + { + error_box(TR("Chiave già inserita")); + s.post_select(r); + _last_serno = 0; + break; + } + } + } + } + return _last_serno > 0; + } + case se_notify_add: + s.row(jolly).add(_last_serno, 0); + break; + case se_notify_modify: + { + TToken_string& r = s.row(jolly); + const int serno = r.get_int(0); + if (serno == _last_serno) + { + if (yesno_box(FR("Si desidera salvare la nuova chiave %d?"), serno)) + send_key(K_SPACE, DLG_SAVEREC, &s); + _last_serno = 0; + } + } + break; + case se_query_del: return false; + default: break; + } + return true; +} bool Tdninst_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) { @@ -839,8 +892,29 @@ bool Tdninst_mask::on_field_event(TOperable_field& o, TField_event e, long jolly } break; case DLG_ELABORA: - if (e == fe_button && yesno_box(TR("Aggiornare il file DNINST in base al DB MySQL?"))) - merge_sheet(); + if (e == fe_button) + { + TMask q(TR("Elaborazione"), 1, 50, 10); + TToken_string options = TR("Aggiornare il DNINST in base al DB|Aggiornare il DB in base al DNINST"); + q.add_radio(101, 0, TR("Operazione di aggiornamento"), 1, 1, 48, "0|1", options); + q.add_button(DLG_OK, 0, "", -12, -1, 10, 2); + q.add_button(DLG_CANCEL, 0, "", -22, -1, 10, 2); + if (q.run() == K_ENTER) + { + const int i = q.get_int(101); + if (yesno_box(options.get(i))) + { + switch (i) + { + case 1: + break; + default: + merge_sheet(); + break; + } + } + } + } break; case DLG_SAVEREC: if (e == fe_button) @@ -915,9 +989,7 @@ bool Tdninst_mask::on_field_event(TOperable_field& o, TField_event e, long jolly case F_XML_WWW: if ((e == fe_init || e == fe_modify || e == fe_close) && o.empty()) { - o.set(get(F_XML_WWW)); - if (o.empty()) - o.set("85.18.53.183"); + o.set("85.18.53.183"); set(F_XML_USR, "attivazioni"); set(F_XML_PWD, "viagra"); } @@ -932,56 +1004,8 @@ bool Tdninst_mask::on_field_event(TOperable_field& o, TField_event e, long jolly } break; case F_DNSHEET: - switch (e) - { - case se_query_add: // Lascio aggiungere una riga alla volta - { - TSheet_field& s = (TSheet_field&)o; - TToken_string& r = s.row(s.items()-1); - _last_serno = r.get_int(0); - if (_last_serno > 0) - { - char str[8] = ""; - xvt_dm_post_string_prompt(TR("Inserire il numero di serie"), str, sizeof(str)); - _last_serno = atoi(str); - if (_last_serno > 0) - { - FOR_EACH_SHEET_ROW(s, r, row) - { - if (row->get_int(0) == _last_serno) - { - error_box(TR("Chiave già inserita")); - s.post_select(r); - _last_serno = 0; - break; - } - } - } - } - return _last_serno > 0; - } - case se_notify_add: - { - TSheet_field& s = (TSheet_field&)o; - s.row(jolly).add(_last_serno, 0); - } - break; - case se_notify_modify: - { - TSheet_field& s = (TSheet_field&)o; - TToken_string& r = s.row(jolly); - const int serno = r.get_int(0); - if (serno == _last_serno) - { - if (yesno_box(FR("Si desidera salvare la nuova chiave %d?"), serno)) - send_key(K_SPACE, DLG_SAVEREC, &o); - _last_serno = 0; - } - } - break; - case se_query_del: return false; - default: break; - } + if (o.is_sheet()) + return on_sheet_event((TSheet_field&)o, e, jolly); break; case F_SUSPEND: case F_KILLED: @@ -1014,6 +1038,9 @@ Tdninst_mask::Tdninst_mask() : TAutomask("ba2800a") _c_xmlowner = s.cid2index(F_ATOWNER); _c_xmlyear = s.cid2index(F_ATYEAR); _c_xmlaccess= s.cid2index(F_ATACCESS); + + disable(DLG_ELABORA); + disable(DLG_SAVEREC); } /////////////////////////////////////////////////////////// @@ -1030,14 +1057,15 @@ protected: bool Tdninst_manager::create() { - const word n = dongle().number(); - // 8453 = Ilaria; 8517 = Sara; 8578 = Monica - if (n != 8453 && n != 8517 && !is_power_station()) - return error_box(TR("Postazione non abilitata")); - if (user() != dongle().administrator()) return error_box(TR("Utente non abilitato")); + const word n = dongle().number(); + // 8453 = Ilaria; 8517 = Sara; 8578 = Monica + if (n != 8453 && n != 8517 && !is_power_station() && + get_hostname().compare("nbkgiardini", -1, true) != 0) + return error_box(TR("Postazione non abilitata")); + TSheet_field::set_line_number_width(4); // Numero di chiavette ~ 1000 return TSkeleton_application::create(); diff --git a/ba/ba2800a.uml b/ba/ba2800a.uml index ddf24bc43..550c15583 100644 --- a/ba/ba2800a.uml +++ b/ba/ba2800a.uml @@ -12,12 +12,14 @@ BUTTON DLG_ELABORA 2 2 BEGIN PROMPT 2 1 "Elabora" PICTURE TOOL_ELABORA + FLAGS "D" END BUTTON DLG_SAVEREC 2 2 BEGIN PROMPT 2 1 "Salva" PICTURE TOOL_SAVEREC + FLAGS "D" END diff --git a/ba/ba4200b.uml b/ba/ba4200b.uml index 2f23c4437..706be6d2f 100755 --- a/ba/ba4200b.uml +++ b/ba/ba4200b.uml @@ -622,23 +622,23 @@ END STRING FLD_AF2_FAXRF 30 BEGIN -PROMPT 35 14 "Numero " -FIELD LF_ANAG->FAXRF -HELP "Numero del FAX" + PROMPT 35 14 "Numero " + FIELD LF_ANAG->FAXRF + HELP "Numero del FAX" END STRING FLD_AF2_PTLEXRF 10 BEGIN -PROMPT 2 15 "Telex : Prefisso " -FIELD LF_ANAG->PTLEXRF -HELP "Prefisso del telex" + PROMPT 2 15 "Telex : Prefisso " + FIELD LF_ANAG->PTLEXRF + HELP "Prefisso del telex" END STRING FLD_AF2_TLEXRF 30 BEGIN -PROMPT 35 15 "Numero " -FIELD LF_ANAG->TLEXRFX -HELP "Numero del telex" + PROMPT 35 15 "Numero " + FIELD LF_ANAG->TLEXRFX + HELP "Numero del telex" END STRING F_MAIL 50 @@ -653,8 +653,8 @@ PAGE "Pag.4" -1 -1 77 20 GROUPBOX DLG_NULL 78 5 BEGIN -PROMPT 0 0 "Persone fisiche" -FLAGS "R" + PROMPT 0 0 "Persone fisiche" + FLAGS "R" END NUMBER DLG_NULL 5