Пример #1
0
        /// <summary>
        /// Return a list of changes between this object and an old version
        /// We really aren't that interested in changes to these details just adding and deletion
        /// </summary>
        /// <param name="oldObject"></param>
        /// <returns></returns>
        public List <AuditTrailEntry> AuditChanges(AssetGroup oldObject)
        {
            AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess();

            // Construct the return list
            List <AuditTrailEntry> listChanges = new List <AuditTrailEntry>();

            // Is this a new item or an update to an existing one
            if (GroupID == 0)
            {
                AuditTrailEntry ate = new AuditTrailEntry();
                ate.Date      = DateTime.Now;
                ate.Class     = AuditTrailEntry.CLASS.location;
                ate.Type      = AuditTrailEntry.TYPE.added;
                ate.Key       = _name;
                ate.AssetID   = 0;
                ate.AssetName = "";
                ate.Username  = System.Environment.UserName;
                listChanges.Add(ate);
            }

            // Add all of these changes to the Audit Trail
            foreach (AuditTrailEntry entry in listChanges)
            {
                lwDataAccess.AuditTrailAdd(entry);
            }

            // Return the constructed list
            return(listChanges);
        }
Пример #2
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 GetSelectedGroups(UltraTreeNode parentNode)
        {
            AssetGroup assetGroup = parentNode.Tag as AssetGroup;

            // If this node is unchecked then all children are also unchecked
            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 if (parentNode.Tag is AssetGroup)
            {
                // This is an asset group - we only add if it is CHECKED (not if indeterminate)
                if (parentNode.CheckedState == CheckState.Checked)
                {
                    AssetGroup group = parentNode.Tag as AssetGroup;
                    selectedItems.Append(group.GroupID + ";");
                }

                // But in all cases (CHECKED OR INDETERMINATE) we add child groups
                foreach (UltraTreeNode childNode in parentNode.Nodes)
                {
                    // recurse if this child is a n Asset Group
                    if (childNode.Tag is AssetGroup)
                    {
                        GetSelectedGroups(childNode);
                    }
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Expand a node within the tree
        /// </summary>
        /// <param name="node"></param>
        public void ExpandNode(UltraTreeNode expandingNode)
        {
            // Nothing to do if already expanded
            if (expandingNode.HasNodes == true)
            {
                return;
            }

            //	Call BeginUpdate to prevent drawing while we are populating the control
            this.locationsTree.BeginUpdate();
            this.Cursor = Cursors.WaitCursor;

            // get the asset group and populate it
            AssetGroup expandingGroup = expandingNode.Tag as AssetGroup;

            expandingGroup.Populate(false, false, true);

            // Add the top level groups (and assets if available) to the tree
            foreach (AssetGroup group in expandingGroup.Groups)
            {
                UltraTreeNode childNode = new UltraTreeNode(null, group.Name);

                // Set the correct image for this group type
                Bitmap image = (group.GroupType == AssetGroup.GROUPTYPE.domain) ? Properties.Resources.domain16 : Properties.Resources.location_16;
                childNode.LeftImages.Add(image);

                // Set the check state of this child to mirror that of the parent
                //childNode.Override.NodeStyle = NodeStyle.CheckBoxTriState;
                childNode.CheckedState = expandingNode.CheckedState;

                // Set the tag for the node to be the AssetGroup object
                childNode.Tag = group;

                // ...and add the node to the tree
                expandingNode.Nodes.Add(childNode);
            }

            // Add any assets which have been defined outside of groups to the tree also
            foreach (Asset asset in expandingGroup.Assets)
            {
                // Create the new tree node for this asset
                UltraTreeNode childNode = new UltraTreeNode(null, asset.Name);
                childNode.LeftImages.Add(Properties.Resources.computer16);

                // Set the check state of this child to mirror that of the parent
                childNode.Override.NodeStyle = NodeStyle.CheckBox;
                childNode.CheckedState       = expandingNode.CheckedState;
                childNode.Override.ShowExpansionIndicator = ShowExpansionIndicator.Never;

                // Set the tag for assets to be the asset
                childNode.Tag = asset;
                expandingNode.Nodes.Add(childNode);
            }

            //	Restore the cursor and finish updating the tree
            this.Cursor = Cursors.Default;
            this.locationsTree.EndUpdate(true);
        }
Пример #4
0
        public void Populate(bool showByDomain, bool ignoreTopAssets, bool ignoreChildAssets)                                                   // CMD 8.4.2 Include additional parameter
        {
            LocationsDAO lwDataAccess = new LocationsDAO();

            AssetGroup.GROUPTYPE displayType = (_showByDomain) ? AssetGroup.GROUPTYPE.domain : AssetGroup.GROUPTYPE.userlocation;
            DataTable            table       = lwDataAccess.GetGroups(new AssetGroup(displayType));

            _rootAssetGroup = new AssetGroup(table.Rows[0], displayType);

            // +CMD 8.4.1 - Changes required to prevent performance issues with large databases.  We can now elect to not display assets and also
            // the tree is load on demand if we do require assets so that we only load them if required.
            //
            // If we need to show assets at the root then populate this now
            if (!ignoreTopAssets)
            {
                _rootAssetGroup.Populate(false, false, true);
            }

            // Populate all levels for this group beneath this group again optionally including assets
            _rootAssetGroup.Populate(true, true, true);

            // Load on demand is active if we are displaying child assets
            locationsTree.Override.ShowExpansionIndicator = (ignoreChildAssets) ? ShowExpansionIndicator.CheckOnDisplay : ShowExpansionIndicator.CheckOnExpand;

            // -CMD 8.4.1
            // begin updating the tree
            locationsTree.BeginUpdate();

            // Add the root node to the tree first
            try
            {
                UltraTreeNode rootNode  = new UltraTreeNode(null, _rootAssetGroup.Name);
                Bitmap        rootImage = (_showByDomain) ? Properties.Resources.domain16 : Properties.Resources.location_16;
                rootNode.Override.NodeAppearance.Image         = rootImage;
                rootNode.Override.ExpandedNodeAppearance.Image = rootImage;
                rootNode.Tag          = _rootAssetGroup;
                rootNode.CheckedState = CheckState.Unchecked;

                // ...add the children to the tree beneath it now
                AddChildNodes(rootNode, _rootAssetGroup);

                // Set the root node in the Explore view
                locationsTree.Nodes.Add(rootNode);

                // Expand the root node
                rootNode.Expanded = true;
            }
            catch (Exception ex)
            {
                //MessageBox.Show("Exception adding tree nodes in [SelectLocationsControl::AddApplicationNode], the exception text was " + ex.Message);
                logger.Error(ex.Message);
            }

            // Finished updating the tree
            locationsTree.EndUpdate();
        }
Пример #5
0
        /// <summary>
        /// This function is responsible for generating the actual data which will be displayed by the report
        /// </summary>
        protected void GenerateReportData()
        {
            // Create a string representation of the publisher filter list passed to us
            // We need to get the entire licensing information at this point
            FileSystemDAO lwDataAccess = new FileSystemDAO();
            DataTable     dataTable    = lwDataAccess.EnumerateFileSystemFiles(_filterFile);

            // Create a string representation of the publisher filter list passed to us
            // We need to get the entire licensing information at this point
            AssetGroup.GROUPTYPE displayType        = AssetGroup.GROUPTYPE.userlocation;
            DataTable            table              = new LocationsDAO().GetGroups(new AssetGroup(displayType));
            AssetGroup           _cachedAssetGroups = new AssetGroup(table.Rows[0], displayType);

            _cachedAssetGroups.Populate(true, _ignoreChildAssets, true);

            // Now apply the filter to these groups
            _cachedAssetGroups.ApplyFilters(_selectedGroups, _selectedAssets, _ignoreChildAssets);

            // Now that we have a definitive list of the assets (as objects) which we want to include in the
            // report we could really do with expanding this list so that ALL of the assets are in a single list
            // and not distributed among the publishers
            //AssetList _cachedAssetList = _cachedAssetGroups.GetAllAssets();
            //_selectedAssets = String.Empty;

            //foreach (Asset asset in _cachedAssetList)
            //{
            //    _selectedAssets += asset.Name + ";";
            //}

            //char[] charsToTrim = { ';' };
            //_selectedAssets.TrimEnd(charsToTrim);

            _selectedAssets = new AssetDAO().ConvertIdListToNames(new AssetDAO().GetSelectedAssets(), ',');

            ResetSelectedAssets();

            // ...then create InternetReportEntry objects for each returned and add to the view
            foreach (DataRow row in dataTable.Rows)
            {
                FileSystemFile file = new FileSystemFile(row);

                // Check for this being filtered by location/asset
                if (FilterRecord(file))
                {
                    AddRecord(file);
                }
            }
        }
Пример #6
0
        /// <summary>
        /// Update this Group defininition in the database
        /// </summary>
        /// <returns></returns>
        public int Update(AssetGroup oldgroup)
        {
            AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess();

            if (this._groupID == 0)
            {
                Add();
            }
            else
            {
                lwDataAccess.GroupAdd(this);
                AuditChanges(oldgroup);
            }

            return(0);
        }
Пример #7
0
        /// <summary>
        /// Apply the filters to a specific group and its descendants
        /// </summary>
        /// <param name="listFilterGroups"></param>
        /// <param name="listFilterGroups"></param>
        /// <param name="thisGroup"></param>
        /// <returns></returns>
        protected bool FilterGroup(List <string> listFilterGroups, List <string> listFilterAssets, AssetGroup thisGroup)
        {
            // is this group explitily mentioned in the filter list?
            if (listFilterGroups.Contains(thisGroup.FullName))
            {
                return(false);
            }

            // OK this group is not mentioned but we should check it's children
            for (int index = 0; index < thisGroup.Groups.Count;)
            {
                // Get the (next) child group
                AssetGroup childGroup = thisGroup.Groups[index];

                // Check to see if we need to filter it and if so remove it from the list now
                // If it is not going to be filtered then simply iterate to the next child
                if (FilterGroup(listFilterGroups, listFilterAssets, childGroup))
                {
                    thisGroup.Groups.Remove(childGroup);
                }
                else
                {
                    index++;
                }
            }

            // OK Child groups have now been handled (if any) - check to see if this group
            // should remain owing to an asset within the group being in the filter
            for (int index = 0; index < thisGroup.Assets.Count;)
            {
                Asset asset = thisGroup.Assets[index];
                if (!listFilterAssets.Contains(asset.Name))
                {
                    thisGroup.Assets.RemoveAt(index);
                }
                else
                {
                    index++;
                }
            }

            // If we have no child groups or assets left then this group should be filtered
            return((thisGroup.Groups.Count == 0) && (thisGroup.Assets.Count == 0));
        }
Пример #8
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);
                        }
                    }
                }
            }
        }
