From 484f0244fc03dc4ac12d121184801224d1bd7ece Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 15 Dec 1997 15:11:40 +0000 Subject: [PATCH] ba1500?.* Gestione autorizzazioni basate sulle date ba1600.* Fascicolatore con versione sottomoduli ba1700.* Gestione versione sottomodule bacnv.cpp Corretta conversione uffici unici delle imposte Governo ladro: meno uffici, meno imposte, piu' quote latte! git-svn-id: svn://10.65.10.50/trunk@5749 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- ba/ba1500.cpp | 689 ++++++++++++++++++++++++++++++++++++++----------- ba/ba1500.h | 74 +++++- ba/ba1500a.h | 8 +- ba/ba1500a.uml | 25 +- ba/ba1600.cpp | 86 +++++- ba/ba1600.h | 6 + ba/ba1700.cpp | 259 +++++++++++++++---- ba/ba1700a.uml | 104 -------- ba/bacnv.cpp | 16 +- 9 files changed, 933 insertions(+), 334 deletions(-) delete mode 100755 ba/ba1700a.uml diff --git a/ba/ba1500.cpp b/ba/ba1500.cpp index 8b81f8293..d6f7e4efd 100755 --- a/ba/ba1500.cpp +++ b/ba/ba1500.cpp @@ -1,8 +1,10 @@ #include #include +#include #include #include #include +#include #include #include @@ -11,6 +13,7 @@ #include "ba1.h" #include "ba1500.h" #include "ba1500a.h" +#include "ba1600.h" #define USERADR 26952 #define AGAADR 26953 @@ -23,52 +26,11 @@ #define BITTEST(w,p) (((w) & (0x0001 << (p))) != 0) #define BITSET(w,p,v) ((v) ? ((w) |= (0x0001 << (p))) : ((w) &= (~(0x0001 << (p))))) -enum KeyType { _user_key, _aga_key, _prassi_key, _procom_key}; -class TDongle : public TObject -{ - word _serno, _max_users; - KeyType _type; - word _eprom[64]; - TDate _last_update; - -#if XVT_OS == XVT_OS_SCOUNIX - word _port; -#endif - - TBit_array _module; - bool _dirty; - -protected: - bool already_programmed() const; - bool write_octect(word reg, word data[4]) const; - -public: - bool login(); - bool logout(); - - word number() const { return _serno; } - bool ok() const { return _serno != 0xFFFF; } - word max_users() const { return _max_users; } - - void garble(word data[4]) const; - - KeyType type() const { return _type; } - - bool active(word module) const { return _module[module]; } - void activate(word module, bool on = TRUE) { _module.set(module, on); _dirty = TRUE; } - void deactivate(word module) { activate(module, FALSE); } - void set_max_users(word u) { _max_users = u; _dirty = TRUE; } - - bool dirty() const { return _dirty; } - bool burn(); - - TDongle(); - virtual ~TDongle() { logout(); } -}; TDongle::TDongle() - : _type(_user_key), _serno(0xFFFF), _dirty(FALSE), _max_users(1) + : _type(_user_key), _serno(0xFFFF), _dirty(FALSE), + _max_users(1), _year_assist(1997) { memset(_eprom, 0, sizeof(_eprom)); } @@ -92,10 +54,10 @@ bool TDongle::already_programmed() const memcpy(data, &_eprom[60], sizeof(data)); garble(data); - if (data[0] != 0xFACE) + if (data[0] < 1997 || data[0] > 2997) return FALSE; - if (data[1] == 0 || data[1] > 255) + if (data[1] == 0 || data[1] >= 10000) return FALSE; const TDate today(TODAY); @@ -156,13 +118,14 @@ bool TDongle::login() { #ifdef DBG if (data[0] == 0x3283) - { - _type = _aga_key; + { +// _type = _aga_key; _serno = 0; - } -#endif + } +#else if (_type == _user_key) ok = FALSE; +#endif } } @@ -204,23 +167,35 @@ bool TDongle::login() break; } - // Legge numero massimo di utenti + // Legge anno di assitenza e numero massimo di utenti memcpy(data, &_eprom[60], sizeof(data)); - garble(data); - _max_users = data[1]; - if (_max_users <= 0 || _max_users > 255) - _max_users = 1; + garble(data); - const long& giulio = (const long&)data[2]; - const long yyyymmdd = _last_update.julian2date(giulio); - _last_update = yyyymmdd; + if (already) + { + _year_assist = data[0]; + _max_users = data[1]; + const long& giulio = (const long&)data[2]; + const long yyyymmdd = _last_update.julian2date(giulio); + _last_update = yyyymmdd; + } + else + { + _max_users = 1; + _last_update = TDate(TODAY); + _year_assist = _last_update.year(); + } } else { - _module.set(MAX_AUT-1); - _module.set(); + if (_type != _user_key) + { + _module.set(MAX_AUT); + _module.set(); // Activate all modules + } _max_users = 1; _last_update = TDate(TODAY); + _year_assist = _last_update.year(); } } #endif @@ -270,9 +245,9 @@ bool TDongle::burn() { memcpy(data, &_eprom[60], sizeof(data)); garble(data); - if (data[0] != 0xFACE) - return error_box("Checksum error."); - if (data[1] == 0 || data[1] > 255) + if (data[0] < 1997 || data[0] > 2997) + return error_box("On Line Assistance error."); + if (data[1] == 0 || data[1] >= 10000) return error_box("Bad users number."); const long& val = (const long&)data[2]; const long yyyymmdd = today.julian2date(val); @@ -281,7 +256,7 @@ bool TDongle::burn() return error_box("Too late sir: key has already expired!"); } - data[0] = 0xFACE; + data[0] = _year_assist; data[1] = _max_users; long& val = (long&)data[2]; val = today.date2julian(); @@ -364,7 +339,7 @@ TInformazione_moduli::TInformazione_moduli() } } -const char * TInformazione_moduli::get_description_by_order(int index) +const char* TInformazione_moduli::get_description_by_order(int index) { if (index >= 0 && index < _infos.items()) return _infos.row(index).get(0); @@ -372,7 +347,7 @@ const char * TInformazione_moduli::get_description_by_order(int index) return ""; } -const char * TInformazione_moduli::get_name_by_order(int index) +const char* TInformazione_moduli::get_name_by_order(int index) { if (index >= 0 && index < _infos.items()) return _infos.row(index).get(1); @@ -388,17 +363,105 @@ int TInformazione_moduli::get_module_by_order(int index) return -1; } -const char * TInformazione_moduli::get_description(int module) +TDongle::KeyType TInformazione_moduli::get_owner(int module) const +{ + if (module >= 40 && module <= 46) + return TDongle::_procom_key; + + const int aut[] = { CMAUT, ATAUT, POAUT, AFAUT, TCAUT, TMAUT, + VEAUT, MGAUT, ORAUT, EFAUT, DBAUT, SVAUT, -1 }; + for (int a = 0; aut[a] >= 0; a++) + if (module == aut[a]) + return TDongle::_aga_key; + + return TDongle::_prassi_key; +} + +bool TInformazione_moduli::test_owner(int module, TDongle::KeyType owner) const +{ + TDongle::KeyType ow = get_owner(module); + bool yes = owner == ow || (owner == TDongle::_aga_key && ow == TDongle::_prassi_key); + return yes; +} + +const char* TInformazione_moduli::get_description(int module) { return get_description_by_order(_index[module]); } -const char * TInformazione_moduli::get_name(int module) +const char* TInformazione_moduli::get_name(int module) { return get_name_by_order(_index[module]); } int TInformazione_moduli::get_index(int module) { return _index[module]; } + /////////////////////////////////////////////////////////// -// +// TForm richiesta attivazione +/////////////////////////////////////////////////////////// + +class TRequest_form : public TForm +{ +public: + void update_serno(const TString& serno); + void update_dongle(const TDongle& dongle); + void print_footer(); + + TRequest_form(const char* name); + virtual ~TRequest_form() { } +}; + +TRequest_form::TRequest_form(const char* name) + : TForm(name) +{ + const TPrint_section& header = section('H', odd_page); + const TPrint_section& footer = section('F', odd_page); + + int riga[66]; + int y1 = header.height()-2; + int y2 = printer().formlen() - footer.height(); + if ((y2-y1) & 0x1) y2--; // Forza un numero pari di righe + + for (int i = 0; ; i++) + { + riga[i] = y1 + 2*(i+1); + if (riga[i] >= y2-1) + { + riga[i] = 0; + break; + } + } + genera_intestazioni(odd_page, y1+1); + genera_fincatura(odd_page, y1, y2, riga); +} + +void TRequest_form::update_serno(const TString& num) +{ + const TDate today(TODAY); + TForm_item& data = find_field('H', odd_page, 101); + data.set(today.string()); + TForm_item& serno = find_field('H', odd_page, 102); + serno.set(num); +} + +void TRequest_form::update_dongle(const TDongle& dongle) +{ + TForm_item& year = find_field('H', odd_page, 103); + TString str; + str << "31-12-" << (int)dongle.year_assist(); + year.set(str); + + TForm_item& user = find_field('H', odd_page, 104); + str.format("%d", dongle.max_users()); + user.set(str); +} + +void TRequest_form::print_footer() +{ + set_footer(odd_page, TRUE); + printer().formfeed(); +} + +/////////////////////////////////////////////////////////// +// TAttivazione_moduli /////////////////////////////////////////////////////////// class TAttivazione_moduli : public TApplication @@ -408,6 +471,8 @@ class TAttivazione_moduli : public TApplication TDongle _dongle; word _serno; + + word _wanted_users, _wanted_assist; protected: virtual bool create() ; @@ -417,7 +482,8 @@ protected: void garble(word k[4]) const; void garble(word n, TString& str) const; - void garble_users(word u, TString& str) const; + void garble_user(word u, TString& str) const; + void garble_year(word u, TString& str) const; word& serno() { return _serno; } @@ -431,18 +497,29 @@ protected: static void keyext(const TString & s, word * v); static void encode_second_key(); - static bool user_hnd(TMask_field & f, KEY k); - static bool date_hnd(TMask_field & f, KEY k); - static bool serno_hnd(TMask_field & f, KEY k); - static bool decode_hnd(TMask_field & f, KEY k); - static bool activate_hnd(TMask_field & f, KEY k); + static bool user_hnd(TMask_field& f, KEY k); + static bool date_hnd(TMask_field& f, KEY k); + static bool serno_hnd(TMask_field& f, KEY k); + static bool decode_hnd(TMask_field& f, KEY k); + static bool activate_hnd(TMask_field& f, KEY k); - static bool k_notify(TSheet_field & f, int r, KEY k); + static bool k_notify(TSheet_field& f, int r, KEY k); static bool change_users_handler(TMask_field&, KEY key); static bool maxuser_handler(TMask_field& fld, KEY key); + static bool change_assist_handler(TMask_field&, KEY key); + static bool assist_handler(TMask_field& fld, KEY key); + static bool print_handler(TMask_field& fld, KEY key); + static bool aggiorna_listino_handler(TMask_field& fld, KEY key); + +protected: + void print_request(); + void print_answer(); -public: - TAttivazione_moduli() : _msk(NULL) { } +public: + virtual void print(); + + TAttivazione_moduli() : _msk(NULL), _wanted_users(0), _wanted_assist(0) { } + virtual ~TAttivazione_moduli() { } }; @@ -452,7 +529,7 @@ int TAttivazione_moduli::build_sheet(bool on) { int nmod = 0; TSheet_field& sf = (TSheet_field&)_msk->field(F_MODULI); - for (int i = 0; i < _im->items(); i++) + for (int i = 0; i < MAX_AUT; i++) { const TFixed_string d(_im->get_description_by_order(i)); if (d.blank()) @@ -494,60 +571,76 @@ void TAttivazione_moduli::garble(word n, TString& str) const str.format("%04X%04X", data[0], data[1]); } -void TAttivazione_moduli::garble_users(word u, TString& str) const +void TAttivazione_moduli::garble_user(word u, TString& str) const { + const TDate today(_msk->get(F_DT)); + const long val = today.date2julian(); + word data[4]; data[0] = word(_msk->get_int(F_SN)); data[1] = u; - data[2] = 0; - data[3] = 0; + data[2] = word(val >> 16); + data[3] = word(val & 0xFFFF); garble(data); str.format("%04X%04X", data[0], data[1]); } +void TAttivazione_moduli::garble_year(word y, TString& str) const +{ + const TDate today(_msk->get(F_DT)); + const long val = today.date2julian(); + + word data[4]; + data[0] = y; + data[1] = word(_msk->get_int(F_SN)); + data[2] = word(val >> 16); + data[3] = word(val & 0xFFFF); + garble(data); + str.format("%04X%04X", data[0], data[1]); +} void TAttivazione_moduli::build_key_column() { - TSheet_field& sf = (TSheet_field&)_msk->field(F_MODULI); + TSheet_field& sf = _msk->sfield(F_MODULI); sf.enable_column(F_KEY, FALSE); TString16 tmp; - for (int i = sf.items()-1; i >= 0; i--) + FOR_EACH_SHEET_ROW_BACK(sf, i, riga) { if (!sf.cell_disabled(i, 1)) { - TToken_string& riga = sf.row(i); - int module = riga.get_int(2); + int module = riga->get_int(2); garble(module, tmp); - riga.add(tmp, 3); + riga->add(tmp, 3); } } - sf.force_update(); + + _msk->set(F_USERS, _dongle.max_users()); + _msk->set(F_ASSIST, _dongle.year_assist()); } bool TAttivazione_moduli::burn_dongle() { - bool ok = _dongle.type() == _user_key; + bool ok = _dongle.type() == TDongle::_user_key; if (ok) { TString16 str, key; TSheet_field& sf = _msk->sfield(F_MODULI); - for (int i = 0; i < sf.items(); i++) + FOR_EACH_SHEET_ROW(sf, i, riga) { - TToken_string& riga = sf.row(i); - key = riga.get(3); key.trim(); + key = riga->get(3); key.trim(); if (key.not_empty()) { - const int module = riga.get_int(2); + const int module = riga->get_int(2); garble(module, str); if (key == str) { if (!_dongle.active(module) && yesno_box("Confermare l'attivazione del modulo %d:\n%s", - module, riga.get(0))) + module, riga->get(0))) { _dongle.activate(module); } @@ -556,7 +649,7 @@ bool TAttivazione_moduli::burn_dongle() { if (_dongle.active(module) && yesno_box("Confermare la disattivazione del modulo %d:\n%s", - module, riga.get(0))) + module, riga->get(0))) { _dongle.deactivate(module); } @@ -581,10 +674,10 @@ bool TAttivazione_moduli::maxuser_handler(TMask_field& fld, KEY key) if (key == K_TAB && fld.focusdirty()) { const int utenti = atoi(fld.get()); - if (utenti > 0 && utenti <= 255) + if (utenti > 0 && utenti < 10000) { TString16 str; - app().garble_users(utenti, str); + app().garble_user(utenti, str); fld.mask().set(102, str); } else @@ -597,17 +690,16 @@ bool TAttivazione_moduli::change_users_handler(TMask_field& fld, KEY key) { if (key == K_SPACE) { - TMask m("Utenti", 1, 40, 6); - m.add_number(101, 0, "Utenti ", 1, 1, 3, "U"); + TMask m("Utenti", 1, 40, 5); + m.add_number(101, 0, "Utenti ", 1, 1, 4, "U"); m.add_string(102, 0, "Codice ", 1, 2, 8, "U"); m.add_button(DLG_OK, 0, "", -12, -1, 10, 2); m.add_button(DLG_CANCEL, 0, "", -22, -1, 10, 2); TDongle& dongle = app().dongle(); - - m.set(101, dongle.max_users()); - - if (dongle.type() != _user_key) + if (dongle.type() == TDongle::_user_key) + m.set(101, dongle.max_users()); + else { m.set_handler(101, maxuser_handler); m.disable(102); @@ -615,29 +707,123 @@ bool TAttivazione_moduli::change_users_handler(TMask_field& fld, KEY key) if (m.run() == K_ENTER) { - if (dongle.type() == _user_key) + const int utenti = m.get_int(101); + if (dongle.type() == TDongle::_user_key) { - const int utenti = m.get_int(101); - if (utenti > 0 && utenti <= 255) - { - TString16 str; - app().garble_users(utenti, str); - if (str == m.get(102)) - { - dongle.set_max_users(utenti); - fld.mask().set(F_USERS, utenti); - } + if (utenti > 0 && utenti < 10000) + { + if (m.field(102).empty()) + { + app()._wanted_users = utenti; + if (utenti > 0) + fld.message_box("Premere il bottone '%s'\n" + "per richiedere l'attivazione di %d utenti.", + fld.mask().field(F_PRINT).prompt(), utenti); + } else - error_box("Codice errato"); + { + TString16 str; + app().garble_user(utenti, str); + if (str == m.get(102)) + { + dongle.set_max_users(utenti); + fld.mask().set(F_USERS, utenti); + } + else + fld.error_box("Codice errato"); + } } else - error_box("Numero di utenti errato"); + fld.error_box("Numero di utenti errato"); } + else + app()._wanted_users = utenti; } } return TRUE; } +bool TAttivazione_moduli::assist_handler(TMask_field& fld, KEY key) +{ + bool ok = TRUE; + if (key == K_TAB && fld.focusdirty()) + { + const int year = atoi(fld.get()); + if (year > 1997 && year <= 2997) + { + TString16 str; + app().garble_year(year, str); + fld.mask().set(102, str); + } + else + ok = fld.error_box("Anno errato"); + } + return ok; +} + +bool TAttivazione_moduli::change_assist_handler(TMask_field& fld, KEY key) +{ + if (key == K_SPACE) + { + TMask m("Assistenza", 1, 40, 5); + m.add_number(101, 0, "Anno ", 1, 1, 4, "U"); + m.add_string(102, 0, "Codice ", 1, 2, 8, "U"); + m.add_button(DLG_OK, 0, "", -12, -1, 10, 2); + m.add_button(DLG_CANCEL, 0, "", -22, -1, 10, 2); + + TDongle& dongle = app().dongle(); + if (dongle.type() == TDongle::_user_key) + m.set(101, dongle.year_assist()); + else + { + m.set_handler(101, assist_handler); + m.disable(102); + } + + if (m.run() == K_ENTER) + { + const word year = m.get_int(101); + if (dongle.type() == TDongle::_user_key) + { + if (year > dongle.year_assist() && year <= 2997) + { + if (m.field(102).empty()) + { + app()._wanted_assist = year; + fld.message_box("Premere il bottone '%s'\n" + "per rinnovare il contratto di assistenza per l'anno %u.", + fld.mask().field(F_PRINT).prompt(), year); + } + else + { + TString16 str; + app().garble_year(year, str); + if (str == m.get(102)) + { + dongle.set_year_assist(year); + fld.mask().set(F_ASSIST, year); + } + else + fld.error_box("Codice errato"); + } + } + else + fld.error_box("Anno errato"); + } + else + app()._wanted_assist = year; + } + } + return TRUE; +} + +bool TAttivazione_moduli::print_handler(TMask_field& fld, KEY key) +{ + if (key == K_SPACE) + app().print(); + return TRUE; +} + void TAttivazione_moduli::generate_key() { #if XVT_OS == XVT_OS_SCOUNIX @@ -674,8 +860,8 @@ void TAttivazione_moduli::generate_key() _msk->set(F_SN, _dongle.number()); _msk->set(F_DT, d); - const int utenti = _dongle.max_users(); - _msk->set(F_USERS, utenti); + _msk->set(F_USERS, _dongle.max_users()); + _msk->set(F_ASSIST, _dongle.year_assist()); } int hexdigit(char c) @@ -750,7 +936,8 @@ bool TAttivazione_moduli::user_hnd(TMask_field & f, KEY k) HL_WRITE(50, ud2[2]); HL_WRITE(51, ud2[3]); #endif - } else + } + else sf.force_update(); return TRUE; } @@ -764,19 +951,24 @@ bool TAttivazione_moduli::serno_hnd(TMask_field& f, KEY k) return TRUE; } - bool TAttivazione_moduli::date_hnd(TMask_field& f, KEY k) { - bool ok = TRUE; if (k == K_TAB && f.focusdirty()) { const TDate data(f.get()); const TDate oggi(TODAY); - ok = data <= oggi; - if (!ok) - f.error_box("La data deve essere antecedente a quella di sistema"); + if (data > oggi) + return f.error_box("La data deve essere antecedente a quella di sistema"); + + const TDate& last_update = app()._dongle.last_update(); + if (data < last_update) + return f.error_box("La data deve essere successiva al %s", last_update.string()); + + const int year_assist = app()._dongle.year_assist()+1; + if (data.year() > year_assist) + return f.error_box("La data deve essere antecedente al 31-12-%d", year_assist); } - return ok; + return TRUE; } void TAttivazione_moduli::encode_second_key() @@ -870,6 +1062,218 @@ bool TAttivazione_moduli::k_notify(TSheet_field& f, int r, KEY k) return TRUE; } +bool TAttivazione_moduli::aggiorna_listino_handler(TMask_field& fld, KEY key) +{ + bool ok = TRUE; + if (key == K_SPACE) + { + TInstall_ini ini; + TFilename name = ini.get("DiskPath"); + name.add(ini.default_name()); + while (!fexist(name)) + { + TMask msk("Aggiornamento listino", 1, -1, -1, 60, 4); + msk.add_string(DLG_USER, 0, "Percorso", 1, 1, 50); + msk.add_button(DLG_CANCEL, 0, "", -12, -1, 10, 2); + msk.add_button(DLG_OK, 0, "", -22, -1, 10, 2); + msk.set(DLG_USER, name); + if (msk.run() == K_ENTER) + name = msk.get(DLG_USER); + else + { + ok = FALSE; + break; + } + } + if (ok) + ok = ini.update_prices(name); + } + return ok; +} + +void TAttivazione_moduli::print_request() +{ + TRequest_form form("ba1500a"); + TForm_item& num = form.find_field('B', odd_page, 101); + TForm_item& descr = form.find_field('B', odd_page, 102); + TForm_item& codice = form.find_field('B', odd_page, 103); + TForm_item& price = form.find_field('B', odd_page, 104); + TForm_item& manut = form.find_field('B', odd_page, 105); + + TInstall_ini ini; + const bool special = _wanted_assist > _dongle.year_assist() || _wanted_users != 0; + const word users = max(_wanted_users, _dongle.max_users()); + + TSheet_field& sheet = _msk->sfield(F_MODULI); + for (TDongle::KeyType owner = TDongle::_aga_key; + owner <= TDongle::_procom_key; + owner = TDongle::KeyType(owner+1)) + { + int found = 0; + TString str; + + FOR_EACH_SHEET_ROW(sheet, r, row) + { + const int module = _im->get_module_by_order(r); + const bool active = _dongle.active(module); + const bool wanted = *row->get(1) > ' '; + + if (!special && active) + continue; + if (!wanted && !active) + continue; + if (_im->get_owner(module) != owner) + continue; + + if (found == 0) + { + printer().open(); + form.update_serno(_msk->get(F_SN)); + form.update_dongle(_dongle); + } + + str.format("%3d", ++found); + num.set(str); + + str = row->get(0); + descr.set(str); + + str = active ? "*ATTIVO*" : ""; + codice.set(str); + + str = _im->get_name(module); + real full, assist; + ini.prices(str, users, full, assist); + if (active) + { + real old_full, old_assist; + ini.prices(str, _dongle.max_users(), old_full, old_assist); + full -= old_full; + assist -= old_assist; + } + else + assist = 0.0; + + price.set(full.string()); + manut.set(assist.string()); + + form.print(-1); + } + + if (special && found > 0) + { + codice.set(""); + price.set(""); + manut.set(""); + if (_wanted_users != 0) + { + str.format("%3d", ++found); + num.set(str); + + str.format("Variazione del numero utenti da %u a %u", + _dongle.max_users(), _wanted_users); + descr.set(str); + form.print(-1); + } + if (_wanted_assist > _dongle.year_assist()) + { + str.format("%3d", ++found); + num.set(str); + str.format("Contratto di assistenza per l'anno %u", _wanted_assist); + descr.set(str); + form.print(-1); + } + } + + if (found) + { + form.print_footer(); + printer().close(); + } + } +} + +void TAttivazione_moduli::print_answer() +{ + TString str; + int found = 0; + + TRequest_form form("ba1500a"); + TForm_item& num = form.find_field('B', odd_page, 101); + TForm_item& descr = form.find_field('B', odd_page, 102); + TForm_item& codice = form.find_field('B', odd_page, 103); + + TSheet_field& sheet = _msk->sfield(F_MODULI); + FOR_EACH_SHEET_ROW(sheet, r, row) if (*row->get(1) > ' ') + { + const int module = _im->get_module_by_order(r); + if (module != BAAUT) + { + if (found == 0) + { + printer().open(); + form.update_serno(_msk->get(F_SN)); + } + + str.format("%3d", ++found); + num.set(str); + + str = row->get(0); + descr.set(str); + + str = row->get(3); + codice.set(str); + + form.print(-1); + } + } + + if (_wanted_users != 0 || _wanted_assist != 0) + { + if (found == 0) + { + printer().open(); + form.update_serno(_msk->get(F_SN)); + } + if (_wanted_users != 0) + { + str.format("%3d", ++found); + num.set(str); + str.format("Variazione del numero utenti da %u a %u", + _dongle.max_users(), _wanted_users); + descr.set(str); + garble_user(_wanted_users, str); + codice.set(str); + form.print(-1); + } + if (_wanted_assist != 0) + { + str.format("%3d", ++found); + num.set(str); + str.format("Contratto di assistenza per l'anno %u", _wanted_assist); + descr.set(str); + garble_year(_wanted_assist, str); + codice.set(str); + form.print(-1); + } + } + + if (found) + { + form.print_footer(); + printer().close(); + } +} + + +void TAttivazione_moduli::print() +{ + if (_dongle.type() == TDongle::_user_key) + print_request(); + else + print_answer(); +} + bool TAttivazione_moduli::create() { bool ok = _dongle.login(); @@ -885,14 +1289,17 @@ bool TAttivazione_moduli::create() _msk = new TMask("ba1500a") ; _msk->set_handler(F_CHANGEUSERS, change_users_handler); + _msk->set_handler(F_CHANGEASSIST, change_assist_handler); + _msk->set_handler(F_PRINT, print_handler); + TSheet_field& sf = _msk->sfield(F_MODULI); sf.set_notify(k_notify); const int un = _im->unassigned(); - - switch (_dongle.type()) + const TDongle::KeyType mydongle = _dongle.type(); + switch (mydongle) { - case _user_key: + case TDongle::_user_key: { _msk->disable(F_K1); _msk->disable(F_K2); @@ -902,19 +1309,13 @@ bool TAttivazione_moduli::create() _msk->set_handler(F_DT, date_hnd); generate_key(); - sf.enable_column(F_ENABLE, FALSE); +// sf.enable_column(F_ENABLE, FALSE); sf.enable_column(F_KEY, serno() != 0); } break; - case _prassi_key: - { - const int aut[] = { CMAUT, ATAUT, POAUT, AFAUT, TCAUT, TMAUT, - VEAUT, MGAUT, ORAUT, EFAUT, DBAUT, SVAUT, -1 }; - for (int a = 0; aut[a] >= 0; a++) - sf.disable_cell(_im->get_index(aut[a])-un,1); - } - case _aga_key: - case _procom_key: + case TDongle::_prassi_key: + case TDongle::_aga_key: + case TDongle::_procom_key: { _msk->set_handler(F_K2, decode_hnd); _msk->disable(F_K3); @@ -931,12 +1332,9 @@ bool TAttivazione_moduli::create() const int af = _im->get_module_by_order(i); const int index = i-un; if (af == 0) - sf.disable_cell(index,1); - if (_dongle.type() == _procom_key) - sf.enable_cell(index,1,af>=40 && af<=46); - else - if (af>=40 && af<=46) - sf.disable_cell(index,1); + sf.disable_cell(index,1); + else + sf.enable_cell(index,1,_im->test_owner(af, mydongle)); } build_key_column(); @@ -944,7 +1342,10 @@ bool TAttivazione_moduli::create() break; default: break; - } + } + + enable_menu_item(M_FILE_PG_SETUP); + enable_menu_item(M_FILE_PRINT); dispatch_e_menu(BAR_ITEM(1)); return TRUE; } diff --git a/ba/ba1500.h b/ba/ba1500.h index a6bf05175..fdc1081c6 100755 --- a/ba/ba1500.h +++ b/ba/ba1500.h @@ -5,7 +5,57 @@ #include #endif -const word MAX_AUT = 48 * 3; +class TDongle : public TObject +{ +public: + enum KeyType { _user_key, _aga_key, _prassi_key, _procom_key }; + +private: + word _serno, _max_users, _year_assist; + KeyType _type; + word _eprom[64]; + TDate _last_update; + +#if XVT_OS == XVT_OS_SCOUNIX + word _port; +#endif + + TBit_array _module; + bool _dirty; + +protected: + bool already_programmed() const; + bool write_octect(word reg, word data[4]) const; + +public: + + bool login(); + bool logout(); + + word number() const { return _serno; } + bool ok() const { return _serno != 0xFFFF; } + word max_users() const { return _max_users; } + word year_assist() const { return _year_assist; } + + void garble(word data[4]) const; + + KeyType type() const { return _type; } + + bool active(word module) const { return _module[module]; } + void activate(word module, bool on = TRUE) { _module.set(module, on); _dirty = TRUE; } + void deactivate(word module) { activate(module, FALSE); } + void set_max_users(word u) { _max_users = u; _dirty = TRUE; } + void set_year_assist(word y) { _year_assist = y; _dirty = TRUE; } + const TDate& last_update() const { return _last_update; } + + bool dirty() const { return _dirty; } + bool burn(); + + TDongle(); + virtual ~TDongle() { logout(); } +}; + +const int MAX_AUT = 48 * 3; class TInformazione_moduli : public TObject { @@ -14,16 +64,18 @@ class TInformazione_moduli : public TObject int _unassigned_modules; // Moduli non assegnati, con descrizione vuota public: - const char * get_description_by_order(int index); - const char * get_name_by_order(int index); - int get_module_by_order(int index); - const char * get_description(int module); - const char * get_name(int module); - int get_index(int module); - int unassigned() { return _unassigned_modules; } - int items() const { return _infos.items(); } - TInformazione_moduli() ; - ~TInformazione_moduli() {}; + const char* get_description_by_order(int index); + const char* get_name_by_order(int index); + int get_module_by_order(int index); + const char* get_description(int module); + const char* get_name(int module); + int get_index(int module); + TDongle::KeyType get_owner(int module) const; + bool test_owner(int module, TDongle::KeyType owner) const; + int unassigned() const { return _unassigned_modules; } + int items() const { return _infos.items(); } + TInformazione_moduli(); + virtual ~TInformazione_moduli() {}; }; #endif diff --git a/ba/ba1500a.h b/ba/ba1500a.h index a59a5696a..ca36b9b0e 100755 --- a/ba/ba1500a.h +++ b/ba/ba1500a.h @@ -11,9 +11,11 @@ #define F_SN 211 #define F_DT 212 #define F_MODULI 213 -#define F_USERS 214 -#define F_CHANGEUSERS 215 -#define F_REQUEST 216 +#define F_USERS 214 +#define F_CHANGEUSERS 215 +#define F_ASSIST 216 +#define F_CHANGEASSIST 217 +#define F_PRINT 218 #define F_NOMEMOD 101 #define F_ENABLE 102 diff --git a/ba/ba1500a.uml b/ba/ba1500a.uml index 9bad8e736..717ed0b9b 100755 --- a/ba/ba1500a.uml +++ b/ba/ba1500a.uml @@ -7,9 +7,9 @@ BEGIN PROMPT -13 -1 "" END -BUTTON F_REQUEST 18 2 +BUTTON F_PRINT 22 2 BEGIN - PROMPT -11 -1 "~Stampa richiesta" + PROMPT -11 -1 "~Stampa Attivazioni" END BUTTON DLG_QUIT 10 2 @@ -35,27 +35,37 @@ END STRING F_SN 5 BEGIN - PROMPT 56 1 "N.Serie " + PROMPT 54 1 "N.Serie " FLAGS "DUZ" END DATE F_DT BEGIN - PROMPT 56 2 "Data " + PROMPT 54 2 "Data " FLAGS "AD" END -NUMBER F_USERS 3 +NUMBER F_USERS 4 BEGIN - PROMPT 56 3 "Utenti " + PROMPT 54 3 "Utenti " FLAGS "D" END BUTTON F_CHANGEUSERS 6 1 BEGIN - PROMPT 69 3 "Cambia" + PROMPT 71 3 "Cambia" END +NUMBER F_ASSIST 4 +BEGIN + PROMPT 54 4 "Assistenza " + FLAGS "D" +END + +BUTTON F_CHANGEASSIST 6 1 +BEGIN + PROMPT 71 4 "Cambia" +END STRING F_K3 16 BEGIN @@ -120,3 +130,4 @@ END ENDPAGE ENDMASK + diff --git a/ba/ba1600.cpp b/ba/ba1600.cpp index 4d53dbf07..1cc02dd59 100755 --- a/ba/ba1600.cpp +++ b/ba/ba1600.cpp @@ -24,7 +24,7 @@ int TInstall_ini::build_list(const TString& module, TString_array& a, CHECKS(module.len() >= 2 || module[0]=='_', "Bad module ", (const char*)module); TConfig* sum = NULL; - if (sommario) + if (sommario && *sommario) sum = new TConfig(sommario, module); TAuto_token_string tmp; @@ -89,7 +89,8 @@ void TInstall_ini::export_paragraph(const char* module, const char* summary) } void TInstall_ini::export_module_paragraphs(const char* module, const char* summary) -{ +{ + CHECK(summary && *summary, "NULL export ini"); TString mod; for (int sub = -1; sub <= 9; sub++) { @@ -100,6 +101,81 @@ void TInstall_ini::export_module_paragraphs(const char* module, const char* summ } } +const TString& TInstall_ini::version(const char* module) +{ + CHECK(module && *module, "Can't get version of NULL module"); + const TString& ver = get("Versione", module); + if (ver.empty() && strlen(module) > 2) + { + TString16 str; + str.strncpy(module, 2); + return get("Versione", str); + } + return ver; +} + +bool TInstall_ini::update_prices(const char* from) +{ + TConfig from_ini(from); + const TDate curr_date = get("Main", "Listino"); + const TDate from_date = from_ini.get("Main", "Listino"); + if (from_date < curr_date) + return FALSE; + + set("Listino", from_date); + + TString_array modules; + from_ini.list_paragraphs(modules); + FOR_EACH_ARRAY_ROW_BACK(modules, r, row) if (row->len() == 2) + { + TAssoc_array& prices = (TAssoc_array&)from_ini.list_variables(*row); + FOR_EACH_ASSOC_STRING(prices, obj, key, str) + { + const TFixed_string price(key); + if (price.compare("Prezzo", 6, TRUE) == 0) + set(key, str); + } + } + return TRUE; +} + +void TInstall_ini::prices(const char* module, word users, + real& full, real& assist) +{ + word min_user = 0; + TAssoc_array& arr = (TAssoc_array&)list_variables(module); + FOR_EACH_ASSOC_STRING(arr, obj, key, str) + { + const TFixed_string price(key); + if (price.compare("Prezzo", 6, TRUE) == 0) + { + const word user = atoi(key+7); + if (user >= min_user && user <= users) + { + min_user = user; + + TAuto_token_string tmp = str; + full = tmp.get(0); + if (full < 50000.0) + full *= 1000.0; + assist = tmp.get(); + if (assist < 50000.0) + assist *= 1000.0; + + if (user == 1 && users > 1) + { + full *= users; + assist *= users; + } + + const int mese = TDate(TODAY).month(); + assist = assist * (12-mese) / 12; + assist.round(-3); + } + } + } +} + /////////////////////////////////////////////////////////// // TFconv_ini /////////////////////////////////////////////////////////// @@ -132,8 +208,7 @@ void TFconv_ini::export_module(const char* module, const char* summary) FOR_EACH_ARRAY_ROW(paragraphs, p, para) { - set_paragraph(*para); - TAssoc_array& variables = (TAssoc_array&)list_variables(); + TAssoc_array& variables = (TAssoc_array&)list_variables(*para); FOR_EACH_ASSOC_STRING(variables, obj, key, str) { const char* parenthesis = strchr(key, '('); @@ -516,6 +591,8 @@ void TModule_mask::save() int index; const TString module = get(F_MODULE); + const TString version = ini.version(module); + for (index = 0; index <= 9; index++) { TString16 sub; sub << module << index; @@ -545,6 +622,7 @@ void TModule_mask::save() const bool agg = row->get_char() > ' '; if (agg) tmp.add("X"); // Flag aggiornamento ini.set("File", tmp, sub, TRUE, index++); + ini.set("Versione", version); // Aggiorna versione del sottomodulo } } } diff --git a/ba/ba1600.h b/ba/ba1600.h index 41eb14c41..05a399849 100755 --- a/ba/ba1600.h +++ b/ba/ba1600.h @@ -16,6 +16,12 @@ public: void export_paragraph(const char* module, const char* summary); void export_module_paragraphs(const char* module, const char* summary); + bool demo() { return get_bool("Demo", "Main"); } + const TString& version(const char* module); + + bool update_prices(const char* src_ini); + void prices(const char* module, word users, real& full, real& manut); + static const char* default_name() { return "install.ini"; } TInstall_ini() : TConfig("install.ini", "Main") { } diff --git a/ba/ba1700.cpp b/ba/ba1700.cpp index 1ce17638d..b105bbbae 100755 --- a/ba/ba1700.cpp +++ b/ba/ba1700.cpp @@ -9,10 +9,11 @@ #include #include "ba1.h" +#include "ba1500.h" #include "ba1600.h" #include "ba1700a.h" -HIDDEN int compare_version(const TString& v1, const TString& v2) +HIDDEN int compare_version(const char* v1, const char* v2) { TString16 ver1(v1), ver2(v2); ver1.trim(); @@ -24,6 +25,15 @@ HIDDEN int compare_version(const TString& v1, const TString& v2) return ver1.compare(ver2, -1, TRUE); } +HIDDEN word version2year(const char* v) +{ + TString16 ver(v); + if (ver.len() == 4) + ver.insert((v[0] == '9') ? "19" : "20", 0); + ver.cut(4); + return atoi(ver); +} + /////////////////////////////////////////////////////////// // Maschera principale /////////////////////////////////////////////////////////// @@ -33,7 +43,7 @@ class TInstaller_mask : public TArray_sheet static TInstaller_mask* _curr_mask; protected: // TSheet - bool on_key(KEY key); + virtual bool on_key(KEY key); protected: static bool path_handler(TMask_field& fld, KEY key); @@ -42,9 +52,14 @@ protected: bool add_module(TConfig& ini, const TString& module); void update_version(); + + bool move_file(const TFilename& file, const char* dir) const; + bool move_module(const TString& module, TInstall_ini& ini, bool update) const; + + bool can_install(const char* module, TInstall_ini& ini); void install_selection(); - bool do_process(TAuto_token_string& commands) const; + bool do_process(TToken_string& commands) const; bool pre_process(TInstall_ini& ini, const char* module) const; bool post_process(TInstall_ini& ini, const char* module) const; @@ -89,16 +104,6 @@ void TInstaller_mask::update_version() const TString16 oldver = ini.get("Versione"); row->add(oldver, 5); row->add(ini.get("Data"), 6); - -/* - const int cmp = compare_version(newver, oldver); - if (cmp > 0) - sheet.set_back_and_fore_color(FOCUS_BACK_COLOR, NORMAL_COLOR, m); - if (cmp == 0) - sheet.set_back_and_fore_color(NORMAL_BACK_COLOR, NORMAL_COLOR, m); - if (cmp < 0) - sheet.set_back_and_fore_color(DISABLED_BACK_COLOR, NORMAL_COLOR, m); -*/ } force_update(); } @@ -125,10 +130,10 @@ bool TInstaller_mask::autoload() TInstall_ini ini(ininame); ini.list_paragraphs(modules); - FOR_EACH_ARRAY_ROW_BACK(modules, i, row) + FOR_EACH_ARRAY_ROW(modules, i, row) { const TString& module = *row; - if (module.len() == 2 && module != "xx") + if (module.len() == 2) add_module(ini, module); } } @@ -137,7 +142,7 @@ bool TInstaller_mask::autoload() ininame = path; ininame.add("??inst.ini"); list_files(ininame, modules); - FOR_EACH_ARRAY_ROW_BACK(modules, m, row) + FOR_EACH_ARRAY_ROW(modules, m, row) { TString& ininame = *row; ininame.lower(); @@ -160,7 +165,7 @@ bool TInstaller_mask::autoload() return ok; } -bool TInstaller_mask::do_process(TAuto_token_string& commands) const +bool TInstaller_mask::do_process(TToken_string& commands) const { bool ok = TRUE; TFilename cmd; @@ -181,28 +186,6 @@ bool TInstaller_mask::pre_process(TInstall_ini& ini, const char* module) const { bool ok = TRUE; - TInstall_ini cur_ini; - TAuto_token_string altri(ini.get("Moduli", module)); - if (stricmp(module, "ba") != 0) - altri.add("ba"); // La base e' obbligatoria per tutti - - TString submodule, curver, reqver; - for (const char* mod = altri.get(0); mod && ok; mod = altri.get()) - { - submodule = mod; - submodule.cut(2); - reqver = ini.get("Versione", submodule); - curver = cur_ini.get("Versione", submodule); - ok = compare_version(reqver, curver) <= 0; - if (!ok) - { - TString msg; - msg << "L'installazione del modulo " << module - << " richiede\nla versione " << reqver - << " del sottomodulo " << submodule; - error_box(msg); - } - } if (ok) { TAuto_token_string commands(ini.get("PreProcess", module)); @@ -218,9 +201,141 @@ bool TInstaller_mask::post_process(TInstall_ini& ini, const char* module) const return do_process(commands); } +bool TInstaller_mask::can_install(const char* module, TInstall_ini& ini) +{ + TInstall_ini curini; + if (curini.demo() != ini.demo()) + { + TString msg; + msg << "Attenzione: Non e' possibile installare la versione "; + msg << (ini.demo() ? "dimostrativa" : "normale"); + msg << " nella cartella della versione "; + msg << (curini.demo() ? "dimostrativa" : "normale"); + return error_box(msg); + } + + const TString& version = ini.version(module); + const word year = version2year(module); + if (year < 1997) + return error_box("Il modulo '%s' non ha una versione valida.", module); + + TDongle dongle; dongle.login(); dongle.logout(); + if (year > dongle.year_assist()) + return error_box("Per installare il modulo %s %s e' necessario\n" + "rinnovare il contratto di assistenza del %d.", + module, (const char*)version, year); + + + TAuto_token_string altri(ini.get("Moduli", module)); + if (stricmp(module, "ba") != 0 && altri.get_pos("ba") < 0) + altri.add("ba"); // La base e' obbligatoria per tutti + + bool ok = TRUE; + TString submodule; + for (const char* mod = altri.get(0); mod && ok; mod = altri.get()) + { + submodule = mod; + if (submodule.len() == 2) + { + if (curini.get("Versione", submodule).empty()) + { + TString msg; + msg << "L'installazione del modulo " << module + << "\nrichiede la presenza del modulo " << submodule + << ":\nSi desidera procedere alla sua installazione?"; + ok = yesno_box(msg); + if (ok) + ok = install(submodule); + } + } + } + + return ok; +} + +bool TInstaller_mask::move_file(const TFilename& file, const char* dir) const +{ + TFilename dest(dir); + dest.add(file.name()); + + const long filesize = fsize(file); + + bool space_ok = FALSE; + while (!space_ok) + { + int disk = 0; + if (dest[1] == ':') + { + const char letter = toupper(dest[0]); + disk = 'A' - letter + 1; + } + struct _diskfree_t drive; + _dos_getdiskfree(disk, &drive); + + const unsigned requested_clusters = unsigned(filesize / drive.sectors_per_cluster / drive.bytes_per_sector) + 1; + space_ok = requested_clusters <= drive.avail_clusters; + if (!space_ok) + { + TString msg; + msg << "Lo spazio sull'unita' e' insufficiente"; + if (GetDriveType(disk-1) == DRIVE_REMOVABLE) + { + msg << ":\nInserire un nuovo disco e ritentare?"; + if (!yesno_box(msg)) + return FALSE; + } + else + return error_box(msg); + } + } + + bool write_ok = TRUE; + bool user_abort = FALSE; + do + { + write_ok = ::fcopy(file, dest); + if (write_ok) + ::remove(file); + else + { + if (!yesno_box("Errore di scrittura del file %s.\nSi desidera riprovare?", + (const char*)file)); + user_abort = TRUE; + } + } while (!write_ok && !user_abort); + + return write_ok; +} + +bool TInstaller_mask::move_module(const TString& module, TInstall_ini& ini, bool update) const +{ + bool ok = TRUE; + + TFilename src; + TString_array list; + ini.build_list(module, list); + FOR_EACH_ARRAY_ROW(list, f, file) + { + src.tempdir(); + src.add(file->get(0)); + if (update) + { + const bool move_ok = move_file(src, "."); + if (!move_ok) + ok = update = FALSE; + } + if (!update) + ::remove(src); + } + + if (update) + ini.export_paragraph(module, ini.default_name()); + + return ok; +} + bool TInstaller_mask::install(const TString& module) { - TWait_cursor hourglass; bool ok = FALSE; const TString& path = get(F_PATH); @@ -231,9 +346,12 @@ bool TInstaller_mask::install(const TString& module) if (fexist(ininame)) { TInstall_ini ini(ininame); + + if (!can_install(module, ini)) + return FALSE; + const int dischi = ini.get_int("Dischi", module); ok = dischi > 0; - if (!ok) { return error_box("Impossibile determinare il numero dei dischetti"); @@ -245,6 +363,7 @@ bool TInstaller_mask::install(const TString& module) } TProgind pi(dischi, "Decompressione in corso...", FALSE, TRUE); + TFilename tempdir; tempdir.tempdir(); TFilename cmdline; for (int d = 1; d <= dischi && ok; d++) @@ -272,7 +391,7 @@ bool TInstaller_mask::install(const TString& module) { struct _diskfree_t drive; _dos_getdiskfree(0, &drive); - const long required = fsize(cmdline) * (dischi-d+1) * 3; + const long required = fsize(cmdline) * (dischi-d+1) * 4; const unsigned requested_clusters = unsigned(required / drive.sectors_per_cluster / drive.bytes_per_sector) + 1; if (requested_clusters >= drive.avail_clusters) { @@ -285,17 +404,45 @@ bool TInstaller_mask::install(const TString& module) { TWait_cursor hourglass; cmdline.insert("unzip.pif -o ", 0); + cmdline << ' ' << tempdir; + TExternal_app app(cmdline); ok = app.run(FALSE, FALSE, FALSE, FALSE) == 0; pi.addstatus(1); } - } - + } if (ok) - { - post_process(ini, module); - ini.export_module_paragraphs(module, ini.default_name()); + { + pi.set_text("Aggiornamento in corso..."); + ok = move_module(module, ini, TRUE); + + TAuto_token_string altri(ini.get("Moduli", module)); + FOR_EACH_TOKEN(altri, mod) + { + const TString16 submod = mod; + if (submod.len() > 2) // sposta sottomoduli esterni + { + bool upd = ok; + if (ok) + { + TInstall_ini curini; + const TString16 curver = curini.version(submod); + const TString16 reqver = ini.version(submod); + upd = compare_version(reqver, curver) > 0; + if (!upd) + { + warning_box("La versione del sottomodulo %s (%s) e' piu' aggiornata\n" + "di quella che si desidera installare (%s):\n" + "L'aggiornamento del sottomodulo verra' ignorato.", + (const char*)submod, (const char*)curver, (const char*)reqver); + } + } + ok &= move_module(submod, ini, upd); + } + } } + if (ok) + ok = post_process(ini, module); } else { @@ -305,6 +452,9 @@ bool TInstaller_mask::install(const TString& module) if (ok) { TInstall_ini ini(ininame); + if (!can_install(module, ini)) + return FALSE; + TString_array list; const int files = ini.build_list(module, list); if (files > 0) @@ -328,7 +478,7 @@ bool TInstaller_mask::install(const TString& module) if (ok) { ini.export_module_paragraphs(module, ini.default_name()); - post_process(ini, module); + ok = post_process(ini, module); } } } @@ -339,9 +489,10 @@ bool TInstaller_mask::install(const TString& module) TInstall_ini ini; ini.set("DiskPath", path); ini.set("Data", TDate(TODAY), module); + ini.update_prices(ininame); } - // Non spostare nell'if precedente + // Non spostare nell'if precedente: permettere l'aggiornamento del .ini if (ok) update_version(); @@ -375,7 +526,13 @@ void TInstaller_mask::install_selection() { const TString modulo = row->get(2); const TString newver = row->get(3); - const TString oldver = row->get(5); + const TString oldver = row->get(5); + + if (version2year(newver) < 1997) + { + error_box("Il modulo '%s' non ha una versione valida.", (const char*)modulo); + continue; + } bool ok = TRUE; const int cmp = compare_version(oldver, newver); @@ -389,8 +546,6 @@ void TInstaller_mask::install_selection() "funzionamento di tutti i programmi!", (const char*)oldver); if (ok) install(modulo); - else - break; } } diff --git a/ba/ba1700a.uml b/ba/ba1700a.uml deleted file mode 100755 index adce3bf1e..000000000 --- a/ba/ba1700a.uml +++ /dev/null @@ -1,104 +0,0 @@ -#include "ba1700a.h" - -TOOLBAR "" 0 20 0 2 - -BUTTON F_UPDATE 15 2 -BEGIN - PROMPT -12 -11 "Aggiorna lista" -END - -BUTTON DLG_QUIT 15 2 -BEGIN - PROMPT -22 -11 "" -END - -ENDPAGE - -PAGE "Installazione" -1 -1 78 20 - -STRING F_PATH 45 -BEGIN - PROMPT 1 1 "Percorso da cui installare " -END - -STRING F_CURPATH 45 -BEGIN - PROMPT 1 2 "Percorso in cui installare " - FLAGS "D" -END - -SPREADSHEET F_SHEET -BEGIN - PROMPT 1 3 "" - ITEM "Modulo@30" - ITEM "Cod." - ITEM "Versione\nda installare@13" - ITEM "Data\nRilascio@10" - ITEM "Versione\nInstallata@10" - ITEM "Data\nInstallazione@13" -END - -ENDPAGE - -ENDMASK - -PAGE "Modulo" -1 -1 52 10 - -GROUPBOX DLG_NULL 50 3 -BEGIN - PROMPT 1 0 "@bModulo" -END - -STRING 101 43 -BEGIN - PROMPT 6 1 "" -END - -STRING 102 2 -BEGIN - PROMPT 2 1 "" -END - -GROUPBOX DLG_NULL 50 3 -BEGIN - PROMPT 1 3 "@bVersione da installare" -END - -STRING 103 6 -BEGIN - PROMPT 2 4 "Versione " -END - -DATE 104 -BEGIN - PROMPT 34 4 "Data " -END - -GROUPBOX DLG_NULL 50 3 -BEGIN - PROMPT 1 6 "@bVersione installata" -END - -STRING 105 6 -BEGIN - PROMPT 2 7 "Versione " -END - -DATE 106 -BEGIN - PROMPT 34 7 "Data " -END - -BUTTON DLG_CANCEL 10 2 -BEGIN - PROMPT -12 -1 "" -END - -BUTTON 100 10 2 -BEGIN - PROMPT -22 -1 "Installa" -END - -ENDPAGE - -ENDMASK diff --git a/ba/bacnv.cpp b/ba/bacnv.cpp index 71903646d..4dbfba825 100755 --- a/ba/bacnv.cpp +++ b/ba/bacnv.cpp @@ -1429,9 +1429,9 @@ void TConversione_archivi::convert_uue() const { TProgind pi(0, "Caricamento tabella Uffici Unici", FALSE, FALSE); TSystemisamfile uue(LF_TABCOM); - TFilename lf; - - lf.format("%sstd/bacnv16a.txt", __ptprf); + TFilename lf; + lf = __ptprf; + lf.add("std/bacnv16a.txt"); uue.load(lf); pi.set_text("Caricamento Uffici Unici nei comuni"); @@ -1441,7 +1441,8 @@ void TConversione_archivi::convert_uue() const TSystemisamfile comuni(LF_COMUNI); comuni.open(_excllock); - lf.format("%sstd/bacnv16b.txt", __ptprf); + lf = __ptprf; + lf.add("std/bacnv16b.txt"); TScanner scan16b(lf); TToken_string line; @@ -1460,8 +1461,7 @@ void TConversione_archivi::convert_uue() const { fieldname = "CODUUE"; fieldname << uue; fieldval = comuni.get(fieldname); - - if (first_uue == 0 && fieldval.empty()) + if (first_uue == 0 && atoi(fieldval) == 0) first_uue = uue; if (fieldval == uff) { @@ -1475,9 +1475,7 @@ void TConversione_archivi::convert_uue() const comuni.put(fieldname, uff); err = comuni.rewrite(); } - - if (uue == 1) - cod_uue.add(cod, comuni.get("CODUUE1")); + cod_uue.add(cod, comuni.get("CODUUE1")); } if (err != NOERR) error_box("Impossibile aggiornare l'ufficio unico del comune %s: errore %d",