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:
mtollari 2017-11-09 08:56:30 +00:00
parent b71d03efc0
commit 856419d4b5
4 changed files with 63 additions and 38 deletions

View File

@ -1,8 +1,10 @@
#include <confapp.h>
#include <automask.h>
#include <sheet.h>
#include <utility.h>
#include "bs0.h"
#include "bs0100a.h"
class TParametri_mask : public TAutomask
{
@ -10,9 +12,16 @@ protected:
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
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)
{
@ -37,27 +46,24 @@ bool TParametri_mask::on_field_event(TOperable_field& o, TField_event e, long jo
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:
virtual bool check_autorization() const { return false; }
virtual const char* get_mask_name() const { return "bs0100a"; }
TParametri_ditta() : TConfig_application(CONFIG_DITTA), _pm(NULL) {}
virtual void main_loop();
};
TMask* TParametri_ditta::create_mask(const TFilename& fname)
void TParametri_ditta::main_loop()
{
if (_pm == NULL)
_pm = new TParametri_mask(fname);
return _pm;
TParametri_mask pm("bs0100a");
while(pm.run() == K_ENTER)
{
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[])

View File

@ -1,2 +1,4 @@
#define F_DATASOURCE 101
#define F_LOG 102
#define F_DATASOURCE 101
#define F_USER 102
#define F_PASSWORD 103
#define F_LOG 104

View File

@ -6,7 +6,7 @@ ENDPAGE
PAGE "Parametri Bee Store" 0 2 0 0
GROUPBOX DLG_NULL 78 4
GROUPBOX DLG_NULL 78 6
BEGIN
PROMPT 1 1 "@bODBC"
END
@ -19,9 +19,23 @@ BEGIN
FIELD DSN
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
BEGIN
PROMPT 2 3 "File di log errori SQL "
PROMPT 2 5 "File di log errori SQL "
FIELD Log
END

View File

@ -149,6 +149,8 @@ typedef bool TFieldEvaluator(const TISAM_recordset& rec, const char* fldname, co
class TBeeStore_sync : public TSkeleton_application
{
TString16 _dsn;
TString _usr;
TString _psw;
TFilename _sqlog;
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)
{
TString str(255);
str << "ODBC(" << _dsn << ")\nSELECT ";
str << "SELECT ";
FOR_EACH_ARRAY_ROW(pairs, f, row)
str << row->get(0) << ',';
str.rtrim(1); // toglie ultima virgola
str << "\nFROM " << in_table << " WHERE (Origine=1);";
TODBC_recordset odbc(str);
odbc.connect(_dsn, _usr, _psw);
const TRecnotype n = odbc.items();
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();
TString str(255);
str << "ODBC(" << _dsn << ")\n";
TODBC_recordset odbc(str);
odbc.connect(_dsn, _usr, _psw);
str.cut(0) << "DELETE FROM " << out_table << " WHERE Origine=2;";
odbc.exec(str);
@ -651,13 +653,14 @@ void TBeeStore_sync::sync_barcode(const TDate& dal, const TDate& al)
fields.add("BarCode|"ANAMAG_DESCR);
TString str(255);
str << "ODBC(" << _dsn << ")\nSELECT ";
str << "SELECT ";
FOR_EACH_ARRAY_ROW(fields, f, row)
str << row->get(0) << ',';
str.rtrim(1); // toglie ultima virgola
str << "\nFROM tieArtBarCode WHERE (Origine=1);";
TODBC_recordset odbc(str);
odbc.connect(_dsn, _usr, _psw);
const TRecnotype n = odbc.items();
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)
{
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);";
TFast_isamfile clifo(LF_CLIFO);
TODBC_recordset odbc(str);
odbc.connect(_dsn, _usr, _psw);
const TRecnotype n = odbc.items();
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');
TString str(255);
str << "ODBC(" << _dsn << ")\n";
TODBC_recordset clifo(str);
clifo.connect(_dsn, _usr, _psw);
str << "DELETE FROM tieAnagCFP WHERE Origine=1;";
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)
{
TString str(255);
str << "ODBC(" << _dsn << ")\n";
TODBC_recordset prz(str);
prz.connect(_dsn, _usr, _psw);
str = "DELETE FROM tiePrzVendita WHERE Origine=1";
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);
str << "ODBC(" << _dsn << ")\n";
str << "SELECT * FROM tieDMovMag WHERE Origine=1 AND TipoTestata=" << tipotestata;
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";
TODBC_recordset mov(str);
mov.connect(_dsn, _usr, _psw);
TProgress_monitor pi(mov.items(), str);
TString num_mov, nm;
@ -1219,7 +1222,6 @@ void TBeeStore_sync::sync_doc(const TDate& dal, const TDate& al)
}
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
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";
TODBC_recordset docs(str);
docs.connect(_dsn, _usr, _psw);
TProgress_monitor pi(docs.items(), str);
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 tipodoc =docs.get("TipoDocCE").as_string();
numdoc = "B099";
tipodoc = "B01";
TTipo_documento tipo(tipodoc);
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);
str << "ODBC(" << _dsn << ")\n";
str << "SELECT * FROM tieCorrispettivi WHERE Origine=1";
str << "\nORDER BY DataCorr,CodCorrispettivo";
TODBC_recordset corr(str);
corr.connect(_dsn, _usr, _psw);
TProgress_monitor pi(corr.items(), str);
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();
mrec.put(MOV_TOTDOC, totdoc);
str.cut(0) << "ODBC(" << _dsn << ")\n";
str << "SELECT * FROM tieDCorrispettivi WHERE (Origine=1)";
str << "AND(CodCorrispettivo='" << corr.get("CodCorrispettivo") << "')";
TODBC_recordset dett(str);
dett.connect(_dsn, _usr, _psw);
TBill zio1; caus.bill(1, zio1);
TBill zio2; caus.bill(2, zio2);
@ -1486,8 +1486,8 @@ void TBeeStore_sync::sync_corrisp(const TDate&, const TDate&)
if (!pi.is_cancelled())
{
TString str(255);
str << "ODBC(" << _dsn << ")\n";
TODBC_recordset sco(str);
sco.connect(_dsn, _usr, _psw);
str = "DELETE FROM tieCorrispettivi WHERE Origine=1";
sco.exec(str);
@ -1501,12 +1501,15 @@ bool TBeeStore_sync::create()
{
_dsn = ini_get_string(CONFIG_DITTA, "bs", "DSN", "BEESTORE");
_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())
{
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);
recset.connect(_dsn, _usr, _psw); // Dovrebbe connettersi anche con solo _dsn valorizzato
recset.move_first();
if (_sqlog.full() && _sqlog.is_relative_path())
{