Ejemplo n.º 1
0
 /// <summary>
 /// Locations the info.
 /// </summary>
 /// <param name="ipAddress">The ip.</param>
 /// <returns></returns>
 public LocationInfoDto GetLocationInfo(string ipAddress)
 {
     if (ipAddress.CompareTo("::1") == 0 || ipAddress.CompareTo("127.0.0.1") == 0)
     {
         return GetLocationInfo();
     }
     else
     {
         string sinaResult;
         using (var w = new WebClient())
         {
             sinaResult = w.DownloadString("http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=xml&ip=" + ipAddress);
         }
         ArrayList sinaInfo = new ArrayList(sinaResult.Split('\t'));
         if (sinaInfo.Count > 1)
         {
             if (Convert.ToInt16(sinaInfo[0]) < 1)
             {
                 return GetLocationInfo();
             }
             else
             {
                 if (sinaInfo.Count > 7)
                 {
                     LocationInfoDto location = new LocationInfoDto();
                     location.startIP = sinaInfo[1].ToString();
                     location.endIP = sinaInfo[2].ToString();
                     location.Country = sinaInfo[3].ToString();
                     location.Province = sinaInfo[4].ToString();
                     location.City = sinaInfo[5].ToString();
                     location.ISP = sinaInfo[7].ToString();
                     return location;
                 }
                 else
                 {
                     return GetLocationInfo();
                 }
             }
         }
         else
         {
             return GetLocationInfo();
             //return LocationInfo(ip);
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Locations the info.
 /// </summary>
 /// <returns></returns>
 public LocationInfoDto GetLocationInfo()
 {
     string sinaResult;
     using (var w = new WebClient())
     {
         sinaResult = w.DownloadString("http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=xml");
     }
     ArrayList sinaInfo = new ArrayList(sinaResult.Split('\t'));
     if (sinaInfo != null && sinaInfo.Count > 7)
     {
         LocationInfoDto location = new LocationInfoDto();
         location.startIP = sinaInfo[1].ToString();
         location.endIP = sinaInfo[2].ToString();
         location.Country = sinaInfo[3].ToString();
         location.Province = sinaInfo[4].ToString();
         location.City = sinaInfo[5].ToString();
         location.ISP = sinaInfo[7].ToString();
         return location;
     }
     else
     {
         return GetLocationInfo();
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Gets the city info by sina.
 /// 从新浪IP得到,我们数据库里面的一个城市信息
 /// </summary>
 /// <param name="li">The li.</param>
 /// <returns></returns>
 public Miaow.Domain.Dto.Sys_CityInfoDto GetCityInfoBySina(LocationInfoDto li)
 {
     //edit by yjihrp 2011.8.16.13.2
     //modify:li.city == null ?"shenzhen":li.city
     var ci = cityInfoRepository.GetList().
         Where(e => e.city == (string.IsNullOrEmpty(li.City) ? "shenzhen" : li.City) && e.province == li.Province)
         .FirstOrDefault();
     return ci.ToDto();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Inits the city info.
 /// 根据名字中文名字找到当前传入省的所有城市
 /// 如果省为空则按市选
 /// 如果市为空则按省选 
 /// 两个为空则按当前IP地址选
 /// edit by yjihrp 2011.8.2.17.18
 /// </summary>
 /// <param name="province">The province.</param>
 /// <param name="city">The city.</param>
 public List<Miaow.Domain.Dto.Sys_CityInfoDto> GetCityInfoByName(LocationInfoDto li, string province, string city)
 {
     IQueryable<Miaow.Infrastructure.Data.DataSys.Sys_CityInfo> ci = null;
     //根据IP中的城市选出这个省的 其他城市哈在数据库中选哦
     if (string.IsNullOrEmpty(province) && string.IsNullOrEmpty(city))
     {
         ci = (from d in cityInfoRepository.GetList()
               where d.province == li.Province && d.city != li.City
               select d).AsQueryable();
     }
     //根据市选
     else if (string.IsNullOrEmpty(province) && !string.IsNullOrEmpty(city))
     {
         List<Miaow.Infrastructure.Data.DataSys.Sys_CityInfo> c = (from e in cityInfoRepository.GetList()
                                                                  where e.city == city
                                                                  select e).Distinct().ToList();
         if (c != null)
         {
             if (c.Count > 0)
             {
                 ci = (from d in cityInfoRepository.GetList()
                       where d.city == c[0].city && c[0].province == d.province
                       select d).AsQueryable();
             }
         }
         else
         {
             ci = (from d in cityInfoRepository.GetList()
                   where d.city == city
                   select d).AsQueryable();
         }
     }
     //根据省选
     else if (!string.IsNullOrEmpty(province) && string.IsNullOrEmpty(city))
     {
         ci = (from d in cityInfoRepository.GetList()
               where d.province == province
               select d).AsQueryable();
     }
     //根据省市选
     else
     {
         ci = (from d in cityInfoRepository.GetList()
               where d.province == province && d.city != city
               select d).AsQueryable();
     }
     return ci.ToDto().ToList();
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Inits the sight info. 根据城市得到景区
        /// 并分页
        /// 中文的省和名哦
        /// 数据库里面存的中文的名字,不是拼音
        /// </summary>
        /// <param name="li">The li.</param>
        /// <param name="currentClassId">The current class id.</param>
        /// <param name="province">The province.</param>
        /// <param name="city">The city or province.</param>
        /// <param name="type">The type.</param>
        /// <param name="pi">Index of the page.</param>
        /// <param name="take">Size of the page.</param>
        /// <param name="total">The total.</param>
        /// <param name="sortCount">The sort count.</param>
        /// <param name="topList">The top list.</param>
        /// <returns></returns>
        public List<DefaultSightInfoDto> GetSightListByProvinceOrCity(
            LocationInfoDto li, ref  int currentClassId, string province, string city,
            int? type, int? pi, int? take, ref int total, ref int sortCount,
            ref List<Miaow.Application.jq.Dto.TopClassDto> topList)
        {
            var typeList = sightClassRepository.GetList().Distinct().Select(d => d.ClassID);
            int index = (pi == null || pi < 0) ? 1 : (int)pi;
            int size = (take == null || pi < 0) ? 10 : (int)take;

            List<DefaultSightInfoDto> sightList = new List<DefaultSightInfoDto>();
            IEnumerable<Miaow.Infrastructure.Data.DataSys.Sys_SightInfo> temp = null;
            //根据传入城市
            if (string.IsNullOrEmpty(province) && !string.IsNullOrEmpty(city))
            {
                #region
                if (typeList != null && typeList.Contains((int)type))
                {
                    temp = (from d in sightInfoRepository.GetList()
                            where d.City == city && d.ClassID == type && d.IsDelete == 0
                            orderby d.ViCount descending
                            select d);
                    currentClassId = (int)type;
                }
                else
                {
                    temp = (from d in sightInfoRepository.GetList()
                            where d.City == city && d.IsDelete == 0
                            orderby d.ViCount descending
                            select d);
                    currentClassId = 0;
                }
                topList = topClassService.GetTopClassBySight(temp);
                sightList = ToPageList(addSortService.SelectSightInfo(temp), index, size);
                sortCount = addSortService.AddSortSightInfoByCity(sightList, city, index, size);
                #endregion
                total = temp.Count();
            }
            //根据当前IP中的市选择
            else if (string.IsNullOrEmpty(province) && string.IsNullOrEmpty(city))
            {
                #region

                if (typeList != null && typeList.Contains((int)type))
                {
                    temp = (from d in sightInfoRepository.GetList()
                            where d.City == li.City && d.ClassID == type && d.IsDelete == 0
                            orderby d.ViCount descending
                            select d);
                    currentClassId = (int)type;
                }
                else
                {
                    temp = (from d in sightInfoRepository.GetList()
                            where d.City == li.City && d.IsDelete == 0
                            orderby d.ViCount descending
                            select d);
                    currentClassId = 0;
                }
                topList = topClassService.GetTopClassBySight(temp);
                sightList = ToPageList(addSortService.SelectSightInfo(temp), index, size);
                sortCount = addSortService.AddSortSightInfoByCity(sightList, city, index, size);
                #endregion
                total = temp.Count();
            }
            //根据传入省
            else if (!string.IsNullOrEmpty(province) && string.IsNullOrEmpty(city))
            {
                #region

                if (typeList != null && typeList.Contains((int)type))
                {
                    temp = (from d in sightInfoRepository.GetList()
                            where d.Province == province && d.ClassID == type && d.IsDelete == 0
                            orderby d.ViCount descending
                            select d).ToList();
                    currentClassId = (int)type;
                }
                else
                {
                    temp = (from d in sightInfoRepository.GetList()
                            where d.Province == province && d.IsDelete == 0
                            orderby d.ViCount descending
                            select d).ToList();
                    currentClassId = 0;
                }
                topList = topClassService.GetTopClassBySight(temp);
                sightList = ToPageList(addSortService.SelectSightInfo(temp), index, size);
                sortCount = addSortService.AddSortSightInfoByProvince(sightList, province, (int)pi, (int)take);
                #endregion
                total = temp.Count();
            }
            //根据传入省和市选
            else
            {
                #region

                if (typeList != null && typeList.Contains((int)type))
                {
                    temp = (from d in sightInfoRepository.GetList()
                            where d.City == city && d.Province == province && d.ClassID == type && d.IsDelete == 0
                            orderby d.ViCount descending
                            select d);
                    currentClassId = (int)type;
                }
                else
                {
                    temp = (from d in sightInfoRepository.GetList()
                            where d.City == city && d.Province == province && d.IsDelete == 0
                            orderby d.ViCount descending
                            select d);
                    currentClassId = 0;
                }
                topList = topClassService.GetTopClassBySight(temp);
                sightList = ToPageList(addSortService.SelectSightInfo(temp), index, size);
                sortCount = addSortService.AddSortSightInfoByCity(sightList, city, (int)pi, (int)take);
                #endregion
                total = temp.Count();
            }
            //添加全局排序的景区
            int global = addSortService.AddSortSightInfoByGlobal(sightList, (int)pi, (int)take);
            sortCount += global;
            total += global;
            return sightList;
        }