Exemple #1
0
            internal UnorderedTree _tree;               // The tree of that item


            /// <summary>
            /// Constructs a new Treeitem with specified data and parent
            /// </summary>
            /// <param name="data">Data of the item</param>
            /// <param name="parent">Parent of the item (another item). CAN be null (if null the item is Orphan)</param>
            internal TreeItem(object data, TreeItem parent)
            {
                _childs  = new ArrayList();
                _data    = data;
                _parents = new ArrayList();
                _tree    = null;
                // If we have a parent, the parent must have us as a child
                if (parent != null)
                {
                    _parents.Add(parent);
                    parent._childs.Add(this);
                    _tree = parent._tree;
                }
            }
        /// <summary>
        /// Gets the parent of the ID specified
        /// </summary>
        /// <param name="itemToAdd">Item to add in the list</param>
        /// <param name="child">Child of the current item to add (NULL if no child - at the 1st call)</param>
        /// <param name="currentTree">Tree where to store the items</param>
        /// <param name="searchPhyGroups">If true, only physical groups (DGRP_PHYORDER NOT NULL) will be searched</param>
        protected void GetUnitTree(StatusTreeItem itemToAdd, OTS.Framework.Collections.UnorderedTree.TreeItem child,
                                   ref OTS.Framework.Collections.UnorderedTree currentTree, bool searchPhyGroups)
        {
            CmpGroupsChildsGisDB cmp = new CmpGroupsChildsGisDB();

            if (currentTree == null)
            {
                currentTree = new OTS.Framework.Collections.UnorderedTree();
            }

            // Add the current element, find the parent
            OTS.Framework.Collections.UnorderedTree.TreeItem titem = currentTree.Add(itemToAdd);
            if (child != null)
            {
                titem.AddChild(child);
            }
            //currentList.Add (itemToAdd);

            DataTable dtParents = cmp.GetParentsGroup(itemToAdd.Id, itemToAdd.IsUnit, searchPhyGroups);

            // If the parents exists ==> recursivity
            foreach (DataRow row in dtParents.Rows)
            {
                // NOTE: Although we pass _isUnit that parameter is not longer used (its only used in the 1st iteration)
                int parentId = Convert.ToInt32(row["CGRPG_ID"]);
                int dgrpid   = Convert.ToInt32(row["DGRP_ID"]);
                int phyorder = Convert.ToInt32(row["DGRP_PHYORDER"]);

                // Next item that will be added (in next recurisvity call).
                // Note that item is a GROUP (4th and 5th ctor parameters are false) nor a UNIT, nor a GROUPS_DEF because:
                //		a) We don't add GROUPS_DEF in that phase
                //		b) UNITs cannot be parents of anything!
                StatusTreeItem item = new StatusTreeItem(parentId, dgrpid, phyorder, false, false);
                GetUnitTree(item, titem, ref currentTree, searchPhyGroups);
            }
        }