示例#1
0
        //------------------------------------------------------------------
        public CDefinitionProprieteDynamique[] GetDefinitionsChamps(CObjetPourSousProprietes objet, CDefinitionProprieteDynamique defParente)
        {
            List <CDefinitionProprieteDynamique> lstDefs = new List <CDefinitionProprieteDynamique>();

            lstDefs.AddRange(new CFournisseurGeneriqueProprietesDynamiques().GetDefinitionsChamps(objet));
            if (objet.TypeAnalyse != null && objet.TypeAnalyse == typeof(CTrapInstance))
            {
                foreach (CTrapField field in FieldsFromTrap)
                {
                    lstDefs.Add(new CDefinitionProprieteDynamiqueTrapField(field));
                }
                foreach (CTrapFieldSupplementaire field in FieldsSupplementaires)
                {
                    lstDefs.Add(new CDefinitionProprieteDynamiqueTrapFieldSupplementaire(field));
                }
                lstDefs.Add(new CDefinitionProprieteDynamiqueInterrogateurSnmp(InterrogateurSNMP));
            }
            if (objet.TypeAnalyse != null && objet.TypeAnalyse == typeof(CAgentSnmpPourSupervision))
            {
                //Ajoute les requêtes
                foreach (IRunnableEasyQuery query in TypeAgent.Queries)
                {
                    CDefinitionProprieteDynamiqueRunnableEasyQuery def = new CDefinitionProprieteDynamiqueRunnableEasyQuery(query);
                    def.Rubrique = "Queries";
                    lstDefs.Add(def);
                }

                //Ajoute les listes de types d'entités
                foreach (CTypeEntiteSnmpPourSupervision typeEntite in TypeAgent.TypesEntites)
                {
                    CDefinitionProprieteDynamiqueListeEntitesSnmp def = new CDefinitionProprieteDynamiqueListeEntitesSnmp(typeEntite);
                    def.Rubrique = "Entities";
                    lstDefs.Add(def);
                }
            }
            if (objet.TypeAnalyse == typeof(CEntiteSnmpPourSupervision))
            {
                if (defParente is CDefinitionProprieteDynamiqueListeEntitesSnmp)
                {
                    CDefinitionProprieteDynamiqueListeEntitesSnmp defListe = defParente as CDefinitionProprieteDynamiqueListeEntitesSnmp;
                    CTypeEntiteSnmpPourSupervision typeEntite = new CTypeEntiteSnmpPourSupervision(Database);
                    if (typeEntite.ReadIfExist(defListe.NomProprieteSansCleTypeChamp))
                    {
                        foreach (IChampEntiteSNMP champ in typeEntite.Champs)
                        {
                            lstDefs.Add(new CDefinitionProprieteDynamiqueChampEntiteSnmp(champ));
                        }
                    }
                }
                else
                {
                    foreach (IChampEntiteSNMP champ in TypeAgent.TousLesChampsSNMPDefinis)
                    {
                        lstDefs.Add(new CDefinitionProprieteDynamiqueChampEntiteSnmp(champ));
                    }
                }
            }
            return(lstDefs.ToArray());
        }
        //-------------------------------------------------------------------
        public void Init(CTypeEntiteSnmpPourSupervision typeEntite,
                         CTypeAgentPourSupervision typeAgent)
        {
            m_typeAgent  = typeAgent;
            m_typeEntite = typeEntite;

            InitChamps();
        }
