예제 #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;
     });
 }
예제 #2
0
 public void SendLocation(GeoIp ip)
 {
     // Call the addNewMessageToPage method to update clients.
     Clients.All.SendLocation(ip);
 }
예제 #3
0
 public static void SendIp(GeoIp ip)
 {
     GetGeoHub().SendMessage(ip);
 }
예제 #4
0
 public void SendMessage(GeoIp ip)
 {
     hubProxy.Invoke("SendLocation", ip).Wait();
 }
예제 #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...");
        }