diff --git a/ps/pl0002100a.h b/ps/pl0002100a.h new file mode 100755 index 000000000..7ecbbd114 --- /dev/null +++ b/ps/pl0002100a.h @@ -0,0 +1,9 @@ +//campi maschera pl0002100a (Importatore LIF) +#define F_ANAGRAFICHE 101 +#define F_CONTRATTI 102 +#define F_ARTICOLI 103 + +#define F_DSN1 201 +#define F_DSN2 203 +#define F_USR 204 +#define F_PWD 205 \ No newline at end of file diff --git a/ps/pl0002lib.h b/ps/pl0002lib.h new file mode 100755 index 000000000..656dbf905 --- /dev/null +++ b/ps/pl0002lib.h @@ -0,0 +1,136 @@ +#ifndef __pl0002LIB_H +#define __pl0002LIB_H + +#ifndef __CONFIG_H +#include +#endif + +#ifndef __DICTION_H +#include +#endif + +#ifndef __ISAM_H +#include +#endif + +#ifndef __ODBCRECSET_H +#include +#endif + +#ifndef __PROGIND_H +class TProgind; +#endif + +#ifndef __MODAUT_H +#include +#endif + +#ifndef __REPUTILS_H +#include +#endif + +#ifndef __CLIFOR_H +#include "../ve/clifor.h" +#endif + +#include "../ve/velib.h" + +class TCache_th; + +class TLif_log : public TLog_report +{ +public: + TLif_log() : TLog_report("Conversione LIF") {} +}; + +class TLif_transfer : public TObject +{ + TString _query_header; + TLif_log* _log; + TConfig _config; + + TRecordset* _recset; + bool _write_enabled; + TODBC_recordset* _outset; + TCache_th* _tab; + +protected: + const TString& build_insert_query(const char* table, const char* f, const char* v) const; + + TRecordset& create_recordset(const char* query); + long odbc_exec(const char* command); + + const TString& decode_value(const char* tab, const TString& field_value); + const TString& decode_field(const char* tab, const char* recset_field); + + TLif_transfer(); + virtual bool trasferisci() pure; + void aggiorna_record(TRectype& rec, const TString_array& lista_campi); + void aggiorna_ini(TConfig& conf, const TString_array& lista_campi); + +public: + void init(const char* rh, const char* qh, TLif_log& log); + const TString& title() const; + TConfig& config() { return _config; } + const TString& query_header() const { return _query_header; } + + void log(const char* msg, int sev = 0) const; + bool log_error(const char* msg); + bool log_cancelled(); + const TRecordset& recordset() const; + TRecordset& recordset(); + + const TString& get_str(const char* campo) const; // Get string from current recordset + real get_real(const char* campo) const; // Get real from current recordset + const TString& get_real_str(const char* campo) const; // Get eventually empty string from numeric field + long get_long(const char* campo) const; + + bool write_enabled() const { return _write_enabled; } + + bool test_write(TBaseisamfile& file); + + virtual ~TLif_transfer(); +}; + +class TLif_iterator +{ + TLif_transfer* _ht; + TProgind* _pi; + TRecnotype _rec; + +public: + bool ok() const; + bool cancelled() const; + TLif_iterator& operator=(TRecnotype n); + TLif_iterator& operator++(); + operator int() const { return ok(); } + + TLif_iterator(TLif_transfer* ht); + ~TLif_iterator(); +}; + +/////////////////////////////////////////////////////////// +// Cache generica per il trasferimento +/////////////////////////////////////////////////////////// + +class TCache_th : public TCache +{ + TLif_transfer* _ht; + +protected: + void log(const char* msg, int sev) const { _ht->log(msg, sev); } + bool test_write(TBaseisamfile& file) const { return _ht->test_write(file); } + const TRecordset& recordset() const { return _ht->recordset(); } + TConfig& config() const { return _ht->config(); } + const TString& query_header() const { return _ht->query_header(); } + +public: + const TString& get_str(const char* campo) const { return _ht->get_str(campo); } + const TString& get_real_str(const char* campo) const { return _ht->get_real_str(campo); } + long get_long(const char* campo) const { return _ht->get_long(campo); } + virtual const TString& decode(const TToken_string& tokens) pure; + + TCache_th(TLif_transfer* ht) : _ht(ht) {} +}; + +#endif \ No newline at end of file