Ejemplo n.º 1
0
        public static bool HasChild(int regionId, int depth)
        {
            if (depth < 0 || depth > 4)
            {
                return(false);
            }
            switch (depth)
            {
            case 0:
                return(true);

            case 4:
                return(false);

            default:
            {
                IList <Hidistro.Entities.Store.RegionInfo> allRegions = RegionHelper.GetAllRegions();
                IList <Hidistro.Entities.Store.RegionInfo> list       = (from r in allRegions
                                                                         where r.ParentRegionId == regionId
                                                                         select r).ToList();
                if (list == null || list.Count == 0)
                {
                    return(false);
                }
                return(true);
            }
            }
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
 }
Ejemplo 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);
        }
Ejemplo n.º 5
0
        public static IList <Hidistro.Entities.Store.RegionInfo> GetAllProvinceLists(bool containDel = true)
        {
            IList <Hidistro.Entities.Store.RegionInfo> allRegions = RegionHelper.GetAllRegions();

            if (containDel)
            {
                return((from r in allRegions
                        where r.Depth == 1
                        select r).ToList());
            }
            return((from r in allRegions
                    where r.Depth == 1 && !r.IsDel
                    select r).ToList());
        }
Ejemplo n.º 6
0
        public static Dictionary <int, string> GetRegions()
        {
            Dictionary <int, string> dictionary = new Dictionary <int, string>();
            IList <Hidistro.Entities.Store.RegionInfo> allRegions = RegionHelper.GetAllRegions();
            IList <Hidistro.Entities.Store.RegionInfo> list       = (from r in allRegions
                                                                     where r.Depth == 0
                                                                     select r).ToList();

            foreach (Hidistro.Entities.Store.RegionInfo item in list)
            {
                int regionId = item.RegionId;
                dictionary.Add(item.RegionId, item.RegionName);
            }
            return(dictionary);
        }
Ejemplo n.º 7
0
        public static IDictionary <int, string> GetAllProvinces(bool containDel = true)
        {
            IDictionary <int, string> dictionary = new Dictionary <int, string>();
            IList <Hidistro.Entities.Store.RegionInfo> allRegions = RegionHelper.GetAllRegions();
            IList <Hidistro.Entities.Store.RegionInfo> list       = (!containDel) ? (from r in allRegions
                                                                                     where r.Depth == 1 && !r.IsDel
                                                                                     select r).ToList() : (from r in allRegions
                                                                                                           where r.Depth == 1
                                                                                                           select r).ToList();

            foreach (Hidistro.Entities.Store.RegionInfo item in list)
            {
                int regionId = item.RegionId;
                if (!dictionary.ContainsKey(item.RegionId))
                {
                    dictionary.Add(item.RegionId, item.RegionName);
                }
            }
            return(dictionary);
        }
Ejemplo n.º 8
0
        private static Dictionary <int, string> GetChildList(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)
            {
                return(dictionary);
            }
            foreach (Hidistro.Entities.Store.RegionInfo item in list)
            {
                if (item.RegionId > 0 && !dictionary.ContainsKey(item.RegionId))
                {
                    dictionary.Add(item.RegionId, item.RegionName);
                }
            }
            return(dictionary);
        }
Ejemplo n.º 9
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);
        }