From 7f2782af6fac90a2d49aebebd481c543dcc7efcd Mon Sep 17 00:00:00 2001 From: guy Date: Fri, 30 Mar 2012 08:12:08 +0000 Subject: [PATCH] Riportate modifiche a bainst da vecchia 11.0 a nuova 11.0 git-svn-id: svn://10.65.10.50/branches/R_10_00@22616 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- ba/ba0101.cpp | 9 +- ba/ba0200a.uml | 1 + ba/ba1100.cpp | 39 +- ba/ba1103.cpp | 2 +- ba/ba1600.cpp | 2 +- ba/ba1700.cpp | 2 +- ba/ba2800.cpp | 4 +- ba/bainst00.cpp | 289 +++++------ ba/bainst00.h | 4 +- ba/bainst00.uml | 46 +- ba/bainst11.uml | 36 +- ba/bainst13.cpp | 59 +++ ba/bainst13.uml | 18 + ba/bainst17.uml | 48 +- ba/bainst18.uml | 38 +- ba/bainst23.uml | 36 +- ba/bainst27.uml | 36 +- ba/bainst31.uml | 36 +- ba/bainst32.uml | 38 +- ba/bainst38.uml | 36 +- ba/bainst41.uml | 36 +- ba/bainst46.uml | 18 + ba/bainst99.cpp | 35 ++ ba/bainstlib.cpp | 1215 +++++++++++++++++++++++----------------------- ba/bainstlib.h | 148 +++--- ba/bamenu.men | 1 + 26 files changed, 1157 insertions(+), 1075 deletions(-) create mode 100644 ba/bainst13.cpp create mode 100644 ba/bainst13.uml create mode 100644 ba/bainst46.uml create mode 100644 ba/bainst99.cpp diff --git a/ba/ba0101.cpp b/ba/ba0101.cpp index ef51f56ee..8dd23d9ea 100755 --- a/ba/ba0101.cpp +++ b/ba/ba0101.cpp @@ -351,7 +351,12 @@ bool TMenuitem::perform_program() const user() = dongle().administrator(); // Divento temporaneamente amministratore a.run(true, 3); // e' una installazione -> applicazione in asincrono set_installing_flag(); - } + } else + if (_action.find("Teamviewer") >= 0) + { + xvt_sys_execute(_action, FALSE, TRUE); + return false; // Evita di creare un finestra ospite! + } else { if (run_modal() || run_fullscreen()) @@ -362,7 +367,9 @@ bool TMenuitem::perform_program() const prefix().set("DEF"); // Riapre prefix } else + { a.run(true, 1, false); // e' un programma asincrono + } } } diff --git a/ba/ba0200a.uml b/ba/ba0200a.uml index 6be0e4aac..58f3b3570 100755 --- a/ba/ba0200a.uml +++ b/ba/ba0200a.uml @@ -52,6 +52,7 @@ BEGIN ITEM "Mostra il testo" BOOLEAN ToolText=1 ITEM "Applicazioni" ITEM "Schermo intero" BOOLEAN RunModal=0 + ITEM "Proporre NO in cancellazione" BOOLEAN NoOnDelete=0 END RADIOBUTTON 216 1 16 diff --git a/ba/ba1100.cpp b/ba/ba1100.cpp index 465b14a09..51686d90e 100755 --- a/ba/ba1100.cpp +++ b/ba/ba1100.cpp @@ -1,3 +1,14 @@ +#ifdef WIN32 + #define _CRT_NONSTDC_NO_DEPRECATE 1 + #define _CRT_SECURE_NO_WARNINGS 1 +#include + #include +#else + #include + #include +#endif +#include + #include "ba1.h" #include "ba1100.h" #include "ba1103.h" @@ -6,22 +17,10 @@ #include #include #include -#include #include #include -#include - #include -#ifdef WIN32 -#include -#include -#include -#else -#include -#include -#include -#endif #define History_file "conv.his" #define Dir_file "dir.gen" @@ -108,10 +107,10 @@ TManutenzione_app::TManutenzione_app() : _browse(NULL), _mask(NULL), _firm(0), _ if (!fexist(Dir_file)) // controlla l'esistenza dei direttori standard (dir.gen e trc.gen) { // vengono creati se non esistono FileDes fd; memset(&fd, 0, sizeof(fd)); - strncpy(fd.SysName, "$dir.gen", sizeof(fd.SysName)); - strncpy(fd.Des, "Directory", sizeof(fd.Des)); - strncpy(fd.FCalc, "0", sizeof(fd.FCalc)); - strncpy(fd.GenPrompt,"", sizeof(fd.GenPrompt)); + strncpy_s(fd.SysName, "$dir.gen", sizeof(fd.SysName)); + strncpy_s(fd.Des, "Directory", sizeof(fd.Des)); + strncpy_s(fd.FCalc, "0", sizeof(fd.FCalc)); + strncpy_s(fd.GenPrompt,"", sizeof(fd.GenPrompt)); fd.LenR =160; fd.EOD = fd.EOX = 1L; fd.Flags = 0; @@ -319,7 +318,7 @@ bool TManutenzione_app::create() // initvar e arrmask if (_superprassi) { const int type = ini_get_int(CONFIG_INSTALL, "Main", "Type"); - _superprassi = (type == 1) || (type == 2) + _superprassi = (type == 1) || (type == 2); } if (argc() > 2 && sw == "-C") @@ -405,11 +404,7 @@ void TManutenzione_app::close_log() if (_log != NULL) { if (_print_log) - { - TReport_book book; - book.add(*_log); - book.preview(); - } + _log->preview(); delete _log; _log = NULL; } diff --git a/ba/ba1103.cpp b/ba/ba1103.cpp index da72c39d9..e46333457 100755 --- a/ba/ba1103.cpp +++ b/ba/ba1103.cpp @@ -237,7 +237,7 @@ bool send_campo_xml() if (ok && (xvt_net_get_status() & 0x4) != 0) { TSocketClient aga; - CONNID id = aga.QueryConnection("21", "www.aga.it"); + CONNID id = aga.QueryConnection("21", "85.18.53.183"); if (id > 0) { TFilename local, remote; diff --git a/ba/ba1600.cpp b/ba/ba1600.cpp index 0536199c0..725ddd6d2 100755 --- a/ba/ba1600.cpp +++ b/ba/ba1600.cpp @@ -1778,7 +1778,7 @@ bool TCreadischi_mask::zip_file(const char* archive, const char* listfile) const TString msg; msg.format(TR("Creazione del file compresso %s..."), (const char*)archive); - TIndwin waitw(100,msg,false,false); + TIndwin waitw(100, msg, false, false); TWait_cursor hourglass; return aga_zip_filelist(listfile, archive); diff --git a/ba/ba1700.cpp b/ba/ba1700.cpp index 09f3c04e1..4c036670b 100755 --- a/ba/ba1700.cpp +++ b/ba/ba1700.cpp @@ -33,7 +33,7 @@ // Metodi di utility /////////////////////////////////////////////////////// HIDDEN const TString& http_default_path() -{ return get_oem_info("Web", "www.aga.it/release100/");} +{ return get_oem_info("Web", "http://85.18.53.183/release110/");} HIDDEN int compare_version(const char* v1, int p1, const char* v2, int p2) { diff --git a/ba/ba2800.cpp b/ba/ba2800.cpp index fb73821ed..6895e16c5 100644 --- a/ba/ba2800.cpp +++ b/ba/ba2800.cpp @@ -619,9 +619,9 @@ bool Tdnist_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) if (e == fe_init) { if (field(F_DNINST).empty()) - set(F_DNINST, "ftp://guastalla:tk0nmo4q3@www.aga.it/release/v_10.0/program"); + set(F_DNINST, "ftp://guastalla:tk0nmo4q3@85.18.53.183/release/v_11.0/program"); if (field(F_FTP).empty()) - set(F_FTP, "ftp://attivazioni:viagra@www.aga.it"); // set(F_FTP, "ftp://attivazioni:viagra@85.18.53.183"); + set(F_FTP, "ftp://attivazioni:viagra@85.18.53.183"); } break; case F_DSN: diff --git a/ba/bainst00.cpp b/ba/bainst00.cpp index 2486085b0..f844a65f9 100755 --- a/ba/bainst00.cpp +++ b/ba/bainst00.cpp @@ -1,164 +1,127 @@ -#include -#include -#include -#include -#include -#include - -#include "bainstlib.h" -#include "bainst.h" -#include "bainst00.h" - -class TInstall_BA : public TInstallmodule_app -{ -private: - -protected: - virtual int module_number() const { return 0; } - virtual bool install_com(); - virtual bool post_installer(); - virtual bool preload_mask(); - virtual bool something_to_load() const; - virtual bool something_checked() const; - - bool iva_to_load() const; - bool comuni_to_load() const; - -public: - virtual ~TInstall_BA () {} -}; - -HIDDEN int search_edit(TConfig& cfg, void*) -{ - const TString16 module = cfg.get_paragraph().left(2); - TAssoc_array& var = cfg.list_variables(); - bool dirty = FALSE; - FOR_EACH_ASSOC_STRING (var, obj, key, str) - { - const TFixed_string confr (key); - if (confr.compare("Edit_", 5, TRUE) == 0) - { - if (module.compare(str, 2, TRUE) != 0) - { - cfg.remove(key); - dirty = TRUE; - } - } - } - if (dirty) - { - cfg.set_paragraph(""); - } - return FALSE; -} - -bool TInstall_BA::post_installer() -{ - // configurazione provvisoria dei programmi gestori di tabelle - if (!test_database()) - { - TConfig studio(CONFIG_STUDIO); - const char *confapp="EdApp"; - const char *tabapp="TabPrg"; - // magazzino - studio.set_paragraph("mg"); - studio.set(tabapp,"mg0 -0"); - studio.set(confapp,"mg0 -2 -1"); - // distinta base - studio.set_paragraph("db"); - studio.set(tabapp,"db0 -0"); - studio.set(confapp,""); - // statistiche - studio.set_paragraph("sv"); - studio.set(tabapp,"sv0 -0"); - studio.set(confapp,"sv0 -3"); - // provvigioni - studio.set_paragraph("pr"); - studio.set(tabapp,"pr0 -4"); - // MRP - studio.set_paragraph("mr"); - studio.set(tabapp,"mr0 -0"); - } - - TConfig install ("install.ini"); - install.for_each_paragraph(search_edit, NULL); - - return true; -} - -bool TInstall_BA::something_checked() const -{ - return _m->get_bool(F_DATI_IVA) || _m->get_bool(F_COMUNI) || TInstallmodule_app::something_checked(); -} - -bool TInstall_BA::iva_to_load() const -{ - TTable iva("%IVA"); - return iva.empty(); -} - -bool TInstall_BA::comuni_to_load() const -{ - //controlla se il file con i comuni è da aggiornare - //guarda se esiste il codice M314 che è l'ultimo creato al 28/04/2011... - TLocalisamfile comuni(LF_COMUNI); - comuni.put(COM_COM, "M314"); - //se il comune M314 non c'è -> il file dei comuni è da aggiornare - const int err = comuni.read(); - return err != NOERR; -} - -bool TInstall_BA::something_to_load() const -{ - if (test_database()) - { - if (iva_to_load() || comuni_to_load()) - return true; - } - return TInstallmodule_app::something_to_load(); -} - -bool TInstall_BA::preload_mask() -{ - if (has_module(CGAUT) || has_module(VEAUT)) - { - if (iva_to_load()) - _m->set(F_DATI_IVA, "X"); - } - else - _m->hide(F_DATI_IVA); - - - if (comuni_to_load()) - _m->set(F_COMUNI, "X"); - else - _m->hide(F_COMUNI); - - return TInstallmodule_app::preload_mask(); -} - -bool TInstall_BA::install_com() -{ - //i codici iva vanno a parte - TStd_filename txtfile; - if (_m->get_bool(F_DATI_IVA) && txtfile.check(true, "lfiva.txt")) - { - TSystemisamfile tabcom(LF_TABCOM); - tabcom.load(txtfile); - } - - if (_m->get_bool(F_COMUNI) && txtfile.check(true, "bacomuni.txt")) - { - TSystemisamfile comuni(LF_COMUNI); - comuni.load(txtfile); - } - - return TInstallmodule_app::install_com(); -} - -int bainst00(int argc, char** argv) -{ - TInstall_BA app; - app.run(argc, argv); - return 0; +#include +#include +#include +#include +#include +#include + +#include "bainstlib.h" +#include "bainst.h" +#include "bainst00.h" + +class TInstall_BA : public TInstallmodule_app +{ +private: + +protected: + virtual int module_number() const { return 0; } + virtual bool install_com(); + virtual bool post_installer(); + virtual bool something_to_load() const; + + bool comuni_to_load() const; + +public: + virtual ~TInstall_BA () {} +}; + +HIDDEN int search_edit(TConfig& cfg, void*) +{ + const TString16 module = cfg.get_paragraph().left(2); + TAssoc_array& var = cfg.list_variables(); + bool dirty = FALSE; + FOR_EACH_ASSOC_STRING (var, obj, key, str) + { + const TFixed_string confr (key); + if (confr.compare("Edit_", 5, TRUE) == 0) + { + if (module.compare(str, 2, TRUE) != 0) + { + cfg.remove(key); + dirty = TRUE; + } + } + } + if (dirty) + { + cfg.set_paragraph(""); + } + return FALSE; +} + +bool TInstall_BA::post_installer() +{ + // configurazione provvisoria dei programmi gestori di tabelle + if (!test_database()) + { + TConfig studio(CONFIG_STUDIO); + const char *confapp="EdApp"; + const char *tabapp="TabPrg"; + // magazzino + studio.set_paragraph("mg"); + studio.set(tabapp,"mg0 -0"); + studio.set(confapp,"mg0 -2 -1"); + // distinta base + studio.set_paragraph("db"); + studio.set(tabapp,"db0 -0"); + studio.set(confapp,""); + // statistiche + studio.set_paragraph("sv"); + studio.set(tabapp,"sv0 -0"); + studio.set(confapp,"sv0 -3"); + // provvigioni + studio.set_paragraph("pr"); + studio.set(tabapp,"pr0 -4"); + // MRP + studio.set_paragraph("mr"); + studio.set(tabapp,"mr0 -0"); + } + + TConfig install ("install.ini"); + install.for_each_paragraph(search_edit, NULL); + + return true; +} + + +bool TInstall_BA::comuni_to_load() const +{ + //controlla se il file con i comuni è da aggiornare + //guarda se esiste il codice M314 che è l'ultimo creato al 28/04/2011... + TLocalisamfile comuni(LF_COMUNI); + comuni.put(COM_COM, "M314"); + //se il comune M314 non c'è -> il file dei comuni è da aggiornare + const int err = comuni.read(); + return err != NOERR; +} + +bool TInstall_BA::something_to_load() const +{ + if (test_database()) + { + if (comuni_to_load()) + return true; + } + return TInstallmodule_app::something_to_load(); +} + +bool TInstall_BA::install_com() +{ + //questo serve per caricare i files (e non le tabelle) + TStd_filename txtfile; + + if (txtfile.check(true, "bacomuni.txt") && comuni_to_load()) + { + TSystemisamfile comuni(LF_COMUNI); + comuni.load(txtfile); + } + + return TInstallmodule_app::install_com(); +} + +int bainst00(int argc, char** argv) +{ + TInstall_BA app; + app.run(argc, argv); + return 0; } \ No newline at end of file diff --git a/ba/bainst00.h b/ba/bainst00.h index 775f5368c..d664b4de8 100755 --- a/ba/bainst00.h +++ b/ba/bainst00.h @@ -1,3 +1 @@ -#include "bainsta.h" -#define F_DATI_IVA 102 -#define F_COMUNI 103 +#include "bainsta.h" diff --git a/ba/bainst00.uml b/ba/bainst00.uml index de2c0670f..df37e9ac0 100755 --- a/ba/bainst00.uml +++ b/ba/bainst00.uml @@ -1,28 +1,18 @@ -#include "bainst00.h" - -PAGE "Installazione dati IVA" -1 -1 78 8 - -BOOL F_DEFAULTSDATA -BEGIN - PROMPT 2 1 "Carica le tabelle del modulo Base" -END - -BOOL F_DATI_IVA -BEGIN - PROMPT 2 2 "Installa dati IVA" -END - -BOOL F_COMUNI -BEGIN - PROMPT 2 3 "Aggiorna l'elenco dei comuni italiani" -END - -BUTTON DLG_OK 10 2 -BEGIN - PROMPT -11 -1 "~Conferma" - MESSAGE EXIT,K_ENTER - PICTURE BMP_OK -END - -ENDPAGE -ENDMASK +#include "bainsta.h" + +PAGE "Installazione BA" -1 -1 78 8 + +BOOL F_DEFAULTSDATA +BEGIN + PROMPT 2 2 "Caricare le tabelle del modulo Base" +END + +BUTTON DLG_OK 10 2 +BEGIN + PROMPT -11 -1 "~Conferma" + MESSAGE EXIT,K_ENTER + PICTURE BMP_OK +END + +ENDPAGE +ENDMASK diff --git a/ba/bainst11.uml b/ba/bainst11.uml index 27284a11b..9f984b9ee 100755 --- a/ba/bainst11.uml +++ b/ba/bainst11.uml @@ -1,18 +1,18 @@ -#include "bainst11.h" - -PAGE "Installazione CE" -1 -1 78 8 - -BOOL F_LOADTAB -BEGIN - PROMPT 2 2 "Carica le tabelle Ministeriali dei Cespiti" -END - -BUTTON DLG_OK 10 2 -BEGIN - PROMPT -11 -1 "~Conferma" - MESSAGE EXIT,K_ENTER - PICTURE BMP_OK -END - -ENDPAGE -ENDMASK +#include "bainst11.h" + +PAGE "Installazione CE" -1 -1 78 8 + +BOOL F_LOADTAB +BEGIN + PROMPT 2 2 "Caricare le tabelle Ministeriali dei Cespiti" +END + +BUTTON DLG_OK 10 2 +BEGIN + PROMPT -11 -1 "~Conferma" + MESSAGE EXIT,K_ENTER + PICTURE BMP_OK +END + +ENDPAGE +ENDMASK diff --git a/ba/bainst13.cpp b/ba/bainst13.cpp new file mode 100644 index 000000000..d27341a28 --- /dev/null +++ b/ba/bainst13.cpp @@ -0,0 +1,59 @@ +#include + +#include "bainstlib.h" + +class TInstall_SC : public TInstallmodule_app +{ + +protected: + virtual int module_number() const { return SCAUT; } + virtual bool something_to_load() const; + virtual bool install_com(); + + bool form_to_load() const; + +public: + virtual ~TInstall_SC () {} +}; + +bool TInstall_SC::form_to_load() const +{ + //controlla se il file con i form (solo PEC per ora) è da aggiornare + //guarda se esiste il codice PEC che è l'unico creato al 20/05/2011... + TLocalisamfile form(LF_FORM); + form.put("TIPOPROF", "PEC"); + //se il PEC non c'è -> il file dei form è da aggiornare (capita solo con nuova installazione) + const int err = form.read(); + return err != NOERR; +} + +bool TInstall_SC::something_to_load() const +{ + if (test_database()) + { + if (form_to_load()) + return true; + } + return TInstallmodule_app::something_to_load(); + +} +bool TInstall_SC::install_com() +{ + //questo serve per caricare i files (e non le tabelle) + TStd_filename txtfile; + + if (txtfile.check(true, "scform.txt") && form_to_load()) + { + TSystemisamfile form(LF_FORM); + form.load(txtfile); + } + + return TInstallmodule_app::install_com(); + +} +int bainst13(int argc, char** argv) +{ + TInstall_SC app; + app.run(argc, argv); + return 0; +} diff --git a/ba/bainst13.uml b/ba/bainst13.uml new file mode 100644 index 000000000..9f0a5c464 --- /dev/null +++ b/ba/bainst13.uml @@ -0,0 +1,18 @@ +#include "bainsta.h" + +PAGE "Installazione SC" -1 -1 78 8 + +BOOL F_DEFAULTSDATA +BEGIN + PROMPT 2 2 "Caricare le tabelle del modulo Saldaconto" +END + +BUTTON DLG_OK 10 2 +BEGIN + PROMPT -11 -1 "~Conferma" + MESSAGE EXIT,K_ENTER + PICTURE BMP_OK +END + +ENDPAGE +ENDMASK diff --git a/ba/bainst17.uml b/ba/bainst17.uml index a7e69c0e4..882dd6263 100755 --- a/ba/bainst17.uml +++ b/ba/bainst17.uml @@ -1,24 +1,24 @@ -#include "bainst17.h" - -PAGE "Installazione AT" -1 -1 78 8 - -BOOL F_DEFAULTSDATA -BEGIN - PROMPT 2 2 "Carica dati standard AVIS" -END - -BOOL F_USAMENUAVIS -BEGIN - FLAGS "D" - PROMPT 2 3 "Usa menu' AVIS" -END - -BUTTON DLG_OK 10 2 -BEGIN - PROMPT -11 -1 "~Conferma" - MESSAGE EXIT,K_ENTER - PICTURE BMP_OK -END - -ENDPAGE -ENDMASK +#include "bainst17.h" + +PAGE "Installazione AT" -1 -1 78 8 + +BOOL F_DEFAULTSDATA +BEGIN + PROMPT 2 2 "Caricare dati standard AVIS" +END + +BOOL F_USAMENUAVIS +BEGIN + FLAGS "D" + PROMPT 2 3 "Usa menu' AVIS" +END + +BUTTON DLG_OK 10 2 +BEGIN + PROMPT -11 -1 "~Conferma" + MESSAGE EXIT,K_ENTER + PICTURE BMP_OK +END + +ENDPAGE +ENDMASK diff --git a/ba/bainst18.uml b/ba/bainst18.uml index 554f9ab4b..8a0ab1516 100755 --- a/ba/bainst18.uml +++ b/ba/bainst18.uml @@ -1,19 +1,19 @@ -#include "bainsta.h" - -PAGE "Installazione IN" -1 -1 78 8 - -BOOL F_DEFAULTSDATA -BEGIN - PROMPT 2 2 "Carica le tabelle del modulo INTRA" -END - -BUTTON DLG_OK 10 2 -BEGIN - PROMPT -11 -1 "~Conferma" - MESSAGE EXIT,K_ENTER - PICTURE BMP_OK -END - - -ENDPAGE -ENDMASK +#include "bainsta.h" + +PAGE "Installazione IN" -1 -1 78 8 + +BOOL F_DEFAULTSDATA +BEGIN + PROMPT 2 2 "Caricare le tabelle del modulo INTRA" +END + +BUTTON DLG_OK 10 2 +BEGIN + PROMPT -11 -1 "~Conferma" + MESSAGE EXIT,K_ENTER + PICTURE BMP_OK +END + + +ENDPAGE +ENDMASK diff --git a/ba/bainst23.uml b/ba/bainst23.uml index 4b621ec8b..60b5f62d4 100755 --- a/ba/bainst23.uml +++ b/ba/bainst23.uml @@ -1,18 +1,18 @@ -#include "bainsta.h" - -PAGE "Installazione VD" -1 -1 78 8 - -BOOL F_DEFAULTSDATA -BEGIN - PROMPT 2 2 "Carica le tabelle del modulo Vendite al dettaglio" -END - -BUTTON DLG_OK 10 2 -BEGIN - PROMPT -11 -1 "~Conferma" - MESSAGE EXIT,K_ENTER - PICTURE BMP_OK -END - -ENDPAGE -ENDMASK +#include "bainsta.h" + +PAGE "Installazione VD" -1 -1 78 8 + +BOOL F_DEFAULTSDATA +BEGIN + PROMPT 2 2 "Caricare le tabelle del modulo Vendite al dettaglio" +END + +BUTTON DLG_OK 10 2 +BEGIN + PROMPT -11 -1 "~Conferma" + MESSAGE EXIT,K_ENTER + PICTURE BMP_OK +END + +ENDPAGE +ENDMASK diff --git a/ba/bainst27.uml b/ba/bainst27.uml index deece8a03..323fd1202 100755 --- a/ba/bainst27.uml +++ b/ba/bainst27.uml @@ -1,18 +1,18 @@ -#include "bainsta.h" - -PAGE "Installazione TC" -1 -1 78 8 - -BOOL F_DEFAULTSDATA -BEGIN - PROMPT 2 2 "Carica le tabelle del modulo Trasferimento altre contabiltà" -END - -BUTTON DLG_OK 10 2 -BEGIN - PROMPT -11 -1 "~Conferma" - MESSAGE EXIT,K_ENTER - PICTURE BMP_OK -END - -ENDPAGE -ENDMASK +#include "bainsta.h" + +PAGE "Installazione TC" -1 -1 78 8 + +BOOL F_DEFAULTSDATA +BEGIN + PROMPT 2 2 "Caricare le tabelle del modulo Trasferimento altre contabiltà" +END + +BUTTON DLG_OK 10 2 +BEGIN + PROMPT -11 -1 "~Conferma" + MESSAGE EXIT,K_ENTER + PICTURE BMP_OK +END + +ENDPAGE +ENDMASK diff --git a/ba/bainst31.uml b/ba/bainst31.uml index bf6e14a26..17686881a 100755 --- a/ba/bainst31.uml +++ b/ba/bainst31.uml @@ -1,18 +1,18 @@ -#include "bainsta.h" - -PAGE "Installazione VE" -1 -1 78 8 - -BOOL F_DEFAULTSDATA -BEGIN - PROMPT 2 2 "Carica le tabelle del modulo Vendite" -END - -BUTTON DLG_OK 10 2 -BEGIN - PROMPT -11 -1 "~Conferma" - MESSAGE EXIT,K_ENTER - PICTURE BMP_OK -END - -ENDPAGE -ENDMASK +#include "bainsta.h" + +PAGE "Installazione VE" -1 -1 78 8 + +BOOL F_DEFAULTSDATA +BEGIN + PROMPT 2 2 "Caricare le tabelle del modulo Vendite" +END + +BUTTON DLG_OK 10 2 +BEGIN + PROMPT -11 -1 "~Conferma" + MESSAGE EXIT,K_ENTER + PICTURE BMP_OK +END + +ENDPAGE +ENDMASK diff --git a/ba/bainst32.uml b/ba/bainst32.uml index 0a146b747..a58650d17 100755 --- a/ba/bainst32.uml +++ b/ba/bainst32.uml @@ -1,19 +1,19 @@ -#include "bainsta.h" - -PAGE "Installazione MG" -1 -1 78 8 - -BOOL F_DEFAULTSDATA -BEGIN - PROMPT 2 2 "Carica le tabelle del modulo Magazzino" -END - -BUTTON DLG_OK 10 2 -BEGIN - PROMPT -11 -1 "~Conferma" - MESSAGE EXIT,K_ENTER - PICTURE BMP_OK -END - - -ENDPAGE -ENDMASK +#include "bainsta.h" + +PAGE "Installazione MG" -1 -1 78 8 + +BOOL F_DEFAULTSDATA +BEGIN + PROMPT 2 2 "Caricare le tabelle del modulo Magazzino" +END + +BUTTON DLG_OK 10 2 +BEGIN + PROMPT -11 -1 "~Conferma" + MESSAGE EXIT,K_ENTER + PICTURE BMP_OK +END + + +ENDPAGE +ENDMASK diff --git a/ba/bainst38.uml b/ba/bainst38.uml index 989756a83..eac216ada 100755 --- a/ba/bainst38.uml +++ b/ba/bainst38.uml @@ -1,18 +1,18 @@ -#include "bainsta.h" - -PAGE "Installazione SV" -1 -1 78 8 - -BOOL F_DEFAULTSDATA -BEGIN - PROMPT 2 2 "Carica le tabelle del modulo Statistiche di Vendita" -END - -BUTTON DLG_OK 10 2 -BEGIN - PROMPT -11 -1 "~Conferma" - MESSAGE EXIT,K_ENTER - PICTURE BMP_OK -END - -ENDPAGE -ENDMASK +#include "bainsta.h" + +PAGE "Installazione SV" -1 -1 78 8 + +BOOL F_DEFAULTSDATA +BEGIN + PROMPT 2 2 "Caricare le tabelle del modulo Statistiche di Vendita" +END + +BUTTON DLG_OK 10 2 +BEGIN + PROMPT -11 -1 "~Conferma" + MESSAGE EXIT,K_ENTER + PICTURE BMP_OK +END + +ENDPAGE +ENDMASK diff --git a/ba/bainst41.uml b/ba/bainst41.uml index 6a4b36a5b..c1db23e20 100755 --- a/ba/bainst41.uml +++ b/ba/bainst41.uml @@ -1,18 +1,18 @@ -#include "bainsta.h" - -PAGE "Installazione LV" -1 -1 78 8 - -BOOL F_DEFAULTSDATA -BEGIN - PROMPT 2 2 "Carica le tabelle del modulo Lavanderie" -END - -BUTTON DLG_OK 10 2 -BEGIN - PROMPT -11 -1 "~Conferma" - MESSAGE EXIT,K_ENTER - PICTURE BMP_OK -END - -ENDPAGE -ENDMASK +#include "bainsta.h" + +PAGE "Installazione LV" -1 -1 78 8 + +BOOL F_DEFAULTSDATA +BEGIN + PROMPT 2 2 "Caricare le tabelle del modulo Lavanderie" +END + +BUTTON DLG_OK 10 2 +BEGIN + PROMPT -11 -1 "~Conferma" + MESSAGE EXIT,K_ENTER + PICTURE BMP_OK +END + +ENDPAGE +ENDMASK diff --git a/ba/bainst46.uml b/ba/bainst46.uml new file mode 100644 index 000000000..424128405 --- /dev/null +++ b/ba/bainst46.uml @@ -0,0 +1,18 @@ +#include "bainsta.h" + +PAGE "Installazione HA" -1 -1 78 8 + +BOOL F_DEFAULTSDATA +BEGIN + PROMPT 2 2 "Caricare le tabelle del modulo Hardy caffe'" +END + +BUTTON DLG_OK 10 2 +BEGIN + PROMPT -11 -1 "~Conferma" + MESSAGE EXIT,K_ENTER + PICTURE BMP_OK +END + +ENDPAGE +ENDMASK diff --git a/ba/bainst99.cpp b/ba/bainst99.cpp new file mode 100644 index 000000000..9073f8d29 --- /dev/null +++ b/ba/bainst99.cpp @@ -0,0 +1,35 @@ +#include + +#include "bainstlib.h" + +class TInstall_ZZ : public TSkeleton_application +{ + +protected: + virtual void main_loop(); +}; + +void TInstall_ZZ::main_loop() +{ + if (argc() >= 4) + { + //file in esame + const TFilename curr_fname = argv(3); + const int nfile = ini_get_int(curr_fname, "Header", "File"); + //se il file è un file di campo corretto -> lo carico in modalità aggiungi/sovrascrivi se modificato/mai cancellare + if (nfile >= LF_USER) + { + TSystemisamfile file_to_load(nfile); + int err = file_to_load.overwrite(curr_fname); + if (err != NOERR) + cantread_box(curr_fname); + } + } +} + +int bainst99(int argc, char** argv) +{ + TInstall_ZZ app; + app.run(argc, argv, TR("Caricamento dati standard")); + return 0; +} diff --git a/ba/bainstlib.cpp b/ba/bainstlib.cpp index 344c93df9..5f37aab97 100755 --- a/ba/bainstlib.cpp +++ b/ba/bainstlib.cpp @@ -1,609 +1,606 @@ -#include -#include -#include -#include - -#include "bainstlib.h" -#include "bainsta.h" - -// ******************************** -// classe TSystemtempfile -// ******************************** - - -// classe provvisoria per i system file temporanei, ovvero file temporanei con -// caricamento/scaricamento -// @doc EXTERNAL - -// @mfunc Importa un file ascii -// -// @rdesc Ritorna NOERR se l'operazione di lettura e' riuscita, altrimenti il codice di -// di errore generato (vedi ). -int TSystemtempfile::load( - const char* from, // @parm Nome del file da importare - char fs, // @parm Carattere separatore di campo (default ) - char fd, // @parm Carattere delimitatore di campi (default '\\0') - char rs, // @parm Carattere separatore di record (default '\\n') - bool vis, // @parm Indica se visualizzare lo stato dell'operazione (default TRUE) - bool extended) // @parm Indica se interpretare alcune stringhe come macro (default FALSE) - -// @comm Se

