Patch level : 12.0 582
Files correlati : bs Commento : Implementata importazione per data ultimo aggiornamento git-svn-id: svn://10.65.10.50/branches/R_10_00@24503 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
ab20751771
commit
d220ba055d
@ -1,3 +1,4 @@
|
||||
#include "bs0300b.h"
|
||||
#include <applicat.h>
|
||||
#include <automask.h>
|
||||
#include <config.h>
|
||||
@ -10,7 +11,7 @@
|
||||
|
||||
#include "../mg/mglib.h"
|
||||
#include "../cg/cglib01.h"
|
||||
#include "../cg/cg2101.h"
|
||||
|
||||
#include "../ve/velib.h"
|
||||
#include <doc.h>
|
||||
#include <rdoc.h>
|
||||
@ -18,10 +19,7 @@
|
||||
#include "bs0.h"
|
||||
|
||||
#include "../fe/felib.h"
|
||||
#include "../ve/condv.h"
|
||||
#include "../ve/rcondv.h"
|
||||
|
||||
#include <comuni.h>
|
||||
#include <clifo.h>
|
||||
#include <cfven.h>
|
||||
#include <rcausali.h>
|
||||
@ -88,70 +86,27 @@ const TString clifo_add_note(TLocalisamfile& cfv, TString& note)
|
||||
return codnote;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TSknet_cache
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TSknet_cache : TCache
|
||||
TObject* TSknet_cache::key2obj(const char* key)
|
||||
{
|
||||
protected:
|
||||
virtual TObject* key2obj(const char* key)
|
||||
{
|
||||
const char tipo = *key;
|
||||
const long codice = atol(key + 1);
|
||||
return new TAnagrafica(LF_CLIFO, tipo, codice);
|
||||
}
|
||||
|
||||
public:
|
||||
const TAnagrafica& anag(char tipo, long codice)
|
||||
{
|
||||
CHECKD((tipo == 'C' || tipo == 'F') && codice > 0L, "Codice cli/for non valido", codice);
|
||||
TString8 key; key.format("%c%06ld", tipo, codice);
|
||||
const TAnagrafica* a = (const TAnagrafica*)objptr(key);
|
||||
return *a;
|
||||
}
|
||||
const TAnagrafica& anag(const TRectype& rec)
|
||||
{
|
||||
const char tipo = rec.get_char(CLI_TIPOCF);
|
||||
const long codice = rec.get_long(CLI_CODCF);
|
||||
return anag(tipo, codice);
|
||||
}
|
||||
const TAnagrafica& anag(const TISAM_recordset& rec)
|
||||
{
|
||||
return anag(rec.cursor()->curr());
|
||||
}
|
||||
};
|
||||
|
||||
static TSknet_cache _anagr;
|
||||
const char tipo = *key;
|
||||
const long codice = atol(key + 1);
|
||||
return new TAnagrafica(LF_CLIFO, tipo, codice);
|
||||
}
|
||||
|
||||
const TAnagrafica& TSknet_cache::anag(char tipo, long codice)
|
||||
{
|
||||
CHECKD((tipo == 'C' || tipo == 'F') && codice > 0L, "Codice cli/for non valido", codice);
|
||||
TString8 key;
|
||||
key.format("%c%06ld", tipo, codice);
|
||||
const TAnagrafica* a = (const TAnagrafica*)objptr(key);
|
||||
return *a;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TSknet_mask
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TSknet_mask : public TAutomask
|
||||
{
|
||||
protected:
|
||||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||
|
||||
public:
|
||||
void autoload();
|
||||
void autosave() const;
|
||||
|
||||
bool get_bool(const char* fld)
|
||||
{
|
||||
TMask_field* f = find_by_fieldname(fld); return f ? f->get().full() : false;
|
||||
}
|
||||
|
||||
TDate get_date(const char* fld)
|
||||
{
|
||||
TMask_field* f = find_by_fieldname(fld); return TDate(f ? f->get() : EMPTY_STRING);
|
||||
}
|
||||
|
||||
TSknet_mask() : TAutomask("bs0300a") { autoload(); }
|
||||
~TSknet_mask() { autosave(); }
|
||||
};
|
||||
|
||||
bool TSknet_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||
{
|
||||
if (e == fe_modify && !o.empty())
|
||||
@ -183,6 +138,8 @@ bool TSknet_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (e == fe_button && o.dlg() == DLG_EDIT)
|
||||
bss().clean();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -214,46 +171,6 @@ void TSknet_mask::autosave() const
|
||||
|
||||
typedef bool TFieldEvaluator(const TISAM_recordset& rec, const char* fldname, const char* expr, TVariant& var);
|
||||
|
||||
class TSknet_sync : public TSkeleton_application
|
||||
{
|
||||
TString _dsn;
|
||||
TString _usr;
|
||||
TString _psw;
|
||||
TFilename _sqlog;
|
||||
TLog_report* _log;
|
||||
bool hasConai;
|
||||
|
||||
private:
|
||||
const TString& comune(const TRecordset& recset, const char* fld_cap, const char* fld_den) const;
|
||||
bool split_phone(const TRecordset& odbc, const char* number, TIsamfile& clifo, const char* pre, const char* num) const;
|
||||
void load_clifo(const char tipocf);
|
||||
void add_rmov(TMovimentoPN& mov, const real& importo, const TCausale& caus, const char* cod) const;
|
||||
|
||||
protected:
|
||||
bool save_and_delete_movmag(TMov_mag*& doc) const;
|
||||
bool save_and_delete_doc(TDocumento*& doc) const;
|
||||
|
||||
void load_their_origine(TISAM_recordset& out_set, const char* in_table, const TString_array& pairs);
|
||||
|
||||
void sync_table(TISAM_recordset& in_set, const char* out_table,
|
||||
const TString_array& pairs);
|
||||
void sync_table(const char* in_table, const char* out_table,
|
||||
const TString_array& fields);
|
||||
void sync_table(const int logicnum, const char* out_table,
|
||||
const TString_array& fields);
|
||||
|
||||
void sync_iva();
|
||||
void sync_ums();
|
||||
void sync_val();
|
||||
void sync_anamag();
|
||||
void sync_doc();
|
||||
void sync_clifo(int cfmask);
|
||||
void clean();
|
||||
|
||||
public:
|
||||
virtual bool create();
|
||||
virtual void main_loop();
|
||||
};
|
||||
|
||||
// Carica da BeeStore i record con Origine=their_origin(), cioè generati da lui ed eventualmente aggiorna i corrispondenti in Campo
|
||||
void TSknet_sync::load_their_origine(TISAM_recordset& out_set, const char* in_table, const TString_array& pairs)
|
||||
@ -263,7 +180,7 @@ void TSknet_sync::load_their_origine(TISAM_recordset& out_set, const char* in_ta
|
||||
FOR_EACH_ARRAY_ROW(pairs, f, row)
|
||||
str << row->get(0) << ',';
|
||||
str.rtrim(1); // toglie ultima virgola
|
||||
str << "\nFROM " << in_table << " WHERE (Origine=" << their_origin() << ");";
|
||||
str << "\nFROM " << in_table << " WHERE (Origine=" << their_origin() << ") AND " << where_time_import() << ";";
|
||||
|
||||
TODBC_recordset odbc(str);
|
||||
odbc.connect(_dsn, _usr, _psw);
|
||||
@ -497,7 +414,7 @@ void TSknet_sync::sync_anamag()
|
||||
|
||||
// Sincronizzo le unità di misura
|
||||
{
|
||||
query.cut(0) << "SELECT * from tieArticoli where Origine=" << their_origin();
|
||||
query.cut(0) << "SELECT * from tieArticoli where Origine=" << their_origin() << " AND " << where_time_import() << ";";
|
||||
TODBC_recordset odbcunit(query);
|
||||
odbcunit.connect(_dsn, _usr, _psw);
|
||||
TProgress_monitor p(odbcunit.items(), "Aggiornamento unità di misura");
|
||||
@ -526,7 +443,7 @@ void TSknet_sync::sync_anamag()
|
||||
|
||||
{
|
||||
// Controllo se esistono varianti e le aggiungo
|
||||
query.cut(0) << "SELECT * FROM tieArtVarianti where origine=" << their_origin();
|
||||
query.cut(0) << "SELECT * FROM tieArtVarianti where origine=" << their_origin() << " AND " << where_time_import() << ";";
|
||||
TODBC_recordset odbc(query);
|
||||
odbc.connect(_dsn, _usr, _psw);
|
||||
|
||||
@ -589,12 +506,12 @@ void TSknet_sync::sync_anamag()
|
||||
}
|
||||
|
||||
// Conai
|
||||
if (hasConai)
|
||||
if (_hasConai)
|
||||
{
|
||||
// Apro anamag per aggiungere le informazioni sugli articoli
|
||||
TLocalisamfile art(LF_ANAMAG);
|
||||
TRectype rart(LF_ANAMAG);
|
||||
query.cut(0) << "SELECT * FROM tieArtCONAI where origine=" << their_origin();
|
||||
query.cut(0) << "SELECT * FROM tieArtCONAI where origine=" << their_origin() << " AND " << where_time_import() << ";";
|
||||
TODBC_recordset odbc(query);
|
||||
odbc.connect(_dsn, _usr, _psw);
|
||||
TProgress_monitor p(odbc.items(), "Aggiornamento CONAI");
|
||||
@ -805,8 +722,8 @@ bool TSknet_sync::split_phone(const TRecordset& odbc, const char* number, TIsamf
|
||||
void TSknet_sync::load_clifo(const char tipocf)
|
||||
{
|
||||
TString str(255);
|
||||
str << "SELECT * FROM tieAnagCFP WHERE (Origine=" << their_origin() << ")AND";
|
||||
str << '(' << (tipocf == 'F' ? "Fornitore" : "Cliente") << "=1);";
|
||||
str << "SELECT * FROM tieAnagCFP WHERE [Origine]=" << their_origin() << " AND";
|
||||
str << '[' << (tipocf == 'F' ? "Fornitore" : "Cliente") << "]=1 AND " << where_time_import() << ";";
|
||||
|
||||
TFast_isamfile clifo(LF_CLIFO);
|
||||
|
||||
@ -947,7 +864,7 @@ void TSknet_sync::load_clifo(const char tipocf)
|
||||
clifo.put(CLI_MAIL, odbc.get("EMail").as_string());
|
||||
clifo.put(CLI_CODPAG, odbc.get("Cli_CodPagamento").as_string());
|
||||
|
||||
if (hasConai)
|
||||
if (_hasConai)
|
||||
{
|
||||
cfv.put(CFV_DATAECONAI, odbc.get("CNDataEs").as_date());
|
||||
cfv.put(CFV_ESACC, odbc.get("CNEsac").as_string()); // Esenzione Acciaio
|
||||
@ -977,6 +894,15 @@ void TSknet_sync::load_clifo(const char tipocf)
|
||||
cfb.put("CODCF", codcf);
|
||||
cfb.put("TIPOBAN", "V");
|
||||
cfb.put("NRIGA", 1);
|
||||
if (cfb.read(_isequal) != NOERR)
|
||||
{
|
||||
cfb.zero();
|
||||
cfb.put("TIPOCF", tipocf);
|
||||
cfb.put("CODCF", codcf);
|
||||
cfb.put("TIPOBAN", "V");
|
||||
cfb.put("NRIGA", 1);
|
||||
}
|
||||
|
||||
TString cin, abi, cab, contcor, iban;
|
||||
if (tipocf == 'C')
|
||||
{
|
||||
@ -990,52 +916,56 @@ void TSknet_sync::load_clifo(const char tipocf)
|
||||
cab = odbc.get("For_Cab").as_string();
|
||||
contcor = odbc.get("For_ContoCorr").as_string();
|
||||
}
|
||||
int err = 1;
|
||||
// Calcolo il CIN
|
||||
TString msg, bban;
|
||||
bban << "#" << abi << cab << contcor;
|
||||
for (char cin = 'A'; cin <= 'Z' && err == 1; cin++)
|
||||
if (!abi.blank() && !cab.blank() && !contcor.blank())
|
||||
{
|
||||
bban[0] = cin;
|
||||
err = bban_check(bban, msg);
|
||||
if (err == 0)
|
||||
int err = 1;
|
||||
// Calcolo il CIN
|
||||
TString msg, bban;
|
||||
bban << "#" << abi << cab << contcor;
|
||||
for (char cin = 'A'; cin <= 'Z' && err == 1; cin++)
|
||||
{
|
||||
cin = bban[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Calcolo l'IBAN
|
||||
if (err == NOERR)
|
||||
{
|
||||
err = 1;
|
||||
iban.cut(0) << statoISO << "##" << bban;
|
||||
for (int pp = 0; pp <= 99 && err == 1; pp++)
|
||||
{
|
||||
msg.format("%02d", pp);
|
||||
iban.overwrite(msg, 2);
|
||||
err = iban_check(iban, msg);
|
||||
bban[0] = cin;
|
||||
err = bban_check(bban, msg);
|
||||
if (err == 0)
|
||||
{
|
||||
cin = bban[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Calcolo l'IBAN
|
||||
if (err == NOERR)
|
||||
{
|
||||
err = 1;
|
||||
iban.cut(0) << statoISO << "##" << bban;
|
||||
for (int pp = 0; pp <= 99 && err == 1; pp++)
|
||||
{
|
||||
msg.format("%02d", pp);
|
||||
iban.overwrite(msg, 2);
|
||||
err = iban_check(iban, msg);
|
||||
if (err == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Abi e Cab sempre, posso anche avere solo il primo dei due
|
||||
cfb.put("ABI", abi);
|
||||
cfb.put("CAB", cab);
|
||||
// Il conto corrente ovviamente solo se è giusto
|
||||
if (err == NOERR)
|
||||
{
|
||||
cfb.put("NUMCC", contcor);
|
||||
cfb.put("IBAN", iban);
|
||||
// Abi e Cab sempre, posso anche avere solo il primo dei due
|
||||
cfb.put("ABI", abi);
|
||||
cfb.put("CAB", cab);
|
||||
// Il conto corrente ovviamente solo se è giusto
|
||||
if (err == NOERR)
|
||||
{
|
||||
cfb.put("NUMCC", contcor);
|
||||
cfb.put("IBAN", iban);
|
||||
}
|
||||
else if (!odbc.get("Cli_ContoCorr").as_string().blank())
|
||||
{
|
||||
TString msg; msg << "L'IBAN del contatto " << tipocf << " " << codcf << "non è corretto, non ho sovrascritto nulla";
|
||||
_log->log(1, msg);
|
||||
}
|
||||
else
|
||||
cfb.write_rewrite();
|
||||
}
|
||||
else if(!odbc.get("Cli_ContoCorr").as_string().blank())
|
||||
{
|
||||
TString msg; msg << "L'IBAN del contatto " << tipocf << " " << codcf << "non è corretto, è stato omesso";
|
||||
_log->log(1, msg);
|
||||
}
|
||||
|
||||
// Always true
|
||||
cfv.put(CFV_RAGGEFF, true);
|
||||
cfv.put(CFV_ADDBOLLI, tipocf == 'C');
|
||||
@ -1145,7 +1075,7 @@ void TSknet_sync::load_clifo(const char tipocf)
|
||||
if (!dua.ok()) dua = TDate(TODAY);
|
||||
clifo.put(CLI_DATAAGG, dua);
|
||||
|
||||
cfb.write_rewrite();
|
||||
|
||||
cfv.write_rewrite();
|
||||
clifo.write_rewrite();
|
||||
|
||||
@ -1164,45 +1094,81 @@ void TSknet_sync::clean()
|
||||
{
|
||||
if (yesno_box("Vuoi svuotare il database?") == 1)
|
||||
{
|
||||
// Mi ricarico il tempo
|
||||
set_time();
|
||||
|
||||
TString str;
|
||||
TODBC_recordset voldemort(str);
|
||||
voldemort.connect(_dsn, _usr, _psw);
|
||||
// Clienti
|
||||
if (ini_get_bool(CONFIG_DITTA, "BS", "SKSyncClienti"))
|
||||
str << "DELETE FROM tieAnagCFP WHERE Origine=" << their_origin() << " AND Cliente=1;\n";
|
||||
str << "DELETE FROM tieAnagCFP WHERE Origine=" << their_origin() << " AND Cliente=1 AND " << where_time_delete() << ";\n";
|
||||
// Fornitori
|
||||
if (ini_get_bool(CONFIG_DITTA, "BS", "SKSyncFornitori"))
|
||||
str << "DELETE FROM tieAnagCFP WHERE Origine=" << their_origin() << " AND Fornitore=1;\n";
|
||||
str << "DELETE FROM tieAnagCFP WHERE Origine=" << their_origin() << " AND Fornitore=1 AND " << where_time_delete() << ";\n";
|
||||
|
||||
// Documenti
|
||||
if (ini_get_bool(CONFIG_DITTA, "BS", "SKSyncDoc"))
|
||||
{
|
||||
str << "DELETE FROM tieTBolFat WHERE Origine=" << their_origin() << ";\n";
|
||||
str << "DELETE FROM tieDMovMag WHERE Origine=" << their_origin() << ";\n";
|
||||
str << "DELETE FROM tieDMovMagCONAI WHERE Origine=" << their_origin() << ";\n";
|
||||
str << "DELETE FROM tieTBolFat WHERE Origine=" << their_origin() << " AND " << where_time_delete() << ";\n";
|
||||
str << "DELETE FROM tieDMovMag WHERE Origine=" << their_origin() << " AND " << where_time_delete() << ";\n";
|
||||
str << "DELETE FROM tieDMovMagCONAI WHERE Origine=" << their_origin() << " AND " << where_time_delete() << ";\n";
|
||||
}
|
||||
// Articoli di Magazzino
|
||||
if (ini_get_bool(CONFIG_DITTA, "BS", "SKSyncAnamag"))
|
||||
{
|
||||
str << "DELETE FROM tieArticoli WHERE Origine=" << their_origin() << ";\n";
|
||||
str << "DELETE FROM tieArtVarianti WHERE Origine=" << their_origin() << ";\n";
|
||||
str << "DELETE FROM tieArtCONAI WHERE Origine=" << their_origin() << ";\n";
|
||||
str << "DELETE FROM tieArticoli WHERE Origine=" << their_origin() << " AND " << where_time_delete() << ";\n";
|
||||
str << "DELETE FROM tieArtVarianti WHERE Origine=" << their_origin() << " AND " << where_time_delete() << ";\n";
|
||||
str << "DELETE FROM tieArtCONAI WHERE Origine=" << their_origin() << " AND " << where_time_delete() << ";\n";
|
||||
}
|
||||
// Valute
|
||||
if (ini_get_bool(CONFIG_DITTA, "BS", "SKSyncVAL"))
|
||||
str << "DELETE FROM tieValute WHERE Origine=" << their_origin() << ";\n";
|
||||
str << "DELETE FROM tieValute WHERE Origine=" << their_origin() << " AND " << where_time_delete() << ";\n";
|
||||
// Codici IVA
|
||||
if (ini_get_bool(CONFIG_DITTA, "BS", "SKSyncIVA"))
|
||||
str << "DELETE FROM tieIVA WHERE Origine=" << their_origin() << ";\n";
|
||||
str << "DELETE FROM tieIVA WHERE Origine=" << their_origin() << " AND " << where_time_delete() << ";\n";
|
||||
// UMS
|
||||
if (ini_get_bool(CONFIG_DITTA, "BS", "SKSyncUMS"))
|
||||
str << "DELETE FROM tieUntMisura WHERE Origine=" << their_origin() << ";\n";
|
||||
str << "DELETE FROM tieUntMisura WHERE Origine=" << their_origin() << " AND " << where_time_delete() << ";\n";
|
||||
|
||||
voldemort.exec(str); // Elimina tutte le anagrafiche importate da BeeStore
|
||||
voldemort.commit();
|
||||
}
|
||||
}
|
||||
|
||||
void TSknet_sync::set_time()
|
||||
{
|
||||
// Prelevo il tempo dell'ultima importazione
|
||||
sprintf_s(_lastUpdate, sizeof(_lastUpdate), ini_get_string(CONFIG_DITTA, "BS", "LAST_IMPORT", "1990-01-01 00:00:00.000"));
|
||||
|
||||
// Preparo il tempo attuale
|
||||
time_t rt = time(NULL);
|
||||
struct tm * now = localtime(&rt);
|
||||
|
||||
sprintf_s(_thisUpdate, sizeof(_thisUpdate),
|
||||
"%d-%02d-%02d %02d:%02d:%02d.999",
|
||||
now->tm_year + 1900,
|
||||
now->tm_mon + 1,
|
||||
now->tm_mday,
|
||||
now->tm_hour,
|
||||
now->tm_min,
|
||||
now->tm_sec);
|
||||
}
|
||||
|
||||
const TString TSknet_sync::where_time_import()
|
||||
{
|
||||
TString time_import;
|
||||
time_import << "[DTUltAgg] > '" << _lastUpdate << "'";
|
||||
return time_import;
|
||||
}
|
||||
|
||||
const TString TSknet_sync::where_time_delete()
|
||||
{
|
||||
TString time_delete;
|
||||
time_delete << "[DTUltAgg] <= '" << _lastUpdate << "'";
|
||||
return time_delete;
|
||||
}
|
||||
|
||||
bool TSknet_sync::save_and_delete_movmag(TMov_mag*& doc) const
|
||||
{
|
||||
int err = 0;
|
||||
@ -1277,9 +1243,9 @@ void TSknet_sync::sync_doc()
|
||||
TString str(255);
|
||||
str << "SELECT tieDMovMag.*, tieTBolFat.*, tieTBolFat.Annullato AS DOCANNULLATO, tieDMovMagCONAI.*\n";
|
||||
str << "FROM tieDMovMag\nRIGHT JOIN tieTBolFat ON tieDMovMag.CodTestata = tieTBolFat.Cod_PK\n";
|
||||
if (hasConai)
|
||||
if (_hasConai)
|
||||
str << "LEFT JOIN tieDMovMagCONAI ON tieDMovMag.Cod_PK = tieDMovMagCONAI.Cod_PK\n";
|
||||
str << "WHERE tieTBolFat.Origine = " << their_origin();
|
||||
str << "WHERE tieTBolFat.Origine = " << their_origin() << " AND tieTBolFat." << where_time_import();
|
||||
//str << "WHERE tieDMovMag.Origine = " << their_origin() << " AND tieDMovMag.TipoTestata = 2"; // verificare
|
||||
str << "\nORDER BY tieTBolFat.Cod_PK,tieDMovMag.NumRiga";
|
||||
|
||||
@ -1548,7 +1514,7 @@ void TSknet_sync::sync_doc()
|
||||
|
||||
// "CONSCACC", "CONSCALL", "CONSCCAR", "CONSCPLA", "CONSCLEG", "CONSCVET"
|
||||
TString keyCli; keyCli << tipocf << "|" << codcf;
|
||||
if (hasConai && cache().get(LF_CFVEN, keyCli, "ADDCONAI") == "X")
|
||||
if (_hasConai && cache().get(LF_CFVEN, keyCli, "ADDCONAI") == "X")
|
||||
{
|
||||
// In base al conai che ha abilitato controllo
|
||||
if (ini_get_bool(CONFIG_DITTA, "ve", "CONFACC")) // Acciaio
|
||||
@ -1595,7 +1561,7 @@ bool TSknet_sync::create()
|
||||
_sqlog = ini_get_string(CONFIG_DITTA, "BS", "Log", "");
|
||||
_usr = ini_get_string(CONFIG_DITTA, "BS", "USR", "BEESTORE");
|
||||
_psw = decode(ini_get_string(CONFIG_DITTA, "BS", "PSW", "BEESTORE"));
|
||||
hasConai = ini_get_bool(CONFIG_DITTA, "BS", "SKEnabCONAI", false);
|
||||
_hasConai = ini_get_bool(CONFIG_DITTA, "BS", "SKEnabCONAI", false);
|
||||
|
||||
if (_dsn.full())
|
||||
{
|
||||
@ -1625,6 +1591,9 @@ void TSknet_sync::main_loop()
|
||||
{
|
||||
mask.autosave(); // Rende definitivi tutti i paramentri in [bs]
|
||||
_log = new TLog_report;
|
||||
|
||||
// Prendo la data attuale
|
||||
set_time();
|
||||
|
||||
if (mask.get_bool("SKSyncUMS"))
|
||||
sync_ums();
|
||||
@ -1650,16 +1619,23 @@ void TSknet_sync::main_loop()
|
||||
delete _log;
|
||||
_log = NULL;
|
||||
|
||||
// Aggiorno l'ultimo uppidate
|
||||
ini_set_string(CONFIG_DITTA, "BS", "LAST_IMPORT", _thisUpdate);
|
||||
|
||||
if (mask.get_bool("SKEmptyOnImp"))
|
||||
clean();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TSknet_sync& bss()
|
||||
{
|
||||
static TSknet_sync* bss = new TSknet_sync();
|
||||
return *bss;
|
||||
}
|
||||
|
||||
int bs0300(int argc, char* argv[])
|
||||
{
|
||||
TSknet_sync bss;
|
||||
bss.run(argc, argv, TR("SKNT Importer"));
|
||||
bss().run(argc, argv, TR("SKNT Importer"));
|
||||
return 0;
|
||||
}
|
@ -1,55 +1,49 @@
|
||||
#include "bs0300a.h"
|
||||
|
||||
TOOLBAR "topbar" 0 0 0 2
|
||||
#include <elabar.h>
|
||||
BUTTON DLG_OK 2 2
|
||||
BEGIN
|
||||
PROMPT 1 1 "Elabora"
|
||||
PICTURE TOOL_ELABORA
|
||||
END
|
||||
|
||||
BUTTON DLG_EDIT 2 2
|
||||
BEGIN
|
||||
PROMPT 1 1 "Compatta DB"
|
||||
PICTURE TOOL_PACK
|
||||
END
|
||||
|
||||
#include <helpbar.h>
|
||||
ENDPAGE
|
||||
|
||||
PAGE "SKNT Importer" 0 2 0 0
|
||||
|
||||
GROUPBOX DLG_NULL 78 5
|
||||
GROUPBOX DLG_NULL 78 4
|
||||
BEGIN
|
||||
PROMPT 1 1 "@bArchivi"
|
||||
END
|
||||
|
||||
BOOLEAN F_UMS
|
||||
BEGIN
|
||||
PROMPT 2 2 "Unità di misura "
|
||||
FIELD SKSyncUMS
|
||||
END
|
||||
|
||||
BOOLEAN F_IVA
|
||||
BEGIN
|
||||
PROMPT 30 2 "Codici IVA "
|
||||
FIELD SKSyncIVA
|
||||
END
|
||||
|
||||
BOOLEAN F_VALUTE
|
||||
BEGIN
|
||||
PROMPT 60 2 "Valute"
|
||||
FIELD SKSyncVAL
|
||||
END
|
||||
|
||||
BOOLEAN F_CLIENTI
|
||||
BEGIN
|
||||
PROMPT 2 3 "Clienti"
|
||||
PROMPT 2 2 "Clienti"
|
||||
FIELD SKSyncClienti
|
||||
END
|
||||
|
||||
BOOLEAN F_FORNITORI
|
||||
BEGIN
|
||||
PROMPT 30 3 "Fornitori "
|
||||
PROMPT 30 2 "Fornitori "
|
||||
FIELD SKSyncFornitori
|
||||
END
|
||||
|
||||
BOOLEAN F_ART
|
||||
BEGIN
|
||||
PROMPT 2 4 "Articoli "
|
||||
PROMPT 2 3 "Articoli "
|
||||
FIELD SKSyncAnamag
|
||||
END
|
||||
|
||||
BOOLEAN F_DOCUMENTI
|
||||
BEGIN
|
||||
PROMPT 30 4 "Documenti "
|
||||
PROMPT 30 3 "Documenti "
|
||||
FIELD SKSyncDoc
|
||||
END
|
||||
|
||||
|
127
src/bs/bs0300b.h
Normal file
127
src/bs/bs0300b.h
Normal file
@ -0,0 +1,127 @@
|
||||
#include <applicat.h>
|
||||
#include <automask.h>
|
||||
#include <config.h>
|
||||
#include <ODBCrset.h>
|
||||
#include <reputils.h>
|
||||
#include "../mg/mglib.h"
|
||||
#include "../cg/cg2101.h"
|
||||
#include "../ve/velib.h"
|
||||
#include "../fe/felib.h"
|
||||
#include <clifo.h>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Utility
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
const TString my_origin();
|
||||
const TString their_origin();
|
||||
const TString clifo_add_note(TLocalisamfile& cfv, TString& note);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TSknet_cache
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TSknet_cache : TCache
|
||||
{
|
||||
protected:
|
||||
virtual TObject* key2obj(const char* key);
|
||||
|
||||
public:
|
||||
const TAnagrafica& anag(char tipo, long codice);
|
||||
|
||||
const TAnagrafica& anag(const TRectype& rec)
|
||||
{
|
||||
const char tipo = rec.get_char(CLI_TIPOCF);
|
||||
const long codice = rec.get_long(CLI_CODCF);
|
||||
return anag(tipo, codice);
|
||||
}
|
||||
const TAnagrafica& anag(const TISAM_recordset& rec)
|
||||
{
|
||||
return anag(rec.cursor()->curr());
|
||||
}
|
||||
};
|
||||
|
||||
static TSknet_cache _anagr;
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TSknet_mask
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TSknet_mask : public TAutomask
|
||||
{
|
||||
protected:
|
||||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||
|
||||
public:
|
||||
void autoload();
|
||||
void autosave() const;
|
||||
|
||||
bool get_bool(const char* fld)
|
||||
{
|
||||
TMask_field* f = find_by_fieldname(fld); return f ? f->get().full() : false;
|
||||
}
|
||||
|
||||
TDate get_date(const char* fld)
|
||||
{
|
||||
TMask_field* f = find_by_fieldname(fld); return TDate(f ? f->get() : EMPTY_STRING);
|
||||
}
|
||||
|
||||
TSknet_mask() : TAutomask("bs0300a") { autoload(); }
|
||||
~TSknet_mask() { autosave(); }
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TSknet_sync
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TSknet_sync : public TSkeleton_application
|
||||
{
|
||||
TString _dsn;
|
||||
TString _usr;
|
||||
TString _psw;
|
||||
TFilename _sqlog;
|
||||
TLog_report* _log;
|
||||
bool _hasConai;
|
||||
char _lastUpdate[50];
|
||||
char _thisUpdate[50];
|
||||
|
||||
private:
|
||||
const TString& comune(const TRecordset& recset, const char* fld_cap, const char* fld_den) const;
|
||||
bool split_phone(const TRecordset& odbc, const char* number, TIsamfile& clifo, const char* pre, const char* num) const;
|
||||
void load_clifo(const char tipocf);
|
||||
void add_rmov(TMovimentoPN& mov, const real& importo, const TCausale& caus, const char* cod) const;
|
||||
void set_time();
|
||||
const TString where_time_import();
|
||||
const TString where_time_delete();
|
||||
|
||||
protected:
|
||||
bool save_and_delete_movmag(TMov_mag*& doc) const;
|
||||
bool save_and_delete_doc(TDocumento*& doc) const;
|
||||
|
||||
void load_their_origine(TISAM_recordset& out_set, const char* in_table, const TString_array& pairs);
|
||||
|
||||
void sync_table(TISAM_recordset& in_set, const char* out_table,
|
||||
const TString_array& pairs);
|
||||
void sync_table(const char* in_table, const char* out_table,
|
||||
const TString_array& fields);
|
||||
void sync_table(const int logicnum, const char* out_table,
|
||||
const TString_array& fields);
|
||||
|
||||
void sync_iva();
|
||||
void sync_ums();
|
||||
void sync_val();
|
||||
void sync_anamag();
|
||||
void sync_doc();
|
||||
void sync_clifo(int cfmask);
|
||||
|
||||
public:
|
||||
virtual bool create();
|
||||
virtual void main_loop();
|
||||
void clean();
|
||||
};
|
||||
|
||||
TSknet_sync& bss();
|
Loading…
x
Reference in New Issue
Block a user