コード例 #1
0
ファイル: TagsTree.cs プロジェクト: pgupta35/ITILServiceDesk
        // 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
ファイル: TagsTree.cs プロジェクト: pgupta35/ITILServiceDesk
            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
        // Tags

        #region DisplayCategoryTree
        private void DisplayCategoryTree()
        {
            bool boolUserAssignedToTask = false;
            ServiceDeskDALDataContext objServiceDeskDALDataContext = new ServiceDeskDALDataContext();

            ITILServiceDesk_Task objITILServiceDesk_Tasks = (from ITILServiceDesk_Tasks in objServiceDeskDALDataContext.ITILServiceDesk_Tasks
                                                             where ITILServiceDesk_Tasks.TaskID == Convert.ToInt32(Request.QueryString["TaskID"])
                                                             select ITILServiceDesk_Tasks).FirstOrDefault();

            //Is user in the Assigned Role?
            RoleController objRoleController = new RoleController();
            RoleInfo       objRoleInfo       = objRoleController.GetRole(objITILServiceDesk_Tasks.AssignedRoleID, PortalId);

            if (objRoleInfo != null)
            {
                if (UserInfo.IsInRole(objRoleInfo.RoleName))
                {
                    boolUserAssignedToTask = true;
                }
            }

            if (boolUserAssignedToTask || UserInfo.IsInRole(GetAdminRole()) || UserInfo.IsInRole(PortalSettings.AdministratorRoleName) || UserInfo.IsSuperUser)
            {
                // Show all Tags
                TagsTreeExistingTasks.Visible     = true;
                TagsTreeExistingTasks.TagID       = Convert.ToInt32(Request.QueryString["TaskID"]);
                TagsTreeExistingTasks.DisplayType = Utility.DisplayTypeAdministrator;
                TagsTreeExistingTasks.Expand      = false;
            }
            else
            {
                // Show only Visible Tags
                TagsTreeExistingTasks.Visible     = true;
                TagsTreeExistingTasks.TagID       = Convert.ToInt32(Request.QueryString["TaskID"]);
                TagsTreeExistingTasks.DisplayType = Utility.DisplayTypeRequestor;
                TagsTreeExistingTasks.Expand      = false;
            }

            // Select Existing values
            if (objITILServiceDesk_Tasks.ITILServiceDesk_TaskCategories.Select(x => x.CategoryID).ToArray <int>().Count() > 0)
            {
                int[]  ArrStrCategories = objITILServiceDesk_Tasks.ITILServiceDesk_TaskCategories.Select(x => x.CategoryID).ToArray <int>();
                int?[] ArrIntCatagories = Array.ConvertAll <int, int?>(ArrStrCategories, new Converter <int, int?>(ConvertToNullableInt));

                TagsTreeExistingTasks.SelectedCategories = ArrIntCatagories;
            }

            // Set visibility of Tags
            bool RequestorCatagories = (TagsTreeExistingTasks.DisplayType == Utility.DisplayTypeAdministrator) ? false : true;

            int CountOfCatagories = (from ServiceDeskCategories in CategoriesTable.GetCategoriesTable(PortalId, RequestorCatagories)
                                     where ServiceDeskCategories.PortalID == PortalId
                                     where ServiceDeskCategories.Level == 1
                                     select ServiceDeskCategories).Count();

            imgTags.Visible    = (CountOfCatagories > 0);
            lbltxtTags.Visible = (CountOfCatagories > 0);
        }
コード例 #4
0
        private void SelectTreeNode()
        {
            if (tvCategories.SelectedNode != null)
            {
                if (tvCategories.SelectedNode.Value != "")
                {
                    var result = (from ITILServiceDesk_Categories in CategoriesTable.GetCategoriesTable(PortalId, false)
                                  where ITILServiceDesk_Categories.CategoryID == Convert.ToInt32(tvCategories.SelectedNode.Value)
                                  select ITILServiceDesk_Categories).FirstOrDefault();

                    txtCategory.Text            = result.CategoryName;
                    txtCategoryID.Text          = result.CategoryID.ToString();
                    chkRequesterVisible.Checked = result.RequestorVisible;
                    chkSelectable.Checked       = result.Selectable;

                    // Remove Node from the Bind DropDown drop-down
                    BindDropDown(result.CategoryID);

                    // Set the Parent drop-down
                    ddlParentCategory.SelectedValue = (result.ParentCategoryID == null) ? "0" : result.ParentCategoryID.ToString();
                    txtParentCategoryID.Text        = (result.ParentCategoryID == null) ? "" : result.ParentCategoryID.ToString();
                }
            }
        }
コード例 #5
0
ファイル: TagsTree.cs プロジェクト: pgupta35/ITILServiceDesk
            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));
            }
コード例 #6
0
 private void GetEntireTable()
 {
     // Get the entire table only once from cache
     EntireTable = CategoriesTable.GetCategoriesTable(_PortalID, false);
 }