Exemplo n.º 1
0
 private IPtoDNS GetOrCreateIP(string ipaddress)
 {
     loggingDataContext db = new loggingDataContext();
     IPtoDNS ipdetails = db.IPtoDNS.Where(x => x.ipaddress.Equals(ipaddress.Trim())).FirstOrDefault();
     if (ipdetails == null || ipdetails.ID == 0) {
         ipdetails = new IPtoDNS {
             ipaddress = ipaddress.Trim(),
             dateChecked = DateTime.Now
         };
         db.IPtoDNS.InsertOnSubmit(ipdetails);
         db.SubmitChanges();
         ipdetails.LookupAsync();
     }
     return ipdetails;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Announce completion of PUT operation
 /// </summary>
 /// <param name="result"></param>
 private void LookupAsyncCompleteCallback(IAsyncResult ar)
 {
     ResolveState ioContext = (ResolveState)ar.AsyncState;
     loggingDataContext db = new loggingDataContext();
     string hostname = "unknown";
     try {
         ioContext.IPs = Dns.EndGetHostEntry(ar);
         hostname = ioContext.IPs.HostName;
     } catch { };
     IPtoDNS ip = db.IPtoDNS.Where(x => x.ID.Equals(ioContext.DnsID)).FirstOrDefault();
     if (ip != null && ip.ID > 0) {
         ip.dnsentry = hostname;
         db.SubmitChanges();
     }
     GetHostEntryFinished.Set();
 }
Exemplo n.º 3
0
 public void Log()
 {
     try {
         loggingDataContext db = new loggingDataContext();
         IPtoDNS ip = GetOrCreateIP(GetIp().ToString());
         HttpRequest req = HttpContext.Current.Request;
         APIAnalytic entry = new APIAnalytic {
             ID = Guid.NewGuid(),
             addressID = ip.ID,
             url = req.Url.OriginalString,
             method = req.Url.LocalPath,
             querystring = req.Url.Query,
             referrer = req.ServerVariables["HTTP_REFERER"],
             HttpMethod = req.HttpMethod,
             date = DateTime.Now
         };
         db.APIAnalytics.InsertOnSubmit(entry);
         db.SubmitChanges();
     } catch { }
 }