Esempio n. 1
0
 private void refreshAll()
 {
     if (connection.State == ConnectionState.Closed)
     {
         connection.Open();
     }
     allContactsBox.Items.Clear();
     foreach (IPInfo ip in IPInfo.GetIPInfo())
     {
         //localIP = ip.IpAddress.ToString();
         Console.WriteLine(ip.IPAddress.ToString());
         if (ip.IPAddress.StartsWith(globalIPStarts)) // 192. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
         {
             SqlCommand command1 = connection.CreateCommand();
             //listBox2.Items.Add(ip.IPAddress);
             command1.CommandText = "SELECT name FROM users WHERE ip=@0 AND online='online'";
             command1.Parameters.AddWithValue("@0", ip.IPAddress);
             string login = "";
             try
             {
                 login = command1.ExecuteScalar().ToString();
             }
             catch (Exception ex)
             {
             }
             if (login != "")
             {
                 allContactsBox.Items.Add(login);
             }
         }
     }
     connection.Close();
 }
Esempio n. 2
0
        /// <summary>
        /// Retrieves the IPInfo for the machine on the local network with the specified MAC Address.
        /// </summary>
        /// <param name="macAddress">The MAC Address of the IPInfo to retrieve.</param>
        /// <returns></returns>
        public static IPInfo GetIPInfo(string macAddress)
        {
            var ipinfo = (from ip in IPInfo.GetIPInfo()
                          where ip.MacAddress.ToLowerInvariant() == macAddress.ToLowerInvariant()
                          select ip).FirstOrDefault();

            return(ipinfo);
        }