2020-03-05 10:44:33 +01:00
|
|
|
#ifndef __MAJORXML_H__
|
|
|
|
#define __MAJORXML_H__
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
#include "strings.h"
|
|
|
|
#include "stdtypes.h"
|
|
|
|
#include "xml_element.h"
|
|
|
|
#include "date.h"
|
|
|
|
|
|
|
|
#define XML_ESCAPE_CHAR '&'
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// TEsa_import_xml
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief \a TXML_element Contenitore Importazione Flexform.
|
|
|
|
*/
|
|
|
|
struct TEsa_import_xml : TXML_element
|
|
|
|
{
|
|
|
|
void set_attributes(const TString& source, const TDate& creation_date, const TString& instance_guid, const TString& file_version)
|
|
|
|
{
|
|
|
|
add_attribute("Source", source);
|
|
|
|
add_attribute("CreationDate", creation_date.string(full, '/'));
|
|
|
|
add_attribute("InstanceGuid", instance_guid);
|
|
|
|
add_attribute("FileVersion", file_version);
|
|
|
|
}
|
|
|
|
TEsa_import_xml() : TXML_element("ESA_IMPORT", "") { }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// ELEMENTI DDT
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief \a TXML_element Testata DDT.
|
|
|
|
*/
|
|
|
|
class TDDT_testata_xml : public TXML_element
|
|
|
|
{
|
|
|
|
friend class TDDT_riga_xml;
|
|
|
|
TXML_element* _datarow;
|
|
|
|
|
|
|
|
// Figli di _datarow: campi della testata
|
|
|
|
|
|
|
|
TXML_element* _dat_doc;
|
|
|
|
TXML_element* _des_num;
|
|
|
|
public:
|
|
|
|
void add_row(TDDT_riga_xml& riga) { add_child((TXML_element&)riga); }
|
|
|
|
void set_testata(const char* data_doc, const char* num_doc);
|
|
|
|
|
|
|
|
TDDT_testata_xml() : TXML_element("MG_MOVMAGT", ""), _datarow(nullptr), _dat_doc(nullptr), _des_num(nullptr) { }
|
|
|
|
~TDDT_testata_xml();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief \a TXML_element Riga DDT.
|
|
|
|
*/
|
|
|
|
class TDDT_riga_xml : public TXML_element
|
|
|
|
{
|
|
|
|
TXML_element* _datarow; // Unico figlio di OR_ORDINIR contenenti i campi campi dell'ordine
|
|
|
|
|
|
|
|
// Figli di _datarow: campi dell'ordine
|
|
|
|
|
|
|
|
TXML_element* _tiporiga;
|
|
|
|
TXML_element* _art;
|
|
|
|
TXML_element* _des_articolo;
|
|
|
|
TXML_element* _merce;
|
|
|
|
TXML_element* _libero;
|
|
|
|
|
|
|
|
public:
|
|
|
|
void set_datarow(const char* ind_tiporiga, const char* cod_art, const char* des_articolo_riga, const char* qta_merce, const char* des_campo_libero6);
|
|
|
|
void set_datarow(const char* ind_tiporiga, const char* cod_art, const wchar_t* des_articolo_riga, const char* qta_merce, const char* des_campo_libero6);
|
|
|
|
|
|
|
|
TDDT_riga_xml() : TXML_element("MG_MOVMAGR", ""), _datarow(nullptr), _tiporiga(nullptr), _art(nullptr), _des_articolo(nullptr), _merce(nullptr), _libero(nullptr) { }
|
|
|
|
~TDDT_riga_xml();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// ELEMENTI ORDINI
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief \a TXML_element Testata Ordine.
|
|
|
|
*/
|
|
|
|
class TOrdini_testata_xml : public TXML_element
|
|
|
|
{
|
|
|
|
friend class TOrdini_riga_xml;
|
|
|
|
|
|
|
|
TXML_element* _datarow;
|
|
|
|
|
|
|
|
// Figli di _datarow: campi della testata
|
|
|
|
|
|
|
|
TXML_element* _dat_doc;
|
|
|
|
TXML_element* _des_num;
|
|
|
|
TXML_element* _sig_serie;
|
|
|
|
public:
|
|
|
|
void add_row(TOrdini_riga_xml& riga) { add_child((TXML_element&)riga); }
|
|
|
|
void set_testata(const char* data_doc, const char* num_doc, const char* str = "CCL");
|
|
|
|
|
|
|
|
TOrdini_testata_xml() : TXML_element("OR_ORDINIT", ""), _datarow(nullptr), _dat_doc(nullptr), _des_num(nullptr), _sig_serie(nullptr) { }
|
|
|
|
~TOrdini_testata_xml();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief \a TXML_element Riga Ordine.
|
|
|
|
*/
|
|
|
|
class TOrdini_riga_xml : public TXML_element
|
|
|
|
{
|
|
|
|
TXML_element* _datarow; // Unico figlio di OR_ORDINIR contenenti i campi campi dell'ordine
|
|
|
|
|
|
|
|
// Figli di _datarow: campi dell'ordine
|
|
|
|
|
|
|
|
TXML_element* _tiporiga;
|
|
|
|
TXML_element* _art;
|
|
|
|
TXML_element* _des_articolo;
|
|
|
|
TXML_element* _merce;
|
|
|
|
TXML_element* _libero;
|
|
|
|
|
|
|
|
public:
|
|
|
|
void set_datarow(const char* ind_tiporiga, const char* cod_art, const char* des_articolo_riga, const char* qta_merce, const char* des_campo_libero6);
|
|
|
|
TOrdini_riga_xml() : TXML_element("OR_ORDINIR", ""), _datarow(nullptr), _tiporiga(nullptr), _art(nullptr), _des_articolo(nullptr), _merce(nullptr), _libero(nullptr) { }
|
|
|
|
~TOrdini_riga_xml();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Flexform export xml
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Main FLEXFORM XML Class.
|
|
|
|
*/
|
|
|
|
class TFlexform_xml
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
TString _file_name;
|
|
|
|
ofstream* _fout;
|
|
|
|
TEsa_import_xml _esa_import;
|
|
|
|
|
|
|
|
static const char* generate_GUID();
|
|
|
|
void set_indentation(const bool use_tab, const short n_spaces) { _esa_import.set_indentation(use_tab, n_spaces); }
|
|
|
|
virtual bool print() pure;
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool ok() const { return _fout != nullptr && _fout->is_open(); }
|
|
|
|
|
|
|
|
TFlexform_xml(const char* xml_name = "");
|
|
|
|
virtual ~TFlexform_xml() { delete _fout; }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Esportatore XML DDT Flexform.
|
|
|
|
*/
|
|
|
|
class TFlexform_xml_ddt final : public TFlexform_xml
|
|
|
|
{
|
2020-03-05 13:01:01 +01:00
|
|
|
vector<shared_ptr<TXML_element>> _docs_unico; // Tanti doc_unico, figli di _esa_import
|
|
|
|
vector<shared_ptr<TDDT_testata_xml>> _testate; // _testata contiene i dati di testata, piu' tutte gli ordini riga come figli
|
2020-03-05 10:44:33 +01:00
|
|
|
|
2020-03-05 13:01:01 +01:00
|
|
|
vector<shared_ptr<TDDT_riga_xml>> _rows;
|
2020-03-05 10:44:33 +01:00
|
|
|
public:
|
|
|
|
int add_doc();
|
|
|
|
/** Aggiungo la riga al documento n. \a which_riga, altrimenti se non specificato mette sull'ultimo doc presente.
|
|
|
|
* \returns indice documento in cui e' stata inserita la riga.
|
|
|
|
* \returns -1 se non e' mai stato inserito alcun documento o l'indice (\a which_doc) non e' corretto.
|
|
|
|
*/
|
2020-03-05 13:01:01 +01:00
|
|
|
int add_row(shared_ptr<TDDT_riga_xml> riga, int which_doc = -1);
|
|
|
|
bool print() override;
|
|
|
|
shared_ptr<TDDT_riga_xml> new_row() { _rows.insert(_rows.end(), make_shared<TDDT_riga_xml>()); return _rows.back(); }
|
2020-03-05 10:44:33 +01:00
|
|
|
|
|
|
|
/** Setto testata al documento n. \a which_riga, altrimenti se non specificato setta l'ultimo doc presente.
|
|
|
|
* \returns indice documento settato.
|
|
|
|
* \returns -1 se non e' mai stato inserito alcun documento o l'indice (\a which_doc) non e' corretto.
|
|
|
|
*/
|
|
|
|
int set_testata(const char* data_doc, const char* num_doc, int which_doc = -1);
|
|
|
|
|
|
|
|
TFlexform_xml_ddt(const char* xml_name = "") : TFlexform_xml(xml_name) { }
|
2020-03-05 13:01:01 +01:00
|
|
|
~TFlexform_xml_ddt() = default;
|
2020-03-05 10:44:33 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Esportatore XML Ordini Flexform.
|
|
|
|
*/
|
|
|
|
class TFlexform_xml_ordini final : public TFlexform_xml
|
|
|
|
{
|
|
|
|
TXML_element _ordine_impegno; // Unico ordine, figlio di _esa_import
|
|
|
|
TOrdini_testata_xml _testata; // _testata contiene i dati di testata, piu' tutte gli ordini riga come figli, figlio di _ordine_impegno
|
|
|
|
|
|
|
|
public:
|
|
|
|
void add_row(TOrdini_riga_xml* riga) { riga->set_parent(_testata); }
|
|
|
|
bool print() override;
|
|
|
|
void set_testata(const char* data_doc, const char* num_doc, const char* str) { _testata.set_testata(data_doc, num_doc, str); }
|
|
|
|
|
|
|
|
TFlexform_xml_ordini(const char* xml_name = "");
|
|
|
|
};
|
|
|
|
|
2020-03-05 13:01:01 +01:00
|
|
|
#endif // __MAJORXML_H__
|