e' TRUE e trova alcune stringhe col formato %stringa% (es. %frm%) -// ne sostituisce i valori (es. ditta corrente). - -// @xref - -{ - FILE* fl = fopen(from, "r"); - int err=NOERR; - if (fl == NULL) - { - error_box("Non riesco ad aprire il file %s",from); - return 2; - } - TRecnotype r = 0, e = 0, nitems = 0, nread = 0; - TString16 firm, year, attprev("00000"); - - if (extended) - { - TDate d(TODAY); - TLocalisamfile ditte(LF_NDITTE); - - firm.format("%05ld", prefix().get_codditta()); - year.format("%04d", d.year()); - ditte.zero(); - ditte.put("CODDITTA", firm); - if (ditte.read() == NOERR) - attprev = ditte.get("CODATTPREV"); - } - if (fl == NULL) - { - clearerr(fl); - setstatus(err); - return err; - } - char w[256]; - while ((fgets(w, sizeof(w), fl) != NULL)) - { - if (strncmp(w, "[Data]", 6) == 0) - { - nitems = ftell(fl); - break; - } - } - fseek(fl, 0L, SEEK_END); - nitems = ftell(fl) - nitems; - fclose(fl); - TScanner f(from); - - TToken_string s(1024, fs); - bool fixedlen = (fs == '\0'); - int nflds = curr().items(); - TArray fld(nflds); - int len[MaxFields]; - TString sfd(3); - TString s1(64); - - if (f.paragraph("Header")) - { - f.equal(); - const unsigned int level = atoi(f.line()); - const unsigned int stdlev = prefix().get_stdlevel(); - if (level > stdlev) - error_box("L'archivio %s e' stato generato con gli archivi di livello %ld%/%ld.\n Il livello attuale e' %ld/%ld.\n Convertire gli archivi e ripetere l' operazione.", - from, level/100, level%100, stdlev/100, stdlev%100); - - nflds = 0; - while (true) - { - const TString& riga = f.line(); - //quando termina la testata deve uscire dal ciclo! - if (riga.blank() || riga[0] == ']') - break; - //legge il tracciato record - if (riga.starts_with("Fields")) - { - TToken_string s2 = riga.after("="); - for (const char * fd = s2.get(); fd != NULL; fd = s2.get()) - { - TToken_string wfd(fd, ','); - fld.add(new TString(wfd.get())); - len[nflds] = wfd.get_int(); - nflds++; - } - } - } - } - else - { - for (int j = 0; j < nflds; j++) - { - fld.add(TString(curr().fieldname(j)), j); - const TString & wfld = (const TString & ) fld[j]; - len[j] = (curr().type(wfld) == _datefld) ? 10 : curr().length(wfld); - } - } - if (!f.paragraph("Data")) - { - error_box("Formato dei dati non valido"); - //close(); - err = 1; - setstatus(err); - return err; - } - - if (fd) sfd << fd; - int last = NOERR; - - s1.format("Imp. archivio %s\n%6ld records %6ld errori - %3d", filename(), r, e, last); - TProgind p(nitems, s1, TRUE, TRUE, 70); - s = f.line(); - while (s.not_empty() && !p.iscancelled()) - { - if (extended) - { - int p, i; - - while ((p = s.find("%yr%")) >= 0) - for (i = 0; i < 4; i++) s[p + i] = year[i]; - while ((p = s.find("%frm%")) >= 0) - for (i = 0; i < 5; i++) s[p + i] = firm[i]; - while ((p = s.find("%att%")) >= 0) - for (i = 0; i < 5; i++) s[p + i] = attprev[i]; - } - if ((r + e) % 50 == 0) - { - s1.format("Imp. archivio %s\n%6ld records %6ld errori - %3d", filename(), r, e, last); - p.set_text(s1); - } - p.setstatus(nread + 1); - nread += s.len() + 1; - zero(); - if (fixedlen) - { - int pos = 0; - for (int j = 0; j < nflds; j++) - { - s1 = s.mid(pos,len[j]); - s1.rtrim(); - put((const TString&) fld[j], s1); - pos += len[j]; - } - } - else - { - s.restart(); - for (int j = 0; j < nflds; j++) - { - char* s2 = (char*) s.get(); - if (fd) - { - s2++; - s2[strlen(s2) - 1] = '\0'; - } - put((const TString&) fld[j], s2); - } - } - if (write() == NOERR) r++; - else - { -#ifdef DBG - yesnofatal_box("Numero linea relativa all'errore: %ld",r+e+1); -#endif - e++; - last = status(); - } - s = f.line(); - } - s1.format("Imp. archivio %s\n%6ld records %6ld errori - %3d", filename(), r, e, last); - p.set_text(s1); - //close(); - setstatus(err); - return err; -} - -// @mfunc Esporta VERSO un file ascii. -// -// @rdesc Ritorna NOERR se l'operazione di esportazione e' riuscita, altrimenti il codice di -// di errore generato (vedi ). -int TSystemtempfile::dump( - const char* to, // @parm Nome del file verso quale esportare - int nkey, // @parm Numero della chiave di ordinamento con cui scaricare i dati (defualt 1) - char fs, // @parm Carattere seperatore di campo (defualt ) - char fd, // @parm Carattere delimitatore di campo (default '\\0') - char rs, // @parm Carattere separatore di record (default '\\n') - bool vis, // @parm Indica se visualizzare lo stato dell'operazione (defualt TRUE) - bool withdeleted) // @parm Indica se scaricare anche i record cancellati (dafault FALSE) - -// @xref - -{ - FILE* f = fopen(to, "w"); - - if (f == NULL) - { - setstatus(2); - return 2; - } - - if (withdeleted) nkey = 0; - int err = ferror(f); - - //open(FALSE, nkey ? TRUE : FALSE); - TString s(512); - bool fixedlen = (fs == '\0'); - int nflds = curr().items(); - TArray fld(nflds); - TBit_array rjust(nflds); - int len[MaxFields]; - int j; - - for (j = 0; j < nflds; j++) - { - fld.add(TString(curr().fieldname(j)), j); - const TString & wfld = (const TString&) fld[j]; - const TFieldtypes t = curr().type(wfld); - rjust.set(j, t == _intfld || t == _longfld || t == _realfld || - t == _wordfld || t == _intzerofld || t == _longzerofld); - len[j] = (t == _datefld) ? 10 : curr().length(wfld); - } - TRecnotype i = 0; - const TRecnotype nitems = items(); - s.format("Esportazione archivio %s", filename()); - TProgind p(nitems, s, TRUE, TRUE, 70); - TString s1; - - fprintf(f, "[Header]\nVersion=%ld", (long) prefix().filelevel()); - for (int k = 0; k < nflds; k++) - { - if ((k % 10) == 0) fprintf(f, "\nFields="); - else fprintf(f, "|"); - fprintf(f, "%s,%d", (const char *) (const TString&) fld[k], len[k]); - } - fprintf(f, "\n\n[Data]\n"); - if (nkey) - { - setkey(nkey); - for ( first(); status() == NOERR && !p.iscancelled(); next(), i++) - { - p.setstatus(i + 1); - s = ""; - for (j = 0; j < nflds; j++) - { - if (fixedlen) - { - s1 = get((const TString&)fld[j]); - if (rjust[j]) s1.right_just(len[j]); - else s1.left_just(len[j]); - } - else - { - s1 = ""; - if (j && fs) s1 << fs; - if (fd) s1 << fd; - s1 << get((const TString&)fld[j]); - if (fd) s1 << fd; - } - s << s1; - } - fprintf(f, "%s%c", (const char*) s, rs); - } - } - else - { - - for (i = 0; i < nitems && !p.iscancelled(); i++) - { - zero(); - p.setstatus(i + 1); - readat(i + 1); - s=""; - if (withdeleted || curr().valid()) - { - for (j = 0; j < nflds; j++) - { - if (fixedlen) - { - s1 = get((const TString&)fld[j]); - if (rjust[j]) s1.right_just(len[j]); - else s1.left_just(len[j]); - } - else - { - s1 = ""; - if (j && fs) s1 << fs; - if (fd) s1 << fd; - s1 << get((const TString&)fld[j]); - if (fd) s1 << fd; - } - s << s1; - } - fprintf(f, "%s%c", (const char*) s, rs); - } - } - } - p.setstatus(nitems); - //close(); - fclose(f); - setstatus(err); - return err; -} - -// ******************************** -// classe TStd_filename -// ******************************** - -bool TStd_filename::check(bool verbose,const char * n) -{ - if (n && *n) - set(n); - insert("STD\\"); - if (!exist()) - { - *this = name(); - if (!exist()) - { - insert("STD\\"); - insert(prefix().get_studio()); - if (!exist()) - { - if (verbose) - error_box("Non riesco a trovare il file: %s", (const char *)name()); - cut(0); - return FALSE; - } - } - } - return TRUE; -} - -// ******************************** -// classe TInstallmodule_app -// ******************************** - -const char* TInstallmodule_app::module_name() const -{ - return dongle().module_code2desc(module_number()); -} - -const char* TInstallmodule_app::module_code() const -{ - return dongle().module_code2name(module_number()); -} - - -bool TInstallmodule_app::create() -{ - if (modal()) - { - TString16 maskname; - maskname.format("bainst%02d",module_number()); - _m = new TMask(maskname); - } - else - _m = NULL; - - TConfig campo_ini(CONFIG_INSTALL, "Main"); - const int type = campo_ini.get_int("Type"); - if (type == 1 || type == 2) - _test_database = true; - else - _test_database = campo_ini.get_bool("TestDatabase"); - - return TSkeleton_application::create(); -} - -bool TInstallmodule_app::destroy() -{ - if (_m) delete _m; - return TSkeleton_application::destroy(); -} - -bool TInstallmodule_app::something_to_load() const -{ - bool yes = false; - //dati comuni - TFilename file_to_load = module_code(); - file_to_load << "tabcom.txt"; - yes = ci_sono_novita(file_to_load, LF_TABCOM); - //dati ditta - if (!yes) - { - file_to_load = module_code(); - file_to_load << "tab.txt"; - yes = ci_sono_novita(file_to_load, LF_TAB); - } - //dati di modulo - if (!yes) - { - file_to_load = module_code(); - file_to_load << "tabmod.txt"; - yes = ci_sono_novita(file_to_load, LF_TABMOD); - } - return yes; -} - -bool TInstallmodule_app::preload_mask() -{ - if (test_database()) - { - if (something_to_load()) - _m->set(F_DEFAULTSDATA,"X"); - } - else - { - _m->set(F_DEFAULTSDATA," "); - _m->disable(F_DEFAULTSDATA); - } - return true; -} - -bool TInstallmodule_app::ci_sono_novita(const TFilename& filesource, const int filedest) const -{ - bool ok = (filedest == LF_TAB || filedest == LF_TABCOM || filedest == LF_TABMOD) && filesource.exist(); - if (ok) - { - TScanner scan(filesource); - ok = scan.paragraph("Data"); - if (ok) - { - TIsamfile ifile(filedest); - ok = ifile.open_ex() != NOERR; //se il file non e' buono va aggiornato... - if (!ok) - { - ok = ifile.read(_isfirst) != NOERR; //se il file e' vuoto ci sono sicuramente novita'!!! - TToken_string tok; - while (!ok) - { - tok = scan.line(); - if (tok.blank()) - break; - if (filedest == LF_TABMOD) - { - ifile.put("MOD", tok.get(0)); - ifile.put("CUST", tok.get(1)); - ifile.put("COD", tok.get(2)); - ifile.put("CODTAB", tok.get(3)); - } - else - { - ifile.put("COD", tok.get(0)); - ifile.put("CODTAB", tok.get(1)); - } - ok = ifile.read() != NOERR; - } - ifile.close(); - } - } - } - return ok; -} - -bool TInstallmodule_app::something_checked() const -{ - return _m->get_bool(F_DEFAULTSDATA); -} - -void TInstallmodule_app::main_loop() -{ - bool ok = true; - - if (modal()) - { - if (test_database()) //solo se puoi modificare i dati ti e' permesso di entrare, oh utonto! - { - preload_mask(); - if (something_checked() && _m->run() != K_QUIT) //modifica per far apparire il caricamento dei dati standard solo se non ci sono - { - if (something_checked()) //rifare il test in caso di flaggaggio manuale - { - install_com(); - install_firm(); - install_mod(); - } - } - else - ok = false; - } - } - if (ok) - post_installer(); -} - -bool TInstallmodule_app::install_firm() -{ - // ciclo su ogni ditta - TStd_filename txtfile(module_code()); - txtfile << "tab.txt"; - if (txtfile.check()) - { - TLocalisamfile ditte(LF_NDITTE); - for (ditte.first(); !ditte.eof() ; ditte.next()) - { - const int newditta=ditte.get_int("CODDITTA"); - if (prefix().exist(newditta)) - { - set_firm(newditta); - TSystemisamfile tab(LF_TAB); - tab.load(txtfile); - } - } - // carica le tabelle nei file di default - TSystemtempfile tabstd(LF_TAB); - TFilename stdtabname(prefix().get_studio()); - stdtabname << "STD\\lf0005.txt"; - tabstd.load(txtfile); - tabstd.load(stdtabname); - tabstd.set_autodel(); - TFilename tempfile; - tempfile.temp(); - - // riconverte le macro delle date - tabstd.dump(tempfile); - TScanner scan(tempfile); - FILE *dest=fopen((const char *)stdtabname,"w"); - while (TRUE) { - TString &line=scan.line(); - if (line.empty()) break; - - int pos=(line.find("-0000")); - while (pos >= 0 ) - { - line.overwrite("%yr%",pos+1); - pos=(line.find("-0000")); - } - line << '\n' ; - fputs((const char * )line,dest); - } - fclose(dest); - } - return true; -} - -bool TInstallmodule_app::install_com() -{ - bool ok = true; - TStd_filename txtfile(module_code()); - txtfile << "tabcom.txt"; - if (txtfile.check()) - { - TSystemisamfile tabcom(LF_TABCOM); - tabcom.load(txtfile); - } - return ok; -} - -bool TInstallmodule_app::install_mod() -{ - // ciclo su ogni ditta - TStd_filename txtfile(module_code()); - txtfile << "tabmod.txt"; - if (txtfile.check()) - { - TLocalisamfile ditte(LF_NDITTE); - for (ditte.first(); !ditte.eof() ; ditte.next()) - { - const int newditta=ditte.get_int("CODDITTA"); - if (prefix().exist(newditta)) - { - set_firm(newditta); - TSystemisamfile tabmod(LF_TABMOD); - tabmod.load(txtfile); - } - } - } - return true; -} - -void TInstallmodule_app::run(int argc, char* argv[]) -{ - TString title("Installazione "); - title << module_name(); - TSkeleton_application::run(argc, argv,(const char* )title); -} - -void TInstallmodule_app::set_tab_app(const char * appname) -{ - TConfig ditta(CONFIG_DITTA); - ditta.set_paragraph(module_code()); - ditta.set("TabApp",appname); -} +#include +#include +#include +#include + +#include "bainstlib.h" +#include "bainsta.h" + +// ******************************** +// classe TSystemtempfile +// ******************************** + + +// classe provvisoria per i system file temporanei, ovvero file temporanei con +// caricamento/scaricamento +// @doc EXTERNAL + +// @mfunc Importa un file ascii +// +// @rdesc Ritorna NOERR se l'operazione di lettura e' riuscita, altrimenti il codice di +// di errore generato (vedi ). +int TSystemtempfile::load( + const char* from, // @parm Nome del file da importare + char fs, // @parm Carattere separatore di campo (default ) + char fd, // @parm Carattere delimitatore di campi (default '\\0') + char rs, // @parm Carattere separatore di record (default '\\n') + bool vis, // @parm Indica se visualizzare lo stato dell'operazione (default TRUE) + bool extended) // @parm Indica se interpretare alcune stringhe come macro (default FALSE) + +// @comm Se

