public void MettreAJour(bool bMAJTotale, bool bDiffere) { if (!bDiffere) { if (m_bUpdateEnCours) { return; } try { m_bUpdateEnCours = true; IDonneeSynchronisationMediation donneesSynchro = CSnmpConnexion.DefaultInstance.GetDonneesPourSynchro(IdProxy, bMAJTotale?-1:m_nIdLastSyncSessionConnue); if (donneesSynchro == null) { return; } CMemoryDb destDb = DataBase; if (bMAJTotale) { destDb = new CMemoryDb(); } CMemoryDb sourceDB = donneesSynchro.Database; DateTime dt = DateTime.Now; destDb.Importe(sourceDB); TimeSpan sp = DateTime.Now - dt; Console.WriteLine("Update médiation (full = " + bMAJTotale + ") : " + sp.TotalMilliseconds); if (bMAJTotale) { m_database = destDb; RegisterAllTypesInDb(); } CServiceMediation.GetDefaultInstance().OnChangementDansBaseConfiguration(); m_nIdLastSyncSessionConnue = donneesSynchro.IdSyncSessionDesDonnees; SaveConfig(); CServiceMediation.GetDefaultInstance().Trace.Write("Mediation service updated " + m_updateAFaire.ToString(), ALTRACE.TRACE, ALTRACE.DEBUG); m_updateAFaire = EModeUpdateAFaire.None; CSnmpPollingService.Configuration = this; } catch (Exception e) { } finally { m_bUpdateEnCours = false; } } else { m_updateAFaire = bMAJTotale ? EModeUpdateAFaire.Full : EModeUpdateAFaire.Partial; if (m_timerMiseAJour == null) { m_timerMiseAJour = new Timer(5000); m_timerMiseAJour.Elapsed += new ElapsedEventHandler(m_timerMiseAJour_Elapsed); } m_timerMiseAJour.Start(); } }
//---------------------------------------------------------- public static CServiceMediation GetDefaultInstance() { if (m_defaultInstance == null) { m_defaultInstance = new CServiceMediation(); CSnmpPollingService.Configuration = m_defaultInstance.m_configuration; } return(m_defaultInstance); }