public HttpResponseMessage SaveData([FromUri] EnquirySavaQuery query) { string host_ip = Request.GetClientIpAddress(); string basePath = System.AppDomain.CurrentDomain.BaseDirectory;//纯真IP数据文件路径.. QQWry.NET.QQWryLocator2 qqWry2 = new QQWry.NET.QQWryLocator2(basePath + "\\Models\\QQWry.dat"); QQWry.NET.IPLocation ip2 = qqWry2.Query(host_ip); //查询一个IP地址 string country = ip2.Country; string email = query.email; string content = query.content; string productName = query.productName; string yourName = query.yourName; string company = query.company; string tel = query.tel; string msn = query.msn; string language = query.language; //访问语言 string recievedId = query.recievedId; //接受者 EnquiryService.EnquirySave(host_ip, email, content, productName, productName, yourName, company, tel, msn, language, country, recievedId); List <string> retList = new List <string>(); var returnObj = new ResultObject <List <string> >(); retList.Add("leave message success!"); returnObj.ReturnData = retList; returnObj.Status = ServerStatus.SaveSuccess; return(Request.CreateResponse <ResultObject <List <string> > >(HttpStatusCode.OK, returnObj)); }
public HttpResponseMessage visitorRecordSave([FromUri] VisitorRecordSaveQuery query) { string purchaserIp = Request.GetClientIpAddress(); string purchaserProduct = string.Empty; string language = string.Empty; string purchaserDomain = string.Empty; string targetEmail = string.Empty; if (!string.IsNullOrWhiteSpace(query.PurchaserProduct)) { purchaserProduct = query.PurchaserProduct; } if (!string.IsNullOrWhiteSpace(query.Language)) { language = query.Language; } if (!string.IsNullOrWhiteSpace(query.PurchaserDomain)) { purchaserDomain = query.PurchaserDomain; } if (!string.IsNullOrWhiteSpace(query.TargetEmail)) { targetEmail = query.TargetEmail; } string basePath = System.AppDomain.CurrentDomain.BaseDirectory;//纯真IP数据文件路径.. QQWry.NET.QQWryLocator2 qqWry2 = new QQWry.NET.QQWryLocator2(basePath + "\\Models\\QQWry.dat"); QQWry.NET.IPLocation ip2 = qqWry2.Query(purchaserIp); //查询一个IP地址 string puchaserCountry = ip2.Country; Business.Serives.VisitRecordService.VisitRecordSave(purchaserIp, purchaserProduct, language, puchaserCountry, purchaserDomain, targetEmail); List <string> retList = new List <string>(); var returnObj = new ResultObject <List <string> >(); //retList.Add("save record success!"); returnObj.ReturnData = retList; returnObj.Status = ServerStatus.SaveSuccess; try { return(Request.CreateResponse <ResultObject <List <string> > >(HttpStatusCode.OK, returnObj)); } catch (Exception ex) { LogHelper.Error("visitorRecordSave", ex); } return(null); }
static void Main(string[] args) { try { QQWry.NET.QQWryLocator qqWry = new QQWry.NET.QQWryLocator("qqwry.dat"); //初始化数据库文件,并获得IP记录数,通过Count可以获得 QQWry.NET.IPLocation ip = qqWry.Query("120.67.217.7"); //查询一个IP地址 Console.WriteLine("{0} {1} {2}", ip.IP, ip.Country, ip.Local); Stopwatch stopwatch = new Stopwatch(); List <string> ips = new List <string> { "218.5.3.128", "120.67.217.7", "125.78.67.175", "220.250.64.23", "218.5.3.128", "120.67.217.7", "125.78.67.175", "220.250.64.23" }; stopwatch.Start(); for (int i = 0; i < 100; i++) { foreach (string item in ips) { ip = qqWry.Query(item); // Console.WriteLine("{0} {1} {2}", ip.IP, ip.Country, ip.Local); } } stopwatch.Stop(); Console.WriteLine("查询了800次IP,QQWryLocator 花了{0} ms", stopwatch.ElapsedMilliseconds); stopwatch.Reset(); stopwatch.Start(); for (int i = 0; i < 100; i++) { foreach (string item in ips) { string s = IPLocation.IPLocation.IPLocate("qqwry.dat", item); // Console.WriteLine(s); } } stopwatch.Stop(); Console.WriteLine("查询了800次IP,IPLocation 花了{0} ms", stopwatch.ElapsedMilliseconds); } catch (Exception e) { Console.WriteLine(e.Message); } Console.Read(); }