Пример #1
0
        public static string GetPath <G> (long groupId, CacheEntityCollection <G> cache) where G : GroupBase <G>, ICacheableEntity <G>, new ()
        {
            if (groupId < 0)
            {
                return(null);
            }

            cache.EnsureCompleteLoad();
            G g = cache.GetById(groupId);

            StringBuilder ret = new StringBuilder();

            while (g != null)
            {
                ret.Insert(0, g.name);
                ret.Insert(0, pathSeparator);
                g = g.parent ?? cache.GetByCode(g.ParentCode);
            }

            return(ret.ToString());
        }
Пример #2
0
        protected override void GetGroupTree()
        {
            if (!string.IsNullOrEmpty(code))
            {
                List <LocationsGroup> groups = new List <LocationsGroup> {
                    this
                };

                StringBuilder error = new StringBuilder();
                try {
                    error.Append("\nBefore complete load: " + cache);
                    cache.EnsureCompleteLoad();
                    error.Append("\nAfter complete load: " + cache);
                    groups.AddRange(cache.Select(ce => ce.Value.Entity).Where(g => g.ParentCode == code));
                } catch (Exception ex) {
                    throw new Exception("Error while getting the group tree: " + error, ex);
                }

                MakeGroupTree(groups, (code.Length / 3) - 1);
            }
        }