Пример #9
0
        /// <summary>
        /// This function is called to apply a filtor the list of groups and assets and remove any
        /// not included in the filter.
        /// </summary>
        /// <param name="_groupFiler"></param>
        /// <param name="_assetFilter"></param>
        public void ApplyFilters(string groupFilter, string assetFilter, bool ignoreChildAssets)
        {
            // Do not remove any groups or assets if no filters applied
            if ((groupFilter == "") && (assetFilter == ""))
            {
                return;
            }

            // Convert the input strings into lists as these are easier to manipulate
            List <string> listFilterGroups = Utility.ListFromString(groupFilter, ';', true);
            List <string> listFilterAssets = Utility.ListFromString(assetFilter, ';', true);

            // Filter the groups and assets BENEATH this one
            // Iterate through the groups identified and check to see which are in the filter
            for (int index = 0; index < this.Groups.Count;)
            {
                AssetGroup thisGroup = this.Groups[index];
                if (FilterGroup(listFilterGroups, listFilterAssets, thisGroup))
                {
                    this.Groups.RemoveAt(index);
                }
                else
                {
                    index++;
                }
            }

            // We still have to deal with the assets at this level though
            for (int index = 0; index < this.Assets.Count;)
            {
                Asset asset = this.Assets[index];
                if (!listFilterAssets.Contains(asset.Name))
                {
                    this.Assets.RemoveAt(index);
                }
                else
                {
                    index++;
                }
            }
        }
