//-------------------------------------------------------------------------- public CResultAErreur CreateUpdateObjet(object objet) { CResultAErreur result = CResultAErreur.True; if (!IsMySelf()) { ISnmpConnexion cnxDisttante = GetConnexionDistante(); if (cnxDisttante != null) { return(cnxDisttante.CreateUpdateObjet(objet)); } result.EmpileErreur(I.T("Can not reach host @1|20009", EndPoint.Address.ToString())); return(result); } if (objet is CSnmpProxyConfiguration) { CSnmpProxyConfiguration.SetDefaultInstance((CSnmpProxyConfiguration)objet); } if (objet is CValiseEntiteDeMemoryDb) { objet = ((CValiseEntiteDeMemoryDb)objet).Entite; } if (objet is CEntiteDeMemoryDb) { result = CServiceMediation.GetDefaultInstance().Configuration.UpdateEntite(objet as sc2i.common.memorydb.CEntiteDeMemoryDb); } return(result); }
//------------------------------------------------------------------------- public void CalcTimeoutFromIp() { IEnumerable <CAgentSnmpPourSupervision> agents = CServiceMediation.GetDefaultInstance().Configuration.GetAgentsForIp(EndPoint.Address.ToString()); if (agents.Count() > 0) { IEnumerable <int> timeouts = from a in agents select a.Timeout; TimeOut = Math.Max(timeouts.Max(), TimeOut); } }
//-------------------------------------------------------------------- public void RedescendAlarmes(CMemoryDb dbContenantLesAlarmesARedescendre) { CServiceMediation.GetDefaultInstance().RedescendAlarmes(dbContenantLesAlarmesARedescendre); foreach (CSnmpProxy proxy in CSnmpProxyConfiguration.GetInstance().ListeProxySuivants) { try { ISnmpConnexion connexion = proxy.GetConnexion(); RedescendAlarmesDelegate del = new RedescendAlarmesDelegate(RedescendAlarmeAsync); del.BeginInvoke(connexion, dbContenantLesAlarmesARedescendre, null, null); } catch { } } }
protected override void OnStart(string[] args) { try { C2iEventLog.Init("Timos", NiveauBavardage.VraiPiplette); RemotingConfiguration.Configure(AppDomain.CurrentDomain.BaseDirectory + "\\serviceMediation.remoting.config", false); RemotingConfiguration.CustomErrorsMode = CustomErrorsModes.On; CAutoexecuteurClasses.RunAllAutoexecs(); CSnmpProxyConfiguration.GetInstance().MiseAJour(true); CServiceMediation.GetDefaultInstance().Configuration.MettreAJour(true, true); } catch (Exception e) { C2iEventLog.WriteErreur(e.Message); throw e; } }
//------------------------------------------------ public void RemoveTraceListener(IFuturocomTraceListener listener) { if (!IsMySelf()) { ISnmpConnexion cnxDistante = GetConnexionDistante(); if (cnxDistante != null) { CProxyListener proxy = new CProxyListener(listener); m_sponsor.Unregister(listener); cnxDistante.RemoveTraceListener(proxy); } } else { CServiceMediation.GetDefaultInstance().RemoveTraceListener(listener); } }
//------------------------------------------------------------------ public static void Init(double fDelaiPollingMinutes) { InterrompPolling(); lock (typeof(CLockerPollingList)) { if (m_timerPolling != null) { m_timerPolling.Stop(); m_timerPolling.Dispose(); m_timerPolling = null; } if (fDelaiPollingMinutes > 0) { m_timerPolling = new Timer((double)fDelaiPollingMinutes * 60.0 * 1000.0); m_timerPolling.Elapsed += new ElapsedEventHandler(m_timerPolling_Elapsed); m_timerPolling.Start(); } CServiceMediation.GetDefaultInstance().Trace.Write("Polling frequency set to " + new CValeurUnite(fDelaiPollingMinutes, "min").ToString("h min s"), ALTRACE.POLLING); } }
//--------------------------------------------------- public CResultAErreur DeleteObjet(Type typeObjet, string strIdObjet) { CResultAErreur result = CResultAErreur.True; if (!IsMySelf()) { ISnmpConnexion cnxDisttante = GetConnexionDistante(); if (cnxDisttante != null) { return(cnxDisttante.DeleteObjet(typeObjet, strIdObjet)); } result.EmpileErreur(I.T("Can not reach host @1|20009")); return(result); } if (typeof(CEntiteSnmpPourSupervision).IsAssignableFrom(typeObjet)) { result = CServiceMediation.GetDefaultInstance().Configuration.RemoveEntite(typeObjet, strIdObjet); } return(result); }
public void MiseAJour(bool bDiffere) { if (!bDiffere) { if (m_bMiseAJourEnCours) { return; } m_bMiseAJourEnCours = true; try { ISnmpConnexion cnx = new CSnmpConnexion(); CSnmpProxyConfiguration config = cnx.GetConfigurationDeSnmpProxy(GetInstance().IdProxyConfiguré); if (config != null) { m_instance = config; CSnmpPollingService.Init(m_instance.FrequencePollingMinutes); } } catch { } m_bMiseAJourEnCours = false; m_bMiseAJourDemandee = false; CServiceMediation.GetDefaultInstance().Trace.Write("Proxy setup updated", ALTRACE.TRACE, ALTRACE.DEBUG); } else { m_bMiseAJourDemandee = true; if (m_timerMiseAJour == null) { m_timerMiseAJour = new Timer(5000); m_timerMiseAJour.Elapsed += new ElapsedEventHandler(m_timerMiseAJour_Elapsed); } m_timerMiseAJour.Start(); } }
//--------------------------------------------------- public void NotifyProxyNecessiteMAJ( int nIdProxy, bool bConfigProxy, bool bServiceMediation, bool bFullSync) { if (IsMySelf()) { StringBuilder bl = new StringBuilder(); bl.Append("Proxy setup update requiered "); bl.Append("proxy setup="); bl.Append(bConfigProxy); bl.Append(", mediation setup="); bl.Append(bServiceMediation); bl.Append(", Full update="); bl.Append(bFullSync); CServiceMediation.GetDefaultInstance().Trace.Write(bl.ToString(), ALTRACE.DEBUG, ALTRACE.POLLING, ALTRACE.TRACE); CSnmpProxyConfiguration.GetInstance().IdProxyConfiguré = nIdProxy; if (bConfigProxy) { CSnmpProxyConfiguration.GetInstance().MiseAJour(false); } if (bServiceMediation) { CServiceMediation.GetDefaultInstance().Configuration.MettreAJour(bFullSync, true); } } else { ISnmpConnexion cnxDisttante = GetConnexionDistante(); if (cnxDisttante != null) { cnxDisttante.NotifyProxyNecessiteMAJ(nIdProxy, bConfigProxy, bServiceMediation, bFullSync); } } }
//-------------------------------------------------------------------- public void UpdateAgentIpFromMediation(string strAgentId, string strNewIp, bool bUpdateTimosDb) { if (m_traiteurAlarme != null) { m_traiteurAlarme.UpdateAgentIpFromMediation(strAgentId, strNewIp, bUpdateTimosDb); } else { CServiceMediation service = CServiceMediation.GetDefaultInstance(); if (service != null && service.Configuration != null && service.Configuration.DataBase != null) { CAgentSnmpPourSupervision agent = service.Configuration.DataBase.GetEntite <CAgentSnmpPourSupervision>(strAgentId); if (agent != null) { agent.Ip = strNewIp; } } foreach (CSnmpProxy proxy in CSnmpProxyConfiguration.GetInstance().GetProxiesPrecedents()) { ISnmpConnexion cnx = proxy.GetConnexion(); cnx.UpdateAgentIpFromMediation(strAgentId, strNewIp, bUpdateTimosDb); } } }
private void m_lnkServiceMediation_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { CFormVisualisationDataSet.AfficheDonnees(CServiceMediation.GetDefaultInstance().Configuration.DataBase); }
//----------------------------------------------- public CTrapInstance(CInterrogateurSnmp snmpAgent) { m_interrogateurSNMP = snmpAgent; m_dbPourAlarmes.EnforceConstraints = false; m_dbPourAlarmes.AddFournisseurElementsManquants(CServiceMediation.GetDefaultInstance().Configuration); }
//------------------------------------------------------------------ private static void m_timerPolling_Elapsed(object sender, ElapsedEventArgs e) { if (m_bIsPolling) { return; } m_bIsPolling = true; if (!m_bDemandeInterruption) { lock (typeof(CLockerPollingList)) { DateTime dtPoll = DateTime.Now.AddSeconds(-2); DateTime dtDebug = DateTime.Now; int nNbPooled = 0; List <CDonneeCumuleeTransportable> lstDonnees = new List <CDonneeCumuleeTransportable>(); if (m_configuration == null || m_configuration.DataBase == null) { return; } IEnumerable <CInfoPolling> lstToPoll = m_pollingList.GetElementsAPoller(DateTime.Now); if (lstToPoll.Count() > 0) { CServiceMediation.GetDefaultInstance().Trace.Write("Poll " + lstToPoll.Count() + " elements", ALTRACE.POLLING); } foreach (CInfoPolling info in lstToPoll) { if (m_bDemandeInterruption) { break; } /*CSnmpPollingSetup setup = new CSnmpPollingSetup(m_configuration.DataBase); * if (setup.ReadIfExist(info.IdPollingSetup)) * { * CDonneeCumuleeTransportable donnee = setup.GetDonneeTransportable(); * if (donnee != null) * { * lstDonnees.Add(donnee); * info.LastPollDate = dtPoll; * info.NextPollDate = dtPoll.AddMinutes(setup.FrequenceMinutes); * nNbPooled++; * } * } * else*/ { CSnmpHotelPollingSetup hotelSetup = new CSnmpHotelPollingSetup(m_configuration.DataBase); if (hotelSetup.ReadIfExist(info.IdHotelPollingSetup)) { hotelSetup.DoPoll(); info.LastPollDate = dtPoll; info.NextPollDate = dtPoll.AddMilliseconds(hotelSetup.FrequenceMinutes); nNbPooled++; } else { m_pollingList.RemoveElement(info); } } } if (nNbPooled > 0) { TimeSpan sp = DateTime.Now - dtDebug; Console.WriteLine("Pool1 " + nNbPooled + " : " + sp.TotalMilliseconds.ToString()); } CSnmpConnexion.DefaultInstance.SendDonneesPooled(lstDonnees); if (nNbPooled > 0) { TimeSpan sp = DateTime.Now - dtDebug; Console.WriteLine("Pool2 " + nNbPooled + " : " + sp.TotalMilliseconds.ToString()); } } } m_bIsPolling = false; m_bDemandeInterruption = false; }
private void Form1_Load(object sender, EventArgs e) { CSnmpProxyConfiguration.GetInstance().MiseAJour(true); CServiceMediation.GetDefaultInstance().Configuration.MettreAJour(true, true); }
private void button1_Click(object sender, EventArgs e) { m_dataGrid.DataSource = null; m_dataGrid.DataSource = CServiceMediation.GetDefaultInstance().Configuration.DataBase; }