Exemplo n.º 1
0
    public System.Collections.Generic.List<NetworkVO> getN()
    {
        FVSL_LINQDataContext dbcon = new FVSL_LINQDataContext();

        List<NetworkVO> lista = new List<NetworkVO>();

        try
        {

            List<mapa_get_network_compResult> resultset = dbcon.mapa_get_network_comp().ToList();

            foreach (mapa_get_network_compResult net in resultset)
            {
                NetworkVO netw = new NetworkVO();
                EntityVO ent = new EntityVO();

                ent.id = net.Id.ToString();
                ent.name = net.Nombre;
                ent.latitude = net.Latitud.ToString();
                ent.longitude = net.Longitud.ToString();
                netw.parent = ent;
                netw.type = NetworkVO.EMP_EXTRACTOR;

                lista.Add(netw);
            }

            return lista;

        }
        catch (Exception e)
        {
            Logging.WriteError(e.StackTrace.ToString());
            return null;
        }
    }
Exemplo n.º 2
0
        /// <summary>
        /// 使用win32方式获取网络连接。获取不到名称。
        /// </summary>
        /// <returns></returns>
        public static List <NetworkVO> GetNetworkListWin32()
        {
            List <NetworkVO>           list = new List <NetworkVO>();
            ManagementClass            mc   = new ManagementClass("Win32_NetworkAdapterConfiguration");
            ManagementObjectCollection moc  = mc.GetInstances();

            foreach (ManagementObject mo in moc)
            {
                PropertyDataCollection coll = mo.Properties;
                bool ipEnabled = (bool)mo["IPEnabled"];
                if (!ipEnabled)
                {
                    continue;
                }
                string description = (string)mo["Description"];
                string dnsHostName = (string)mo["DNSHostName"];
                string macAddress  = (string)mo["MACAddress"];
                string dhcpServer  = (string)mo["DHCPServer"];
                bool   dhcpEnabled = (bool)mo["DHCPEnabled"];

                string[] addresses = (string[])mo["IPAddress"];
                string[] subnets   = (string[])mo["IPSubnet"];
                string[] gateways  = (string[])mo["DefaultIPGateway"];
                string[] dnses     = (string[])mo["DNSServerSearchOrder"];

                NetworkVO v = new NetworkVO();
                v.IpEnabled = ipEnabled;
                if (addresses != null && addresses.Length > 0 && addresses[0] != null)
                {
                    v.Address = addresses[0];
                }
                if (subnets != null && subnets.Length > 0 && subnets[0] != null)
                {
                    v.SubnetMask = subnets[0];
                }
                if (gateways != null && gateways.Length > 0 && gateways[0] != null)
                {
                    v.Gateway = gateways[0];
                }
                v.DnsServers = new List <string>();
                foreach (string dns in dnses)
                {
                    v.DnsServers.Add(dns);
                }
                v.Description = description;
                v.MacAddress  = macAddress;
                v.DnsHostName = dnsHostName;
                v.DhcpServer  = dhcpServer;
                v.DhcpEnabled = dhcpEnabled;
                list.Add(v);
            }
            return(list);
        }
Exemplo n.º 3
0
    public NetworkVO getDetails(int padre)
    {
        FVSL_LINQDataContext dbcon = new FVSL_LINQDataContext();

        NetworkVO network = new NetworkVO();
        EntityVO enti = new EntityVO();

        List<EntityVO> nodos = new List<EntityVO>();

        try
        {
            enti = EntityExtractor.create(NetworkVO.COOP_EXTRACTOR).getDetails(padre);

            enti.type = NetworkVO.COOP_EXTRACTOR;

            network.type = NetworkVO.COOP_EXTRACTOR;

            network.parent = enti;

            List<mapa_get_network_nodesResult> resultset = dbcon.mapa_get_network_nodes(3, padre).ToList();

            foreach (mapa_get_network_nodesResult res in resultset)
            {
                EntityVO nodo = new EntityVO();

                nodo.id = res.id_invitada.ToString();
                nodo.name = res.nombre;
                nodo.latitude = res.latitud;
                nodo.longitude = res.longitud;
                nodo.type = NetworkVO.COOP_EXTRACTOR;

                nodos.Add(nodo);
            }

            network.nodes = nodos;

            return network;
        }
        catch (Exception e)
        {
            Logging.WriteError(e.StackTrace.ToString());
            return null;
        }
    }
