示例#1
0
        // Starting with the rootNode, recursively build a list of
        // nodes, create objects, add them all to the collection,
        // and return the list.
        public override IHierarchicalEnumerable Select()
        {
            CatagoriesEnumerable CHE = new CatagoriesEnumerable();

            // Get the top level
            var results = from ServiceDeskCategories in CategoriesTable.GetCategoriesTable(_PortalID, _RequestorCatagories)
                          where ServiceDeskCategories.PortalID == _PortalID
                          where ServiceDeskCategories.Level == 1
                          orderby ServiceDeskCategories.CategoryName
                          select ServiceDeskCategories;

            // Loop thru the top level
            foreach (ITILServiceDesk_Category objITILServiceDesk_Category in results)
            {
                // Create a top level item
                ListItem objListItem = new ListItem();
                objListItem.Text  = objITILServiceDesk_Category.CategoryName;
                objListItem.Value = objITILServiceDesk_Category.CategoryID.ToString();
                objListItem.Attributes.Add("PortalId", _PortalID.ToString());
                objListItem.Attributes.Add("Selectable", objITILServiceDesk_Category.Selectable.ToString());
                objListItem.Attributes.Add("RequestorVisible", objITILServiceDesk_Category.RequestorVisible.ToString());
                objListItem.Attributes.Add("RequestorCatagories", _RequestorCatagories.ToString());

                // Add a top level item to the final collection
                CHE.Add(new CatagoriesHierarchyData(objListItem));
            }

            return(CHE);
        }
示例#2
0
            public IHierarchicalEnumerable GetChildren()
            {
                AttributeCollection objAttributeCollection = objListItem.Attributes;
                int  intPortalID             = Convert.ToInt32(objAttributeCollection["PortalID"]);
                bool boolRequestorCatagories = Convert.ToBoolean(objAttributeCollection["RequestorCatagories"]);

                var ChildResults = from ServiceDeskCategories in CategoriesTable.GetCategoriesTable(intPortalID, boolRequestorCatagories)
                                   where ServiceDeskCategories.ParentCategoryID == Convert.ToInt32(objListItem.Value)
                                   orderby ServiceDeskCategories.CategoryName
                                   select ServiceDeskCategories;

                CatagoriesEnumerable children = new CatagoriesEnumerable();

                // Loop thru each item
                foreach (ITILServiceDesk_Category objCategory in ChildResults)
                {
                    // Create a new list item to add to the collection
                    ListItem objChildListItem = new ListItem();
                    // AddDots method is used to add the dots to indicate the item is a sub item
                    objChildListItem.Text  = String.Format("{0}", objCategory.CategoryName);
                    objChildListItem.Value = objCategory.CategoryID.ToString();
                    objChildListItem.Attributes.Add("PortalID", intPortalID.ToString());
                    objChildListItem.Attributes.Add("Selectable", objCategory.Selectable.ToString());
                    objChildListItem.Attributes.Add("RequestorVisible", objCategory.RequestorVisible.ToString());
                    objListItem.Attributes.Add("RequestorCatagories", boolRequestorCatagories.ToString());

                    children.Add(new CatagoriesHierarchyData(objChildListItem));
                }

                return(children);
            }
示例#3
0
            public IHierarchyData GetParent()
            {
                CatagoriesEnumerable parentContainer = new CatagoriesEnumerable();

                AttributeCollection objAttributeCollection = objListItem.Attributes;
                int  intPortalID             = Convert.ToInt32(objAttributeCollection["PortalID"]);
                bool boolRequestorCatagories = Convert.ToBoolean(objAttributeCollection["RequestorCatagories"]);

                var ParentResult = (from ServiceDeskCategories in CategoriesTable.GetCategoriesTable(intPortalID, boolRequestorCatagories)
                                    where ServiceDeskCategories.ParentCategoryID == Convert.ToInt32(objListItem.Value)
                                    select ServiceDeskCategories).FirstOrDefault();

                // Create a new list item to add to the collection
                ListItem objChildListItem = new ListItem();

                // AddDots method is used to add the dots to indicate the item is a sub item
                objChildListItem.Text  = String.Format("{0}", ParentResult.CategoryName);
                objChildListItem.Value = ParentResult.CategoryID.ToString();
                objChildListItem.Attributes.Add("PortalID", intPortalID.ToString());
                objChildListItem.Attributes.Add("Selectable", ParentResult.Selectable.ToString());
                objChildListItem.Attributes.Add("RequestorVisible", ParentResult.RequestorVisible.ToString());

                return(new CatagoriesHierarchyData(objChildListItem));
            }