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(); }
/// <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); }
/// <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); } } }