Exemplo n.º 4
0
    public List<NetworkVO> getSearch(List<String> lista)
    {
        FVSL_LINQDataContext dbcon = new FVSL_LINQDataContext();

        List<NetworkVO> listain = new List<NetworkVO>();

        try
        {

            List<mapa_search_network_cooperantes_byResult> resultset = dbcon.mapa_search_network_cooperantes_by(int.Parse(lista[0]), int.Parse(lista[1]), lista[2]).ToList();

            foreach (mapa_search_network_cooperantes_byResult snet in resultset)
            {
                NetworkVO netw = new NetworkVO();
                EntityVO ent = new EntityVO();

                ent.id = snet.id_anfitriona.ToString();
                ent.name = snet.nombre;
                ent.latitude = snet.latitud.ToString();
                ent.longitude = snet.longitud.ToString();
                ent.type = NetworkVO.COOP_EXTRACTOR;
                netw.parent = ent;
                netw.type = NetworkVO.ODS_EXTRACTOR;

                listain.Add(netw);
            }

            return listain;
        }
        catch (Exception e)
        {
            Logging.WriteError(e.StackTrace.ToString());
            return null;
        }
    }
Exemplo n.º 5
0
    public List<NetworkVO> getSearch(List<String> listain)
    {
        FVSL_LINQDataContext dbcon = new FVSL_LINQDataContext();

        List<NetworkVO> lista = new List<NetworkVO>();

        try
        {

            //EMPRESAS//
            List<mapa_search_network_ods_byResult> resultset = dbcon.mapa_search_network_ods_by(int.Parse(listain[0]), int.Parse(listain[1]), listain[2]).ToList();

            foreach (mapa_search_network_ods_byResult net in resultset)
            {
                NetworkVO netw = new NetworkVO();
                EntityVO ent = new EntityVO();

                ent.id = net.id_anfitriona.ToString();
                ent.name = net.nombre;
                ent.latitude = net.latitud.ToString();
                ent.longitude = net.longitud.ToString();
                netw.parent = ent;
                netw.type = NetworkVO.ODS_EXTRACTOR;

                lista.Add(netw);
            }
            //ODS//
            List<mapa_search_network_emp_byResult> resultset1 = dbcon.mapa_search_network_emp_by(int.Parse(listain[0]), int.Parse(listain[1]), listain[2]).ToList();

            foreach (mapa_search_network_emp_byResult net1 in resultset1)
            {
                NetworkVO netw1 = new NetworkVO();
                EntityVO ent1 = new EntityVO();

                ent1.id = net1.id_anfitriona.ToString();
                ent1.name = net1.nombre;
                ent1.latitude = net1.latitud.ToString();
                ent1.longitude = net1.longitud.ToString();
                netw1.parent = ent1;
                netw1.type = NetworkVO.EMP_EXTRACTOR;

                lista.Add(netw1);
            }
            //COOPERANTES//
            List<mapa_search_network_cooperantes_byResult> resultset2 = dbcon.mapa_search_network_cooperantes_by(int.Parse(listain[0]),int.Parse(listain[1]), listain[2]).ToList();/*int.Parse(listain[1]),*/

            foreach (mapa_search_network_cooperantes_byResult net2 in resultset2)
            {
                NetworkVO netw2 = new NetworkVO();
                EntityVO ent2 = new EntityVO();

                ent2.id = net2.id_anfitriona.ToString();
                ent2.name = net2.nombre;
                ent2.latitude = net2.latitud.ToString();
                ent2.longitude = net2.longitud.ToString();
                netw2.parent = ent2;
                netw2.type = NetworkVO.COOP_EXTRACTOR;

                lista.Add(netw2);
            }

            return lista;

        }
        catch (Exception e)
        {
            Logging.WriteError(e.StackTrace.ToString());
            return null;
        }
    }
Exemplo n.º 6
0
    public List<NetworkVO> getN()
    {
        FVSL_LINQDataContext dbcon = new FVSL_LINQDataContext();

        List<NetworkVO> lista = new List<NetworkVO>();

        try
        {
            //EMPRESAS//
            List<mapa_get_network_compResult> resultset = dbcon.mapa_get_network_comp().ToList();

            foreach (mapa_get_network_compResult net in resultset)
            {
                NetworkVO netw = new NetworkVO();
                EntityVO ent = new EntityVO();

                ent.id = net.Id.ToString();
                ent.name = net.Nombre;
                ent.latitude = net.Latitud.ToString();
                ent.longitude = net.Longitud.ToString();
                netw.parent = ent;
                netw.type = NetworkVO.EMP_EXTRACTOR;

                lista.Add(netw);
            }
            //ODS//
            List<mapa_get_network_odsResult> resultset1 = dbcon.mapa_get_network_ods().ToList();

            foreach (mapa_get_network_odsResult net1 in resultset1)
            {
                NetworkVO netw1 = new NetworkVO();
                EntityVO ent1 = new EntityVO();

                ent1.id = net1.id_ods.ToString();
                ent1.name = net1.nombre;
                ent1.latitude = net1.Latitud.ToString();
                ent1.longitude = net1.Longitud.ToString();
                netw1.parent = ent1;
                netw1.type = NetworkVO.ODS_EXTRACTOR;

                lista.Add(netw1);
            }
            //COOPERANTES//
            List<mapa_get_network_coopResult> resultset2 = dbcon.mapa_get_network_coop().ToList();

            foreach (mapa_get_network_coopResult net2 in resultset2)
            {
                NetworkVO netw2 = new NetworkVO();
                EntityVO ent2 = new EntityVO();

                ent2.id = net2.id_coperante.ToString();
                ent2.name = net2.nombre;
                ent2.latitude = net2.Latitud.ToString();
                ent2.longitude = net2.Longitud.ToString();
                netw2.parent = ent2;
                netw2.type = NetworkVO.COOP_EXTRACTOR;

                lista.Add(netw2);
            }

            return lista;

        }
        catch (Exception e)
        {
            Logging.WriteError(e.StackTrace.ToString());
            return null;
        }
    }
