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); }
//-------------------------------------------------------------- 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()