From 25ebf7f9c5225fbaf77152ab2db061bad21ad168 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 21 May 2015 15:09:18 +0200 Subject: [PATCH] Fixed missing reference --- Logic/Logic.csproj | 7 ++++++- Logic/Special/DummyGeoLookup.cs | 31 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 Logic/Special/DummyGeoLookup.cs diff --git a/Logic/Logic.csproj b/Logic/Logic.csproj index 9e68995d..ca94b603 100644 --- a/Logic/Logic.csproj +++ b/Logic/Logic.csproj @@ -68,8 +68,12 @@ False ..\External Dependencies\bin\NBitcoin.dll + + ..\packages\NGeoIP.1.0.1\lib\net45\NGeoIP.dll + True + - ..\packages\RestSharp.104.2.0\lib\net4\RestSharp.dll + ..\packages\NGeoIP.1.0.1\lib\net45\RestSharp.dll True @@ -288,6 +292,7 @@ + diff --git a/Logic/Special/DummyGeoLookup.cs b/Logic/Special/DummyGeoLookup.cs new file mode 100644 index 00000000..11f6be02 --- /dev/null +++ b/Logic/Special/DummyGeoLookup.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Web; +using NGeoIP; +using NGeoIP.Client; + +namespace Swarmops.Logic.Special +{ + /// + /// The point of this class is to reference NGeoIP, so the DLL gets copied to the output folder for Site to use. + /// Kind of a kludgy hack, but works. + /// + public class DummyGeoLookup + { + public static string Lookup (string ip) + { + NGeoIP.Request request = new Request() + { + Format = Format.Json, + IP = HttpContext.Current.Request.UserHostAddress + }; + NGeoClient client = new NGeoClient(request); + NGeoIP.RawData rawData = client.Execute(); + + return rawData.CountryCode; + } + } +}