示例#1
0
        /// <summary>
        /// 获取解析Add命令的参数
        /// </summary>
        /// <returns></returns>
        public List <TraceItem> CmdAddInfo()
        {
            List <TraceItem> returnList = new List <TraceItem>();

            if (null == TraceDoc)
            {
                return(null);
            }

            XmlNodeList typeNodeList = null;

            try
            {
                typeNodeList = TraceDoc.SelectNodes(@"/TraceInfo/AddTrace/ParaNode");
            }
            catch (SystemException ex)
            {
                return(null);
            }

            if (null == typeNodeList)
            {
                return(null);
            }

            foreach (XmlNode curNode in typeNodeList)
            {
                XmlAttributeCollection attributes   = curNode.Attributes;
                XmlAttribute           typeNameAttr = attributes["Oid"];
                string strOid = typeNameAttr.Value;

                XmlAttribute typeNameAttr1 = attributes["DisplayName"];
                string       displayName   = typeNameAttr1.Value;

                XmlAttribute typeNameAttr2 = attributes["Range"];
                string       range         = typeNameAttr2.Value;

                XmlAttribute typeNameAttr3 = attributes["Value"];
                string       value         = typeNameAttr3.Value;

                XmlAttribute typeNameAttr4 = attributes["Type"];
                string       type          = typeNameAttr4.Value;
                TraceItem    newItem       = new TraceItem(strOid, displayName, range, value, type);
                returnList.Add(newItem);
            }


            return(returnList);
        }
示例#2
0
        /// <summary>
        /// 获取解析get命令相关信息
        /// </summary>
        /// <returns></returns>
        public List <TraceItem> CmdGetInfo()
        {
            List <TraceItem> returnList = new List <TraceItem>();

            if (null == TraceDoc)
            {
                return(null);
            }

            XmlNodeList typeNodeList = null;

            try
            {
                typeNodeList = TraceDoc.SelectNodes(@"/TraceInfo/GetTrace/ParaNode");
            }
            catch (SystemException ex)
            {
                return(null);
            }

            if (null == typeNodeList)
            {
                return(null);
            }

            foreach (XmlNode curNode in typeNodeList)
            {
                XmlAttributeCollection attributes   = curNode.Attributes;
                XmlAttribute           typeNameAttr = attributes["Oid"];
                string    strOid  = typeNameAttr.Value;
                TraceItem newItem = new TraceItem();
                newItem.Oid = strOid;
                returnList.Add(newItem);
            }


            return(returnList);
        }
示例#3
0
        /// <summary>
        /// 下发添加命令
        /// </summary>
        /// <param name="peerAddresss"></param>
        /// <param name="nIndex"></param>
        /// <returns></returns>
        public bool AddTraceTask(string peerAddresss, int nIndex)
        {
            SnmpAgentInfo snmpAgent = GetSnmpAgent(peerAddresss, 2, 2000);
            string        index     = string.Format(".{0}", nIndex);
            int           count     = ListAddTrace.Count;

            Vb[]      vbs    = new Vb[count];
            int       curNum = 0;
            TraceItem inter  = new TraceItem();

            foreach (TraceItem item in ListAddTrace)
            {
                if ("跟踪任务类型" == item.DisplayName)
                {
                    inter = item;
                }
                if ("跟踪管理对象OID" == item.DisplayName)
                {
                    if (null != inter)
                    {
                        if ("" == item.Value)
                        {
                            item.Value = "0";
                        }
                        string curValue = CommonOid + SpcialDeal(inter.Value) + item.Value;
                        vbs[curNum] = new Vb(new Oid(CommonOid + item.Oid + index), new Oid(curValue));
                    }
                    else
                    {
                    }
                }
                else
                {
                    if ("行状态" == item.DisplayName)
                    {
                        vbs[curNum] = new Vb(new Oid(CommonOid + item.Oid + index), new Integer32(4));
                    }
                    else
                    {
                        vbs[curNum] = new Vb(new Oid(CommonOid + item.Oid + index), item.GetValue());
                    }
                }

                curNum++;
            }
            IEnumerator <Vb> getRes = null;

            try
            {
                getRes = SnmpSessionHelper.Instance.Set(snmpAgent, vbs);

                return(true);
            }
            catch (SnmpErrorStatusException snmpex)
            {
                log.Error(string.Format("启动网元{0}的删除命令失败!, 原因为:{1}", snmpAgent.PeerAddress, snmpex.Message));
            }
            catch (System.Exception ex)
            {
                log.Error(string.Format("启动网元{0}的删除命令失败!, 原因为:{1}", snmpAgent.PeerAddress, ex.Message));
            }

            return(false);
        }