//------------------------------------------------------------ static CResultAErreur CContexteDonneeServeur_DoTraitementExterneApresSauvegarde(CContexteDonnee contexte, Hashtable tableData) { CResultAErreur result = CResultAErreur.True; HashSet <DataRow> proxyAMediationModifiee = contexte.ExtendedProperties[c_cleMediationModifiee] as HashSet <DataRow>; if (proxyAMediationModifiee == null) { return(result); } CSynchroniseurBaseDistante synchro = CSynchroniseurBaseDistante.GetSynchroniseur(contexte.IdSession); foreach (DataRow row in proxyAMediationModifiee) { if (row[CSnmpProxyInDb.c_champSnmpIp] != DBNull.Value) { COperationSynchronisationSurAgentSynchronisation op = new COperationSynchronisationSurAgentSynchronisation( typeof(CNotifieurMiseAJourProxySnmp), row[CSnmpProxyInDb.c_champSnmpIp] + "/" + row[CSnmpProxyInDb.c_champId], EOperationSynchronisationSurAgentSynchronisation.CreateOrUpdate, row[CSnmpProxyInDb.c_champId].ToString()); synchro.AddOperation(contexte.IdSession, row[CSnmpProxyInDb.c_champSnmpIp].ToString(), op); } } HashSet <DataRow> proxyAConfigurationModifee = contexte.ExtendedProperties[c_cleConfigModifiee] as HashSet <DataRow>; HashSet <CSnmpProxyInDb> proxysAMettreAJour = new HashSet <CSnmpProxyInDb>(); foreach (DataRow row in proxyAConfigurationModifee) { CSnmpProxyInDb proxy = new CSnmpProxyInDb(contexte); try{ if (proxy.ReadIfExists((int)row[CSnmpProxyInDb.c_champId])) { FillHashSetProxiesAMettreAJour(proxy, proxysAMettreAJour); } } catch { } } foreach (CSnmpProxyInDb proxy in proxysAMettreAJour) { CSynchroniseurBaseDistante.GetSynchroniseur(contexte.IdSession).AddOperation( contexte.IdSession, proxy.CleBaseDistante, new COperationSynchronisationSurAgentSynchronisation( typeof(CSnmpConfigurationSynchroniseur), proxy.AdresseIp, EOperationSynchronisationSurAgentSynchronisation.CreateOrUpdate, proxy.Id.ToString())); } contexte.ExtendedProperties.Remove(c_cleMediationModifiee); contexte.ExtendedProperties.Remove(c_cleConfigModifiee); return(result); }
//--------------------------------------------------------------------------- public CResultAErreur TraitementApresSauvegarde(CContexteDonnee contexte) { CResultAErreur result = CResultAErreur.True; DataTable table = contexte.Tables[GetNomTable()]; if (table == null) { return(result); } HashSet <DataRow> rowsToSend = table.ExtendedProperties[GetType()] as HashSet <DataRow>; if (rowsToSend == null) { return(result); } CListeObjetsDonnees lstServiceMediation = new CListeObjetsDonnees(contexte, typeof(CSnmpProxyInDb)); HashSet <string> myIps = new HashSet <string>(); System.Net.IPHostEntry moiMeme = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()); foreach (IPAddress adresse in moiMeme.AddressList) { myIps.Add(adresse.ToString()); } foreach (CSnmpProxyInDb proxy in lstServiceMediation.ToArrayList()) { string strParametresAgent = proxy.AdresseIp; foreach (DataRow row in rowsToSend) { if (DoitMettreAJour(proxy, row)) { EOperationSynchronisationSurAgentSynchronisation typeOperation = EOperationSynchronisationSurAgentSynchronisation.CreateOrUpdate; if (row.RowState == DataRowState.Deleted) { typeOperation = EOperationSynchronisationSurAgentSynchronisation.Delete; } string strId = row[ChampIdDeTypeSynchronise, row.RowState == DataRowState.Deleted ? DataRowVersion.Original : DataRowVersion.Current].ToString(); IOperationSynchronisation operation = new COperationSynchronisationSurAgentSynchronisation( GetType(), strParametresAgent, typeOperation, strId); if (myIps.Contains(proxy.AdresseIp)) { Init(proxy.AdresseIp); result = DoOperation(operation, contexte); if (!result) { return(result); } } else { CSynchroniseurBaseDistante.DefaultInstance.AddOperation(contexte.IdSession, proxy.CleBaseDistante, operation); } } } } table.ExtendedProperties.Remove(GetType()); return(result); }