Ejemplo n.º 1
0
        void GetDonneesObjetSnmpTableVariables(object obj, ref object[] datas)
        {
            CVarTableItem varTableItem = obj as CVarTableItem;

            if (varTableItem == null)
            {
                return;
            }

            ArrayList lst = new ArrayList();

            lst.Add(varTableItem.index);
            foreach (CSpvMibobj mibobj in varTableItem.m_lstMibObj)
            {
                string stOid   = mibobj.OidObjet.TrimEnd('.');
                string stIndex = varTableItem.index.TrimStart('.');

                CRequeteSnmpOID requeteSnmp = new CRequeteSnmpOID(
                    m_spvEquip.AdresseIP, m_spvEquip.CommunauteSnmp, stOid + "." + stIndex);
                using (CContexteDonnee ctx = new CContexteDonnee(CSc2iWin32DataClient.ContexteCourant.IdSession, true, false))
                {
                    CResultAErreur resultSnmp = requeteSnmp.GetValueSNMP(ctx);
                    if (resultSnmp != null && resultSnmp.Data != null)
                    {
                        string stValue = resultSnmp.Data.ToString();
                        lst.Add(stValue);
                    }
                    else
                    {
                        lst.Add(I.T("Not found|60074"));
                    }
                }
            }

            datas = lst.ToArray();

            return;
        }
Ejemplo n.º 2
0
        private void MajListTableVariables(CSpvMibobj mibobjTable)
        {
            List <string>                lstNomColonnes = new List <string>();
            List <CSpvMibobj>            lstSpvMibobj;
            List <CVarTableItem>         lstItems = new List <CVarTableItem>();
            List <string>                lstIndex = new List <string>();
            List <CVariableSNMPResultat> lstResult;
            string stIndexOID;

            //   select #129S#MIBOBJ_NOM, #257S#MIBOBJ_OID from  MIBOBJ \
            //						where MIBOBJ_FATHERNAME = #129S#:Name and \ 
            //							  MIBOBJ_TYPE = 'VT' and	\
            //							  MIBOBJ_VISIBLE = 1

            CListeObjetsDonnees lstMibObj = new CListeObjetsDonnees(m_spvEquip.ContexteDonnee, typeof(CSpvMibobj));

            lstMibObj.Filtre = new CFiltreData(CSpvMibobj.c_champMIBOBJ_TYPE + " = 'VT' and " +
                                               CSpvMibobj.c_champMIBOBJ_VISIBLE + " = 1 and " + CSpvMibobj.c_champMIBOBJ_FATHERNAME +
                                               "= @1", mibobjTable.NomObjetOfficiel);

            lstSpvMibobj = FillListMibobjToDisplay(lstMibObj);

            //fill lstIndex
            if (lstMibObj.Count > 0 && m_spvEquip.AdresseIP != null && m_spvEquip.AdresseIP.Length > 0 &&
                m_spvEquip.CommunauteSnmp != null && m_spvEquip.CommunauteSnmp.Length >= 0)
            {
                CRequeteSNMPDansTable requeteDansTable = new CRequeteSNMPDansTable(m_spvEquip.AdresseIP,
                                                                                   m_spvEquip.CommunauteSnmp, mibobjTable.ModuleMib.Id, mibobjTable.NomObjetOfficiel,
                                                                                   ((CSpvMibobj)(lstMibObj[0])).NomObjetOfficiel, -1);

                using (CContexteDonnee ctx = new CContexteDonnee(CSc2iWin32DataClient.ContexteCourant.IdSession, true, false))
                {
                    CResultAErreur resultSNMP = requeteDansTable.GetTableSNMP(ctx);
                    if (resultSNMP != null && resultSNMP.Data != null)
                    {
                        lstResult = resultSNMP.Data as List <CVariableSNMPResultat>;

                        foreach (CVariableSNMPResultat varRes in lstResult)
                        {
                            lstIndex.Add(varRes.Index);
                        }
                    }
                }
            }

            foreach (string index in lstIndex)
            {
                CVarTableItem varTableItem = new CVarTableItem();
                varTableItem.index       = index;
                varTableItem.m_lstMibObj = lstSpvMibobj;
                lstItems.Add(varTableItem);
            }


            lstNomColonnes.Add("Index");
            foreach (CSpvMibobj mibobj in lstMibObj)
            {
                lstNomColonnes.Add(mibobj.NomObjetUtilisateur);
            }

            m_lstTableVariables.Init(lstNomColonnes.ToArray(), lstItems.ToArray());
        }