示例#3
0
        //---------------------------------------------

        /// /////////////////////////////////////////////
        public CAgentSnmpPourSupervision GetAgentPourSupervision(CMemoryDb database, bool bAvecEntites)
        {
            if (database == null)
            {
                database = CMemoryDbPourSupervision.GetMemoryDb(ContexteDonnee);
            }
            CAgentSnmpPourSupervision agent = new CAgentSnmpPourSupervision(database);

            if (!agent.ReadIfExist(Id.ToString(), false))
            {
                agent.CreateNew(Id.ToString());
            }
            else
            if (!agent.IsToRead())
            {
                return(agent);
            }
            agent.Row[CMemoryDb.c_champIsToRead] = false;
            CTypeAgentPourSupervision typeAgent = TypeAgent.GetTypeAgentPourSupervision(database);

            agent.TypeAgent     = typeAgent;
            agent.Ip            = SnmpIp;
            agent.Timeout       = Timeout;
            agent.SnmpPort      = SnmpPort;
            agent.SnmpVersion   = SnmpVersion;
            agent.Communaute    = SnmpCommunaute;
            agent.TrapsIpString = TrapsIpsString;
            foreach (CSnmpPollingSetup setup in ParametresPolling)
            {
                CSnmpPollingSetup newSetup = database.ImporteObjet(setup, true, false) as CSnmpPollingSetup;
                newSetup.Agent = agent;
            }
            foreach (CSnmpHotelPollingSetup setup in ParametresHotelPolling)
            {
                CSnmpHotelPollingSetup newSetup = database.ImporteObjet(setup, true, false) as CSnmpHotelPollingSetup;
                newSetup.Agent = agent;
            }
            if (bAvecEntites)
            {
                foreach (CEntiteSnmp entite in EntitesSnmp)
                {
                    if (entite.EntiteSnmpParente == null)
                    {
                        CTypeEntiteSnmpPourSupervision typeEntite = typeAgent.TypesEntites.FirstOrDefault(te => te.Id == entite.TypeEntiteSnmp.Id.ToString());
                        if (typeEntite != null)
                        {
                            CEntiteSnmpPourSupervision ett = entite.GetEntitePourSupervision(typeEntite);
                            if (ett != null)
                            {
                                ett.AgentSnmp = agent;
                            }
                        }
                    }
                }
            }
            return(agent);
        }
示例#4
0
        //---------------------------------------------------------------
        private void m_lnkAddTypeEntite_LinkClicked(object sender, EventArgs e)
        {
            CTypeEntiteSnmpPourSupervision typeEntite = new CTypeEntiteSnmpPourSupervision();

            if (CFormEditTypeEntiteSnmp.EditeTypeEntite(typeEntite, m_baseHandlers))
            {
                m_baseHandlers.AddTypeEntite(typeEntite);
                FillListeTypeEntites();
            }
        }
示例#5
0
 //---------------------------------------------------------------
 private void m_wndRemoveTypeEntite_LinkClicked(object sender, EventArgs e)
 {
     if (m_wndListeHandlers.SelectedItems.Count == 1)
     {
         CTypeEntiteSnmpPourSupervision typeEntite = m_wndListeTypesEntites.SelectedItems[0] as CTypeEntiteSnmpPourSupervision;
         if (typeEntite != null)
         {
             m_baseHandlers.RemoveTypeEntite(typeEntite);
             FillListeTypeEntites();
         }
     }
 }
示例#6
0
 //---------------------------------------------------------------
 private void m_wndListeTypesEntites_DoubleClick(object sender, EventArgs e)
 {
     if (m_wndListeTypesEntites.SelectedItems.Count == 1)
     {
         CTypeEntiteSnmpPourSupervision typeEntite = m_wndListeTypesEntites.SelectedItems[0] as CTypeEntiteSnmpPourSupervision;
         if (typeEntite != null)
         {
             if (CFormEditTypeEntiteSnmp.EditeTypeEntite(typeEntite, m_baseHandlers))
             {
                 FillListeTypeEntites();
             }
         }
     }
 }
示例#7
0
        public static bool EditeTypeEntite(CTypeEntiteSnmpPourSupervision typeEntite,
                                           CTypeAgentPourSupervision typeAgent)
        {
            CFormEditTypeEntiteSnmp        form      = new CFormEditTypeEntiteSnmp();
            CTypeEntiteSnmpPourSupervision typeEdite = CCloner2iSerializable.Clone(typeEntite) as CTypeEntiteSnmpPourSupervision;

            form.m_panelEdition.Init(typeEdite, typeAgent);
            bool bResult = false;

            if (form.ShowDialog() == DialogResult.OK)
            {
                CCloner2iSerializable.CopieTo(typeEdite, typeEntite);
                bResult = true;
            }
            form.Dispose();
            return(bResult);
        }
