Ejemplo n.º 1
0
 //----------------------------------------------------------
 public void RemoveElement(CInfoPolling info)
 {
     if (info != null)
     {
         if (m_dicIdToInfoPolling.ContainsKey(info.IdPollingSetup))
         {
             m_dicIdToInfoPolling.Remove(info.IdPollingSetup);
         }
     }
 }
Ejemplo n.º 2
0
        //----------------------------------------------------------
        //Prépare la liste des éléments à poller.
        public void UpdateFromServiceMediation(CConfigurationServiceMediation configuration)
        {
            //Permet d'éliminer les éléments qui ne font plus partie du service de médiation
            Dictionary <string, bool> dicToDelete = new Dictionary <string, bool>();

            foreach (string strId in m_dicIdToInfoPolling.Keys)
            {
                dicToDelete[strId] = true;
            }

            if (configuration == null || configuration.DataBase == null)
            {
                return;
            }

            CSnmpPollingService.InterrompPolling();
            lock (typeof(CLockerPollingList))
            {
                CListeEntitesDeMemoryDb <CAgentSnmpPourSupervision> lstAgents = new CListeEntitesDeMemoryDb <CAgentSnmpPourSupervision>(configuration.DataBase);

                /*Filtre non nécéssaire (en plus ne marche pas) : seuls les agents de ce proxy sont dans la base
                 * lstAgents.Filtre = new CFiltreMemoryDb(CSnmpProxy.c_champId + "=@1",
                 * CSnmpProxyConfiguration.GetInstance().IdProxyConfiguré.ToString());*/

                foreach (CAgentSnmpPourSupervision agent in lstAgents)
                {
                    foreach (CSnmpPollingSetup setup in agent.PollingSetups)
                    {
                        if (setup.FrequenceMinutes != 0)//Sinon, on ne prend pas
                        {
                            dicToDelete[setup.Id] = false;
                            CInfoPolling info = null;
                            if (!m_dicIdToInfoPolling.TryGetValue(setup.Id, out info))
                            {
                                info = new CInfoPolling();
                                info.IdPollingSetup            = setup.Id;
                                info.NextPollDate              = DateTime.Now;
                                m_dicIdToInfoPolling[setup.Id] = info;
                            }
                            else
                            {
                                if (info.LastPollDate == null)
                                {
                                    info.NextPollDate = DateTime.Now;
                                }
                                else
                                {
                                    info.NextPollDate = info.LastPollDate.Value.AddMinutes(setup.FrequenceMinutes);
                                }
                            }
                        }
                    }
                    foreach (CSnmpHotelPollingSetup setup in agent.HotelPollingSetups)
                    {
                        if (setup.FrequenceMinutes != 0)//Sinon, on ne prend pas
                        {
                            dicToDelete[setup.Id] = false;
                            CInfoPolling info = null;
                            if (!m_dicIdToInfoPolling.TryGetValue(setup.Id, out info))
                            {
                                info = new CInfoPolling();
                                info.IdHotelPollingSetup       = setup.Id;
                                info.NextPollDate              = DateTime.Now;
                                m_dicIdToInfoPolling[setup.Id] = info;
                            }
                            else
                            {
                                if (info.LastPollDate == null)
                                {
                                    info.NextPollDate = DateTime.Now;
                                }
                                else
                                {
                                    info.NextPollDate = info.LastPollDate.Value.AddMinutes(setup.FrequenceMinutes);
                                }
                            }
                        }
                    }
                }
                foreach (KeyValuePair <string, bool> kvToDelete in dicToDelete)
                {
                    if (kvToDelete.Value)
                    {
                        m_dicIdToInfoPolling.Remove(kvToDelete.Key);
                    }
                }
            }
        }