public void Check(string Name, ref Label l)
 {
     try
     {
         string ris    = ArpHelper.FindIpAddressByMacAddress(Name);
         Ping   pinger = new Ping();
         if (ris != null)
         {
             if (pinger.Send(ris).Status == IPStatus.Success)
             {
                 l.Text      = "On--> " + ris;
                 l.ForeColor = Color.DarkGreen;
             }
             else
             {
                 l.Text      = "Offline";
                 l.ForeColor = Color.Orange;
             }
         }
         else
         {
             l.Text      = "Offline";
             l.ForeColor = Color.Orange;
         }
     }
     catch (Exception e)
     {
         l.Text      = "Errore: " + e.Message;
         l.ForeColor = Color.DarkRed;
     }
 }
Beispiel #2
0
        public static string FindIpAddressByMacAddress(string macAddress)
        {
            List <ArpEntity> arpEntities = new ArpHelper().GetArpResult();

            return(arpEntities.FirstOrDefault(a => a.MacAddress == macAddress)?.Ip);
        }