예제 #1
0
        public NameSet GetFacilities(string pathString)
        {
            NameSet       names    = new NameSet(pathString);
            List <string> pathList = Utilities.PathStringToList(pathString);

            AdminTreeNode node = this;

            for (int i = 1; i < pathList.Count; i++)
            {
                int index = node.Children.IndexOfKey(pathList[i]);
                if (index == -1)
                {
                    return(names);
                }
                node = node.Children[index];
            }

            foreach (AdminTreeNode child in node.Children)
            {
                if (child.IsFacility)
                {
                    names.AddName(child.Name);
                }
            }

            return(names);
        }
예제 #2
0
        public void AddAdminPath(List <string> adminPath, int level)
        {
            if (level >= adminPath.Count)
            {
                return;
            }
            string region = adminPath[level];

            int index = children.IndexOfKey(region);

            if (index != -1)
            {
                children[index].AddAdminPath(adminPath, level + 1);
                return;
            }

            AdminTreeNode pathNode = new AdminTreeNode(adminPath, level);

            pathNode.parent = this;

            int pos = 0;

            for (int i = 0; i < children.Count; i++)
            {
                if (region.CompareTo(children[i].Name) < 0)
                {
                    break;
                }
                pos++;
            }

            children.Insert(pos, pathNode);
        }
예제 #3
0
        public AdminTree(CsvTable table, string level0)
        {
            root = new AdminTreeNode(level0);

            for (int row = 0; row < table.Rows; row++)
            {
                List <string> adminPath = table.GetAdminPath(row);
                root.AddAdminPath(adminPath, 1);
            }
        }
예제 #4
0
        public AdminTreeNode(List <string> adminPath, int level) : this(adminPath[level])
        {
            if (level + 1 == adminPath.Count)
            {
                return;
            }

            AdminTreeNode childNode = new AdminTreeNode(adminPath, level + 1);

            children.Add(childNode);
            childNode.parent = this;
        }
예제 #5
0
 public void AddFacility(List <string> adminPath, int level, string facility)
 {
     if (level < adminPath.Count)
     {
         string region = adminPath[level];
         int    index  = children.IndexOfKey(region);
         children[index].AddFacility(adminPath, level + 1, facility);
     }
     else
     {
         AdminTreeNode facilityNode = new AdminTreeNode(facility);
         facilityNode.IsFacility = true;
         facilityNode.parent     = this;
         int pos = children.InsertPosition(facility);
         children.Insert(pos, facilityNode);
     }
 }
예제 #6
0
 public AdminTreeNode()
 {
     this.parent     = null;
     this.children   = new AdminNodeCollection();
     this.isFacility = false;
 }