Exemplo n.º 1
0
 public IObservable<GeoIp> getGeoLocation(String IP)
 {
     WebClient wc = new WebClient();
     var result = wc.DownloadStringTaskAsync(new Uri("http://freegeoip.net/xml/" + IP)).ToObservable();
     return result.Select(x =>
     {
         XDocument xDoc = XDocument.Parse(x);
         var res = new GeoIp()
             {
                 Ip = IP,
                 Lat = Convert.ToDouble((string)xDoc.Root.Element("Latitude")),
                 Long = Convert.ToDouble((string)xDoc.Root.Element("Longitude"))
             };
         return res;
     });
 }
Exemplo n.º 2
0
 public void SendLocation(GeoIp ip)
 {
     // Call the addNewMessageToPage method to update clients.
     Clients.All.SendLocation(ip);
 }
Exemplo n.º 3
0
 public static void SendIp(GeoIp ip)
 {
     GetGeoHub().SendMessage(ip);
 }
Exemplo n.º 4
0
 public void SendMessage(GeoIp ip)
 {
     hubProxy.Invoke("SendLocation", ip).Wait();
 }
Exemplo n.º 5
0
        public void TestEF()
        {
            using (var db = new RepoEF())
            {
                var geoIp = new GeoIp() { Ip = "66.249.76.78", Lat = 37, Long = -122 };
                db.GeoIps.Add(geoIp);
                db.SaveChanges();

                // Display all Blogs from the database
                var query = from b in db.GeoIps
                            orderby b.Ip
                            select b;

                Debug.WriteLine("All geoips in the database:");
                foreach (var item in query)
                {
                    Debug.WriteLine(item.Ip);
                }
            }
            Debug.WriteLine("Done...");
        }