예제 #1
0
    private void PopulateGeographies()
    {
        Person    currentUser = Person.FromIdentity(Int32.Parse(HttpContext.Current.User.Identity.Name));
        Authority authority   = currentUser.GetAuthority();

        Organization org = Organization.FromIdentity(Convert.ToInt32(DropOrganizations.SelectedValue));

        Geographies geoList = authority.GetGeographiesForOrganization(org);

        geoList = geoList.RemoveRedundant();
        geoList = geoList.FilterAbove(Geography.FromIdentity(org.AnchorGeographyId));

        if (org.Identity == Organization.SandboxIdentity)
        {
            geoList = Geographies.FromSingle(Geography.Root);
        }

        this.DropGeographies.Items.Clear();

        foreach (Geography nodeRoot in geoList)
        {
            Geographies nodeTree = nodeRoot.GetTree();

            foreach (Geography node in nodeTree)
            {
                string nodeLabel = node.Name;

                for (int loop = 0; loop < node.Generation; loop++)
                {
                    nodeLabel = "|-- " + nodeLabel;
                }
                DropGeographies.Items.Add(new ListItem(nodeLabel, node.GeographyId.ToString()));
            }
        }
    }
예제 #2
0
    private void Populate()
    {
        Geography wasSelectedGeo = this.SelectedGeography;

        Tree.Nodes.Clear();

        if (roots == null)
        {
            roots = Geographies.FromSingle(Geography.Root);
        }

        RadTreeNode topNode = new RadTreeNode("", "");


        foreach (Geography root in roots)
        {
            Geographies geos = root.GetTree();

            // We need a real f*****g tree structure.

            Dictionary <int, Geographies> lookup = new Dictionary <int, Geographies>();

            foreach (Geography geo in geos)
            {
                if (!lookup.ContainsKey(geo.ParentIdentity))
                {
                    lookup[geo.ParentIdentity] = new Geographies();
                }

                lookup[geo.ParentIdentity].Add(geo);
            }
            topNode.Nodes.Add(RecursiveAdd(lookup, geos[0].ParentIdentity)[0]);
        }

        //Re-added selection of first node to avoid crash in alert activists /JL 2010-12-21
        if (roots.Count > 1)
        {
            //need the dummy root
            Tree.Nodes.Add(topNode);
            topNode.Enabled           = false;
            topNode.Expanded          = true;
            topNode.Nodes[0].Selected = true;
        }
        else
        {
            Tree.Nodes.Add(topNode.Nodes[0]);
            Tree.Nodes[0].Selected = true;
        }

        if (wasSelectedGeo != null)
        {
            SelectedGeography = wasSelectedGeo;
        }

        Tree.Nodes[0].Expanded = true;
    }
예제 #3
0
    protected void PopulateGeographies()
    {
        if (DropOrganizationsLocal.SelectedIndex >= 0)
        {
            Organization org = Organization.FromIdentity(Convert.ToInt32(DropOrganizationsLocal.SelectedValue));

            Geographies geoList = _authority.GetGeographiesForOrganization(org, RoleTypes.AllRoleTypes);

            geoList = geoList.RemoveRedundant();
            geoList = geoList.FilterAbove(Geography.FromIdentity(org.AnchorGeographyId));

            if (org.Identity == Organization.SandboxIdentity)
            {
                geoList = Geographies.FromSingle(Geography.Root);
            }

            this.DropGeographies.Items.Clear();

            foreach (Geography nodeRoot in geoList)
            {
                Geographies nodeTree = nodeRoot.GetTree();

                foreach (Geography node in nodeTree)
                {
                    string nodeLabel = node.Name;

                    for (int loop = 0; loop < node.Generation; loop++)
                    {
                        nodeLabel = "|-- " + nodeLabel;
                    }
                    if (_authority.HasPermission(Permission.CanEditLocalRoles, org.Identity, node.Identity, Authorization.Flag.Default))
                    {
                        DropGeographies.Items.Add(new ListItem(nodeLabel, node.GeographyId.ToString()));
                    }
                }
            }

            if (DropGeographies.Items.Count == 0)
            {
                AddLocalRolePanel.Visible = false;
            }
            else
            {
                AddLocalRolePanel.Visible = true;
            }
        }
    }