Exemplo n.º 7
0
        /// <summary>
        /// 获取当前本地连接列表,根据网络接口类型,和操作状态
        /// </summary>
        /// <param name="type">网络接口类型</param>
        /// <param name="ipEnabled">网络接口的操作状态</param>
        public static List <NetworkVO> GetNetworkList(NetworkInterfaceType type, OperationalStatus status)
        {
            List <NetworkVO> list = new List <NetworkVO>();

            NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
            foreach (NetworkInterface adapter in adapters)
            {
                //过滤网络接口类型
                if (!NetworkInterfaceType.Unknown.Equals(type) && !type.Equals(adapter.NetworkInterfaceType))
                {
                    logger.Debug("跳过的其他类型网络,name=" + adapter.Name + ", NetworkInterfaceType=" + adapter.NetworkInterfaceType + ", OperationalStatus=" + adapter.OperationalStatus);
                    continue;
                }
                //过滤网络接口的操作状态
                if (!status.Equals(adapter.OperationalStatus))
                {
                    logger.Debug("跳过的不是上行网络,name=" + adapter.Name + ", NetworkInterfaceType=" + adapter.NetworkInterfaceType + ", OperationalStatus=" + adapter.OperationalStatus);
                    continue;
                }
                NetworkVO vo = new NetworkVO();
                vo.IpEnabled = true;
                IPInterfaceProperties property = adapter.GetIPProperties();
                vo.DnsHostName = Dns.GetHostName();//本机名
                vo.Name        = adapter.Name;
                vo.Description = adapter.Description;
                vo.Speed       = adapter.Speed;

                //macAddress
                if (adapter.GetPhysicalAddress() != null && adapter.GetPhysicalAddress().ToString().Length > 0)
                {
                    char[] mac = adapter.GetPhysicalAddress().ToString().ToCharArray();
                    vo.MacAddress = mac[0] + mac[1] + "-" + mac[2] + mac[3] + "-" + mac[4] + mac[5] + "-" + mac[6] + mac[7] + "-" + mac[8] + mac[9] + "-" + mac[10] + mac[11];
                }

                //ipAddress subnetMask
                if (property.UnicastAddresses != null && property.UnicastAddresses.Count > 0)
                {
                    foreach (UnicastIPAddressInformation ip in property.UnicastAddresses)
                    {
                        if (ip.Address.AddressFamily.Equals(AddressFamily.InterNetwork))
                        {
                            if (ip.Address != null)
                            {
                                vo.Address = ip.Address.ToString();
                            }
                            if (ip.IPv4Mask != null)
                            {
                                vo.SubnetMask = ip.IPv4Mask.ToString();
                            }
                        }
                    }
                }

                // gateway
                if (property.GatewayAddresses != null && property.GatewayAddresses.Count > 0)
                {
                    foreach (GatewayIPAddressInformation uip in property.GatewayAddresses)
                    {
                        if (uip.Address.AddressFamily.Equals(AddressFamily.InterNetwork))
                        {
                            vo.Gateway = uip.Address.ToString();
                        }
                    }
                }

                // dns server
                if (property.DnsAddresses != null && property.DnsAddresses.Count > 0)
                {
                    vo.DnsServers = new List <string>();
                    foreach (IPAddress ip in property.DnsAddresses)
                    {
                        if (ip.AddressFamily.Equals(AddressFamily.InterNetwork))
                        {
                            vo.DnsServers.Add(ip.ToString());
                        }
                    }
                }

                // dhcp server
                if (property.DhcpServerAddresses != null && property.DhcpServerAddresses.Count > 0)
                {
                    foreach (IPAddress ip in property.DhcpServerAddresses)
                    {
                        if (ip.AddressFamily.Equals(AddressFamily.InterNetwork))
                        {
                            vo.DhcpServer  = ip.ToString();
                            vo.DhcpEnabled = true;
                        }
                    }
                }
                else
                {
                    vo.DhcpEnabled = false;
                }
                list.Add(vo);
            }
            return(list);
        }