e' TRUE e trova alcune stringhe col formato %stringa% (es. %frm%) +// ne sostituisce i valori (es. ditta corrente). + +// @xref + +{ + FILE* fl = fopen(from, "r"); + int err=NOERR; + if (fl == NULL) + { + error_box("Non riesco ad aprire il file %s",from); + return 2; + } + TRecnotype r = 0, e = 0, nitems = 0, nread = 0; + TString16 firm, year, attprev("00000"); + + if (extended) + { + TDate d(TODAY); + TLocalisamfile ditte(LF_NDITTE); + + firm.format("%05ld", prefix().get_codditta()); + year.format("%04d", d.year()); + ditte.zero(); + ditte.put("CODDITTA", firm); + if (ditte.read() == NOERR) + attprev = ditte.get("CODATTPREV"); + } + if (fl == NULL) + { + clearerr(fl); + setstatus(err); + return err; + } + char w[256]; + while ((fgets(w, sizeof(w), fl) != NULL)) + { + if (strncmp(w, "[Data]", 6) == 0) + { + nitems = ftell(fl); + break; + } + } + fseek(fl, 0L, SEEK_END); + nitems = ftell(fl) - nitems; + fclose(fl); + TScanner f(from); + + TToken_string s(1024, fs); + bool fixedlen = (fs == '\0'); + int nflds = curr().items(); + TArray fld(nflds); + int len[MaxFields]; + TString sfd(3); + TString s1(64); + + if (f.paragraph("Header")) + { + f.equal(); + const unsigned int level = atoi(f.line()); + const unsigned int stdlev = prefix().get_stdlevel(); + if (level > stdlev) + error_box("L'archivio %s e' stato generato con gli archivi di livello %ld%/%ld.\n Il livello attuale e' %ld/%ld.\n Convertire gli archivi e ripetere l' operazione.", + from, level/100, level%100, stdlev/100, stdlev%100); + + nflds = 0; + while (true) + { + const TString& riga = f.line(); + //quando termina la testata deve uscire dal ciclo! + if (riga.blank() || riga[0] == ']') + break; + //legge il tracciato record + if (riga.starts_with("Fields")) + { + TToken_string s2 = riga.after("="); + for (const char * fd = s2.get(); fd != NULL; fd = s2.get()) + { + TToken_string wfd(fd, ','); + fld.add(new TString(wfd.get())); + len[nflds] = wfd.get_int(); + nflds++; + } + } + } + } + else + { + for (int j = 0; j < nflds; j++) + { + fld.add(TString(curr().fieldname(j)), j); + const TString & wfld = (const TString & ) fld[j]; + len[j] = (curr().type(wfld) == _datefld) ? 10 : curr().length(wfld); + } + } + if (!f.paragraph("Data")) + { + error_box("Formato dei dati non valido"); + //close(); + err = 1; + setstatus(err); + return err; + } + + if (fd) sfd << fd; + int last = NOERR; + + s1.format("Imp. archivio %s\n%6ld records %6ld errori - %3d", filename(), r, e, last); + TProgind p(nitems, s1, TRUE, TRUE, 70); + s = f.line(); + while (s.not_empty() && !p.iscancelled()) + { + if (extended) + { + int p, i; + + while ((p = s.find("%yr%")) >= 0) + for (i = 0; i < 4; i++) s[p + i] = year[i]; + while ((p = s.find("%frm%")) >= 0) + for (i = 0; i < 5; i++) s[p + i] = firm[i]; + while ((p = s.find("%att%")) >= 0) + for (i = 0; i < 5; i++) s[p + i] = attprev[i]; + } + if ((r + e) % 50 == 0) + { + s1.format("Imp. archivio %s\n%6ld records %6ld errori - %3d", filename(), r, e, last); + p.set_text(s1); + } + p.setstatus(nread + 1); + nread += s.len() + 1; + zero(); + if (fixedlen) + { + int pos = 0; + for (int j = 0; j < nflds; j++) + { + s1 = s.mid(pos,len[j]); + s1.rtrim(); + put((const TString&) fld[j], s1); + pos += len[j]; + } + } + else + { + s.restart(); + for (int j = 0; j < nflds; j++) + { + char* s2 = (char*) s.get(); + if (fd) + { + s2++; + s2[strlen(s2) - 1] = '\0'; + } + put((const TString&) fld[j], s2); + } + } + if (write() == NOERR) r++; + else + { +#ifdef DBG + yesnofatal_box("Numero linea relativa all'errore: %ld",r+e+1); +#endif + e++; + last = status(); + } + s = f.line(); + } + s1.format("Imp. archivio %s\n%6ld records %6ld errori - %3d", filename(), r, e, last); + p.set_text(s1); + //close(); + setstatus(err); + return err; +} + +// @mfunc Esporta VERSO un file ascii. +// +// @rdesc Ritorna NOERR se l'operazione di esportazione e' riuscita, altrimenti il codice di +// di errore generato (vedi ). +int TSystemtempfile::dump( + const char* to, // @parm Nome del file verso quale esportare + int nkey, // @parm Numero della chiave di ordinamento con cui scaricare i dati (defualt 1) + char fs, // @parm Carattere seperatore di campo (defualt ) + char fd, // @parm Carattere delimitatore di campo (default '\\0') + char rs, // @parm Carattere separatore di record (default '\\n') + bool vis, // @parm Indica se visualizzare lo stato dell'operazione (defualt TRUE) + bool withdeleted) // @parm Indica se scaricare anche i record cancellati (dafault FALSE) + +// @xref + +{ + FILE* f = fopen(to, "w"); + + if (f == NULL) + { + setstatus(2); + return 2; + } + + if (withdeleted) nkey = 0; + int err = ferror(f); + + //open(FALSE, nkey ? TRUE : FALSE); + TString s(512); + bool fixedlen = (fs == '\0'); + int nflds = curr().items(); + TArray fld(nflds); + TBit_array rjust(nflds); + int len[MaxFields]; + int j; + + for (j = 0; j < nflds; j++) + { + fld.add(TString(curr().fieldname(j)), j); + const TString & wfld = (const TString&) fld[j]; + const TFieldtypes t = curr().type(wfld); + rjust.set(j, t == _intfld || t == _longfld || t == _realfld || + t == _wordfld || t == _intzerofld || t == _longzerofld); + len[j] = (t == _datefld) ? 10 : curr().length(wfld); + } + TRecnotype i = 0; + const TRecnotype nitems = items(); + s.format("Esportazione archivio %s", filename()); + TProgind p(nitems, s, TRUE, TRUE, 70); + TString s1; + + fprintf(f, "[Header]\nVersion=%ld", (long) prefix().filelevel()); + for (int k = 0; k < nflds; k++) + { + if ((k % 10) == 0) fprintf(f, "\nFields="); + else fprintf(f, "|"); + fprintf(f, "%s,%d", (const char *) (const TString&) fld[k], len[k]); + } + fprintf(f, "\n\n[Data]\n"); + if (nkey) + { + setkey(nkey); + for ( first(); status() == NOERR && !p.iscancelled(); next(), i++) + { + p.setstatus(i + 1); + s = ""; + for (j = 0; j < nflds; j++) + { + if (fixedlen) + { + s1 = get((const TString&)fld[j]); + if (rjust[j]) s1.right_just(len[j]); + else s1.left_just(len[j]); + } + else + { + s1 = ""; + if (j && fs) s1 << fs; + if (fd) s1 << fd; + s1 << get((const TString&)fld[j]); + if (fd) s1 << fd; + } + s << s1; + } + fprintf(f, "%s%c", (const char*) s, rs); + } + } + else + { + + for (i = 0; i < nitems && !p.iscancelled(); i++) + { + zero(); + p.setstatus(i + 1); + readat(i + 1); + s=""; + if (withdeleted || curr().valid()) + { + for (j = 0; j < nflds; j++) + { + if (fixedlen) + { + s1 = get((const TString&)fld[j]); + if (rjust[j]) s1.right_just(len[j]); + else s1.left_just(len[j]); + } + else + { + s1 = ""; + if (j && fs) s1 << fs; + if (fd) s1 << fd; + s1 << get((const TString&)fld[j]); + if (fd) s1 << fd; + } + s << s1; + } + fprintf(f, "%s%c", (const char*) s, rs); + } + } + } + p.setstatus(nitems); + //close(); + fclose(f); + setstatus(err); + return err; +} + +// ******************************** +// classe TStd_filename +// ******************************** + +bool TStd_filename::check(bool verbose, const char * n) +{ + if (n && *n) + set(n); + insert("std\\"); + if (!exist()) + { + *this = name(); + if (!exist()) + { + insert("std\\"); + insert(prefix().get_studio()); + } + } + if (!exist()) + { + if (verbose) + cantread_box(name()); + cut(0); + return false; + } + return true; +} + +// ******************************** +// classe TInstallmodule_app +// ******************************** + +const char* TInstallmodule_app::module_name() const +{ + return dongle().module_code2desc(module_number()); +} + +const char* TInstallmodule_app::module_code() const +{ + return dongle().module_code2name(module_number()); +} + + +bool TInstallmodule_app::create() +{ + if (modal()) + { + TString16 maskname; + maskname.format("bainst%02d",module_number()); + _m = new TMask(maskname); + } + else + _m = NULL; + + TConfig campo_ini(CONFIG_INSTALL, "Main"); + const int type = campo_ini.get_int("Type"); + if (type == 1 || type == 2) + _test_database = true; + else + _test_database = campo_ini.get_bool("TestDatabase"); + + return TSkeleton_application::create(); +} + +bool TInstallmodule_app::destroy() +{ + if (_m) delete _m; + return TSkeleton_application::destroy(); +} + +bool TInstallmodule_app::something_to_load() const +{ + bool yes = false; + //dati comuni + TFilename file_to_load = module_code(); + file_to_load << "tabcom.txt"; + yes = ci_sono_novita(file_to_load, LF_TABCOM); + //dati ditta + if (!yes) + { + file_to_load = module_code(); + file_to_load << "tab.txt"; + yes = ci_sono_novita(file_to_load, LF_TAB); + } + //dati di modulo + if (!yes) + { + file_to_load = module_code(); + file_to_load << "tabmod.txt"; + yes = ci_sono_novita(file_to_load, LF_TABMOD); + } + return yes; +} + +bool TInstallmodule_app::preload_mask() +{ + if (test_database()) + { + if (something_to_load()) + _m->set(F_DEFAULTSDATA,"X"); + } + else + { + _m->set(F_DEFAULTSDATA," "); + _m->disable(F_DEFAULTSDATA); + } + return true; +} + +bool TInstallmodule_app::ci_sono_novita(const TFilename& txt, const int filedest) const +{ + TStd_filename filesource; + bool ok = (filedest == LF_TAB || filedest == LF_TABCOM || filedest == LF_TABMOD) && filesource.check(false, txt); + if (ok) + { + TScanner scan(filesource); + ok = scan.paragraph("Data"); + if (ok) + { + TIsamfile ifile(filedest); + ok = ifile.open_ex() != NOERR; //se il file non e' buono va aggiornato... + if (!ok) + { + ok = ifile.read(_isfirst) != NOERR; //se il file e' vuoto ci sono sicuramente novita'!!! + TToken_string tok; + while (!ok) + { + tok = scan.line(); + if (tok.blank()) + break; + if (filedest == LF_TABMOD) + { + ifile.put("MOD", tok.get(0)); + ifile.put("CUST", tok.get(1)); + ifile.put("COD", tok.get(2)); + ifile.put("CODTAB", tok.get(3)); + } + else + { + ifile.put("COD", tok.get(0)); + ifile.put("CODTAB", tok.get(1)); + } + ok = ifile.read() != NOERR; + } + ifile.close(); + } + } + } + return ok; +} + +bool TInstallmodule_app::something_checked() const +{ + return _m->get_bool(F_DEFAULTSDATA); +} + +void TInstallmodule_app::main_loop() +{ + bool ok = true; + + if (modal()) + { + if (test_database()) //solo se puoi modificare i dati ti e' permesso di entrare, oh utonto! + { + preload_mask(); + if (something_checked() && _m->run() != K_QUIT) //modifica per far apparire il caricamento dei dati standard solo se non ci sono + { + if (something_checked()) //rifare il test in caso di flaggaggio manuale + { + install_com(); + install_firm(); + install_mod(); + } + } + else + ok = false; + } + } + if (ok) + post_installer(); +} + +bool TInstallmodule_app::install_firm() +{ + // ciclo su ogni ditta + TStd_filename txtfile(module_code()); + txtfile << "tab.txt"; + if (txtfile.check()) + { + TString_array firms; + TPrefix::firms(firms); + + FOR_EACH_ARRAY_ROW(firms, r, riga) + { + set_firm(atol(*riga)); + TSystemisamfile tab(LF_TAB); + tab.load(txtfile); + } + // carica le tabelle nei file di default + TSystemtempfile tabstd(LF_TAB); + TFilename stdtabname(prefix().get_studio()); + stdtabname << "STD\\lf0005.txt"; + tabstd.load(txtfile); + tabstd.load(stdtabname); + tabstd.set_autodel(); + TFilename tempfile; + tempfile.temp(); + + // riconverte le macro delle date + tabstd.dump(tempfile); + TScanner scan(tempfile); + FILE *dest=fopen((const char *)stdtabname,"w"); + while (TRUE) { + TString &line=scan.line(); + if (line.empty()) break; + + int pos=(line.find("-0000")); + while (pos >= 0 ) + { + line.overwrite("%yr%",pos+1); + pos=(line.find("-0000")); + } + line << '\n' ; + fputs((const char * )line,dest); + } + fclose(dest); + } + return true; +} + +bool TInstallmodule_app::install_com() +{ + bool ok = true; + TStd_filename txtfile(module_code()); + txtfile << "tabcom.txt"; + if (txtfile.check()) + { + TSystemisamfile tabcom(LF_TABCOM); + tabcom.load(txtfile); + } + return ok; +} + +bool TInstallmodule_app::install_mod() +{ + // ciclo su ogni ditta + TStd_filename txtfile(module_code()); + txtfile << "tabmod.txt"; + if (txtfile.check()) + { + TString_array firms; + TPrefix::firms(firms); + + FOR_EACH_ARRAY_ROW(firms, r, riga) + { + set_firm(atol(*riga)); + TSystemisamfile tabmod(LF_TABMOD); + tabmod.load(txtfile); + } + } + return true; +} + +void TInstallmodule_app::run(int argc, char* argv[]) +{ + TString title("Installazione "); + title << module_name(); + TSkeleton_application::run(argc, argv,(const char* )title); +} + +void TInstallmodule_app::set_tab_app(const char * appname) +{ + TConfig ditta(CONFIG_DITTA); + ditta.set_paragraph(module_code()); + ditta.set("TabApp",appname); +} diff --git a/ba/bainstlib.h b/ba/bainstlib.h index 4d3ba9e47..8332f87ec 100755 --- a/ba/bainstlib.h +++ b/ba/bainstlib.h @@ -1,74 +1,74 @@ -#ifndef __INST_H -#define __INST_H - -#ifndef __APPLICAT_H -#include -#endif - -#ifndef __ISAM_H -#include -#endif - -#ifndef __MASK_H -#include -#endif - -#include "bainsta.h" -// classe provvisoria per i system file temporanei, ovvero file temporanei con -// caricamento/scaricamento -class TSystemtempfile : public TIsamtempfile -{ -public: -//bool getlcf( long flev); // @parm livello archivi di partenza della convesione - - int load(const char* from, char fs = '|', char fd = '\0', char rs = '\n', bool vis = TRUE, bool extended = FALSE) ; - - int dump(const char* to, int nkey = 1, char fs = '|', char fd = '\0', char rs = '\n', bool vis = TRUE, bool withdeleted = FALSE); - - TSystemtempfile(int logicnum) : - TIsamtempfile(logicnum,NULL) {} -}; - -class TStd_filename : public TFilename -{ -public: - bool check(bool verbose=FALSE,const char * name=NULL); - - TStd_filename () : TFilename(){} - TStd_filename (const char * n) : TFilename(n){} -}; - -class TInstallmodule_app: public TSkeleton_application -{ - bool _is_first_inst , _test_database ; - -protected: - TMask * _m ; - -protected: - virtual int module_number() const pure; - - void set_tab_app(const char * appname); - bool test_database() const {return _test_database;} - const char* module_name() const; - const char* module_code() const; - - virtual bool something_to_load() const; - virtual bool modal() const {return true;} - virtual bool preload_mask(); - virtual bool post_installer() {return true;} - virtual bool something_checked() const; - virtual bool ci_sono_novita(const TFilename& filesource, const int filedest) const; - - virtual bool install_com() ; // setta i dati comuni - virtual bool install_firm() ; // setta i dati ditta - virtual bool install_mod() ; // setta i dati modulo - - virtual void main_loop() ; - virtual bool create(); - virtual bool destroy(); -public: - void run(int argc, char* argv[]); -}; - -#endif +#ifndef __INST_H +#define __INST_H + +#ifndef __APPLICAT_H +#include +#endif + +#ifndef __ISAM_H +#include +#endif + +#ifndef __MASK_H +#include +#endif + +#include "bainsta.h" +// classe provvisoria per i system file temporanei, ovvero file temporanei con +// caricamento/scaricamento +class TSystemtempfile : public TIsamtempfile +{ +public: +//bool getlcf( long flev); // @parm livello archivi di partenza della convesione + + int load(const char* from, char fs = '|', char fd = '\0', char rs = '\n', bool vis = TRUE, bool extended = FALSE) ; + + int dump(const char* to, int nkey = 1, char fs = '|', char fd = '\0', char rs = '\n', bool vis = TRUE, bool withdeleted = FALSE); + + TSystemtempfile(int logicnum) : + TIsamtempfile(logicnum,NULL) {} +}; + +class TStd_filename : public TFilename +{ +public: + bool check(bool verbose = false, const char * name = NULL); + + TStd_filename () : TFilename(){} + TStd_filename (const char * n) : TFilename(n){} +}; + +class TInstallmodule_app: public TSkeleton_application +{ + bool _is_first_inst , _test_database ; + +protected: + TMask * _m ; + +protected: + virtual int module_number() const pure; + + void set_tab_app(const char * appname); + bool test_database() const {return _test_database;} + const char* module_name() const; + const char* module_code() const; + + virtual bool something_to_load() const; + virtual bool modal() const {return true;} + virtual bool preload_mask(); + virtual bool post_installer() {return true;} + virtual bool something_checked() const; + virtual bool ci_sono_novita(const TFilename& filesource, const int filedest) const; + + virtual bool install_com() ; // setta i dati comuni + virtual bool install_firm() ; // setta i dati ditta + virtual bool install_mod() ; // setta i dati modulo + + virtual void main_loop() ; + virtual bool create(); + virtual bool destroy(); +public: + void run(int argc, char* argv[]); +}; + +#endif diff --git a/ba/bamenu.men b/ba/bamenu.men index a06864c43..2c9bed3b2 100755 --- a/ba/bamenu.men +++ b/ba/bamenu.men @@ -117,6 +117,7 @@ Item_09 = "Gestione dizionario", "ba2 -6", "" Item_10 = "Query e Report", [MENU_014], "", 10217 Item_11 = "Firma digitale", "ba8 -6", "" Item_12 = "Postino", "ba7 -0", "" +Item_13 = "Teleassistenza", "setup/TeamviewerQS_it.exe", "F", 10231 [MENU_016] Caption = "Procedure speciali"