Correzioni per nuova gestione automatica DNINST

git-svn-id: svn://10.65.10.50/branches/R_10_00@22757 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2012-11-30 14:35:55 +00:00
parent ce161a46a0
commit c3d093ba1f
8 changed files with 332 additions and 211 deletions

View File

@ -579,7 +579,7 @@ bool TInstaller_mask::autoload()
if (!pi.addstatus(1)) if (!pi.addstatus(1))
break; break;
TString& str = modules.row(i); TString& str = modules.row(i);
if (str.match("??????a.ini", true)) if (str.ends_with("a.ini", true))
{ {
const TString& module = str.left(2); const TString& module = str.left(2);
const int patch = atoi(str.mid(2, 4)); const int patch = atoi(str.mid(2, 4));

View File

@ -1,5 +1,4 @@
#include <applicat.h> #include <applicat.h>
#include <assoc.h>
#include <automask.h> #include <automask.h>
#include <colors.h> #include <colors.h>
#include <config.h> #include <config.h>
@ -7,6 +6,7 @@
#include <netsock.h> #include <netsock.h>
#include <odbcrset.h> #include <odbcrset.h>
#include <progind.h> #include <progind.h>
#include <reputils.h>
#include <utility.h> #include <utility.h>
#include <xml.h> #include <xml.h>
@ -56,15 +56,15 @@ int TOEM_cache::Agente2OEM(int agente) const
int oem = -1; int oem = -1;
switch (agente) switch (agente)
{ {
case 1: // Administrator case 2: oem = 0; break; // Aga
case 2: oem = 0; break; case 5: oem = 6; break; // Sipag -> Sicuri
case 3: oem = 1; break; case 7: oem = 7; break; // Prassi Roma -> Itertec
case 4: oem = 3; break; case 8: // Prassi Calabria
case 5: oem = 6; break; case 9: oem = 8; break; // Metacalabria
case 6: oem = 5; break; case 10: oem = 6; break; // Socogem -> Sicuri
case 7: oem = 7; break; case 11: oem = 7; break; // Itertec
case 8: oem = 8; break; case 13: oem = 2; break; // Tetractis
default: break; default: oem = 1; break; // Sirio
} }
return oem; return oem;
} }
@ -200,7 +200,7 @@ bool Tdnist_full::save(int version) const
static int _c_key, _c_oem, _c_owner, _c_suspend, _c_killed; static int _c_key, _c_oem, _c_owner, _c_suspend, _c_killed;
static int _c_dboem, _c_dbowner, _c_dbsuspend, _c_dbkilled; static int _c_dboem, _c_dbowner, _c_dbsuspend, _c_dbkilled;
static int _c_xmloem, _c_xmlowner, _c_xmlaccess; static int _c_xmloem, _c_xmlowner, _c_xmlyear, _c_xmlaccess;
class Tdninst_mask : public TAutomask class Tdninst_mask : public TAutomask
{ {
@ -399,16 +399,16 @@ bool Tdninst_mask::load_odbc(TString_array& a) const
{ {
TString query; TString query;
query << "ODBC(" << dsn << ")\n" query << "ODBC(" << dsn << ")\n"
<< "SELECT chiavette.codice AS Chiave, Agente, RagioneSociale, DataDisattivazione\n" << "SELECT chiavette.Codice, chiavette.Cliente, clienti.RagioneSociale, clienti.Agente, clienti.DataDisattivazione, clienti.Stato"
<< "FROM chiavette,clienti WHERE chiavette.cliente=clienti.codice\n" << "\nFROM chiavette JOIN clienti ON chiavette.cliente=clienti.codice"
<< "ORDER BY Chiave"; << "\nORDER BY Codice";
TODBC_recordset att(query); TODBC_recordset att(query);
TProgind pi(att.items(), dsn); TProgind pi(att.items(), dsn);
for (bool ok = att.move_first(); ok; ok = att.move_next()) for (bool ok = att.move_first(); ok; ok = att.move_next())
{ {
if (!pi.addstatus(1)) break; if (!pi.addstatus(1)) break;
const int key = att.get("Chiave").as_int(); const int key = att.get("Codice").as_int();
if (key > 0) if (key > 0)
{ {
@ -417,15 +417,26 @@ bool Tdninst_mask::load_odbc(TString_array& a) const
r.add(_oem.Agente2OEM(agente), _c_dboem); r.add(_oem.Agente2OEM(agente), _c_dboem);
r.add(smart_trim(att.get("RagioneSociale").as_string(), 50), _c_dbowner); r.add(smart_trim(att.get("RagioneSociale").as_string(), 50), _c_dbowner);
const TString& kill = att.get("DataDisattivazione").as_string(); const TString& stato = att.get("Stato").as_string();
if (kill.full() && kill.len() == 10) if (stato[0] > 'A') // Non Attivo
{ {
const TString& stato = att.get("Stato").as_string(); const TString& kill = att.get("DataDisattivazione").as_string();
switch (stato[0]) if (kill.full() && kill.len() == 10)
{ {
case 'D': r.add(kill, _c_dbkilled); break; // Disdetto TDate d;
case 'S': r.add(kill, _c_dbsuspend); break; // Sospeso if (kill[2] == '-')
default: break; d = TDate(kill); else
if (kill[4] == '-')
d = TDate(atoi(kill.mid(8,2)), atoi(kill.mid(5,2)), atoi(kill.left(4)));
if (d.year() >= 1990)
{
switch (stato[0])
{
case 'D': r.add(d.string(), _c_dbkilled); break; // Disdetto
case 'S': r.add(d.string(), _c_dbsuspend); break; // Sospeso
default: break; // Attivo
}
}
} }
} }
@ -460,6 +471,12 @@ static bool XmlScanner(TXmlItem& item, long jolly)
if (item.GetTag() == "dongle") if (item.GetTag() == "dongle")
{ {
row.add(item.GetAttr("OEM"), _c_xmloem); row.add(item.GetAttr("OEM"), _c_xmloem);
const int year_new = item.GetIntAttr("Year");
const int year_old = row.get_int(_c_xmlyear);
if (year_new > year_old)
row.add(year_new, _c_xmlyear);
} else } else
if (item.GetTag() == "module") if (item.GetTag() == "module")
{ {
@ -601,6 +618,28 @@ bool Tdninst_mask::fill_sheet()
s.set_back_and_fore_color(REQUIRED_BACK_COLOR, NORMAL_COLOR, r, _c_xmlowner); s.set_back_and_fore_color(REQUIRED_BACK_COLOR, NORMAL_COLOR, r, _c_xmlowner);
} }
} }
TDate ds = row->get(_c_suspend);
TDate dk = row->get(_c_killed);
if (ds > ds) ds = dk;
TDate dbs = row->get(_c_dbsuspend);
TDate dbk = row->get(_c_dbkilled);
if (dbk > dbs) dbs = dbk;
if (ds != dbs)
{
if (dbs.ok())
{
s.set_back_and_fore_color(FOCUS_BACK_COLOR, FOCUS_COLOR, r, _c_suspend);
s.set_back_and_fore_color(FOCUS_BACK_COLOR, FOCUS_COLOR, r, _c_killed);
}
else
{
s.set_back_and_fore_color(FOCUS_BACK_COLOR, FOCUS_COLOR, r, _c_dbsuspend);
s.set_back_and_fore_color(FOCUS_BACK_COLOR, FOCUS_COLOR, r, _c_dbkilled);
}
}
} }
s.force_update(); s.force_update();
@ -611,11 +650,15 @@ bool Tdninst_mask::fill_sheet()
void Tdninst_mask::merge_sheet() void Tdninst_mask::merge_sheet()
{ {
TLog_report log;
TString msg;
TSheet_field& sheet = sfield(F_DNSHEET); TSheet_field& sheet = sfield(F_DNSHEET);
TString16 killed; TString16 killed;
TString o1, o2, o3; TString o1, o2, o3;
TString c1, c2, c3; TString c1, c2, c3;
TString d1, d2;
int changed = 0; int changed = 0;
FOR_EACH_SHEET_ROW(sheet, r, row) FOR_EACH_SHEET_ROW(sheet, r, row)
@ -630,7 +673,7 @@ void Tdninst_mask::merge_sheet()
{ {
c1 = c2; c1 = c2;
o1 = row->get(_c_dboem); o1 = row->get(_c_dboem);
} else }
if (c3.full()) if (c3.full())
{ {
c1 = c3; c1 = c3;
@ -641,6 +684,10 @@ void Tdninst_mask::merge_sheet()
row->add(o1, _c_oem); row->add(o1, _c_oem);
row->add(c1, _c_owner); row->add(c1, _c_owner);
changed++; changed++;
msg = TR("Inserito cliente ");
msg << c1;
log.log(0, msg);
} }
} }
else else
@ -653,30 +700,53 @@ void Tdninst_mask::merge_sheet()
{ {
row->add(o2, _c_oem); row->add(o2, _c_oem);
changed++; changed++;
msg = TR("Aggiornato agente del cliente ");
msg << c1;
log.log(0, msg);
}
}
c2 = row->get(_c_dbowner);
if (c2.full() && c1 != c2)
{
row->add(c2, _c_owner);
changed++;
if (xvt_str_fuzzy_compare_ignoring_case(c1, c2) < 0.7)
{
msg = TR("Aggiornata ragione sociale da '");
msg << c1 << "' a '" << c2 << "'";
log.log(0, msg);
} }
} }
} }
o1 = row->get(_c_suspend); o1.trim(); d1 = row->get(_c_suspend); d1.trim();
c1 = row->get(_c_dbsuspend); c1.trim(); d2 = row->get(_c_dbsuspend); d2.trim();
if (o1 != c1) if (d2.full() && d1 != d2)
{ {
row->add(c1, _c_suspend); row->add(d2, _c_suspend);
changed++; changed++;
msg = TR("Sospensione del cliente ");
msg << c1 << TR(" dal ") << d2;
log.log(1, msg);
} }
o1 = row->get(_c_killed); o1.trim(); d1 = row->get(_c_killed); d1.trim();
c1 = row->get(_c_dbkilled); c1.trim(); d2 = row->get(_c_dbkilled); d2.trim();
if (o1 != c1) if (d2.full() && d1 != d2)
{ {
row->add(c1, _c_killed); row->add(d2, _c_killed);
changed++; changed++;
msg = TR("Disattivazione del cliente ");
msg << c1 << TR(" dal ") << d2;
log.log(2, msg);
} }
} }
sheet.force_update(); sheet.force_update();
TString msg; msg.format(FR("Sono stati aggiornati %d campi"), changed);
xvt_dm_popup_message(msg); log.preview();
} }
bool Tdninst_mask::send_remote_dninst(const TString& ftp) const bool Tdninst_mask::send_remote_dninst(const TString& ftp) const
@ -789,24 +859,56 @@ bool Tdninst_mask::on_field_event(TOperable_field& o, TField_event e, long jolly
} }
break; break;
case F_DSN_WWW: case F_DSN_WWW:
if (e == fe_button && !o.empty()) if (e == fe_button)
{ {
TString query; if (o.empty())
query << "ODBC(" << o.get() << ")\n"
<< "SELECT * FROM chiavette,clienti WHERE chiavette.cliente=clienti.codice\n"
<< "ORDER BY ";
switch(get_int(F_SORT))
{ {
case 1: query << "agente,RagioneSociale,chiavette.codice"; break; TConfig odbc("c:/windows/odbc.ini", "ODBC 32 bit Data Sources");
case 2: query << "RagioneSociale,chiavette.codice"; break; TAssoc_array& var = odbc.list_variables();
default: query << "chiavette.codice"; break; if (!var.empty())
{
TArray_sheet dsn(-1, -1, 78, 20, TR("Sorgenti dati ODBC"), HR("Nome@25|Driver@50"));
TToken_string row;
FOR_EACH_ASSOC_OBJECT(var, obj, key, itm)
{
row = key;
row.add(*(TString*)itm);
dsn.add(row);
}
if (dsn.run() == K_ENTER)
o.set(dsn.row(-1).get(0));
}
} }
else
TODBC_recordset att(query);
if (att.move_first())
{ {
TRecordset_sheet sheet(att, TR("Chiavi"),0x10); TString query;
sheet.run(); query << "ODBC(" << o.get() << ")\n"
<< "SELECT chiavette.Codice AS Chiave, chiavette.Cliente, clienti.RagioneSociale AS 'Ragione Sociale', "
<< "clienti.Stato, clienti.DataDisattivazione AS Data, "
<< "agenti.Codice AS Agente, agenti.RagioneSociale AS Rivenditore"
<< "\nFROM (chiavette JOIN clienti ON chiavette.cliente=clienti.codice) JOIN agenti ON clienti.Agente=agenti.Codice"
<< "\nORDER BY ";
switch (get_int(F_SORT))
{
case 1: query << "Agente,clienti.RagioneSociale,Chiave"; break;
case 2: query << "clienti.RagioneSociale,Chiave"; break;
default: query << "Chiave"; break;
}
TODBC_recordset att(query);
bool connected = false;
if (!connected) // Dummy test
{
TWait_cursor hourglass;
connected = att.move_first();
}
if (connected)
{
TRecordset_sheet sheet(att, TR("Chiavi"),0x10);
sheet.run();
}
} }
} }
break; break;
@ -910,6 +1012,7 @@ Tdninst_mask::Tdninst_mask() : TAutomask("ba2800a")
_c_dbkilled = s.cid2index(F_DBKILLED); _c_dbkilled = s.cid2index(F_DBKILLED);
_c_xmloem = s.cid2index(F_ATOEM); _c_xmloem = s.cid2index(F_ATOEM);
_c_xmlowner = s.cid2index(F_ATOWNER); _c_xmlowner = s.cid2index(F_ATOWNER);
_c_xmlyear = s.cid2index(F_ATYEAR);
_c_xmlaccess= s.cid2index(F_ATACCESS); _c_xmlaccess= s.cid2index(F_ATACCESS);
} }

