Patch level : 12.0 478
Files correlati : Commento : - Sistemata la connessione, prima accettava solo odbc con login di windows, ora anche user e psw - Tolte assegnazioni messe in test git-svn-id: svn://10.65.10.50/branches/R_10_00@24185 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
b71d03efc0
commit
856419d4b5
@ -1,8 +1,10 @@
|
|||||||
#include <confapp.h>
|
#include <confapp.h>
|
||||||
#include <automask.h>
|
#include <automask.h>
|
||||||
#include <sheet.h>
|
#include <sheet.h>
|
||||||
|
#include <utility.h>
|
||||||
|
|
||||||
#include "bs0.h"
|
#include "bs0.h"
|
||||||
|
#include "bs0100a.h"
|
||||||
|
|
||||||
class TParametri_mask : public TAutomask
|
class TParametri_mask : public TAutomask
|
||||||
{
|
{
|
||||||
@ -10,9 +12,16 @@ protected:
|
|||||||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TParametri_mask(const char* n) : TAutomask(n) {}
|
TParametri_mask(const char* n);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
TParametri_mask::TParametri_mask(const char * n) : TAutomask(n)
|
||||||
|
{
|
||||||
|
set(F_DATASOURCE, ini_get_string(CONFIG_DITTA, "BS", "DSN"));
|
||||||
|
set(F_USER, ini_get_string(CONFIG_DITTA, "BS", "USR"));
|
||||||
|
set(F_PASSWORD, decode(ini_get_string(CONFIG_DITTA, "BS", "PSW")));
|
||||||
|
set(F_LOG, ini_get_string(CONFIG_DITTA, "BS", "Log"));
|
||||||
|
}
|
||||||
|
|
||||||
bool TParametri_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
bool TParametri_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||||
{
|
{
|
||||||
@ -37,27 +46,24 @@ bool TParametri_mask::on_field_event(TOperable_field& o, TField_event e, long jo
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
class TParametri_ditta : public TConfig_application
|
class TParametri_ditta : public TSkeleton_application
|
||||||
{
|
{
|
||||||
TParametri_mask* _pm;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual TMask* create_mask(const TFilename& fname);
|
|
||||||
virtual TMask* get_mask() { return _pm; }
|
|
||||||
virtual void destroy_mask() { delete _pm; }
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual bool check_autorization() const { return false; }
|
virtual void main_loop();
|
||||||
virtual const char* get_mask_name() const { return "bs0100a"; }
|
|
||||||
|
|
||||||
TParametri_ditta() : TConfig_application(CONFIG_DITTA), _pm(NULL) {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TMask* TParametri_ditta::create_mask(const TFilename& fname)
|
void TParametri_ditta::main_loop()
|
||||||
{
|
{
|
||||||
if (_pm == NULL)
|
TParametri_mask pm("bs0100a");
|
||||||
_pm = new TParametri_mask(fname);
|
while(pm.run() == K_ENTER)
|
||||||
return _pm;
|
{
|
||||||
|
ini_set_string(CONFIG_DITTA, "BS", "DSN", pm.get(F_DATASOURCE));
|
||||||
|
ini_set_string(CONFIG_DITTA, "BS", "USR", pm.get(F_USER));
|
||||||
|
ini_set_string(CONFIG_DITTA, "BS", "PSW", encode(pm.get(F_PASSWORD)));
|
||||||
|
ini_set_string(CONFIG_DITTA, "BS", "Log", pm.get(F_LOG));
|
||||||
|
message_box("Dati salvati correttamente!");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int bs0100(int argc, char* argv[])
|
int bs0100(int argc, char* argv[])
|
||||||
|
@ -1,2 +1,4 @@
|
|||||||
#define F_DATASOURCE 101
|
#define F_DATASOURCE 101
|
||||||
#define F_LOG 102
|
#define F_USER 102
|
||||||
|
#define F_PASSWORD 103
|
||||||
|
#define F_LOG 104
|
||||||
|
@ -6,7 +6,7 @@ ENDPAGE
|
|||||||
|
|
||||||
PAGE "Parametri Bee Store" 0 2 0 0
|
PAGE "Parametri Bee Store" 0 2 0 0
|
||||||
|
|
||||||
GROUPBOX DLG_NULL 78 4
|
GROUPBOX DLG_NULL 78 6
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 1 1 "@bODBC"
|
PROMPT 1 1 "@bODBC"
|
||||||
END
|
END
|
||||||
@ -19,9 +19,23 @@ BEGIN
|
|||||||
FIELD DSN
|
FIELD DSN
|
||||||
END
|
END
|
||||||
|
|
||||||
|
STRING F_USER 20
|
||||||
|
BEGIN
|
||||||
|
PROMPT 2 3 "User "
|
||||||
|
FLAGS ""
|
||||||
|
FIELD USR
|
||||||
|
END
|
||||||
|
|
||||||
|
STRING F_PASSWORD 20
|
||||||
|
BEGIN
|
||||||
|
PROMPT 2 4 "Password "
|
||||||
|
FLAGS "*"
|
||||||
|
FIELD PSW
|
||||||
|
END
|
||||||
|
|
||||||
STRING F_LOG 260 50
|
STRING F_LOG 260 50
|
||||||
BEGIN
|
BEGIN
|
||||||
PROMPT 2 3 "File di log errori SQL "
|
PROMPT 2 5 "File di log errori SQL "
|
||||||
FIELD Log
|
FIELD Log
|
||||||
END
|
END
|
||||||
|
|
||||||
|
@ -149,6 +149,8 @@ typedef bool TFieldEvaluator(const TISAM_recordset& rec, const char* fldname, co
|
|||||||
class TBeeStore_sync : public TSkeleton_application
|
class TBeeStore_sync : public TSkeleton_application
|
||||||
{
|
{
|
||||||
TString16 _dsn;
|
TString16 _dsn;
|
||||||
|
TString _usr;
|
||||||
|
TString _psw;
|
||||||
TFilename _sqlog;
|
TFilename _sqlog;
|
||||||
TLog_report* _log;
|
TLog_report* _log;
|
||||||
|
|
||||||
@ -286,13 +288,14 @@ const TString& expr2sql(const TISAM_recordset& set, const char* expr)
|
|||||||
void TBeeStore_sync::load_origine_1(TISAM_recordset& out_set, const char* in_table, const TString_array& pairs)
|
void TBeeStore_sync::load_origine_1(TISAM_recordset& out_set, const char* in_table, const TString_array& pairs)
|
||||||
{
|
{
|
||||||
TString str(255);
|
TString str(255);
|
||||||
str << "ODBC(" << _dsn << ")\nSELECT ";
|
str << "SELECT ";
|
||||||
FOR_EACH_ARRAY_ROW(pairs, f, row)
|
FOR_EACH_ARRAY_ROW(pairs, f, row)
|
||||||
str << row->get(0) << ',';
|
str << row->get(0) << ',';
|
||||||
str.rtrim(1); // toglie ultima virgola
|
str.rtrim(1); // toglie ultima virgola
|
||||||
str << "\nFROM " << in_table << " WHERE (Origine=1);";
|
str << "\nFROM " << in_table << " WHERE (Origine=1);";
|
||||||
|
|
||||||
TODBC_recordset odbc(str);
|
TODBC_recordset odbc(str);
|
||||||
|
odbc.connect(_dsn, _usr, _psw);
|
||||||
const TRecnotype n = odbc.items();
|
const TRecnotype n = odbc.items();
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
{
|
{
|
||||||
@ -423,9 +426,8 @@ void TBeeStore_sync::save_origine_2(TISAM_recordset& in_set, const char* out_tab
|
|||||||
{
|
{
|
||||||
const TRecnotype n = in_set.items();
|
const TRecnotype n = in_set.items();
|
||||||
TString str(255);
|
TString str(255);
|
||||||
str << "ODBC(" << _dsn << ")\n";
|
|
||||||
TODBC_recordset odbc(str);
|
TODBC_recordset odbc(str);
|
||||||
|
odbc.connect(_dsn, _usr, _psw);
|
||||||
str.cut(0) << "DELETE FROM " << out_table << " WHERE Origine=2;";
|
str.cut(0) << "DELETE FROM " << out_table << " WHERE Origine=2;";
|
||||||
odbc.exec(str);
|
odbc.exec(str);
|
||||||
|
|
||||||
@ -651,13 +653,14 @@ void TBeeStore_sync::sync_barcode(const TDate& dal, const TDate& al)
|
|||||||
fields.add("BarCode|"ANAMAG_DESCR);
|
fields.add("BarCode|"ANAMAG_DESCR);
|
||||||
|
|
||||||
TString str(255);
|
TString str(255);
|
||||||
str << "ODBC(" << _dsn << ")\nSELECT ";
|
str << "SELECT ";
|
||||||
FOR_EACH_ARRAY_ROW(fields, f, row)
|
FOR_EACH_ARRAY_ROW(fields, f, row)
|
||||||
str << row->get(0) << ',';
|
str << row->get(0) << ',';
|
||||||
str.rtrim(1); // toglie ultima virgola
|
str.rtrim(1); // toglie ultima virgola
|
||||||
str << "\nFROM tieArtBarCode WHERE (Origine=1);";
|
str << "\nFROM tieArtBarCode WHERE (Origine=1);";
|
||||||
|
|
||||||
TODBC_recordset odbc(str);
|
TODBC_recordset odbc(str);
|
||||||
|
odbc.connect(_dsn, _usr, _psw);
|
||||||
const TRecnotype n = odbc.items();
|
const TRecnotype n = odbc.items();
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
{
|
{
|
||||||
@ -858,12 +861,13 @@ bool TBeeStore_sync::split_phone(const TRecordset& odbc, const char* number, TIs
|
|||||||
void TBeeStore_sync::load_clifo(char tipocf)
|
void TBeeStore_sync::load_clifo(char tipocf)
|
||||||
{
|
{
|
||||||
TString str(255);
|
TString str(255);
|
||||||
str << "ODBC(" << _dsn << ")\nSELECT * FROM tieAnagCFP WHERE (Origine=1)AND";
|
str << "SELECT * FROM tieAnagCFP WHERE (Origine=1)AND";
|
||||||
str << '(' << (tipocf == 'F' ? "Fornitore" : "Cliente") << "=1);";
|
str << '(' << (tipocf == 'F' ? "Fornitore" : "Cliente") << "=1);";
|
||||||
|
|
||||||
TFast_isamfile clifo(LF_CLIFO);
|
TFast_isamfile clifo(LF_CLIFO);
|
||||||
|
|
||||||
TODBC_recordset odbc(str);
|
TODBC_recordset odbc(str);
|
||||||
|
odbc.connect(_dsn, _usr, _psw);
|
||||||
const TRecnotype n = odbc.items();
|
const TRecnotype n = odbc.items();
|
||||||
|
|
||||||
str.cut(0) << TR("Importazione ") << (tipocf == 'F' ? TR("Fornitori") : TR("Clienti"));
|
str.cut(0) << TR("Importazione ") << (tipocf == 'F' ? TR("Fornitori") : TR("Clienti"));
|
||||||
@ -1012,8 +1016,8 @@ void TBeeStore_sync::sync_clifo(int cfmask, const TDate& dal, const TDate& al)
|
|||||||
if (cfmask & 2) load_clifo('F');
|
if (cfmask & 2) load_clifo('F');
|
||||||
|
|
||||||
TString str(255);
|
TString str(255);
|
||||||
str << "ODBC(" << _dsn << ")\n";
|
|
||||||
TODBC_recordset clifo(str);
|
TODBC_recordset clifo(str);
|
||||||
|
clifo.connect(_dsn, _usr, _psw);
|
||||||
str << "DELETE FROM tieAnagCFP WHERE Origine=1;";
|
str << "DELETE FROM tieAnagCFP WHERE Origine=1;";
|
||||||
clifo.exec(str); // Elimina tutte le anagrafiche importate da BeeStore
|
clifo.exec(str); // Elimina tutte le anagrafiche importate da BeeStore
|
||||||
|
|
||||||
@ -1084,9 +1088,8 @@ void TBeeStore_sync::sync_val(const TDate& dal, const TDate& al)
|
|||||||
void TBeeStore_sync::sync_listino(const TString& listino)
|
void TBeeStore_sync::sync_listino(const TString& listino)
|
||||||
{
|
{
|
||||||
TString str(255);
|
TString str(255);
|
||||||
str << "ODBC(" << _dsn << ")\n";
|
|
||||||
TODBC_recordset prz(str);
|
TODBC_recordset prz(str);
|
||||||
|
prz.connect(_dsn, _usr, _psw);
|
||||||
str = "DELETE FROM tiePrzVendita WHERE Origine=1";
|
str = "DELETE FROM tiePrzVendita WHERE Origine=1";
|
||||||
prz.exec(str); // Ignora tutti i listini di BeeStore
|
prz.exec(str); // Ignora tutti i listini di BeeStore
|
||||||
|
|
||||||
@ -1141,7 +1144,6 @@ void TBeeStore_sync::sync_mov(int tipotestata, const TDate& dal, const TDate& al
|
|||||||
}
|
}
|
||||||
|
|
||||||
TString str(255);
|
TString str(255);
|
||||||
str << "ODBC(" << _dsn << ")\n";
|
|
||||||
str << "SELECT * FROM tieDMovMag WHERE Origine=1 AND TipoTestata=" << tipotestata;
|
str << "SELECT * FROM tieDMovMag WHERE Origine=1 AND TipoTestata=" << tipotestata;
|
||||||
if (dal.ok() || al.ok())
|
if (dal.ok() || al.ok())
|
||||||
{
|
{
|
||||||
@ -1159,6 +1161,7 @@ void TBeeStore_sync::sync_mov(int tipotestata, const TDate& dal, const TDate& al
|
|||||||
str << "\nORDER BY NumMov,NumRiga";
|
str << "\nORDER BY NumMov,NumRiga";
|
||||||
|
|
||||||
TODBC_recordset mov(str);
|
TODBC_recordset mov(str);
|
||||||
|
mov.connect(_dsn, _usr, _psw);
|
||||||
TProgress_monitor pi(mov.items(), str);
|
TProgress_monitor pi(mov.items(), str);
|
||||||
|
|
||||||
TString num_mov, nm;
|
TString num_mov, nm;
|
||||||
@ -1219,7 +1222,6 @@ void TBeeStore_sync::sync_doc(const TDate& dal, const TDate& al)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TString str(255);
|
TString str(255);
|
||||||
str << "ODBC(" << _dsn << ")\n";
|
|
||||||
str << "SELECT tieDMovMag.*,tieTBolFat.* FROM tieDMovMag,tieTBolFat WHERE tieDMovMag.Origine=1 AND tieDMovMag.TipoTestata=2 AND tieDMovMag.CodTestata=tieTBolFat.Cod_PK"; // verificare
|
str << "SELECT tieDMovMag.*,tieTBolFat.* FROM tieDMovMag,tieTBolFat WHERE tieDMovMag.Origine=1 AND tieDMovMag.TipoTestata=2 AND tieDMovMag.CodTestata=tieTBolFat.Cod_PK"; // verificare
|
||||||
if (dal.ok() || al.ok())
|
if (dal.ok() || al.ok())
|
||||||
{
|
{
|
||||||
@ -1237,6 +1239,7 @@ void TBeeStore_sync::sync_doc(const TDate& dal, const TDate& al)
|
|||||||
str << "\nORDER BY NumMov,NumRiga";
|
str << "\nORDER BY NumMov,NumRiga";
|
||||||
|
|
||||||
TODBC_recordset docs(str);
|
TODBC_recordset docs(str);
|
||||||
|
docs.connect(_dsn, _usr, _psw);
|
||||||
TProgress_monitor pi(docs.items(), str);
|
TProgress_monitor pi(docs.items(), str);
|
||||||
|
|
||||||
long num_doc = -1, nd, codcf ;
|
long num_doc = -1, nd, codcf ;
|
||||||
@ -1267,9 +1270,6 @@ void TBeeStore_sync::sync_doc(const TDate& dal, const TDate& al)
|
|||||||
TString8 numdoc =docs.get("TipoDocCE").as_string();
|
TString8 numdoc =docs.get("TipoDocCE").as_string();
|
||||||
TString8 tipodoc =docs.get("TipoDocCE").as_string();
|
TString8 tipodoc =docs.get("TipoDocCE").as_string();
|
||||||
|
|
||||||
numdoc = "B099";
|
|
||||||
tipodoc = "B01";
|
|
||||||
|
|
||||||
TTipo_documento tipo(tipodoc);
|
TTipo_documento tipo(tipodoc);
|
||||||
const TString8 codcaus = tipo.caus_mov().blank() ? codcausdef : tipo.caus_mov();
|
const TString8 codcaus = tipo.caus_mov().blank() ? codcausdef : tipo.caus_mov();
|
||||||
|
|
||||||
@ -1369,11 +1369,11 @@ void TBeeStore_sync::sync_corrisp(const TDate&, const TDate&)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TString str(255);
|
TString str(255);
|
||||||
str << "ODBC(" << _dsn << ")\n";
|
|
||||||
str << "SELECT * FROM tieCorrispettivi WHERE Origine=1";
|
str << "SELECT * FROM tieCorrispettivi WHERE Origine=1";
|
||||||
str << "\nORDER BY DataCorr,CodCorrispettivo";
|
str << "\nORDER BY DataCorr,CodCorrispettivo";
|
||||||
|
|
||||||
TODBC_recordset corr(str);
|
TODBC_recordset corr(str);
|
||||||
|
corr.connect(_dsn, _usr, _psw);
|
||||||
TProgress_monitor pi(corr.items(), str);
|
TProgress_monitor pi(corr.items(), str);
|
||||||
|
|
||||||
TString num_mov, nm;
|
TString num_mov, nm;
|
||||||
@ -1408,10 +1408,10 @@ void TBeeStore_sync::sync_corrisp(const TDate&, const TDate&)
|
|||||||
const real totdoc = corr.get("Valore").as_real();
|
const real totdoc = corr.get("Valore").as_real();
|
||||||
mrec.put(MOV_TOTDOC, totdoc);
|
mrec.put(MOV_TOTDOC, totdoc);
|
||||||
|
|
||||||
str.cut(0) << "ODBC(" << _dsn << ")\n";
|
|
||||||
str << "SELECT * FROM tieDCorrispettivi WHERE (Origine=1)";
|
str << "SELECT * FROM tieDCorrispettivi WHERE (Origine=1)";
|
||||||
str << "AND(CodCorrispettivo='" << corr.get("CodCorrispettivo") << "')";
|
str << "AND(CodCorrispettivo='" << corr.get("CodCorrispettivo") << "')";
|
||||||
TODBC_recordset dett(str);
|
TODBC_recordset dett(str);
|
||||||
|
dett.connect(_dsn, _usr, _psw);
|
||||||
|
|
||||||
TBill zio1; caus.bill(1, zio1);
|
TBill zio1; caus.bill(1, zio1);
|
||||||
TBill zio2; caus.bill(2, zio2);
|
TBill zio2; caus.bill(2, zio2);
|
||||||
@ -1486,8 +1486,8 @@ void TBeeStore_sync::sync_corrisp(const TDate&, const TDate&)
|
|||||||
if (!pi.is_cancelled())
|
if (!pi.is_cancelled())
|
||||||
{
|
{
|
||||||
TString str(255);
|
TString str(255);
|
||||||
str << "ODBC(" << _dsn << ")\n";
|
|
||||||
TODBC_recordset sco(str);
|
TODBC_recordset sco(str);
|
||||||
|
sco.connect(_dsn, _usr, _psw);
|
||||||
str = "DELETE FROM tieCorrispettivi WHERE Origine=1";
|
str = "DELETE FROM tieCorrispettivi WHERE Origine=1";
|
||||||
sco.exec(str);
|
sco.exec(str);
|
||||||
|
|
||||||
@ -1501,12 +1501,15 @@ bool TBeeStore_sync::create()
|
|||||||
{
|
{
|
||||||
_dsn = ini_get_string(CONFIG_DITTA, "bs", "DSN", "BEESTORE");
|
_dsn = ini_get_string(CONFIG_DITTA, "bs", "DSN", "BEESTORE");
|
||||||
_sqlog = ini_get_string(CONFIG_DITTA, "bs", "Log", "");
|
_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"));
|
||||||
|
|
||||||
if (_dsn.full())
|
if (_dsn.full())
|
||||||
{
|
{
|
||||||
TProgress_monitor ti(1, TR("Connessione a SQL Server"), false);
|
TProgress_monitor ti(1, TR("Connessione a SQL Server"), false);
|
||||||
TString query; query << "ODBC(" << _dsn << ")\nSELECT * FROM tieValute;";
|
TString query; query << "SELECT * FROM tieValute;";//"ODBC(" << _dsn << ")\nSELECT * FROM tieValute;";
|
||||||
TODBC_recordset recset(query);
|
TODBC_recordset recset(query);
|
||||||
|
recset.connect(_dsn, _usr, _psw); // Dovrebbe connettersi anche con solo _dsn valorizzato
|
||||||
recset.move_first();
|
recset.move_first();
|
||||||
if (_sqlog.full() && _sqlog.is_relative_path())
|
if (_sqlog.full() && _sqlog.is_relative_path())
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user