Exemplo n.º 1
0
        public static int GetCityId(int currentRegionId)
        {
            int result = 0;

            Hidistro.Entities.Store.RegionInfo region     = RegionHelper.GetRegion(currentRegionId, true);
            Hidistro.Entities.Store.RegionInfo regionInfo = null;
            if (region != null)
            {
                if (region.Depth == 4)
                {
                    regionInfo = RegionHelper.GetRegion(region.ParentRegionId, true);
                    if (regionInfo != null)
                    {
                        result = regionInfo.ParentRegionId;
                    }
                }
                if (region.Depth == 3)
                {
                    result = region.ParentRegionId;
                }
                else if (region.Depth == 2)
                {
                    result = currentRegionId;
                }
            }
            return(result);
        }
Exemplo n.º 2
0
 public static Dictionary <int, string> GetStreets(int countryId, bool containDel = true)
 {
     Hidistro.Entities.Store.RegionInfo region = RegionHelper.GetRegion(countryId, true);
     if (region != null)
     {
         Dictionary <int, string> childList = RegionHelper.GetChildList(countryId, containDel);
         if (childList == null || childList.Count == 0)
         {
             IList <Hidistro.Entities.Store.RegionInfo> streetsOfCity = new RegionDao().GetStreetsOfCity(region.ParentRegionId, containDel);
             if (streetsOfCity == null || streetsOfCity.Count == 0)
             {
                 return(new Dictionary <int, string>());
             }
             IList <Hidistro.Entities.Store.RegionInfo> allRegions = RegionHelper.GetAllRegions();
             allRegions = allRegions.Concat(streetsOfCity).ToList();
             HiCache.Remove("FileCache-Regions");
             HiCache.Insert("FileCache-Regions", allRegions);
             streetsOfCity = ((!containDel) ? (from r in streetsOfCity
                                               where r.ParentRegionId == countryId && !r.IsDel
                                               select r).ToList() : (from r in streetsOfCity
                                                                     where r.ParentRegionId == countryId
                                                                     select r).ToList());
             childList = new Dictionary <int, string>();
             foreach (Hidistro.Entities.Store.RegionInfo item in streetsOfCity)
             {
                 childList.Add(item.RegionId, item.RegionName);
             }
             return(childList);
         }
         return(childList);
     }
     return(null);
 }
Exemplo n.º 3
0
        public static IList <Hidistro.Entities.Store.RegionInfo> GetRegionChildList(int parentRegionId, bool containDel = true)
        {
            Dictionary <int, string> dictionary = new Dictionary <int, string>();
            IList <Hidistro.Entities.Store.RegionInfo> allRegions = RegionHelper.GetAllRegions();
            IList <Hidistro.Entities.Store.RegionInfo> list       = (!containDel) ? (from a in allRegions
                                                                                     where a.ParentRegionId == parentRegionId && !a.IsDel
                                                                                     select a).ToList() : (from a in allRegions
                                                                                                           where a.ParentRegionId == parentRegionId
                                                                                                           select a).ToList();

            if (list == null || list.Count == 0)
            {
                Hidistro.Entities.Store.RegionInfo region = RegionHelper.GetRegion(parentRegionId, containDel);
                if (region.Depth == 3)
                {
                    IList <Hidistro.Entities.Store.RegionInfo> streetsOfCity = new RegionDao().GetStreetsOfCity(region.ParentRegionId, containDel);
                    if (streetsOfCity == null || streetsOfCity.Count == 0)
                    {
                        return(list);
                    }
                    IList <Hidistro.Entities.Store.RegionInfo> allRegions2 = RegionHelper.GetAllRegions();
                    allRegions2 = allRegions2.Concat(streetsOfCity).ToList();
                    HiCache.Remove("FileCache-Regions");
                    HiCache.Insert("FileCache-Regions", allRegions2);
                    return((from r in streetsOfCity
                            where r.ParentRegionId == parentRegionId
                            select r).ToList());
                }
                return(list);
            }
            return(list);
        }
Exemplo n.º 4
0
        private static Hidistro.Entities.Store.RegionInfo FindNodeByRegionName(string regionName, int depth)
        {
            IList <Hidistro.Entities.Store.RegionInfo> allRegions = RegionHelper.GetAllRegions();

            Hidistro.Entities.Store.RegionInfo regionInfo = null;
            try
            {
                regionInfo = (from r in allRegions
                              where r.RegionName.StartsWith(regionName) && r.Depth == depth
                              select r).First();
            }
            catch
            {
            }
            if (regionInfo == null)
            {
                regionInfo = new RegionDao().GetRegionByRegionName(regionName, depth);
                if (regionInfo != null && regionInfo.Depth == 4)
                {
                    Hidistro.Entities.Store.RegionInfo region = RegionHelper.GetRegion(regionInfo.ParentRegionId, true);
                    if (region != null)
                    {
                        IList <Hidistro.Entities.Store.RegionInfo> streetsOfCity = new RegionDao().GetStreetsOfCity(region.ParentRegionId, true);
                        if (streetsOfCity != null && streetsOfCity.Count > 0)
                        {
                            IList <Hidistro.Entities.Store.RegionInfo> allRegions2 = RegionHelper.GetAllRegions();
                            allRegions2 = allRegions2.Concat(streetsOfCity).ToList();
                            HiCache.Remove("FileCache-Regions");
                            HiCache.Insert("FileCache-Regions", allRegions2);
                        }
                    }
                }
            }
            return(regionInfo);
        }
