Example #1
0
 public static IPModel GetIPInfo(string word)
 {
     if (!string.IsNullOrEmpty(word))
     {
         IPModel slt   = null;
         string  key   = "host_" + word;
         object  cache = CacheUtils.GetCache(key);
         if (cache == null)
         {
             if (RegexUtils.IsDomain(word))
             {
                 string ip = GetIPFromDomain(word);
                 slt = GetIP(ip);
             }
             else
             {
                 slt = GetIP(word);
             }
             if (slt != null)
             {
                 CacheUtils.SetCache(key, slt, new TimeSpan(0, 30, 0));
             }
         }
         else
         {
             slt = cache as IPModel;
         }
         return(slt);
     }
     return(null);
 }
Example #2
0
 public static MobileModel GetMobile(string mobile)
 {
     if (!string.IsNullOrEmpty(mobile))
     {
         MobileModel slt   = null;
         string      key   = "phone_" + mobile;
         object      cache = CacheUtils.GetCache(key);
         if (cache == null)
         {
             if (RegexUtils.IsMobile(mobile))
             {
                 string filename = HttpContext.Current.Server.MapPath("~/App_Data/MpData.dat");
                 if (mobile.Length > 7)
                 {
                     mobile = mobile.Substring(0, 7);
                 }
                 MpLocation mpl = MpLocator.GetMpLocation(filename, mobile.ToInt32());
                 slt = new MobileModel()
                 {
                     start    = mpl.NumStart.ToString(),
                     end      = mpl.NumEnd.ToString(),
                     location = mpl.Location
                 };
             }
             if (slt != null)
             {
                 CacheUtils.SetCache(key, slt, new TimeSpan(0, 30, 0));
             }
         }
         else
         {
             slt = cache as MobileModel;
         }
         return(slt);
     }
     return(null);
 }