コード例 #1
0
ファイル: AssetGroup.cs プロジェクト: windygu/AW-master
        /// <summary>
        /// return whether or not the specified named group is already a child of this group
        /// </summary>
        /// <param name="childname"></param>
        /// <returns></returns>
        public AssetGroup IsChildGroup(string childname)
        {
            // First get a list of our current children
            AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess();
            AssetGroupList        listChildren = new AssetGroupList(lwDataAccess.GetGroups(this), _groupType);

            return(listChildren.FindGroup(childname));
        }
コード例 #2
0
        public bool GetSelectedItemsAlertMonitor(out AssetGroupList listSelectedGroups, out AssetList listSelectedAssets)
        {
            // Allocate the lists that we will return
            listSelectedGroups = new AssetGroupList();
            listSelectedAssets = new AssetList();

            // Are all nodes selected as this is SO much easier to handle as we just return TRUE to indicate that
            // all nodes have been selected - the return lists are empty
            UltraTreeNode rootNode = locationsTree.Nodes[0];

            // OK unfortunately not all nodes are selected so we now need to populate the lists based on what has
            // been selected.  Note that if a node is checked then by definition ALL assets and locations beneath that
            // node are deemed to be checked but we do not bother iterating them
            GetSelectedItems(rootNode, listSelectedGroups, listSelectedAssets);

            // return false to show that there is a selection
            return(false);
        }
コード例 #3
0
        /// <summary>
        /// Recursive routine to traverse the locations tree and build up a list of the Asset Groups and Assets
        /// which are checked
        /// </summary>
        /// <param name="parentNode"></param>
        /// <param name="listSelectedGroups"></param>
        /// <param name="listSelectedAssets"></param>
        protected void GetSelectedItems(UltraTreeNode parentNode, AssetGroupList listSelectedGroups, AssetList listSelectedAssets)
        {
            AssetGroup assetGroup = parentNode.Tag as AssetGroup;

            // is this node checked?  If so we simply add it to the groups selected and return
            if (parentNode.CheckedState == CheckState.Checked)
            {
                listSelectedGroups.Add(assetGroup);
                return;
            }

            // If this node is unchecked then all children are also unchecked
            else if (parentNode.CheckedState == CheckState.Unchecked)
            {
                return;
            }

            // Indeterminate means that some children will be checked and some won't - iterate through the
            // groups first by calling ourselves recursively for each child group

            else
            {
                foreach (UltraTreeNode childNode in parentNode.Nodes)
                {
                    // recurse if this child is a n Asset Group
                    if (childNode.Tag is AssetGroup)
                    {
                        GetSelectedItems(childNode, listSelectedGroups, listSelectedAssets);
                    }

                    // or check thge state of an asset
                    else if (childNode.Tag is Asset)
                    {
                        if (childNode.CheckedState == CheckState.Checked)
                        {
                            listSelectedAssets.Add(childNode.Tag as Asset);
                        }
                    }
                }
            }
        }
コード例 #4
0
ファイル: AssetGroup.cs プロジェクト: windygu/AW-master
        /// <summary>
        /// Delete the current location from the database
        /// </summary>
        public bool Delete()
        {
            AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess();

            // As locations are hierarchical we cannot just delete a location without first deleting ALL
            // children and we cannot do that if any of our descendants are still being referenced
            // Get a list of all of our children
            AssetGroupList children = new AssetGroupList(lwDataAccess.GetGroups(this), GroupType);

            // Loop through each child and try and delete them first before we delete ourselves - this actually
            // causes recursion through this deletion function as children may have children and so on...
            foreach (AssetGroup childGroup in children)
            {
                if (!childGroup.Delete())
                {
                    return(false);
                }
            }

            // Only now can we delete ourselves as all of our children have been handled.
            if (lwDataAccess.GroupDelete(this) != 0)
            {
                return(false);
            }

            // ...and audit the deletion
            AuditTrailEntry ate = new AuditTrailEntry();

            ate.Date      = DateTime.Now;
            ate.Class     = AuditTrailEntry.CLASS.location;
            ate.Type      = AuditTrailEntry.TYPE.deleted;
            ate.Key       = _name;
            ate.AssetID   = 0;
            ate.AssetName = "";
            ate.Username  = System.Environment.UserName;
            lwDataAccess.AuditTrailAdd(ate);
            return(true);
        }