예제 #1
0
        static public BasicGeography[] GetGeographyLine(int leafGeographyId)
        {
            List <BasicGeography> result = new List <BasicGeography>();


            BasicGeography currentNode = GeographyCache.GetGeography(leafGeographyId);

            // This iterates until the zero-parentid root node is found

            while (currentNode.GeographyId != 0)
            {
                result.Add(currentNode);

                if (currentNode.ParentGeographyId != 0)
                {
                    currentNode = GeographyCache.GetGeography(currentNode.ParentGeographyId);
                }
                else
                {
                    currentNode = new BasicGeography(0, 0, string.Empty);
                }
            }

            result.Reverse();

            return(result.ToArray());
        }
예제 #2
0
        public BasicGeography[] GetGeographyLine(int leafGeographyId)
        {
            List <BasicGeography> result = new List <BasicGeography>();

            Dictionary <int, List <BasicGeography> > nodes = GetHashedGeographies();

            BasicGeography currentNode = nodes[leafGeographyId][0];

            // This iterates until the zero-parentid root node is found

            while (currentNode.GeographyId != 0)
            {
                result.Add(currentNode);

                if (currentNode.ParentGeographyId != 0)
                {
                    currentNode = nodes[currentNode.ParentGeographyId][0];
                }
                else
                {
                    currentNode = new BasicGeography(0, 0, string.Empty);
                }
            }

            result.Reverse();

            return(result.ToArray());
        }
예제 #3
0
    public RadTreeNode EnsureGeographyLoaded(int geoToLoad, int expandTree)
    {
        try
        {
            RadTreeNode nod = Tree.FindNodeByValue(geoToLoad.ToString());
            if (nod != null)
            {
                //Already loaded, just return it.
                if (expandTree == 1)
                {
                    nod.ExpandParentNodes();
                }
                return(nod);
            }

            //get the line to make sure all nodes down to the selected are loaded;
            BasicGeography[] line = GeographyCache.GetGeographyLine(geoToLoad);

            if (Tree.Nodes.Count == 0)
            {
                // Tree is empty, insert the root.
                Tree.Nodes.Add(new RadTreeNode(this.Root.Name, this.Root.Identity.ToString()));
            }
            BasicGeography        parentbg         = null;
            RadTreeNodeCollection parentCollection = null;
            nod = Tree.Nodes[0];
            foreach (BasicGeography bg in line)
            {
                nod = Tree.FindNodeByValue(bg.Identity.ToString());
                if (parentbg == null)
                {
                    if (nod != null)
                    {
                        parentbg         = bg;
                        parentCollection = nod.Nodes;
                    }
                }
                else
                {
                    // if node found that parent is already loaded
                    if (nod == null)
                    {
                        AddChildren(parentCollection, parentbg.Identity);
                        nod = Tree.FindNodeByValue(bg.Identity.ToString());
                        nod.ParentNode.ExpandMode = TreeNodeExpandMode.ClientSide;
                    }
                    nod.ParentNode.Expanded = (expandTree == 0) ? nod.ParentNode.Expanded : (expandTree < 0) ? false : true;
                    parentbg         = bg;
                    parentCollection = nod.Nodes;
                }
            }
            Tree.Nodes[0].Expanded = (expandTree == 0) ? Tree.Nodes[0].Expanded : (expandTree < 0) ? false : true;;
            return(nod);
        }
        catch
        {
            return(null);
        }
    }
예제 #4
0
        static public void SetGeographyName(int geographyId, string name)
        {
            SwarmDb.GetDatabaseForWriting().SetGeographyName(geographyId, name);
            BasicGeography geo = SwarmDb.GetDatabaseForReading().GetGeography(geographyId);
            Dictionary <int, List <BasicGeography> > hashedGeographies = GetHashedGeographies();

            hashedGeographies[geographyId][0] = geo;
        }
예제 #5
0
        public static int CountGeographyChildren(int parentGeographyId)
        {
            lock (loadCacheLock)
            {
                // Prime the cache
                BasicGeography partent = GeographyCache.GetGeography(parentGeographyId);

                return(GetHashedGeographies()[parentGeographyId].Count - 1);
            }
        }
예제 #6
0
        static public BasicGeography[] GetGeographyChildren(int parentGeographyId)
        {
            List <BasicGeography> result = new List <BasicGeography>();

            lock (loadCacheLock)
            {
                // Prime the cache
                BasicGeography partent = GeographyCache.GetGeography(parentGeographyId);

                //TODO: Possible to miss a child geography here if it was added since last cache reload.

                Dictionary <int, List <BasicGeography> > hashedGeographies = GetHashedGeographies();
                foreach (BasicGeography b in hashedGeographies[parentGeographyId])
                {
                    if (b.Identity != parentGeographyId)
                    {
                        result.Add(b);
                    }
                }
                return(result.ToArray());
            }
        }
예제 #7
0
 public static Geography FromBasic(BasicGeography basic)
 {
     return(new Geography(basic));
 }
예제 #8
0
 private Geography(BasicGeography basic)
     : base(basic)
 {
     // construction from basic
 }