Пример #10
0
        /// <summary>
        /// This function is typically called prior to adding a new location where we have not set the
        /// parentID as we do not know it yet - in this case we need to ensure that the path to the new location
        /// has been created as we cannot create an isolated child
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        protected int ValidateParentPath(string path)
        {
            AuditWizardDataAccess lwDataAccess = new AuditWizardDataAccess();

            // We are passed the path of the item in question for whom we are checking for the existance of their
            // parent.  To do this we must build the name of that parent
            int index = path.LastIndexOf(LOCATIONDELIMITER);

            if (index == 0)
            {
                return(0);
            }

            // ...and make the name of our parent
            string ourParentPath = path.Substring(0, index);

            // Check the database for this location
            int parentID = lwDataAccess.LocationFind(ourParentPath);

            // Does our parent exist?  If so then we can create ourselves and pass this back
            if (parentID != 0)
            {
                AssetGroup ourGroup = new AssetGroup();
                ourGroup.FullName  = path;
                ourGroup.GroupType = GROUPTYPE.userlocation;
                ourGroup.ParentID  = parentID;
                ourGroup.Add();

                // ... and return the ID of the newly added group as the parent
                return(ourGroup.GroupID);
            }

            else
            {
                // Our parent did not exist - iterate back up the tree
                return(ValidateParentPath(ourParentPath));
            }
        }
