Exemplo n.º 1
0
        /// <summary>
        /// ip地址
        /// </summary>
        /// <param name="ip"></param>
        /// <returns></returns>
        public Ipinfo Address(string ip)
        {
            Ipinfo ipinfo = new Ipinfo();

            try
            {
                DateTime start   = DateTime.Now;
                string   url     = "http://ip.taobao.com/service/getIpInfo.php";
                string   dz      = GetHttpPostResult(url + "?ip=" + ip, "UTF-8");
                DateTime end     = DateTime.Now;
                Ipvalid  ipvalid = new Ipvalid();
                ipvalid = JsonHelper.JsonDeserialize <Ipvalid>(dz);
                if (ipvalid.code == 0)
                {
                    ipvalid.data.city = ipvalid.data.city.Replace("市", "");
                    return(ipvalid.data);
                }
                else
                {
                    return(ipinfo);
                }
            }
            catch
            {
                return(ipinfo);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 通过ip地址获取,该城市对应的供应商信息 add by quxiaoshan 2015-4-17
        /// </summary>
        /// <returns></returns>
        public Sys_Branch GetBranchCityByIp(string ip)
        {
            Ipinfo     ipinfo = Address(ip);
            Sys_Branch branch = new Sys_Branch();

            if (!string.IsNullOrEmpty(ipinfo.city))
            {
                branch.LoadByCity(ipinfo.city);
            }
            else
            {
                branch.LoadByCity("北京");
            }
            return(branch);
        }