Esempio n. 1
0
        /// <summary>
        /// Expand the Children for a Hardware based field
        /// </summary>
        /// <param name="field"></param>
        /// <param name="returnDictionary"></param>
        protected void ExpandHardwareFieldChildren(string field)
        {
            AuditedItemsDAO lwDataAccess = new AuditedItemsDAO();

            // Get the child CATEGORIES of this field (if any)
            DataTable categoryTable = lwDataAccess.GetAuditedItemCategories(field);

            // OK there were child CATEGORIES - recurse as we are only actually interested in VALUES beneath
            // the categories, not the categories themselves
            foreach (DataRow row in categoryTable.Rows)
            {
                string category = (string)row["_CATEGORY"];
                ExpandHardwareFieldChildren(category);
            }

            // Now check for any NAMES within this category
            DataTable namesTable = lwDataAccess.GetAuditedItemCategoryNames(field);

            // Add any NAMES into the report
            foreach (DataRow row in namesTable.Rows)
            {
                string category = (string)row["_CATEGORY"];
                string name     = (string)row["_NAME"];
                string icon     = (string)row["_ICON"];

                string fieldName = category + "|" + name;
                this.Add(new AuditDataReportColumn(AuditDataReportColumn.eFieldType.hardware
                                                   , fieldName
                                                   , GetLabelForField(fieldName)));
            }

            // If there were NO SUB-CATEGORIES and NO NAMES then simply add the field itself as it be a NAME
            // If we have no return data then just add the item itself to the dictionary
            if ((categoryTable.Rows.Count == 0) && (namesTable.Rows.Count == 0))
            {
                this.Add(new AuditDataReportColumn(AuditDataReportColumn.eFieldType.hardware, field, GetLabelForField(field)));
                return;
            }
        }
        //protected void PopulateSystemPatches(UltraTreeNode parentNode)
        //{
        //    AuditedItemsDAO lwDataAccess = new AuditedItemsDAO();
        //    DataTable categoryTable = lwDataAccess.GetAuditedItemCategories(parentNode.Key);
        //    //UltraTreeNode[] categoryNodes = new UltraTreeNode[categoryTable.Rows.Count];

        //    // Iterate through the returned rows and add the text and icon to the tree
        //    // All the returned items are categories
        //    foreach (DataRow row in categoryTable.Rows)
        //    {
        //        string category = (string)row["_CATEGORY"];
        //        string icon = (string)row["_ICON"];
        //        UltraTreeNode categoryNode;
        //        int index;
        //        string nodeText = String.Empty;

        //        // We display just the last portion of the category name as the node text
        //        index = category.LastIndexOf("|");
        //        nodeText = category.Substring(index + 1);

        //        // Add the category itself
        //        categoryNode = new UltraTreeNode(category, nodeText);
        //        categoryNode.Tag = parentNode.Tag;
        //        categoryNode.LeftImages.Add(IconMapping.LoadIcon(icon, IconMapping.ICONSIZE.small));
        //        Trace.Write("Adding node " + category + " to tree node " + parentNode.Key + "\n");

        //        try
        //        {
        //            parentNode.Nodes.Add(categoryNode);
        //        }
        //        catch (Exception)
        //        {
        //        }
        //    }
        //}


        /// <summary>
        /// Populate the Hardware node of the tree
        /// </summary>
        /// <param name="parentNode"></param>
        //protected void PopulateHardware(UltraTreeNode parentNode)
        //{
        //    AuditedItemsDAO lwDataAccess = new AuditedItemsDAO();
        //    DataTable categoryTable = lwDataAccess.GetAuditedItemCategories(parentNode.Key);
        //    DataRow catRow;
        //    UltraTreeNode categoryNode, nameNode;
        //    int index;
        //    string icon, nodeText, category, name, nameKey;

        //    UltraTreeNode[] nodes = new UltraTreeNode[categoryTable.Rows.Count];

        //    parentNode.Nodes.Clear();

        //    // Iterate through the returned rows and add the text and icon to the tree
        //    // All the returned items are categories
        //    for (int i = 0; i < categoryTable.Rows.Count; i++)
        //    {
        //        catRow = categoryTable.Rows[i];

        //        category = (string)catRow["_CATEGORY"];
        //        //icon = (string)catRow["_ICON"];

        //        if (category.StartsWith("System|Patches|"))
        //        {
        //            string reducedCategory = category.Substring(0, category.LastIndexOf('|'));

        //            index = reducedCategory.LastIndexOf("|");
        //            nodeText = reducedCategory.Substring(index + 1);

        //            categoryNode = new UltraTreeNode(reducedCategory, nodeText);
        //            categoryNode.Tag = parentNode.Tag;
        //            //categoryNode.LeftImages.Add(IconMapping.LoadIcon(icon, IconMapping.ICONSIZE.small));

        //            try
        //            {
        //                parentNode.Nodes.Add(categoryNode);
        //                // Recurse to check for child categories of the category we have just added
        //                PopulateSystemPatches(categoryNode);
        //            }
        //            catch (Exception ex)
        //            {
        //            }
        //        }
        //        else
        //        {
        //            // We display just the last portion of the category name as the node text
        //            index = category.LastIndexOf("|");
        //            nodeText = category.Substring(index + 1);

        //            // Add the category itself
        //            categoryNode = new UltraTreeNode(category, nodeText);
        //            categoryNode.Tag = parentNode.Tag;
        //            //categoryNode.LeftImages.Add(IconMapping.LoadIcon(icon, IconMapping.ICONSIZE.small));
        //            categoryNode.Override.ShowExpansionIndicator = ShowExpansionIndicator.CheckOnExpand;
        //            nodes[i] = categoryNode;
        //        }
        //    }

        //    parentNode.Nodes.AddRange(nodes);

        //    // Now check for any NAMES within this category
        //    DataTable namesTable = lwDataAccess.GetAuditedItemCategoryNames(parentNode.Key);
        //    UltraTreeNode[] namesNodes = new UltraTreeNode[namesTable.Rows.Count];

        //    // Add any NAMES after the Categories
        //    for (int j = 0; j < namesTable.Rows.Count; j++)
        //    {
        //        DataRow row = namesTable.Rows[j];

        //        category = (string)row["_CATEGORY"];
        //        name = (string)row["_NAME"];
        //        //icon = (string)row["_ICON"];

        //        // Add the NAME node
        //        nameKey = category + "|" + name;
        //        nameNode = new UltraTreeNode(nameKey, name);
        //        nameNode.Tag = parentNode.Tag;
        //        //nameNode.LeftImages.Add(IconMapping.LoadIcon(icon, IconMapping.ICONSIZE.small));
        //        nameNode.Override.NodeStyle = _valueNodeStyle;

        //        namesNodes[j] = nameNode;
        //    }

        //    parentNode.Nodes.AddRange(namesNodes);

        //    // If no sub-categories or Names then set the expansion indicator to none
        //    if ((categoryTable.Rows.Count == 0) && (namesTable.Rows.Count == 0))
        //        parentNode.Override.ShowExpansionIndicator = ShowExpansionIndicator.Never;

        //}

        protected void PopulateHardware(UltraTreeNode parentNode)
        {
            AuditedItemsDAO lwDataAccess  = new AuditedItemsDAO();
            DataTable       categoryTable = lwDataAccess.GetAuditedItemCategories(parentNode.Key);
            DataRow         catRow;
            UltraTreeNode   categoryNode, nameNode;

            UltraTreeNode[] nodes;
            int             index;
            string          nodeText, category, name, nameKey;

            //parentNode.Nodes.Clear();

            if (parentNode.Key == "System|Patches")
            {
                for (int i = 0; i < categoryTable.Rows.Count; i++)
                {
                    catRow   = categoryTable.Rows[i];
                    category = (string)catRow["_CATEGORY"];

                    string reducedCategory = category.Substring(0, category.LastIndexOf('|'));

                    index    = reducedCategory.LastIndexOf("|");
                    nodeText = reducedCategory.Substring(index + 1);

                    categoryNode     = new UltraTreeNode(reducedCategory, nodeText);
                    categoryNode.Tag = parentNode.Tag;
                    categoryNode.Override.ShowExpansionIndicator = ShowExpansionIndicator.CheckOnExpand;

                    if (fieldsTree.GetNodeByKey(reducedCategory) == null)
                    {
                        parentNode.Nodes.Add(categoryNode);
                    }
                }
            }
            else
            {
                nodes = new UltraTreeNode[categoryTable.Rows.Count];

                // Iterate through the returned rows and add the text and icon to the tree
                // All the returned items are categories
                for (int i = 0; i < categoryTable.Rows.Count; i++)
                {
                    catRow   = categoryTable.Rows[i];
                    category = (string)catRow["_CATEGORY"];

                    // We display just the last portion of the category name as the node text
                    index    = category.LastIndexOf("|");
                    nodeText = category.Substring(index + 1);

                    // Add the category itself
                    categoryNode     = new UltraTreeNode(category, nodeText);
                    categoryNode.Tag = parentNode.Tag;
                    categoryNode.Override.ShowExpansionIndicator = ShowExpansionIndicator.CheckOnExpand;
                    nodes[i] = categoryNode;
                }

                parentNode.Nodes.AddRange(nodes);
            }

            // Now check for any NAMES within this category - only need to do this if there were no categories
            DataTable namesTable = new DataTable();

            if (categoryTable.Rows.Count == 0)
            {
                namesTable = lwDataAccess.GetAuditedItemCategoryNames(parentNode.Key);
                UltraTreeNode[] namesNodes = new UltraTreeNode[namesTable.Rows.Count];

                // Add any NAMES after the Categories
                for (int j = 0; j < namesTable.Rows.Count; j++)
                {
                    DataRow row = namesTable.Rows[j];

                    category = (string)row["_CATEGORY"];
                    name     = (string)row["_NAME"];

                    // Add the NAME node
                    nameKey      = category + "|" + name;
                    nameNode     = new UltraTreeNode(nameKey, name);
                    nameNode.Tag = parentNode.Tag;
                    nameNode.Override.NodeStyle = _valueNodeStyle;

                    namesNodes[j] = nameNode;
                }

                parentNode.Nodes.AddRange(namesNodes);
            }

            // If no sub-categories or Names then set the expansion indicator to none
            if ((categoryTable.Rows.Count == 0) && (namesTable.Rows.Count == 0))
            {
                parentNode.Override.ShowExpansionIndicator = ShowExpansionIndicator.Never;
            }
        }