Пример #11
0
        /// <summary>
        /// Add the children of this AssetGroup into the tree
        /// </summary>
        /// <param name="parentNode"></param>
        /// <param name="parentGroup"></param>
        protected void AddChildNodes(UltraTreeNode parentNode, AssetGroup parentGroup)
        {
            // first add child groups
            foreach (AssetGroup group in parentGroup.Groups)
            {
                UltraTreeNode newNode   = new UltraTreeNode(parentNode.Key + group.Name, group.Name);
                Bitmap        rootImage = (_showByDomain) ? Properties.Resources.domain16 : Properties.Resources.location_16;
                newNode.Override.NodeAppearance.Image = rootImage;
                newNode.Key          = "g_" + group.GroupID;
                newNode.Tag          = group;
                newNode.CheckedState = CheckState.Unchecked;
                parentNode.Nodes.Add(newNode);

                // recurse to add any child nodes beneath this group
                AddChildNodes(newNode, group);
            }

            // ...then add the assets for this group
            UltraTreeNode[] nodes = new UltraTreeNode[parentGroup.Assets.Count];
            UltraTreeNode   node;
            Bitmap          image;
            Asset           asset;

            for (int i = 0; i < parentGroup.Assets.Count; i++)
            {
                asset    = parentGroup.Assets[i];
                node     = new UltraTreeNode(null, asset.Name);
                node.Key = "a_" + asset.AssetID.ToString();
                image    = (_showByDomain) ? Properties.Resources.domain16 : Properties.Resources.location_16;
                node.Override.NodeAppearance.Image = (asset.StockStatus == Asset.STOCKSTATUS.disposed) ? Properties.Resources.computer_disposed_16 : Properties.Resources.computer16;
                node.Tag          = asset;
                node.CheckedState = CheckState.Unchecked;
                nodes[i]          = node;
            }

            parentNode.Nodes.AddRange(nodes);
        }
Пример #12
0
 /// <summary>
 /// return whether or not the specified AssetGroup is a child of this group
 /// </summary>
 /// <param name="childname"></param>
 /// <returns></returns>
 public AssetGroup IsChildGroup(AssetGroup group)
 {
     return(IsChildGroup(group.Name));
 }