예제 #1
0
        public static bool RefreshFromSNMP(object obj)
        {
            CEquipementLogique eqpt = obj as CEquipementLogique;

            if (eqpt == null)
            {
                return(false);
            }
            CSpvEquip eqptSpv = CSpvEquip.GetObjetSpvFromObjetTimos(eqpt);

            if (eqptSpv == null)
            {
                return(false);
            }
            string strIP         = eqptSpv.AdresseIP;
            string strCommunaute = eqptSpv.CommunauteSnmp;

            CChampCustom[] lstChamps           = eqpt.TousLesChamps;
            string         strOldContexteModif = eqpt.ContexteDonnee.IdModificationContextuelle;;

            eqpt.ContexteDonnee.IdModificationContextuelle = CSpvChampCustomSNMP.c_contexteModificationRefreshFromSNMP;
            IRequeteSNMPServeur requeteurServeur = C2iFactory.GetNewObjetForSession("CRequeteSNMPServeur", typeof(IRequeteSNMPServeur), eqpt.ContexteDonnee.IdSession) as IRequeteSNMPServeur;

            foreach (CChampCustom champ in lstChamps)
            {
                CSpvChampCustomSNMP champSNMP = CSpvChampCustomSNMP.GetObjetSpvFromObjetTimos(champ);
                if (champSNMP != null && champSNMP.OID != null && champSNMP.OID.Length > 0 &&
                    champSNMP.FormuleIndex != null)
                {
                    CContexteEvaluationExpression ctxFormule = new CContexteEvaluationExpression(eqpt);
                    CResultAErreur result = champSNMP.FormuleIndex.Eval(ctxFormule);
                    if (result)
                    {
                        try
                        {
                            int             nIndex  = Convert.ToInt32(result.Data);
                            string          strOid  = champSNMP.OID + "." + nIndex.ToString();
                            CRequeteSnmpOID requete = new CRequeteSnmpOID(strIP, strCommunaute, strOid);
                            result = requeteurServeur.GetValue(requete);
                            if (result)
                            {
                                eqpt.SetValeurChamp(champ, result.Data);
                            }
                        }
                        catch {}
                    }
                }
            }
            eqpt.ContexteDonnee.IdModificationContextuelle = strOldContexteModif;
            return(true);
        }
예제 #2
0
        //--------------------------------------------------------------
        public override sc2i.common.CResultAErreur MyInitChamps()
        {
            CResultAErreur result = CResultAErreur.True;

            result = base.MyInitChamps();
            if (!result)
            {
                return(result);
            }
            m_txtFormuleIndex.Init(new CFournisseurGeneriqueProprietesDynamiques(), typeof(CEquipementLogique));
            if (ChampCustom.CodeRole != CEquipementLogique.c_roleChampCustom)
            {
                m_panelSNMP.Visible = false;
                m_champSNMP         = null;
            }
            else
            {
                m_panelSNMP.Visible = true;
                if (m_extModeEdition.ModeEdition)
                {
                    m_champSNMP = CSpvChampCustomSNMP.GetObjetSpvFromObjetTimosAvecCreation(ChampCustom);
                }
                else
                {
                    m_champSNMP = CSpvChampCustomSNMP.GetObjetSpvFromObjetTimos(ChampCustom);
                }
                if (m_champSNMP == null)
                {
                    m_panelSNMP.Visible = false;
                }
                else
                {
                    m_txtOID.Text             = m_champSNMP.OID;
                    m_txtFormuleIndex.Formule = m_champSNMP.FormuleIndex;
                }
            }

            return(result);
        }//MyInitChamps()
예제 #3
0
        //////////////////////////////////////////////////////////////////
        public static void ModificationsSNMP(
            CContexteDonnee contexte,
            Hashtable tableData,
            ref CResultAErreur result)
        {
            if (!result)
            {
                return;
            }
            DataTable table = contexte.Tables[CRelationEquipementLogique_ChampCustom.c_nomTable];

            if (table == null)
            {
                return;
            }
            ArrayList           lst = new ArrayList(table.Rows);
            IRequeteSNMPServeur requeteurServeur = null;

            foreach (DataRow row in lst)
            {
                if (row.RowState == DataRowState.Modified || row.RowState == DataRowState.Added)
                {
                    if (row[CObjetDonnee.c_champContexteModification] == DBNull.Value ||
                        (string)row[CObjetDonnee.c_champContexteModification] != CSpvChampCustomSNMP.c_contexteModificationRefreshFromSNMP)
                    {
                        CRelationEquipementLogique_ChampCustom relChamp = new CRelationEquipementLogique_ChampCustom(row);
                        CSpvChampCustomSNMP champSNMP = new CSpvChampCustomSNMP(contexte);
                        if (champSNMP.ReadIfExists(new CFiltreData(CSpvChampCustomSNMP.c_champIdChampCustomTimos + "=@1",
                                                                   (int)row[CChampCustom.c_champId])))
                        {
                            if (!champSNMP.GetOnly)
                            {
                                CSpvEquip eqptSpv = new CSpvEquip(contexte);
                                if (eqptSpv.ReadIfExists(new CFiltreData(CSpvEquip.c_champSmtEquipementLogique_Id + "=@1",
                                                                         row[CEquipementLogique.c_champId])))
                                {
                                    string strIP         = eqptSpv.AdresseIP;
                                    string strCommunaute = eqptSpv.CommunauteSnmp;
                                    if (requeteurServeur == null)
                                    {
                                        requeteurServeur = C2iFactory.GetNewObjetForSession("CRequeteSNMPServeur", typeof(IRequeteSNMPServeur), eqptSpv.ContexteDonnee.IdSession) as IRequeteSNMPServeur;
                                    }
                                    if (champSNMP != null && champSNMP.OID != null && champSNMP.OID.Length > 0 &&
                                        champSNMP.FormuleIndex != null)
                                    {
                                        CContexteEvaluationExpression ctxFormule = new CContexteEvaluationExpression(relChamp.ElementAChamps);
                                        CResultAErreur resTmp = champSNMP.FormuleIndex.Eval(ctxFormule);
                                        if (resTmp)
                                        {
                                            try
                                            {
                                                int             nIndex  = Convert.ToInt32(result.Data);
                                                string          strOid  = champSNMP.OID + "." + nIndex.ToString();
                                                CRequeteSnmpOID requete = new CRequeteSnmpOID(strIP, strCommunaute, strOid);

                                                requeteurServeur.SetValue(requete, relChamp.Valeur);
                                            }
                                            catch { }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }