diff --git a/src/lv/lv2100.cpp b/src/lv/lv2100.cpp index 01a938848..02fe3b945 100755 --- a/src/lv/lv2100.cpp +++ b/src/lv/lv2100.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include "lvlib.h" @@ -140,20 +141,63 @@ bool TGenera_planning_app::elimina_planning_cliente(const TDate& dadata, const T return true; } +HIDDEN void rec2ini(const TRectype& rec, TConfig& ini) +{ + for (int i = 0; i < rec.items(); i++) + { + const char* fname = rec.fieldname(i); + const TString& val = rec.get(fname); + if (val.full()) + { + if (val.find(' ') >= 0 && rec.type(fname) == _alfafld) + { + TString quoted; quoted << '"' << val << '"'; + ini.set(fname, quoted); + } + else + ini.set(fname, val); + } + } +} + +HIDDEN void build_ini(TConfig & ini, const TRectype & rec,const char * action) +{ + ini.set_paragraph("Transaction"); + ini.set("Firm", prefix().get_codditta(), "Transaction"); + ini.set("User", user()); + ini.set("HostName", get_hostname()); + ini.set("Action", action); + ini.set("Mode", "Auto"); + int year, release, tag, patch; + if (TApplication::get_version_info(year, release, tag, patch)) + { + TString80 ver; + ver.format("%d %d.%d-%d", year, release, tag, patch); + ini.set("Version", ver); + } + + TString16 para; para << rec.num(); + + ini.set_paragraph(para); + rec2ini(rec, ini); +} + //KILL_PLANNING: metodo che elimina un recordset generato precedentemente bool TGenera_planning_app::kill_planning (TISAM_recordset& selrighe) const { const TRecnotype righe = selrighe.items(); + if (righe > 0) { TProgress_monitor pi(righe, TR("Eliminazione planning precedenti in corso...")); TLocalisamfile& rplan = selrighe.cursor()->file(); - for (bool ok = selrighe.move_last(); ok; ok = selrighe.move_prev()) + TRectype & rplanrec = rplan.curr(); + + for (bool ok = selrighe.move_last(); pi.addstatus() && ok; ok = selrighe.move_prev()) { - rplan.remove(); - if (!pi.add_status()) - break; - } + send_transaction(rplanrec, TRANSACTION_DELETE); + rplan.remove(); + } } return true; } @@ -417,8 +461,8 @@ void TGenera_planning_app::elabora_passaggio(const TDate& dadata, const TDate& a rplan.put(LVRCONSPLAN_CONSSTD,true); //setta il flag di "consegna standard" rplan.put(LVRCONSPLAN_PERSOSP,codpersosp); //setta il periodo di sospensione lv_set_update_info(rplan); //setta utente, data e ora dell'ultimo aggiornamento - - file_rplan.write(); + file_rplan.write(); + send_transaction(rplan, TRANSACTION_INSERT); } } diff --git a/src/lv/lv2200.cpp b/src/lv/lv2200.cpp index 7c1d53b18..cae6cfda6 100755 --- a/src/lv/lv2200.cpp +++ b/src/lv/lv2200.cpp @@ -295,8 +295,11 @@ void TGestione_planning_mask::aggiorna_plan() if (changed(_rigaoriginale,rigamodificata,F_S_DATA) || codrigaor <= 0) { //se esiste una riga sul file, la rimuovo - if (codrigaor > 0 && rplan.status() == NOERR) - rplan.remove(); + if (codrigaor > 0 && rplan.status() == NOERR) + { + rplan.remove(); + send_transaction(rplan.curr(), TRANSACTION_DELETE); + } //creo la nuova riga rplan.zero(); @@ -310,6 +313,8 @@ void TGestione_planning_mask::aggiorna_plan() //scrivo la nuova riga if (err != NOERR) warning_box (FR("Errore di scrittura. Errore %d"), err); + else + send_transaction(rplan.curr(), TRANSACTION_INSERT); //modifico anche la TToken_string cosė da evitare errori al momento della rewrite @@ -350,6 +355,9 @@ void TGestione_planning_mask::aggiorna_plan() lv_set_update_info(rplan.curr()); if (rplan.rewrite() != NOERR) warning_box (TR("Errore di scrittura.")); + else + send_transaction(rplan.curr(), TRANSACTION_MODIFY); + if (updatecar && _rigaoriginale.not_empty()) rewrite_all(rigamodificata, data, codplan); @@ -396,6 +404,7 @@ void TGestione_planning_mask::rewrite_all(TToken_string& rigamodificata, TDate& lv_set_update_info(rec); //faccio l'effettiva rewrite rec.rewrite(rplan); + send_transaction(rplan.curr(), TRANSACTION_MODIFY); } } fill_sheet(); @@ -428,6 +437,7 @@ bool TGestione_planning_mask::cancella_riga() rplan.put(LVRCONSPLAN_CODPLAN,codplan); rplan.put(LVRCONSPLAN_CODRIGA,codriga); err = rplan.remove(); + send_transaction(rplan.curr(), TRANSACTION_DELETE); } return err == NOERR; } diff --git a/src/lv/lv2A00.cpp b/src/lv/lv2A00.cpp index 6f8f9a674..6b7556fdc 100644 --- a/src/lv/lv2A00.cpp +++ b/src/lv/lv2A00.cpp @@ -9,6 +9,7 @@ #include #include "lvcondv.h" #include "lvpasplan.h" +#include "lvlib.h" #include "lv2a00a.h" @@ -83,55 +84,57 @@ void TAutogiro_app::main_loop() query << "USE LVCONDV SELECT LVPASPLAN->NRIGA!=1" << "\nJOIN LVPASPLAN INTO CODCF==CODCF CODCONT==CODCONT NRIGA==1"; TISAM_recordset contratti(query); + TLog_report log; - TProgress_monitor pi(contratti.items(), title()); - TLog_report log; + { + TProgress_monitor pi(contratti.items(), title()); - for (bool ok = contratti.move_first(); ok; ok = contratti.move_next()) - { - const long codcf = contratti.get(LVCONDV_CODCF).as_int(); - if (codcf <= 0) - continue; - const TDate datasc = contratti.get(LVCONDV_DATASC).as_date(); - if (datasc.ok() && datasc < oggi) - continue; + for (bool ok = contratti.move_first(); pi.addstatus() && ok; ok = contratti.move_next()) + { + const long codcf = contratti.get(LVCONDV_CODCF).as_int(); + if (codcf <= 0) + continue; - int nriga = 1; - for (int day = 0; day < 7; day++) if (msk.get_bool(F_LUNEDI+day)) - { - if (nriga == 1) - { - TString8 cod; cod.format("C|%06ld", codcf); - TString msg; - msg << TR("Contratto ") << cod << '/' << contratti.get(LVCONDV_CODCONT) - << " - " << cache().get(LF_CLIFO, cod, CLI_RAGSOC); - log.log(0, msg); - } - - pasplan.zero(); - pasplan.put(LVPASPLAN_CODCF, contratti.get(LVCONDV_CODCF).as_int()); - pasplan.put(LVPASPLAN_CODCONT, contratti.get(LVCONDV_CODCONT).as_int()); - pasplan.put(LVPASPLAN_NRIGA, nriga++); - pasplan.put(LVPASPLAN_CODITI, msk.get(F_ITINERARIO)); - pasplan.put(LVPASPLAN_FREQ, msk.get(F_FREQUENZA)); - pasplan.put(LVPASPLAN_MODPASS, msk.get(F_CONSEGNA)); - pasplan.put(LVPASPLAN_GGCONS, day+1); - - const int err = pasplan.write(); - if (err != NOERR) - { - cantwrite_box(pasplan.description()); - log.log(2, TR("Errore di scrittura sul file LVPASPLAN")); - contratti.move_last(); - break; - } - } + const TDate datasc = contratti.get(LVCONDV_DATASC).as_date(); + if (datasc.ok() && datasc < oggi) + continue; - if (!pi.add_status()) - break; - } + int nriga = 1; + for (int day = 0; day < 7; day++) if (msk.get_bool(F_LUNEDI + day)) + { + if (nriga == 1) + { + TString8 cod; cod.format("C|%06ld", codcf); + TString msg; + msg << TR("Contratto ") << cod << '/' << contratti.get(LVCONDV_CODCONT) + << " - " << cache().get(LF_CLIFO, cod, CLI_RAGSOC); + log.log(0, msg); + } + pasplan.zero(); + pasplan.put(LVPASPLAN_CODCF, contratti.get(LVCONDV_CODCF).as_int()); + pasplan.put(LVPASPLAN_CODCONT, contratti.get(LVCONDV_CODCONT).as_int()); + pasplan.put(LVPASPLAN_NRIGA, nriga++); + pasplan.put(LVPASPLAN_CODITI, msk.get(F_ITINERARIO)); + pasplan.put(LVPASPLAN_FREQ, msk.get(F_FREQUENZA)); + pasplan.put(LVPASPLAN_MODPASS, msk.get(F_CONSEGNA)); + pasplan.put(LVPASPLAN_GGCONS, day + 1); + + const int err = pasplan.write(); + + if (err != NOERR) + { + cantwrite_box(pasplan.description()); + log.log(2, TR("Errore di scrittura sul file LVPASPLAN")); + contratti.move_last(); + break; + } + else + send_transaction(pasplan.curr(), TRANSACTION_INSERT); + } + } + } log.preview(); } } diff --git a/src/lv/lvlib.cpp b/src/lv/lvlib.cpp index db7f87a4f..fadedea32 100755 --- a/src/lv/lvlib.cpp +++ b/src/lv/lvlib.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -2146,3 +2147,58 @@ void TDoc_inventario_row::set_magazzinoc(const char* magc) { _rinv.put(RDOC_CODMAGC, magc); } + +void rec2ini(const TRectype& rec, TConfig& ini) +{ + for (int i = 0; i < rec.items(); i++) + { + const char* fname = rec.fieldname(i); + const TString& val = rec.get(fname); + if (val.full()) + { + if (val.find(' ') >= 0 && rec.type(fname) == _alfafld) + { + TString quoted; quoted << '"' << val << '"'; + ini.set(fname, quoted); + } + else + ini.set(fname, val); + } + } +} + +void build_ini(TConfig & ini, const TRectype & rec, const char * action) +{ + ini.set_paragraph("Transaction"); + ini.set("Firm", prefix().get_codditta(), "Transaction"); + ini.set("User", user()); + ini.set("HostName", get_hostname()); + ini.set("Action", action); + ini.set("Mode", "Auto"); + int year, release, tag, patch; + if (TApplication::get_version_info(year, release, tag, patch)) + { + TString80 ver; + ver.format("%d %d.%d-%d", year, release, tag, patch); + ini.set("Version", ver); + } + + TString16 para; para << rec.num(); + + ini.set_paragraph(para); + rec2ini(rec, ini); +} + +void send_transaction(const TRectype & rec, const char * action) +{ + if (can_dispatch_transaction(rec)) + { + TFilename temp; temp.temp(); + { + TConfig ini(temp); + + build_ini(ini, rec, action); + } + dispatch_transaction(rec, temp); + } +} \ No newline at end of file diff --git a/src/lv/lvlib.h b/src/lv/lvlib.h index d9318399c..16c2916d8 100755 --- a/src/lv/lvlib.h +++ b/src/lv/lvlib.h @@ -5,6 +5,8 @@ #include "../ve/velib07.h" #endif +#include + #define RDOC_QTAREALE "CIN01" #define RDOC_TOTREALE "CIN02" #define RDOC_PROVV1REALE "CIN03" @@ -405,4 +407,8 @@ public: // Finestra di notifica per messaggi non troppo critici, tipice nelle elaborazioni batch bool lv_popup_msg(const char* fmt, ...); +void rec2ini(const TRectype& rec, TConfig& ini); +void build_ini(TConfig & ini, const TRectype & rec, const char * action); +void send_transaction(const TRectype & rec, const char * action); + #endif