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))
break;
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 int patch = atoi(str.mid(2, 4));

View File

@ -1,5 +1,4 @@
#include <applicat.h>
#include <assoc.h>
#include <automask.h>
#include <colors.h>
#include <config.h>
@ -7,6 +6,7 @@
#include <netsock.h>
#include <odbcrset.h>
#include <progind.h>
#include <reputils.h>
#include <utility.h>
#include <xml.h>
@ -56,15 +56,15 @@ int TOEM_cache::Agente2OEM(int agente) const
int oem = -1;
switch (agente)
{
case 1: // Administrator
case 2: oem = 0; break;
case 3: oem = 1; break;
case 4: oem = 3; break;
case 5: oem = 6; break;
case 6: oem = 5; break;
case 7: oem = 7; break;
case 8: oem = 8; break;
default: break;
case 2: oem = 0; break; // Aga
case 5: oem = 6; break; // Sipag -> Sicuri
case 7: oem = 7; break; // Prassi Roma -> Itertec
case 8: // Prassi Calabria
case 9: oem = 8; break; // Metacalabria
case 10: oem = 6; break; // Socogem -> Sicuri
case 11: oem = 7; break; // Itertec
case 13: oem = 2; break; // Tetractis
default: oem = 1; break; // Sirio
}
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_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
{
@ -399,16 +399,16 @@ bool Tdninst_mask::load_odbc(TString_array& a) const
{
TString query;
query << "ODBC(" << dsn << ")\n"
<< "SELECT chiavette.codice AS Chiave, Agente, RagioneSociale, DataDisattivazione\n"
<< "FROM chiavette,clienti WHERE chiavette.cliente=clienti.codice\n"
<< "ORDER BY Chiave";
<< "SELECT chiavette.Codice, chiavette.Cliente, clienti.RagioneSociale, clienti.Agente, clienti.DataDisattivazione, clienti.Stato"
<< "\nFROM chiavette JOIN clienti ON chiavette.cliente=clienti.codice"
<< "\nORDER BY Codice";
TODBC_recordset att(query);
TProgind pi(att.items(), dsn);
for (bool ok = att.move_first(); ok; ok = att.move_next())
{
if (!pi.addstatus(1)) break;
const int key = att.get("Chiave").as_int();
const int key = att.get("Codice").as_int();
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(smart_trim(att.get("RagioneSociale").as_string(), 50), _c_dbowner);
const TString& stato = att.get("Stato").as_string();
if (stato[0] > 'A') // Non Attivo
{
const TString& kill = att.get("DataDisattivazione").as_string();
if (kill.full() && kill.len() == 10)
{
const TString& stato = att.get("Stato").as_string();
TDate d;
if (kill[2] == '-')
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(kill, _c_dbkilled); break; // Disdetto
case 'S': r.add(kill, _c_dbsuspend); break; // Sospeso
default: break;
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")
{
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
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);
}
}
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();
@ -611,11 +650,15 @@ bool Tdninst_mask::fill_sheet()
void Tdninst_mask::merge_sheet()
{
TLog_report log;
TString msg;
TSheet_field& sheet = sfield(F_DNSHEET);
TString16 killed;
TString o1, o2, o3;
TString c1, c2, c3;
TString d1, d2;
int changed = 0;
FOR_EACH_SHEET_ROW(sheet, r, row)
@ -630,7 +673,7 @@ void Tdninst_mask::merge_sheet()
{
c1 = c2;
o1 = row->get(_c_dboem);
} else
}
if (c3.full())
{
c1 = c3;
@ -641,6 +684,10 @@ void Tdninst_mask::merge_sheet()
row->add(o1, _c_oem);
row->add(c1, _c_owner);
changed++;
msg = TR("Inserito cliente ");
msg << c1;
log.log(0, msg);
}
}
else
@ -653,30 +700,53 @@ void Tdninst_mask::merge_sheet()
{
row->add(o2, _c_oem);
changed++;
}
msg = TR("Aggiornato agente del cliente ");
msg << c1;
log.log(0, msg);
}
}
o1 = row->get(_c_suspend); o1.trim();
c1 = row->get(_c_dbsuspend); c1.trim();
if (o1 != c1)
c2 = row->get(_c_dbowner);
if (c2.full() && c1 != c2)
{
row->add(c1, _c_suspend);
row->add(c2, _c_owner);
changed++;
}
o1 = row->get(_c_killed); o1.trim();
c1 = row->get(_c_dbkilled); c1.trim();
if (o1 != c1)
if (xvt_str_fuzzy_compare_ignoring_case(c1, c2) < 0.7)
{
row->add(c1, _c_killed);
changed++;
msg = TR("Aggiornata ragione sociale da '");
msg << c1 << "' a '" << c2 << "'";
log.log(0, msg);
}
}
}
d1 = row->get(_c_suspend); d1.trim();
d2 = row->get(_c_dbsuspend); d2.trim();
if (d2.full() && d1 != d2)
{
row->add(d2, _c_suspend);
changed++;
msg = TR("Sospensione del cliente ");
msg << c1 << TR(" dal ") << d2;
log.log(1, msg);
}
d1 = row->get(_c_killed); d1.trim();
d2 = row->get(_c_dbkilled); d2.trim();
if (d2.full() && d1 != d2)
{
row->add(d2, _c_killed);
changed++;
msg = TR("Disattivazione del cliente ");
msg << c1 << TR(" dal ") << d2;
log.log(2, msg);
}
}
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
@ -789,26 +859,58 @@ bool Tdninst_mask::on_field_event(TOperable_field& o, TField_event e, long jolly
}
break;
case F_DSN_WWW:
if (e == fe_button && !o.empty())
if (e == fe_button)
{
if (o.empty())
{
TConfig odbc("c:/windows/odbc.ini", "ODBC 32 bit Data Sources");
TAssoc_array& var = odbc.list_variables();
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
{
TString query;
query << "ODBC(" << o.get() << ")\n"
<< "SELECT * FROM chiavette,clienti WHERE chiavette.cliente=clienti.codice\n"
<< "ORDER BY ";
<< "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,RagioneSociale,chiavette.codice"; break;
case 2: query << "RagioneSociale,chiavette.codice"; break;
default: query << "chiavette.codice"; break;
case 1: query << "Agente,clienti.RagioneSociale,Chiave"; break;
case 2: query << "clienti.RagioneSociale,Chiave"; break;
default: query << "Chiave"; break;
}
TODBC_recordset att(query);
if (att.move_first())
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;
case F_XML_WWW:
if ((e == fe_init || e == fe_modify || e == fe_close) && o.empty())
@ -910,6 +1012,7 @@ Tdninst_mask::Tdninst_mask() : TAutomask("ba2800a")
_c_dbkilled = s.cid2index(F_DBKILLED);
_c_xmloem = s.cid2index(F_ATOEM);
_c_xmlowner = s.cid2index(F_ATOWNER);
_c_xmlyear = s.cid2index(F_ATYEAR);
_c_xmlaccess= s.cid2index(F_ATACCESS);
}

View File

@ -27,4 +27,5 @@
#define F_DBKILLED 109
#define F_ATOEM 110
#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 "XML OEM@10"
ITEM "XML Cliente@50"
ITEM "Anno"
ITEM "Ultimo accesso"
DEFAULT "*"
END
@ -252,6 +253,12 @@ DATE F_ATACCESS
BEGIN
PROMPT 28 6 "Ultimo aggiornamento "
END
NUMBER F_ATYEAR 4
BEGIN
PROMPT 2 7 "Numero versione "
END
ENDPAGE
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);
if (yes)
{
msg << "elaborato con successo";
msg << TR("elaborato con successo");
one_saved = true;
}
else
if (err == NOT_GEST)
{
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
{
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)
break;
}
}
else
msg << "ignorato in quanto transazione non riconosciuta";
msg << TR("ignorato in quanto transazione non riconosciuta");
}
log(msg);
}
@ -1341,10 +1341,10 @@ void TMailer_mask::exec_scripts()
row->get(2, des);
log(des.full() ? des : cmd);
TExternal_app app(cmd);
const long ret = app.run();
const long ret = app.run(false, true, false);
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);
}
}
@ -1561,6 +1561,7 @@ void TMailer_mask::save() const
{
TConfig ini(CONFIG_DITTA, "MailTransactions");
ini.remove_all();
ini.set("Server", get(F_SERVER));
ini.set("User", get(F_USER));
ini.set("Password", encode(get(F_PASSWORD)));
@ -1568,6 +1569,7 @@ void TMailer_mask::save() const
ini.set("Log", get(F_TRACKING));
ini.set("Backup", get(F_BACKUP));
ini.set("DelCancel", get(F_DELCANCEL));
save_sheet(ini, F_ADDRESSES, "Recipient");
save_sheet(ini, F_PARAMS, "Filter");
save_sheet(ini, F_SCRIPTS, "Script");
@ -1576,6 +1578,7 @@ void TMailer_mask::save() const
void TMailer_mask::load()
{
TConfig ini(CONFIG_DITTA, "MailTransactions");
set(F_SERVER, ini.get("Server"));
set(F_USER, ini.get("User"));
set(F_PASSWORD, decode(ini.get("Password")));
@ -1583,6 +1586,7 @@ void TMailer_mask::load()
set(F_TRACKING, ini.get("Log"));
set(F_BACKUP, ini.get("Backup"));
set(F_DELCANCEL,ini.get("DelCancel"));
load_sheet(ini, F_ADDRESSES, "Recipient");
load_sheet(ini, F_PARAMS, "Filter");
load_sheet(ini, F_SCRIPTS, "Script");

View File

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

View File

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

View File

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