示例#8
0
        //--------------------------------------
        public static bool EditeChamp(CChampEntiteFromQuery champ,
                                      CTypeEntiteSnmpPourSupervision typeEntite)
        {
            CFormEditChampEntiteFromQuery form = new CFormEditChampEntiteFromQuery();

            form.m_champEdite = champ;
            form.m_typeEntite = CCloner2iSerializable.Clone(typeEntite) as CTypeEntiteSnmpPourSupervision;
            bool bResult = false;

            if (form.ShowDialog() == DialogResult.OK)
            {
                bResult = true;
                CCloner2iSerializable.CopieTo(form.m_typeEntite, typeEntite);
            }
            form.Dispose();
            return(bResult);
        }
        //--------------------------------------
        public static bool EditeChamp(
            CChampEntiteFromQueryToChampCustom champToCustom,
            CTypeEntiteSnmpPourSupervision typeEntite,
            CContexteDonnee contexteDonnee)
        {
            CFormEditChampEntiteFromQueryToChampCustom form = new CFormEditChampEntiteFromQueryToChampCustom();

            form.m_contexteDonnee = contexteDonnee;
            form.m_champToCustom  = CCloner2iSerializable.Clone(champToCustom) as CChampEntiteFromQueryToChampCustom;
            form.m_champEdite     = form.m_champToCustom.Champ;
            form.m_typeEntite     = typeEntite;
            bool bResult = false;

            if (form.ShowDialog() == DialogResult.OK)
            {
                bResult = true;
                CCloner2iSerializable.CopieTo(form.m_champToCustom, champToCustom);
            }
            form.Dispose();
            return(bResult);
        }
示例#10
0
        //----------------------------------------------------------------
        public CEntiteSnmpPourSupervision GetEntitePourSupervision(CTypeEntiteSnmpPourSupervision typeEntite)
        {
            if (typeEntite == null)
            {
                return(null);
            }
            //Cherche le type d'entite
            if (typeEntite == null)
            {
                return(null);
            }

            CEntiteSnmpPourSupervision entite = new CEntiteSnmpPourSupervision(typeEntite.Database);

            if (!entite.ReadIfExist(Id.ToString(), false))
            {
                entite.CreateNew(Id.ToString());
            }
            else
            if (!entite.IsToRead())
            {
                return(entite);
            }
            entite.Row[CMemoryDb.c_champIsToRead] = false;
            entite.TypeEntite = typeEntite;
            entite.Libelle    = Libelle;
            entite.Index      = Index;
            if (SiteSupervise != null)
            {
                entite.IdSiteAssocie = SiteSupervise.DbKey;
            }
            if (EquipementLogiqueSupervise != null)
            {
                entite.IdEquipementLogiqueAssocie = EquipementLogiqueSupervise.DbKey;
                entite.IdSiteAssocie = EquipementLogiqueSupervise.Site.DbKey;
            }
            if (LienReseauSupervise != null)
            {
                entite.IdLienReseauAssocie = LienReseauSupervise.DbKey;
            }
            HashSet <int> champsCustomFaits = new HashSet <int>();

            foreach (CChampEntiteFromQueryToChampCustom champ in TypeEntiteSnmp.ChampsFromQuery)
            {
                if (champ.IdChampCustom != null)
                {
                    object val = GetValeurChamp(champ.IdChampCustom.Value);
                    entite.SetValeurChamp(champ.Champ.Id, val);
                    champsCustomFaits.Add(champ.IdChampCustom.Value);
                }
            }
            //Ajoute les champs qui ne font pas parti des champs from query
            foreach (CRelationDefinisseurChamp_ChampCustom def in TypeEntiteSnmp.RelationsChampsCustomDefinis)
            {
                if (!champsCustomFaits.Contains(def.ChampCustom.Id))
                {
                    object val = GetValeurChamp(def.ChampCustom.Id);
                    if (def.ChampCustom.TypeDonneeChamp.TypeDonnee == TypeDonnee.tObjetDonneeAIdNumeriqueAuto && val is CObjetDonneeAIdNumerique)
                    {
                        val = ((CObjetDonneeAIdNumerique)val).Id;
                    }
                    entite.SetValeurChamp(def.ChampCustom.Id.ToString(), val);
                }
            }

            //Ajoute les valeurs des champs calculés
            foreach (CFormuleNommee champ in TypeEntiteSnmp.ChampsCalculesPourMediation)
            {
                if (champ.Formule != null)
                {
                    CContexteEvaluationExpression ctx = new CContexteEvaluationExpression(this);
                    CResultAErreur result             = champ.Formule.Eval(ctx);
                    if (result && result.Data != null)
                    {
                        if (result.Data is CObjetDonneeAIdNumerique)
                        {
                            result.Data = ((CObjetDonneeAIdNumerique)result.Data).Id;
                        }
                        entite.SetValeurChamp(champ.Id, result.Data);
                    }
                }
            }
            return(entite);
        }