View File

@ -27,4 +27,5 @@
#define F_DBKILLED 109 #define F_DBKILLED 109
#define F_ATOEM 110 #define F_ATOEM 110
#define F_ATOWNER 111 #define F_ATOWNER 111
#define F_ATACCESS 112 #define F_ATYEAR 112
#define F_ATACCESS 113

View File

@ -134,6 +134,7 @@ BEGIN
ITEM "DB Disdetto@10" ITEM "DB Disdetto@10"
ITEM "XML OEM@10" ITEM "XML OEM@10"
ITEM "XML Cliente@50" ITEM "XML Cliente@50"
ITEM "Anno"
ITEM "Ultimo accesso" ITEM "Ultimo accesso"
DEFAULT "*" DEFAULT "*"
END END
@ -252,6 +253,12 @@ DATE F_ATACCESS
BEGIN BEGIN
PROMPT 28 6 "Ultimo aggiornamento " PROMPT 28 6 "Ultimo aggiornamento "
END END
NUMBER F_ATYEAR 4
BEGIN
PROMPT 2 7 "Numero versione "
END
ENDPAGE ENDPAGE
TOOLBAR "" 0 0 0 2 TOOLBAR "" 0 0 0 2

View File

@ -1282,24 +1282,24 @@ void TMailer_mask::save_all_lines()
const bool yes = save_sheet_line(err, nrow); const bool yes = save_sheet_line(err, nrow);
if (yes) if (yes)
{ {
msg << "elaborato con successo"; msg << TR("elaborato con successo");
one_saved = true; one_saved = true;
} }
else else
if (err == NOT_GEST) if (err == NOT_GEST)
{ {
const TMask& m = sf.sheet_mask(); const TMask& m = sf.sheet_mask();
msg << " definire il programma gestore del file " << m.get(F_SUBJECT); msg << TR("definire il programma gestore del file ") << m.get(F_SUBJECT);
} }
else else
{ {
msg << "non elaborato a causa di un errore (n.ro " << err << ')'; msg << TR("non elaborato a causa di un errore (n.ro ") << err << ')';
if (_sequential) if (_sequential)
break; break;
} }
} }
else else
msg << "ignorato in quanto transazione non riconosciuta"; msg << TR("ignorato in quanto transazione non riconosciuta");
} }
log(msg); log(msg);
} }
@ -1341,10 +1341,10 @@ void TMailer_mask::exec_scripts()
row->get(2, des); row->get(2, des);
log(des.full() ? des : cmd); log(des.full() ? des : cmd);
TExternal_app app(cmd); TExternal_app app(cmd);
const long ret = app.run(); const long ret = app.run(false, true, false);
if (ret != 0) if (ret != 0)
{ {
TString80 msg; msg.format(FR("Errore %ld nell'esecuzione di %s"), ret, (const char*)cmd); TString msg; msg.format(FR("Errore %ld nell'esecuzione di %s"), ret, (const char*)cmd);
log(msg); log(msg);
} }
} }
@ -1561,31 +1561,35 @@ void TMailer_mask::save() const
{ {
TConfig ini(CONFIG_DITTA, "MailTransactions"); TConfig ini(CONFIG_DITTA, "MailTransactions");
ini.remove_all(); ini.remove_all();
ini.set("Server", get(F_SERVER));
ini.set("User", get(F_USER)); ini.set("Server", get(F_SERVER));
ini.set("Password", encode(get(F_PASSWORD))); ini.set("User", get(F_USER));
ini.set("Timer", get(F_TIMER)); ini.set("Password", encode(get(F_PASSWORD)));
ini.set("Log", get(F_TRACKING)); ini.set("Timer", get(F_TIMER));
ini.set("Backup", get(F_BACKUP)); ini.set("Log", get(F_TRACKING));
ini.set("Backup", get(F_BACKUP));
ini.set("DelCancel", get(F_DELCANCEL)); ini.set("DelCancel", get(F_DELCANCEL));
save_sheet(ini, F_ADDRESSES, "Recipient"); save_sheet(ini, F_ADDRESSES, "Recipient");
save_sheet(ini, F_PARAMS, "Filter"); save_sheet(ini, F_PARAMS, "Filter");
save_sheet(ini, F_SCRIPTS, "Script"); save_sheet(ini, F_SCRIPTS, "Script");
} }
void TMailer_mask::load() void TMailer_mask::load()
{ {
TConfig ini(CONFIG_DITTA, "MailTransactions"); TConfig ini(CONFIG_DITTA, "MailTransactions");
set(F_SERVER, ini.get("Server"));
set(F_USER, ini.get("User")); set(F_SERVER, ini.get("Server"));
set(F_USER, ini.get("User"));
set(F_PASSWORD, decode(ini.get("Password"))); set(F_PASSWORD, decode(ini.get("Password")));
set(F_TIMER, ini.get_int("Timer")); set(F_TIMER, ini.get_int("Timer"));
set(F_TRACKING, ini.get("Log")); set(F_TRACKING, ini.get("Log"));
set(F_BACKUP, ini.get("Backup")); set(F_BACKUP, ini.get("Backup"));
set(F_DELCANCEL, ini.get("DelCancel")); set(F_DELCANCEL,ini.get("DelCancel"));
load_sheet(ini, F_ADDRESSES, "Recipient"); load_sheet(ini, F_ADDRESSES, "Recipient");
load_sheet(ini, F_PARAMS, "Filter"); load_sheet(ini, F_PARAMS, "Filter");
load_sheet(ini, F_SCRIPTS, "Script"); load_sheet(ini, F_SCRIPTS, "Script");
_sequential = ini.get_bool("StopOnError", "ba7"); _sequential = ini.get_bool("StopOnError", "ba7");
} }

