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);
        }
    }
Exemple #2
0
        public static Organizations GetAllOrganizationsAvailableAtGeography(int geographyId)
        {
            List <BasicGeography> nodeList = new List <BasicGeography>();

            nodeList.AddRange(GeographyCache.GetGeographyLine(geographyId));
            nodeList.AddRange(GeographyCache.GetGeographyTree(geographyId));

            return(FromIdentities(OrganizationCache.GetOrganizationsIdsInGeographies(nodeList.ToArray())));
        }
Exemple #3
0
 public Geographies GetLine()
 {
     return(Geographies.FromArray(GeographyCache.GetGeographyLine(Identity)));
     //return Geographies.FromArray(SwarmDb.GetDatabaseForReading().GetGeographyLine(Identity));
 }
Exemple #4
0
 public static Organizations GetOrganizationsAvailableAtGeography(int geographyId)
 {
     BasicGeography[] nodeLine = GeographyCache.GetGeographyLine(geographyId);
     return(FromIdentities(OrganizationCache.GetOrganizationsIdsInGeographies(nodeLine)));
 }