Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8c5fc8b838 | |||
| 84d4df2329 | |||
| 91ffbbe8dd | |||
| 6a512b14b6 | |||
| 51aaba515f | |||
| 05d38253a2 |
+291
-257
@@ -3,274 +3,308 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace SteamWare
|
namespace SteamWare
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// classe di wrap verso i TableAdapter impiegati
|
/// classe di wrap verso i TableAdapter impiegati
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DataWrap
|
public class DataWrap
|
||||||
{
|
{
|
||||||
#region area protected
|
#region Public Fields
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// metodo protected di avvio della classe
|
/// classe singleton x la gestione dei tableadapters
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected DataWrap()
|
public static DataWrap DW = new DataWrap();
|
||||||
{
|
|
||||||
// inizializzo i table adapters
|
|
||||||
avvioTableAdaptersBase();
|
|
||||||
setupConnectionStringBase();
|
|
||||||
avvioTableAdaptersSpec();
|
|
||||||
setupConnectionStringSpec();
|
|
||||||
setupVocabolario();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// procedura di avvio dei tableAdapter
|
/// oggetto vocabolario organizzato come dizionario con chiave lang#lemma e valore la traduzione
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual void avvioTableAdaptersBase()
|
public Dictionary<string, string> dictVocabolario;
|
||||||
{
|
|
||||||
taLingue = new DataLayer_genericTableAdapters.LingueTableAdapter();
|
|
||||||
taVocabolario = new DataLayer_genericTableAdapters.VocabolarioTableAdapter();
|
|
||||||
taLogVoc = new DataLayer_genericTableAdapters.LogUpdateDbTableAdapter();
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// procedura di avvio dei tableAdapter
|
|
||||||
/// </summary>
|
|
||||||
protected virtual void avvioTableAdaptersSpec()
|
|
||||||
{
|
|
||||||
taCdc = new DataLayer_AnagGenTableAdapters.CDCTableAdapter();
|
|
||||||
taDiritti = new DataLayer_AnagGenTableAdapters.DIRITTITableAdapter();
|
|
||||||
taPermessi = new DataLayer_AnagGenTableAdapters.PermessiTableAdapter();
|
|
||||||
taFunzione = new DataLayer_AnagGenTableAdapters.FUNZIONETableAdapter();
|
|
||||||
taPermessi2Funzione = new DataLayer_AnagGenTableAdapters.Permessi2FunzioneTableAdapter();
|
|
||||||
taUtente = new DataLayer_AnagGenTableAdapters.UTENTETableAdapter();
|
|
||||||
taUserData = new DataLayer_AnagGenTableAdapters.UserDataTableAdapter();
|
|
||||||
taUserDataExt = new DataLayer_AnagGenTableAdapters.UserDataExtTableAdapter();
|
|
||||||
taLogAna = new DataLayer_AnagGenTableAdapters.LogUpdateDbTableAdapter();
|
|
||||||
taAnagDev = new DS_devicesTableAdapters.AnagDevicesTableAdapter();
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// effettua setup dei connection strings da web.config delal singola applicazione
|
|
||||||
/// </summary>
|
|
||||||
protected virtual void setupConnectionStringBase()
|
|
||||||
{
|
|
||||||
string connStr = memLayer.ML.confReadString("VocabolarioConnectionString");
|
|
||||||
// connections del db vocabolario
|
|
||||||
taLingue.Connection.ConnectionString = connStr;
|
|
||||||
taVocabolario.Connection.ConnectionString = connStr;
|
|
||||||
taLogVoc.Connection.ConnectionString = connStr;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// effettua setup dei connection strings da web.config della singola applicazione
|
|
||||||
/// </summary>
|
|
||||||
protected virtual void setupConnectionStringSpec()
|
|
||||||
{
|
|
||||||
string connStrUt = memLayer.ML.confReadString("UtenteCdcConnectionString");
|
|
||||||
string connStrPerm = memLayer.ML.confReadString("PermessiConnectionString");
|
|
||||||
// cambio le connString - db anagrafica principale
|
|
||||||
taCdc.Connection.ConnectionString = connStrUt;
|
|
||||||
taDiritti.Connection.ConnectionString = connStrUt;
|
|
||||||
taFunzione.Connection.ConnectionString = connStrUt;
|
|
||||||
taUtente.Connection.ConnectionString = connStrUt;
|
|
||||||
taUserData.Connection.ConnectionString = connStrUt;
|
|
||||||
taUserDataExt.Connection.ConnectionString = connStrUt;
|
|
||||||
taLogAna.Connection.ConnectionString = connStrUt;
|
|
||||||
taAnagDev.Connection.ConnectionString = connStrUt;
|
|
||||||
// connections del db dell'applicazione
|
|
||||||
taPermessi.Connection.ConnectionString = connStrPerm;
|
|
||||||
taPermessi2Funzione.Connection.ConnectionString = connStrPerm;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// setup delle tabelle vocabolario
|
|
||||||
/// </summary>
|
|
||||||
protected void setupVocabolario()
|
|
||||||
{
|
|
||||||
if (memLayer.ML.isInCacheObject("dictVocabolario"))
|
|
||||||
{
|
|
||||||
if (memLayer.ML.cacheOnRedis)
|
|
||||||
{
|
|
||||||
dictVocabolario = JsonConvert.DeserializeObject<Dictionary<string, string>>(memLayer.ML.objCacheObj("dictVocabolario").ToString());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dictVocabolario = (Dictionary<string, string>)memLayer.ML.objCacheObj("dictVocabolario");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dictVocabolario = ricaricaDictVocabolario();
|
|
||||||
if (memLayer.ML.cacheOnRedis)
|
|
||||||
{
|
|
||||||
string serVal = JsonConvert.SerializeObject(dictVocabolario);
|
|
||||||
memLayer.ML.setCacheVal("dictVocabolario", serVal, true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
memLayer.ML.setCacheVal("dictVocabolario", dictVocabolario, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// scrivo quanti lemmi ha caricato!
|
|
||||||
logger.lg.scriviLog(string.Format("Caricati {0} lemmi!", dictVocabolario.Count));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// prende l'oggetto tabVocabolario in ram e lo trasforma in dictionary
|
/// table adapter Devices utente
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
public DS_devicesTableAdapters.AnagDevicesTableAdapter taAnagDev;
|
||||||
protected Dictionary<string, string> ricaricaDictVocabolario()
|
|
||||||
{
|
/// <summary>
|
||||||
// continuo
|
/// tableAdapter CdC
|
||||||
Dictionary<string, string> answ = new Dictionary<string, string>();
|
/// </summary>
|
||||||
if (taVocabolario == null)
|
public DataLayer_AnagGenTableAdapters.CDCTableAdapter taCdc;
|
||||||
{
|
|
||||||
foreach (DataLayer_generic.VocabolarioRow riga in DW.taVocabolario.GetData())
|
/// <summary>
|
||||||
|
/// tableAdapter diritti
|
||||||
|
/// </summary>
|
||||||
|
public DataLayer_AnagGenTableAdapters.DIRITTITableAdapter taDiritti;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// tableAdapter funzione
|
||||||
|
/// </summary>
|
||||||
|
public DataLayer_AnagGenTableAdapters.FUNZIONETableAdapter taFunzione;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// table adapter lingue
|
||||||
|
/// </summary>
|
||||||
|
public DataLayer_genericTableAdapters.LingueTableAdapter taLingue;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// table adapter versione anagrafica
|
||||||
|
/// </summary>
|
||||||
|
public DataLayer_AnagGenTableAdapters.LogUpdateDbTableAdapter taLogAna;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// table adapter versione vocabolario
|
||||||
|
/// </summary>
|
||||||
|
public DataLayer_genericTableAdapters.LogUpdateDbTableAdapter taLogVoc;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// tableAdapter permessi
|
||||||
|
/// </summary>
|
||||||
|
public DataLayer_AnagGenTableAdapters.PermessiTableAdapter taPermessi;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// tableAdapter permessi2funzione
|
||||||
|
/// </summary>
|
||||||
|
public DataLayer_AnagGenTableAdapters.Permessi2FunzioneTableAdapter taPermessi2Funzione;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// tableAdapter userData (user/pwd)
|
||||||
|
/// </summary>
|
||||||
|
public DataLayer_AnagGenTableAdapters.UserDataTableAdapter taUserData;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// tableAdapter userDataExt (user/pwd)
|
||||||
|
/// </summary>
|
||||||
|
public DataLayer_AnagGenTableAdapters.UserDataExtTableAdapter taUserDataExt;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// tableAdapter utenti
|
||||||
|
/// </summary>
|
||||||
|
public DataLayer_AnagGenTableAdapters.UTENTETableAdapter taUtente;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// table adapter vocabolario
|
||||||
|
/// </summary>
|
||||||
|
public DataLayer_genericTableAdapters.VocabolarioTableAdapter taVocabolario;
|
||||||
|
|
||||||
|
#endregion Public Fields
|
||||||
|
|
||||||
|
#region Public Constructors
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// metodo protected di avvio della classe
|
||||||
|
/// </summary>
|
||||||
|
public DataWrap()
|
||||||
{
|
{
|
||||||
answ.Add(riga.Lingua.ToUpper() + "#" + riga.Lemma.ToUpper(), riga.Traduzione);
|
// inizializzo i table adapters
|
||||||
|
avvioTableAdaptersBase();
|
||||||
|
setupConnectionStringBase();
|
||||||
|
avvioTableAdaptersSpec();
|
||||||
|
setupConnectionStringSpec();
|
||||||
|
setupVocabolario();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
#endregion Public Constructors
|
||||||
{
|
|
||||||
foreach (DataLayer_generic.VocabolarioRow riga in taVocabolario.GetData())
|
#region Public Properties
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// elenco lingue ammesse da vocabolario...
|
||||||
|
/// </summary>
|
||||||
|
public DataLayer_generic.LingueDataTable lingue
|
||||||
{
|
{
|
||||||
answ.Add(riga.Lingua.ToUpper() + "#" + riga.Lemma.ToUpper(), riga.Traduzione);
|
get
|
||||||
|
{
|
||||||
|
return taLingue.GetData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return answ;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
/// <summary>
|
||||||
|
/// restituisce conteggio numero record dell'oggetto vocabolario
|
||||||
#region area public
|
/// </summary>
|
||||||
|
public int numRecVoc
|
||||||
/// <summary>
|
|
||||||
/// tableAdapter diritti
|
|
||||||
/// </summary>
|
|
||||||
public DataLayer_AnagGenTableAdapters.DIRITTITableAdapter taDiritti;
|
|
||||||
/// <summary>
|
|
||||||
/// tableAdapter permessi
|
|
||||||
/// </summary>
|
|
||||||
public DataLayer_AnagGenTableAdapters.PermessiTableAdapter taPermessi;
|
|
||||||
/// <summary>
|
|
||||||
/// tableAdapter funzione
|
|
||||||
/// </summary>
|
|
||||||
public DataLayer_AnagGenTableAdapters.FUNZIONETableAdapter taFunzione;
|
|
||||||
/// <summary>
|
|
||||||
/// tableAdapter permessi2funzione
|
|
||||||
/// </summary>
|
|
||||||
public DataLayer_AnagGenTableAdapters.Permessi2FunzioneTableAdapter taPermessi2Funzione;
|
|
||||||
/// <summary>
|
|
||||||
/// tableAdapter CdC
|
|
||||||
/// </summary>
|
|
||||||
public DataLayer_AnagGenTableAdapters.CDCTableAdapter taCdc;
|
|
||||||
/// <summary>
|
|
||||||
/// tableAdapter utenti
|
|
||||||
/// </summary>
|
|
||||||
public DataLayer_AnagGenTableAdapters.UTENTETableAdapter taUtente;
|
|
||||||
/// <summary>
|
|
||||||
/// tableAdapter userData (user/pwd)
|
|
||||||
/// </summary>
|
|
||||||
public DataLayer_AnagGenTableAdapters.UserDataTableAdapter taUserData;
|
|
||||||
/// <summary>
|
|
||||||
/// tableAdapter userDataExt (user/pwd)
|
|
||||||
/// </summary>
|
|
||||||
public DataLayer_AnagGenTableAdapters.UserDataExtTableAdapter taUserDataExt;
|
|
||||||
/// <summary>
|
|
||||||
/// table adapter lingue
|
|
||||||
/// </summary>
|
|
||||||
public DataLayer_genericTableAdapters.LingueTableAdapter taLingue;
|
|
||||||
/// <summary>
|
|
||||||
/// table adapter vocabolario
|
|
||||||
/// </summary>
|
|
||||||
public DataLayer_genericTableAdapters.VocabolarioTableAdapter taVocabolario;
|
|
||||||
/// <summary>
|
|
||||||
/// table adapter versione vocabolario
|
|
||||||
/// </summary>
|
|
||||||
public DataLayer_genericTableAdapters.LogUpdateDbTableAdapter taLogVoc;
|
|
||||||
/// <summary>
|
|
||||||
/// table adapter versione anagrafica
|
|
||||||
/// </summary>
|
|
||||||
public DataLayer_AnagGenTableAdapters.LogUpdateDbTableAdapter taLogAna;
|
|
||||||
/// <summary>
|
|
||||||
/// table adapter Devices utente
|
|
||||||
/// </summary>
|
|
||||||
public DS_devicesTableAdapters.AnagDevicesTableAdapter taAnagDev;
|
|
||||||
/// <summary>
|
|
||||||
/// oggetto vocabolario organizzato come dizionario con chiave lang#lemma e valore la traduzione
|
|
||||||
/// </summary>
|
|
||||||
public Dictionary<string, string> dictVocabolario;
|
|
||||||
/// <summary>
|
|
||||||
/// resetta il vocabolario rileggendo i dati...
|
|
||||||
/// </summary>
|
|
||||||
public void resetVocabolario()
|
|
||||||
{
|
|
||||||
memLayer.ML.emptyCacheVal("dictVocabolario");
|
|
||||||
setupVocabolario();
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Verifica se il vocabolario sia ok...
|
|
||||||
/// </summary>
|
|
||||||
public bool vocabolarioOk
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
bool answ = false;
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
answ = (dictVocabolario != null);
|
get
|
||||||
if (answ)
|
{
|
||||||
{
|
int answ = 0;
|
||||||
answ = dictVocabolario.Count > 0;
|
try
|
||||||
}
|
{
|
||||||
|
answ = dictVocabolario.Count;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{ }
|
||||||
|
return answ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch
|
|
||||||
{ }
|
|
||||||
return answ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// crea nel db corrente il lemma richiesto e lo valorizza come "--{0}--"
|
/// Verifica se il vocabolario sia ok...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="lemma"></param>
|
public bool vocabolarioOk
|
||||||
/// <returns></returns>
|
|
||||||
public void creaNuovoLemmaVoc(string lemma)
|
|
||||||
{
|
|
||||||
foreach (DataLayer_generic.LingueRow rigaLingua in taLingue.GetData())
|
|
||||||
{
|
|
||||||
taVocabolario.Insert(rigaLingua.Lingua, lemma, string.Format("--{0}--", lemma));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// restituisce conteggio numero record dell'oggetto vocabolario
|
|
||||||
/// </summary>
|
|
||||||
public int numRecVoc
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
int answ = 0;
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
answ = dictVocabolario.Count;
|
get
|
||||||
|
{
|
||||||
|
bool answ = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
answ = (dictVocabolario != null);
|
||||||
|
if (answ)
|
||||||
|
{
|
||||||
|
answ = dictVocabolario.Count > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{ }
|
||||||
|
return answ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch
|
|
||||||
{ }
|
|
||||||
return answ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// elenco lingue ammesse da vocabolario...
|
|
||||||
/// </summary>
|
|
||||||
public DataLayer_generic.LingueDataTable lingue
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return taLingue.GetData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// classe singleton x la gestione dei tableadapters
|
|
||||||
/// </summary>
|
|
||||||
public static DataWrap DW = new DataWrap();
|
|
||||||
|
|
||||||
#endregion
|
#endregion Public Properties
|
||||||
}
|
|
||||||
}
|
#region Protected Methods
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// procedura di avvio dei tableAdapter
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void avvioTableAdaptersBase()
|
||||||
|
{
|
||||||
|
taLingue = new DataLayer_genericTableAdapters.LingueTableAdapter();
|
||||||
|
taVocabolario = new DataLayer_genericTableAdapters.VocabolarioTableAdapter();
|
||||||
|
taLogVoc = new DataLayer_genericTableAdapters.LogUpdateDbTableAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// procedura di avvio dei tableAdapter
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void avvioTableAdaptersSpec()
|
||||||
|
{
|
||||||
|
taCdc = new DataLayer_AnagGenTableAdapters.CDCTableAdapter();
|
||||||
|
taDiritti = new DataLayer_AnagGenTableAdapters.DIRITTITableAdapter();
|
||||||
|
taPermessi = new DataLayer_AnagGenTableAdapters.PermessiTableAdapter();
|
||||||
|
taFunzione = new DataLayer_AnagGenTableAdapters.FUNZIONETableAdapter();
|
||||||
|
taPermessi2Funzione = new DataLayer_AnagGenTableAdapters.Permessi2FunzioneTableAdapter();
|
||||||
|
taUtente = new DataLayer_AnagGenTableAdapters.UTENTETableAdapter();
|
||||||
|
taUserData = new DataLayer_AnagGenTableAdapters.UserDataTableAdapter();
|
||||||
|
taUserDataExt = new DataLayer_AnagGenTableAdapters.UserDataExtTableAdapter();
|
||||||
|
taLogAna = new DataLayer_AnagGenTableAdapters.LogUpdateDbTableAdapter();
|
||||||
|
taAnagDev = new DS_devicesTableAdapters.AnagDevicesTableAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// prende l'oggetto tabVocabolario in ram e lo trasforma in dictionary
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
protected Dictionary<string, string> ricaricaDictVocabolario()
|
||||||
|
{
|
||||||
|
// continuo
|
||||||
|
Dictionary<string, string> answ = new Dictionary<string, string>();
|
||||||
|
if (taVocabolario == null)
|
||||||
|
{
|
||||||
|
foreach (DataLayer_generic.VocabolarioRow riga in DW.taVocabolario.GetData())
|
||||||
|
{
|
||||||
|
answ.Add(riga.Lingua.ToUpper() + "#" + riga.Lemma.ToUpper(), riga.Traduzione);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (DataLayer_generic.VocabolarioRow riga in taVocabolario.GetData())
|
||||||
|
{
|
||||||
|
answ.Add(riga.Lingua.ToUpper() + "#" + riga.Lemma.ToUpper(), riga.Traduzione);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return answ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// effettua setup dei connection strings da web.config delal singola applicazione
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void setupConnectionStringBase()
|
||||||
|
{
|
||||||
|
string connStr = memLayer.ML.confReadString("VocabolarioConnectionString");
|
||||||
|
// connections del db vocabolario
|
||||||
|
taLingue.Connection.ConnectionString = connStr;
|
||||||
|
taVocabolario.Connection.ConnectionString = connStr;
|
||||||
|
taLogVoc.Connection.ConnectionString = connStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// effettua setup dei connection strings da web.config della singola applicazione
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void setupConnectionStringSpec()
|
||||||
|
{
|
||||||
|
string connStrUt = memLayer.ML.confReadString("UtenteCdcConnectionString");
|
||||||
|
string connStrPerm = memLayer.ML.confReadString("PermessiConnectionString");
|
||||||
|
// cambio le connString - db anagrafica principale
|
||||||
|
taCdc.Connection.ConnectionString = connStrUt;
|
||||||
|
taDiritti.Connection.ConnectionString = connStrUt;
|
||||||
|
taFunzione.Connection.ConnectionString = connStrUt;
|
||||||
|
taUtente.Connection.ConnectionString = connStrUt;
|
||||||
|
taUserData.Connection.ConnectionString = connStrUt;
|
||||||
|
taUserDataExt.Connection.ConnectionString = connStrUt;
|
||||||
|
taLogAna.Connection.ConnectionString = connStrUt;
|
||||||
|
taAnagDev.Connection.ConnectionString = connStrUt;
|
||||||
|
// connections del db dell'applicazione
|
||||||
|
taPermessi.Connection.ConnectionString = connStrPerm;
|
||||||
|
taPermessi2Funzione.Connection.ConnectionString = connStrPerm;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// setup delle tabelle vocabolario
|
||||||
|
/// </summary>
|
||||||
|
protected void setupVocabolario()
|
||||||
|
{
|
||||||
|
if (memLayer.ML.isInCacheObject("dictVocabolario"))
|
||||||
|
{
|
||||||
|
if (memLayer.ML.cacheOnRedis)
|
||||||
|
{
|
||||||
|
dictVocabolario = JsonConvert.DeserializeObject<Dictionary<string, string>>(memLayer.ML.objCacheObj("dictVocabolario").ToString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dictVocabolario = (Dictionary<string, string>)memLayer.ML.objCacheObj("dictVocabolario");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dictVocabolario = ricaricaDictVocabolario();
|
||||||
|
if (memLayer.ML.cacheOnRedis)
|
||||||
|
{
|
||||||
|
string serVal = JsonConvert.SerializeObject(dictVocabolario);
|
||||||
|
memLayer.ML.setCacheVal("dictVocabolario", serVal, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memLayer.ML.setCacheVal("dictVocabolario", dictVocabolario, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// scrivo quanti lemmi ha caricato!
|
||||||
|
logger.lg.scriviLog(string.Format("Caricati {0} lemmi!", dictVocabolario.Count));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Protected Methods
|
||||||
|
|
||||||
|
#region Public Methods
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// crea nel db corrente il lemma richiesto e lo valorizza come "--{0}--"
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="lemma"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public void creaNuovoLemmaVoc(string lemma)
|
||||||
|
{
|
||||||
|
foreach (DataLayer_generic.LingueRow rigaLingua in taLingue.GetData())
|
||||||
|
{
|
||||||
|
taVocabolario.Insert(rigaLingua.Lingua, lemma, string.Format("--{0}--", lemma));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// resetta il vocabolario rileggendo i dati...
|
||||||
|
/// </summary>
|
||||||
|
public void resetVocabolario()
|
||||||
|
{
|
||||||
|
memLayer.ML.emptyCacheVal("dictVocabolario");
|
||||||
|
setupVocabolario();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion Public Methods
|
||||||
|
}
|
||||||
|
}
|
||||||
+39
-12
@@ -111,27 +111,54 @@ namespace SteamWare
|
|||||||
}
|
}
|
||||||
string localFile = "";
|
string localFile = "";
|
||||||
string localLast = "";
|
string localLast = "";
|
||||||
|
string DownloadURL = "";
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// in primis scarico update info...
|
// in primis scarico update info...
|
||||||
UpdateInfoEventArgs updateData = getUpdateInfo(remoteUrl);
|
UpdateInfoEventArgs updateData = getUpdateInfo(remoteUrl);
|
||||||
if (updateData.IsUpdateAvailable)
|
if (updateData.IsUpdateAvailable)
|
||||||
{
|
{
|
||||||
string DownloadURL = updateData.DownloadURL;
|
DownloadURL = updateData.DownloadURL;
|
||||||
localFile = string.Format(@"{0}\{1}_Build_{2}.zip", localRepo, packName, updateData.CurrentVersion);
|
localFile = string.Format(@"{0}\{1}_Build_{2}.zip", localRepo, packName, updateData.CurrentVersion);
|
||||||
localLast = string.Format(@"{0}\{1}.zip", localRepo, packName);
|
localLast = string.Format(@"{0}\{1}.zip", localRepo, packName);
|
||||||
// scarica file e salva in directory locale...
|
// scarica file e salva in directory locale...
|
||||||
var client = new WebClient();
|
using (var http = new HttpClient())
|
||||||
bool doAuth = !string.IsNullOrEmpty($"{userName}{passwd}");
|
|
||||||
if (doAuth)
|
|
||||||
{
|
{
|
||||||
client.Credentials = new System.Net.NetworkCredential(userName, passwd);
|
//var client = new WebClient();
|
||||||
|
bool doAuth = !string.IsNullOrEmpty($"{userName}{passwd}");
|
||||||
|
if (doAuth)
|
||||||
|
{
|
||||||
|
//client.Credentials = new System.Net.NetworkCredential(userName, passwd);
|
||||||
|
http.DefaultRequestHeaders.Accept.Clear();
|
||||||
|
var byteArray = System.Text.ASCIIEncoding.UTF8.GetBytes($"{userName}:{passwd}");
|
||||||
|
http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
|
||||||
|
}
|
||||||
|
//client.DownloadFile(updateData.DownloadURL, localFile);
|
||||||
|
|
||||||
|
// url da chiamare
|
||||||
|
http.BaseAddress = new Uri(DownloadURL);
|
||||||
|
// lettura
|
||||||
|
var data = http.GetAsync(DownloadURL).Result;
|
||||||
|
using (var myReader = data.Content.ReadAsStreamAsync())
|
||||||
|
{
|
||||||
|
//var myReader = data.Content.ReadAsStreamAsync();
|
||||||
|
if (data.StatusCode != HttpStatusCode.OK)
|
||||||
|
{
|
||||||
|
logger.lg.scriviLog($"Errore in chiamata getUpdateInfo per URL {remoteUrl}: status code: {data.StatusCode}", tipoLog.INFO);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
using (Stream outStream = File.OpenWrite(localFile))
|
||||||
|
{
|
||||||
|
myReader.Result.CopyTo(outStream);
|
||||||
|
}
|
||||||
|
// ora lo copio come latest...
|
||||||
|
File.Copy(localFile, localLast, true);
|
||||||
|
// indico come fatto!
|
||||||
|
done = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
client.DownloadFile(updateData.DownloadURL, localFile);
|
|
||||||
// ora lo copio come latest...
|
|
||||||
File.Copy(localFile, localLast, true);
|
|
||||||
// indico come fatto!
|
|
||||||
done = 1;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -139,7 +166,7 @@ namespace SteamWare
|
|||||||
// scrivo file in area target...
|
// scrivo file in area target...
|
||||||
using (StreamWriter sw = File.AppendText(localFile))
|
using (StreamWriter sw = File.AppendText(localFile))
|
||||||
{
|
{
|
||||||
sw.WriteLine(string.Format("{0:yyyy-MM-dd HH:mm:ss} ATTENZIONE! Installer NON disponibile | {1}", DateTime.Now, remoteUrl));
|
sw.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss} ATTENZIONE! Installer NON disponibile | {remoteUrl}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,7 +176,7 @@ namespace SteamWare
|
|||||||
// scrivo file in area target...
|
// scrivo file in area target...
|
||||||
using (StreamWriter sw = File.AppendText(localFile))
|
using (StreamWriter sw = File.AppendText(localFile))
|
||||||
{
|
{
|
||||||
sw.WriteLine(string.Format("{0:yyyy-MM-dd HH:mm:ss} Errore in fase di download installers per {1}", DateTime.Now, remoteUrl));
|
sw.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss} Errore in fase di download installers{Environment.NewLine}XML: {remoteUrl}{Environment.NewLine}URL: {DownloadURL}");
|
||||||
sw.WriteLine(exc.ToString());
|
sw.WriteLine(exc.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+988
-941
File diff suppressed because it is too large
Load Diff
@@ -64,7 +64,7 @@ namespace TestBench
|
|||||||
private void btnDownload_Click(object sender, EventArgs e)
|
private void btnDownload_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var currUpdMan = new UpdateMan(txtUser.Text.Trim(), txtPass.Text.Trim());
|
var currUpdMan = new UpdateMan(txtUser.Text.Trim(), txtPass.Text.Trim());
|
||||||
currUpdMan.downloadLatest(txtRemoteUrl.Text.Trim(), "c:\\Temp", "MP-STATS");
|
currUpdMan.downloadLatest(txtRemoteUrl.Text.Trim(), "c:\\Temp", "TEST-FILE");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnReadUpdMan_Click(object sender, EventArgs e)
|
private void btnReadUpdMan_Click(object sender, EventArgs e)
|
||||||
|
|||||||
Reference in New Issue
Block a user