View File

@ -129,7 +129,6 @@ Item_01 = "Riattribuzione codice allegato", "bacnv 21", ""
Item_02 = "Aggiornamento IV direttiva CEE", "bacnv 22", "" Item_02 = "Aggiornamento IV direttiva CEE", "bacnv 22", ""
Item_03 = "Aggiornamento profili documento personalizzati", "bacnv 23", "" Item_03 = "Aggiornamento profili documento personalizzati", "bacnv 23", ""
Item_04 = "Riattribuzione campi CONAI", "bacnv 24", "" Item_04 = "Riattribuzione campi CONAI", "bacnv 24", ""
Item_05 = "Gestione attivazioni", "ba2 -7", ""
[MENU_PREFERITI] [MENU_PREFERITI]
Caption = "Preferiti" Caption = "Preferiti"

View File

@ -1,3 +1,3 @@
163 163
0 0
$tabmod|0|0|585|0|Tabelle di modulo||| $tabmod|0|0|691|0|Tabelle di modulo|||

View File

@ -1,5 +1,5 @@
163 163
46 53
MOD|1|2|0|Codice modulo MOD|1|2|0|Codice modulo
CUST|3|6|0|Codice cliente (opzionale) CUST|3|6|0|Codice cliente (opzionale)
COD|1|3|0|Codice Tabella COD|1|3|0|Codice Tabella
@ -23,6 +23,8 @@ I7|3|8|0|Intero 7
I8|3|8|0|Intero 8 I8|3|8|0|Intero 8
I9|3|8|0|Intero 9 I9|3|8|0|Intero 9
I10|3|8|0|Intero 10 I10|3|8|0|Intero 10
I11|3|8|0|Intero 11
I12|3|8|0|Intero 12
R0|4|18|3|Numero 0 R0|4|18|3|Numero 0
R1|4|18|3|Numero 1 R1|4|18|3|Numero 1
R2|4|18|3|Numero 2 R2|4|18|3|Numero 2
@ -31,6 +33,11 @@ R4|4|18|3|Numero 4
R5|4|18|3|Numero 5 R5|4|18|3|Numero 5
R6|4|18|3|Numero 6 R6|4|18|3|Numero 6
R7|4|18|3|Numero 7 R7|4|18|3|Numero 7
R8|4|18|3|Numero 8
R9|4|18|3|Numero 9
R10|4|18|3|Numero 10
R11|4|18|3|Numero 11
R12|4|18|3|Numero 12
D0|5|8|0|Data 0 D0|5|8|0|Data 0
D1|5|8|0|Data 1 D1|5|8|0|Data 1
D2|5|8|0|Data 2 D2|5|8|0|Data 2