From 337e7d94384c51af9ef642822a37201803cf56a7 Mon Sep 17 00:00:00 2001 From: Simone Palacino Date: Mon, 8 Jun 2020 10:57:35 +0200 Subject: [PATCH] Patch level : 12.0 966 Files correlati : f90.exe fpmenu.men d181.des f181.dir f181.trr all-masks f90104.sql Commento : - Implementata copia file cartacei nel percorso della WebApp costruito secondo documentazione. - Eliminazione cartella pacchetto dalla cartella WebApp nel caso di eliminazione di un pacchetto provvisorio o in errore. - Aggiunto controllo di associazione file ad annesso, nel caso quel tipo di annesso ci fosse gia' un file associato. --- src/f9/f90100.cpp | 14 ++++++++- src/f9/f90100.h | 1 + src/f9/f90200.cpp | 6 ++-- src/f9/f90300.cpp | 19 +++++++++++ src/f9/f9lib01.cpp | 78 +++++++++++++++++++++++++++++++++------------- 5 files changed, 92 insertions(+), 26 deletions(-) diff --git a/src/f9/f90100.cpp b/src/f9/f90100.cpp index 94c4c2b79..a5882e1ed 100644 --- a/src/f9/f90100.cpp +++ b/src/f9/f90100.cpp @@ -1,10 +1,14 @@ +#include + +#include "f90.h" +#include "f90100.h" + #include "lffiles.h" #include "isam.h" #include "../f1/f1lib.h" #include "../fp/fplib.h" #include "urldefid.h" #include "progind.h" -#include "f90100.h" #include "f901tab.h" #include "f90100b.h" #include "f90100d.h" @@ -392,8 +396,15 @@ void TMonitor_mask::controllo_errori() const warning_box("Selezionare un'estrazione."); } +void TMonitor_mask::delete_estr_fld(const TString& idestr) +{ + static const TFilename dir = TString() << F9CONF.get_addr_doc() << SLASH << F9CONF.get_ambiente() << SLASH << idestr << SLASH; + unsigned long long i = experimental::filesystem::remove_all((const char*)dir); +} + void TMonitor_mask::delete_pack(const bool all) const { + // Se nello sheet non c'e' selezionata alcuna riga viene richiamata col flag all = true bool flag = false; TSheet_field& sf = sfield(S_ELAB); FOR_EACH_SHEET_ROW(sf, nr, row) @@ -437,6 +448,7 @@ void TMonitor_mask::delete_pack(const bool all) const return; } fp_db().sq_commit(); + delete_estr_fld(id_estr); if (!all) break; } diff --git a/src/f9/f90100.h b/src/f9/f90100.h index 12a3edfab..424c7fa02 100644 --- a/src/f9/f90100.h +++ b/src/f9/f90100.h @@ -147,6 +147,7 @@ class TMonitor_mask : public TAutomask // Controllo estr. mask void controllo_errori() const; + static void delete_estr_fld(const TString& idestr); void delete_pack(bool all = false) const; // Riempie sheet per visualizzare le estrazioni diff --git a/src/f9/f90200.cpp b/src/f9/f90200.cpp index c5fb4d091..a5a2a25d1 100644 --- a/src/f9/f90200.cpp +++ b/src/f9/f90200.cpp @@ -222,9 +222,9 @@ void TF9_categorie_doc_msk::new_annesso(const TString& catdoc_padre) TCategorie_doc::annesso ann; if (!_categorie_doc.get_ann(catann, ann)) { - const TString& descr = new_ann.get(102); - const TString& tipo = new_ann.get(103); - const bool obblig = new_ann.get_bool(104); + const TString& descr = new_ann.get(102); + const TString& tipo = new_ann.get(103); + const bool obblig = new_ann.get_bool(104); correct_spell_catdoc(catann); _categorie_doc.add_annesso(catdoc_padre, catann, descr, tipo, obblig); fill_annessi(catdoc_padre); diff --git a/src/f9/f90300.cpp b/src/f9/f90300.cpp index dbb480373..df22188b5 100644 --- a/src/f9/f90300.cpp +++ b/src/f9/f90300.cpp @@ -646,6 +646,22 @@ bool TGestione_doc_cartacei_f9_msk::load_file(const TFilename& file, const TStri } else { + // Controllo che non sto gia' utilizzando questa categoria di annesso per questa registrazione + // Prendo la lista degli annessi per questa registrazione e li controllo in cerca della categoria + TF9_doccart doccart; + vector list_annessi; + doccart.mov2listann_vect(numreg, list_annessi); + bool exist = false; + for(auto it = list_annessi.begin(); it != list_annessi.end(); ++it) + { + if(it->catdocann == catdocann) + exist = true; + } + if(exist) + { + message_box("Attenzione: la registrazione num. %s ha gia' un annesso associato con questo tipo di annesso.", (const char*)numreg); + return false; + } f9annessi.zero(); f9annessi.put(F9A_NUMREG, numreg); f9annessi.put(F9A_FILENAME, file.name()); @@ -765,7 +781,10 @@ void TGestione_doc_cartacei_f9_msk::open_import_win() if (!is_annesso || catannpadre.full() && catdocann.full()) { if (load_file(f, numreg, is_annesso, catannpadre, catdocann)) + { message_box("File caricato."); + fill(); + } } else warning_box("Se il documento e' un annesso, si prega di inserire le\ninformazioni per la categoria documentale dell'annesso."); diff --git a/src/f9/f9lib01.cpp b/src/f9/f9lib01.cpp index 880c9a63a..22693a967 100644 --- a/src/f9/f9lib01.cpp +++ b/src/f9/f9lib01.cpp @@ -1,3 +1,5 @@ +#include + #include "f9lib01.h" #include "f1lib.h" @@ -163,7 +165,37 @@ bool TEstrazione::check_periodo_def() const void TEstrazione::copy_file_to_webapp_fld(const movimento_t& movimento) const { - // todo: + // f9pwa + ambiente + idlancio(ID drd) + categoria_documento(drt) + nome_documento + static const TFilename base = TString() << _head.addr_cart << SLASH << _head.cod_soc << SLASH << _head.id_estr << SLASH; + TToken_string categorie; + TToken_string files; + + if(movimento.cartaceo && movimento.catdoc != nullptr) + { + categorie.add(movimento.catdoc->catdoc, 0); + files.add(movimento.nomefilecart, 0); + } + if(!movimento.annessi.empty()) + { + for (auto it = movimento.annessi.begin(); it != movimento.annessi.end(); ++it) + { + categorie.add(it->catdocann); + files.add(TF9_doccart::get_full_path_file_cartaceo(it->filename)); + } + } +#ifdef DBG + CHECK(files.items() == categorie.items(), "Numero di file diverso dal numero di categorie"); +#endif + + for(int i = 0; i < files.items(); ++i) + { + TFilename file = files.get(i); + TFilename dest; dest << base << categorie.get(i) << SLASH << file.name(); + make_dir(dest.path()); + const bool f = CopyFile(file, dest, false); + if (!f) + error_box("Errore nel copiare il file nella cartella di destinazione: %s", (const char*)dest); + } } void TEstrazione::fill_id(TLocalisamfile& clifo, TString& statopaiv, TString& idfisc, TString& paiv, TString& codfis) @@ -481,6 +513,7 @@ const char* TEstrazione::diagnostica_mov() if (mov_i.catdoc) check_annessi(mov_i, numreg); } + if (mov_i.estratto) { if (mov_i.cartaceo) @@ -491,7 +524,6 @@ const char* TEstrazione::diagnostica_mov() if (filecart.mov2doc(reg, file) && file.exist()) { mov_i.nomefilecart << file; - copy_file_to_webapp_fld(mov_i); } else { @@ -501,6 +533,7 @@ const char* TEstrazione::diagnostica_mov() mov_i.descr_estr = movimento_t::no_filecart; } } + copy_file_to_webapp_fld(mov_i); } } ok &= mov_i.err; @@ -588,23 +621,26 @@ const char* TEstrazione::diagnostica_mov() ++_stats.fv_estr; } - if (mov_i.estratto && mov_i.cartaceo) + if (mov_i.estratto) { - TF9_doccart filecart; - TFilename file; - TString reg; reg << it->numreg; - if (filecart.mov2doc(reg, file) && file.exist()) + if(mov_i.cartaceo) { - mov_i.nomefilecart << file; - copy_file_to_webapp_fld(mov_i); - } - else - { - mov_i.err = true; - mov_i.estratto = false; - mov_i.descr_err = "Non e' stato possibile reperire il file del documento cartaceo per questo movimento."; - mov_i.descr_estr = movimento_t::no_filecart; + TF9_doccart filecart; + TFilename file; + TString reg; reg << it->numreg; + if (filecart.mov2doc(reg, file) && file.exist()) + { + mov_i.nomefilecart << file; + } + else + { + mov_i.err = true; + mov_i.estratto = false; + mov_i.descr_err = "Non e' stato possibile reperire il file del documento cartaceo per questo movimento."; + mov_i.descr_estr = movimento_t::no_filecart; + } } + copy_file_to_webapp_fld(mov_i); } } ok &= !mov_i.err; @@ -1192,8 +1228,8 @@ std::map::iterator TCategorie_doc::find_anness void TCategorie_doc::add_annesso(const TString& catdoc_padre, const TString& catdoc_ann, const TString& descr, const TString& class_ann, const bool obblig) { - CHECK(catdoc_padre && *catdoc_padre && catdoc_ann && *catdoc_ann && class_ann && *class_ann, - "add_annesso failed: some parameters are NULL or keys are empty"); + if(!(catdoc_padre && *catdoc_padre && catdoc_ann && *catdoc_ann && class_ann && *class_ann)) + fatal_box("add_annesso failed: some parameters are NULL or keys are empty"); annesso ann{ catdoc_padre, catdoc_ann, descr, class_ann, obblig }; _rows_annessi.insert({ catdoc_padre, ann }); @@ -1203,10 +1239,8 @@ void TCategorie_doc::add_annesso(const TString& catdoc_padre, const TString& cat void TCategorie_doc::add_categoria(const TString& catdoc, const TString& descr, const TString& class_sost, const TString& caus_sost, const TString& causcont, const TString& tipocaus) { -#ifdef DBG - CHECK(catdoc && *catdoc && class_sost && *class_sost && caus_sost && *caus_sost, - "add_categoria failed: some parameters are NULL or keys are empty"); -#endif + if(!(catdoc && *catdoc && class_sost && *class_sost && caus_sost && *caus_sost)) + fatal_box("add_categoria failed: some parameters are NULL or keys are empty"); classe_doc cd = { catdoc, descr, class_sost, caus_sost, causcont, tipocaus }; _rows.emplace_back(std::make_shared(cd)); save_cat();