Exemplo n.º 5
0
        public static int GetTopRegionId(int currentRegionId, bool isEndOnProvince = true)
        {
            Hidistro.Entities.Store.RegionInfo region = RegionHelper.GetRegion(currentRegionId, true);
            if (region == null)
            {
                return(0);
            }
            int result = currentRegionId;
            int num    = 0;

            if (isEndOnProvince)
            {
                num = 1;
            }
            if (region.Depth > num)
            {
                Hidistro.Entities.Store.RegionInfo region2 = RegionHelper.GetRegion(region.ParentRegionId, true);
                while (region2 != null && region2.Depth >= num)
                {
                    result  = region2.RegionId;
                    region2 = RegionHelper.GetRegion(region2.ParentRegionId, true);
                }
            }
            return(result);
        }
Exemplo n.º 6
0
        public static string GetFullPath(int currentRegionId, bool isEndOnProvince = true)
        {
            Hidistro.Entities.Store.RegionInfo region = RegionHelper.GetRegion(currentRegionId, true);
            if (region == null)
            {
                return(string.Empty);
            }
            int    regionId = region.RegionId;
            string text     = regionId.ToString();
            int    num      = 0;

            if (isEndOnProvince)
            {
                num = 1;
            }
            if (region.Depth > num)
            {
                Hidistro.Entities.Store.RegionInfo region2 = RegionHelper.GetRegion(region.ParentRegionId, true);
                while (region2 != null && region2.Depth >= num)
                {
                    regionId = region2.RegionId;
                    text     = regionId.ToString() + "," + text;
                    region2  = RegionHelper.GetRegion(region2.ParentRegionId, true);
                }
            }
            return(text);
        }
Exemplo n.º 7
0
        public static Hidistro.Entities.Store.RegionInfo GetRegion(int regionId, bool containDel = true)
        {
            IList <Hidistro.Entities.Store.RegionInfo> allRegions = RegionHelper.GetAllRegions();

            Hidistro.Entities.Store.RegionInfo regionInfo = null;
            try
            {
                regionInfo = ((!containDel) ? (from r in allRegions
                                               where r.RegionId == regionId && !r.IsDel
                                               select r).First() : (from r in allRegions
                                                                    where r.RegionId == regionId
                                                                    select r).First());
            }
            catch
            {
            }
            if (regionInfo == null)
            {
                regionInfo = new RegionDao().Get <Hidistro.Entities.Store.RegionInfo>(regionId);
                if (regionInfo != null && regionInfo.Depth == 4)
                {
                    Hidistro.Entities.Store.RegionInfo region = RegionHelper.GetRegion(regionInfo.ParentRegionId, true);
                    if (region != null)
                    {
                        IList <Hidistro.Entities.Store.RegionInfo> streetsOfCity = new RegionDao().GetStreetsOfCity(region.ParentRegionId, containDel);
                        if (streetsOfCity != null && streetsOfCity.Count > 0)
                        {
                            IList <Hidistro.Entities.Store.RegionInfo> allRegions2 = RegionHelper.GetAllRegions();
                            allRegions2 = allRegions2.Concat(streetsOfCity).ToList();
                            HiCache.Remove("FileCache-Regions");
                            HiCache.Insert("FileCache-Regions", allRegions2);
                        }
                    }
                }
            }
            return(regionInfo);
        }
Exemplo n.º 8
0
        public static string GetFullRegion(int currentRegionId, string separator, bool isEndOnProvince = true, int endDpeth = 0)
        {
            Hidistro.Entities.Store.RegionInfo region = RegionHelper.GetRegion(currentRegionId, true);
            if (region == null)
            {
                return(string.Empty);
            }
            if (isEndOnProvince)
            {
                endDpeth = 1;
            }
            string text = region.RegionName;

            if (region.Depth > endDpeth)
            {
                Hidistro.Entities.Store.RegionInfo region2 = RegionHelper.GetRegion(region.ParentRegionId, true);
                while (region2 != null && region2.Depth >= endDpeth)
                {
                    text    = region2.RegionName + separator + text;
                    region2 = RegionHelper.GetRegion(region2.ParentRegionId, true);
                }
            }
            return(text);
        }