Beispiel #1
0
 /// <summary>
 /// 根据用户ip地址查询用静态服务器地址
 /// </summary>
 /// <param name="userIp">用户Ip</param>
 /// <returns>城市</returns>
 public static string GetStaticUrl(string userIp)
 {
     URLARRAY urls = new URLARRAY();
     DeserializerXML(@"F:\project\trunk\webapp\Web\Maps\StaticUrl.xml", ref urls);
     List<Staticurl> list = urls.urls;//从xml文件中取出数据放入list中
     IPScanner objScan = new IPScanner();
     objScan.DataPath = @"F:\project\trunk\webapp\service\qqwry.dat";
     objScan.IP = userIp;
     string addre = objScan.IPLocation();
     string country = objScan.Country;
     string name = "中国";
     string err = objScan.ErrMsg;
     string url = null;
     foreach (var item in list)
     {
         if (country.Equals(item.name))
         {
             url = item.src;
             break;
         }
     }
     if (String.IsNullOrEmpty(url))
     {
         foreach (var item in list)
         {
             if (name.Equals(item.name))
             {
                 url = item.src;
                 break;
             }
         }
     }
     return url;
 }
Beispiel #2
0
        /// <summary>
        /// 根据用户ip地址查询用静态服务器地址
        /// </summary>
        /// <param name="userIp">用户Ip</param>
        /// <returns>城市</returns>
        public static string GetStaticUrl(string userIp)
        {
            URLARRAY urls = new URLARRAY();

            DeserializerXML(@"F:\project\trunk\webapp\Web\Maps\StaticUrl.xml", ref urls);
            List <Staticurl> list    = urls.urls;//从xml文件中取出数据放入list中
            IPScanner        objScan = new IPScanner();

            objScan.DataPath = @"F:\project\trunk\webapp\service\qqwry.dat";
            objScan.IP       = userIp;
            string addre   = objScan.IPLocation();
            string country = objScan.Country;
            string name    = "中国";
            string err     = objScan.ErrMsg;
            string url     = null;

            foreach (var item in list)
            {
                if (country.Equals(item.name))
                {
                    url = item.src;
                    break;
                }
            }
            if (String.IsNullOrEmpty(url))
            {
                foreach (var item in list)
                {
                    if (name.Equals(item.name))
                    {
                        url = item.src;
                        break;
                    }
                }
            }
            return(url);
        }