Пример #1
0
 public void AddIpaddress(string ip)
 {
     int ia = session.Query<IpAddress>().Where(p => p.Ipstring.Equals(ip)).Count();
     if (ia > 0)
     {
         return;
     }
     else
     {
         IpAddress ianew = new IpAddress();
         ianew.Ipstring = ip;
         ianew.Iptime = DateTime.Now;
         session.Save(ianew);
         session.Flush();
     }
 }
Пример #2
0
 public bool CheckTimeIp(string ip)
 {
     IpAddress ipadd = session.Query<IpAddress>().Where(p => p.Ipstring.Equals(ip)).FirstOrDefault();
     if (ipadd == null)
     {
         IpAddress ianew = new IpAddress();
         ianew.Ipstring = ip;
         ianew.Iptime = DateTime.Now;
         session.Save(ianew);
         session.Flush();
         return true;
     }
     else
     {
         if (ipadd.Iptime < DateTime.Now.AddMinutes(-5))
         {
             ipadd.Iptime = DateTime.Now;
             session.SaveOrUpdate(ipadd);
             session.Flush();
             return true;
         }
         return false;
     }
 }