Beispiel #1
0
        public List <CdpItem> GetCdpList()
        {
            Cdp          cdp       = new Cdp(Agent);
            CdpResultSet cdpResult = cdp.GetCdpList();

            return(cdpResult.Values.SelectMany(i => i.Values.ToList()).ToList());
        }
Beispiel #2
0
        public List <BasicInterfaceInformation> GetInterfaceInformation()
        {
            List <BasicInterfaceInformation> toRet = new List <BasicInterfaceInformation>();
            Interfaces   ifs       = new Interfaces(Agent);
            Cdp          cdp       = new Cdp(Agent);
            CdpResultSet cdpResult = cdp.GetCdpList();

            List <CdpItem> cdpList = cdpResult.Values.SelectMany(i => i.Values.ToList()).ToList();

            List <Interface> listWithVlan = ifs.ifTable.Values.ToList();

            listWithVlan.RemoveAll(i => i.ifDescr.Contains("Vlan") || i.ifDescr.Contains("Null0"));
            listWithVlan.ForEach(i => toRet.Add(BasicInterfaceInformation.ConvertInterfaceToBasicInterfaceInformation(i)));
            foreach (var item in toRet)
            {
                if (cdpList.Exists(i => i.cdpIfIndex == item.IfIndex))
                {
                    item.IfCdpExist = true;
                }
            }
            return(toRet);
        }
    private void BindPage()
    {
        string key = Request.QueryString["key"];
        //string ip = Request.QueryString["ip"];
        Device d = DataProvider.Devices.FirstOrDefault(i => i.DeviceKey == key);

        if (d != default(Device))
        {
            FinalAgent fa = new FinalAgent(d.IpAddress);
            SwitchInfo             = fa.GetBasicInformation();
            InterfaceInfo          = fa.GetInterfaceInformation();
            ddlBuilding.DataSource = DataProvider.Buildings.ToList();
            ddlBuilding.DataBind();
            SwitchBasicInformation sb = new SwitchBasicInformation()
            {
                DeviceKey = d.DeviceKey, DeviceType = d.DeviceType.DeviceTypeName, HostName = d.HostName, IPAddress = d.IpAddress
            };
            //if (SwitchInfo.Equals(sb)) { string status = "değisiklik var"; }
            SwitchInfo.DeviceKey      = d.DeviceKey;
            ddlBuilding.SelectedValue = d.BuildingId.ToString();
            List <BasicInterfaceInformation> listBif = new List <BasicInterfaceInformation>();
            d.InterfaceInformations.ToList().ForEach(i => listBif.Add(new BasicInterfaceInformation()
            {
                IfCdpExist    = i.HasCdpInfo,
                IfConnected   = i.IsConnected,
                IfDescription = i.InterfaceName,
                IfIndex       = i.InterfaceIndex,
                IfNumber      = i.PortNumber,
                IfStat        = i.IsOpen
            }));
            foreach (BasicInterfaceInformation item in InterfaceInfo)
            {
                BasicInterfaceInformation bif = listBif.FirstOrDefault(i => i.IfIndex == item.IfIndex);
                if (bif == default(BasicInterfaceInformation) ||
                    item.IfCdpExist != bif.IfCdpExist ||
                    item.IfConnected != bif.IfConnected ||
                    item.IfDescription != bif.IfDescription ||
                    item.IfIndex != bif.IfIndex ||
                    item.IfNumber != bif.IfNumber ||
                    item.IfStat != bif.IfStat)
                {
                    item.IsUpdated = true;
                }
            }
            pnlDeviceExist.Visible = true;
            #region CdpBind
            Cdp            cdp       = new Cdp(fa.Agent);
            CdpResultSet   cdpResult = cdp.GetCdpList();
            List <CdpItem> cdpLi     = cdpResult.Values.SelectMany(i => i.Values.ToList()).ToList();
            rpCdp.DataSource = cdpLi;
            rpCdp.DataBind();
            foreach (RepeaterItem item in rpCdp.Items)
            {
                Label       lblAlias   = item.FindControl("lblCdpConnectedPort") as Label;
                HiddenField hdnIfIndex = item.FindControl("hdnCdpIfIndex") as HiddenField;
                lblAlias.Text = Convert.ToString(fa.Get(String.Concat("1.3.6.1.2.1.2.2.1.2.", hdnIfIndex.Value))).Replace("FastEthernet", "Fa ").Replace("GigabitEthernet", "Gi ");
            }
            #endregion
        }
        else
        {
            throw new Exception("Device not found");
        }
        tbHostName.Text   = SwitchInfo.HostName;
        tbDeviceKey.Text  = SwitchInfo.DeviceKey;
        tbDeviceType.Text = SwitchInfo.DeviceType;
        QRCodeGenerate(SwitchInfo.DeviceKey);
        rpInterfaces.DataSource = InterfaceInfo;
        rpInterfaces.DataBind();
    }