示例#1
0
        private List <JsTree3Node> ConvertJS3Tree(List <Node> nodes)
        {
            List <JsTree3Node> nodesToJSON = new List <JsTree3Node>();

            foreach (Node node in nodes)
            {
                JsTree3Node nodeToJSON = new JsTree3Node
                {
                    id    = node.Id.ToString(),
                    text  = node.Value,
                    state = new jsTree3.Models.State(true, false, false) //,
                                                                         //icon = "false"
                };
                if (node.ChildNodes.Count == 0)
                {
                    nodeToJSON.children = new List <JsTree3Node>();
                }
                else
                {
                    nodeToJSON.children = ConvertJS3Tree(node.ChildNodes.ToList());
                }
                nodesToJSON.Add(nodeToJSON);
            }
            return(nodesToJSON);
        }
示例#2
0
        /// <summary>
        /// 获取权限树
        /// </summary>
        /// <param name="selectNodeID"></param>
        /// <returns></returns>
        public ActionResult GetRightTree(string selectNodeID, string userid = "", string thisid = "", bool ismanage = false)
        {
            List <JsTree3Node> rightTreeNodes = new List <JsTree3Node>();
            var rightQueryable = rightService.GetQueryable(r => !r.IsDel);

            if (!ismanage)
            {
                rightQueryable = rightQueryable.Where(r => r.IsAvailable);
            }
            var rightList = rightQueryable.OrderBy(d => d.SortNo).ThenByDescending(d => d.AddDate).ToList();

            rightList.Where(r => r.ParentID == null).ToList().ForEach(r =>
            {
                bool disabled = r.RightIDPath.Trim('/').Split('/').Any(pid => pid == thisid);
                bool select   = !string.IsNullOrEmpty(selectNodeID) && selectNodeID.Contains(r.ID);
                var node      = new JsTree3Node
                {
                    id       = r.ID,
                    text     = r.Name,
                    state    = new State(false, disabled, select),
                    children = new List <JsTree3Node>()
                };
                GenerateTree(node, rightList, selectNodeID, disabled, thisid);
                rightTreeNodes.Add(node);
            });

            return(Json(rightTreeNodes, JsonRequestBehavior.AllowGet));
        }
        public JsonResult GetJsTree3Data()
        {
            var root = new JsTree3Node() // Create our root node and ensure it is opened
            {
                id    = Guid.NewGuid().ToString(),
                text  = "Root Node",
                state = new State(true, false, false)
            };

            // Create a basic structure of nodes
            var children = new List <JsTree3Node>();

            for (int i = 0; i < 5; i++)
            {
                var node = JsTree3Node.NewNode(Guid.NewGuid().ToString());
                node.state = new State(IsPrime(i), false, false);

                for (int y = 0; y < 5; y++)
                {
                    node.children.Add(JsTree3Node.NewNode(Guid.NewGuid().ToString()));
                }

                children.Add(node);
            }

            // Add the sturcture to the root nodes children property
            root.children = children;

            // Return the object as JSON
            return(Json(root, JsonRequestBehavior.AllowGet));
        }
示例#4
0
        public ActionResult GetRoleTree(string selectNodeID = "", string thisid = "", bool ismanage = false)
        {
            var cuser = userBLL.GetCurrentUser();
            //Expression<Func<SysRole, bool>> exp = sr => !sr.IsDel && sr.IsAvailable /*&& sr.RoleIDPath.Contains("/" + cuser.RoleID)*/;
            //var rightQueryable = rightService.GetQueryable(r => !r.IsDel);
            //if (!ismanage)
            //{
            //    rightQueryable = rightQueryable.Where(r => r.IsAvailable);
            //}
            var roleQueryable = roleService.GetQueryable(r => !r.IsDel);

            if (!ismanage)
            {
                roleQueryable = roleQueryable.Where(r => r.IsAvailable);
            }
            var  roles           = roleQueryable.OrderBy(d => d.SortNo).ThenByDescending(d => d.AddDate).ToList();
            var  level1          = roles.FirstOrDefault(d => d.Parent == null);
            bool disabled        = level1.RoleIDPath.Trim('/').Split('/').Any(rid => rid == thisid) || !cuser.RolesID.Contains(level1.ID);
            var  selectedNodeIDs = selectNodeID.Split(',');
            bool selected        = selectedNodeIDs.Any(nodeid => nodeid == level1.ID);
            var  root            = new JsTree3Node()
            {
                id       = level1.ID,
                text     = level1.Name,
                state    = new State(true, disabled, selected),
                children = new List <JsTree3Node>()
            };

            GenerateRoleTree(root, roles, cuser.RolesID, disabled, selectedNodeIDs, thisid);
            return(Json(root, JsonRequestBehavior.AllowGet));
        }
示例#5
0
 public static JsTree3Node GetMenuTreeByUser(int?UserId)
 {
     try
     {
         using (HJStudioEntities db = new HJStudioEntities())
         {
             int Cid  = 0;
             var user = db.EmployeeMasters.Find(UserId);
             if (user.UserType == (int)UserType.Admin)
             {
                 Cid = user.UserType ?? 0;
             }
             else
             {
                 Cid = 0;
             }
             // var admin = CommonService.GetFranchiseeAdmin(Cid);
             int?adminId = CommanModel.LoginUserDetails.EmployeeID;
             //if (admin != null)
             //{
             //    adminId = admin.UserId;
             //}
             var root = new JsTree3Node()
             {
                 id    = "0",
                 text  = "HJ",
                 state = new JsTree3Node.State(true, false, false)
             };
             var        children1 = new List <JsTree3Node>();
             List <int> list      = db.MenuUserAllocations.Where(x => x.UserId == UserId).Select(x => x.MenuId ?? 0).ToList();
             var        menu      = db.MenuMasters.Where(x => x.MenuUserAllocations.Any(y => (y.UserId == adminId || adminId == 0)));
             foreach (var item in menu.Where(x => x.ParentID == null).ToList())
             {
                 var chields = menu.Where(x => x.ParentID == item.MenuID).ToList();
                 var node    = (list.Contains(item.MenuID) && (chields == null || chields.Count == 0)) ? JsTree3Node.NewNode(item.MenuID, item.MenuName, true) : JsTree3Node.NewNode(item.MenuID, item.MenuName, false);
                 foreach (var itemChild in chields)
                 {
                     bool ChildSel = list.Contains(itemChild.MenuID);
                     node.children.Add(JsTree3Node.NewNode(itemChild.MenuID, itemChild.MenuName, ChildSel));
                 }
                 node.state.opened = false;
                 children1.Add(node);
             }
             root.children = children1;
             return(root);
             // return Json(root, JsonRequestBehavior.AllowGet);
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        public JsonResult GetSuperVisorSpecializationData(string UserRecID)
        {
            var model = _unitOfWork.Departments.GetAll();
            ICollection <SupervisorDegreeProgram> CheckedValues = _unitOfWork.Departments.getSuperVisorSpecialzation(UserRecID);

            var root = new JsTree3Node()
            {
                id    = "Dsdfkjasdlfkjsasldkfjsdlfkj",
                text  = "Departments",
                state = new State(true, false, false)
            };

            var DeppartmentNodes = new List <JsTree3Node>();

            foreach (var department in model)
            {
                var DNode = JsTree3Node.NewNode(department.RecID.ToString());
                DNode.state = new State(false, false, false);
                DNode.text  = department.Name;
                foreach (var degreeProgram in department.DegreePrograms)
                {
                    //create degreeProgramNode
                    var DPNode = JsTree3Node.NewNode(degreeProgram.RecID.ToString());
                    DPNode.state = new State(false, false, false);
                    DPNode.text  = degreeProgram.Name;
                    foreach (var specialization in degreeProgram.Specializations)
                    {
                        var IsChecked = false;
                        foreach (var item in CheckedValues)
                        {
                            if (item.Specialization.RecID.Equals(specialization.RecID))
                            {
                                IsChecked = true;
                            }
                        }
                        var SNode = JsTree3Node.NewNode(specialization.RecID.ToString());
                        SNode.state = new State(false, false, IsChecked);

                        SNode.text = specialization.Name;
                        DPNode.children.Add(SNode);
                    }
                    //Add degreeProram in DNode
                    DNode.children.Add(DPNode);
                }
                DeppartmentNodes.Add(DNode);
            }
            //End of foreach
            root.children = DeppartmentNodes;

            return(Json(root, JsonRequestBehavior.AllowGet));
        }
示例#7
0
        private void GenerateCategoryTree(JsTree3Node node, List <Category> list, bool parentDisabled, string[] selectedNodeIDs, string thisid)
        {
            var childs = list.Where(d => d.ParentID == node.id).OrderBy(d => d.SortNo).ThenByDescending(d => d.AddDate).ToList();

            foreach (var c in childs)
            {
                bool disabled = c.CategoryFullIDPath.Trim('/').Split('/').Any(rid => rid == thisid) || (parentDisabled);
                var  child    = new JsTree3Node()
                {
                    id       = c.ID,
                    text     = c.Name,
                    state    = new State(false, disabled, selectedNodeIDs.Any(nodeid => nodeid == c.ID)),
                    children = new List <JsTree3Node>()
                };
                GenerateCategoryTree(child, list, disabled, selectedNodeIDs, thisid);
                node.children.Add(child);
            }
        }
示例#8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <param name="thisid">此ID对应的部门不包含在返回的树节点里(场景:部门编辑时可以选择上级部门,而这个选择范围不应该包含它自己)</param>
        /// <param name="selectNodeID">当前已选中的部门ID</param>
        /// <returns></returns>
        public ActionResult GetDepTree(string id = "root", string thisid = "", string selectNodeID = "")
        {
            id = string.IsNullOrEmpty(id) || id == "#" ? "root" : id;
            Expression <Func <SysDep, bool> > exp = d => d.DepFullIDPath.Contains(id);
            var  deps            = depService.GetList(exp).OrderBy(d => d.SortNo).ThenByDescending(d => d.AddDate).ToList();
            var  level1          = deps.FirstOrDefault(d => d.ID == id);
            var  level1_disabled = !string.IsNullOrEmpty(thisid) && level1.DepFullIDPath.Contains("/" + thisid + "/");
            bool select          = selectNodeID == level1.ID;
            var  root            = new JsTree3Node()
            {
                id       = level1.ID,
                text     = level1.Name,
                state    = new State(true, level1_disabled, select),
                children = new List <JsTree3Node>()
            };

            GenerateTree(root, deps, selectNodeID, level1_disabled, thisid);
            return(Json(root, JsonRequestBehavior.AllowGet));
        }
示例#9
0
        private void GenerateTree(JsTree3Node node, List <SysRight> list, string selectNodeID, bool parentDisabled, string thisid)
        {
            var childs = list.Where(d => d.ParentID == node.id).OrderBy(d => d.SortNo).ThenByDescending(d => d.AddDate).ToList();

            foreach (var c in childs)
            {
                bool disabled = parentDisabled || c.RightIDPath.Trim('/').Split('/').Any(pid => pid == thisid);
                bool select   = !string.IsNullOrEmpty(selectNodeID) && selectNodeID.Contains(c.ID);
                var  child    = new JsTree3Node()
                {
                    id       = c.ID,
                    text     = c.Name,
                    state    = new State(false, disabled, select),
                    children = new List <JsTree3Node>()
                };
                GenerateTree(child, list, selectNodeID, disabled, thisid);
                node.children.Add(child);
            }
        }
示例#10
0
        private void GenerateTree(JsTree3Node node, List <SysDep> list, string selectNodeID, bool parentDisabled, string thisid)
        {
            var childs = list.Where(d => d.ParentID == node.id).OrderBy(d => d.SortNo).ThenByDescending(d => d.AddDate).ToList();

            foreach (var c in childs)
            {
                var  disabled = !string.IsNullOrEmpty(thisid) && (parentDisabled || c.DepFullIDPath.Contains("/" + thisid + "/"));
                bool select   = selectNodeID == c.ID;
                var  child    = new JsTree3Node()
                {
                    id       = c.ID,
                    text     = c.Name,
                    state    = new State(false, disabled, select),
                    children = new List <JsTree3Node>()
                };
                GenerateTree(child, list, selectNodeID, disabled, thisid);
                node.children.Add(child);
            }
        }
示例#11
0
        public JsonResult GetTreeViewNew()
        {
            var parser2 = new GetExcelData(Server.MapPath("~/Content/Task.xlsx"));
            var inData  = parser2.GetData().Convert();

            int nodeUnicID = 0;
            var ParentsDic = new Dictionary <int, string>();//no
            var ReadyList  = new List <JsTree3Node>();
            var mainNode   = new JsTree3Node()
            {
                id       = "0",
                text     = "Портфель проектов",
                state    = new State(true, false, false),
                children = new List <JsTree3Node>(),
                data     = 0
            };

            ReadyList.Add(mainNode);
            ParentsDic.Add(nodeUnicID, "0");
            nodeUnicID++;
            foreach (var elem in inData)
            {
                var newNode = new JsTree3Node()
                {
                    id       = elem.ID,
                    text     = elem.Name,
                    state    = new State(false, false, false),
                    children = new List <JsTree3Node>(),
                    data     = elem.CID
                };
                if (ParentsDic.ContainsValue(elem.Parent_ID.ToString()))
                {
                    ReadyList[ParentsDic.FirstOrDefault(x => x.Value == elem.Parent_ID.ToString()).Key].children.Add(newNode);
                }

                ReadyList.Add(newNode);
                ParentsDic.Add(nodeUnicID, elem.ID.ToString());
                nodeUnicID++;
            }
            return(Json(mainNode, JsonRequestBehavior.AllowGet));
        }
示例#12
0
        private JsonResult GetJSTreeNode(List <TreeViewElements> treeView)
        {
            int nodeUnicID = 0;
            var ParentsDic = new Dictionary <int, string>();//no
            var ReadyList  = new List <JsTree3Node>();
            var mainNode   = new JsTree3Node()
            {
                id       = "0",
                text     = "Портфель проектов",
                state    = new State(true, false, false),
                children = new List <JsTree3Node>(),
                data     = 0
            };

            ReadyList.Add(mainNode);
            ParentsDic.Add(nodeUnicID, "0");
            nodeUnicID++;
            foreach (var elem in treeView)
            {
                var newNode = new JsTree3Node()
                {
                    id       = elem.ID,
                    text     = elem.Name,
                    state    = new State(false, false, false),
                    children = new List <JsTree3Node>(),
                    data     = elem.CID
                };
                if (ParentsDic.ContainsValue(elem.Parent_ID.ToString()))
                {
                    ReadyList[ParentsDic.FirstOrDefault(x => x.Value == elem.Parent_ID.ToString()).Key].children.Add(newNode);
                }

                ReadyList.Add(newNode);
                ParentsDic.Add(nodeUnicID, elem.ID.ToString());
                nodeUnicID++;
            }
            return(Json(mainNode, JsonRequestBehavior.AllowGet));
        }
示例#13
0
        public ActionResult GetCategoryTree(string selectNodeID = "", string thisid = "", bool ismanage = false, string cateTypeID = "")
        {
            List <JsTree3Node> root = new List <JsTree3Node>();
            var cuser             = userBLL.GetCurrentUser();
            var categoryQueryable = categoryService.GetQueryable(r => !r.IsDel && r.CateTypeID == cateTypeID);

            if (!ismanage)
            {
                categoryQueryable = categoryQueryable.Where(r => r.IsAvailable);
            }
            var categorys = categoryQueryable.OrderBy(d => d.SortNo).ThenByDescending(d => d.AddDate).ToList();
            var level1    = categorys.Where(d => d.Parent == null).ToList();

            if (level1.Count > 0)
            {
                level1.ForEach(c =>
                {
                    bool disabled       = c.CategoryFullIDPath.Trim('/').Split('/').Any(rid => rid == thisid);
                    var selectedNodeIDs = selectNodeID.Split(',');
                    bool selected       = selectedNodeIDs.Any(nodeid => nodeid == c.ID);
                    var node            = new JsTree3Node()
                    {
                        id       = c.ID,
                        text     = c.Name,
                        state    = new State(true, disabled, selected),
                        children = new List <JsTree3Node>()
                    };
                    GenerateCategoryTree(node, categorys, disabled, selectedNodeIDs, thisid);
                    root.Add(node);
                });

                return(Json(root, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Content("未找到树的顶级节点"));
            }
        }
示例#14
0
        public static List <JsTree3Node> GetUserMenu(int?UserId)
        {
            try
            {
                using (HJStudioEntities db = new HJStudioEntities())
                {
                    var User      = db.EmployeeMasters.Find(UserId);
                    var children1 = new List <JsTree3Node>();
                    if (User.UserType != (int)UserType.User)
                    {
                        List <int> list = db.MenuUserAllocations.Where(x => x.UserId == UserId).Select(x => x.MenuId ?? 0).ToList();

                        foreach (var item in db.MenuMasters.Where(x => x.ParentID == null).OrderBy(x => x.DisplayOrder).ToList())
                        {
                            var chields = db.MenuMasters.Where(x => x.ParentID == item.MenuID && list.Contains(x.MenuID)).OrderBy(x => x.DisplayOrder).ToList();
                            if (chields != null && chields.Count() > 0)
                            {
                                var node = JsTree3Node.NewNode(item.MenuID, item.MenuName, false, item.MenuLink, item.MenuIcon);
                                foreach (var itemChild in chields)
                                {
                                    node.children.Add(JsTree3Node.NewNode(itemChild.MenuID, itemChild.MenuName, false, itemChild.MenuLink, itemChild.MenuIcon));
                                }
                                node.state.opened = false;
                                children1.Add(node);
                            }
                            else if (list.Contains(item.MenuID))
                            {
                                var node = JsTree3Node.NewNode(item.MenuID, item.MenuName, true, item.MenuLink, item.MenuIcon);
                                node.state.opened = false;
                                children1.Add(node);
                            }
                        }
                    }
                    else
                    {
                        foreach (var item in db.MenuMasters.Where(x => x.ParentID == null).OrderBy(x => x.DisplayOrder).ToList())
                        {
                            var chields = db.MenuMasters.Where(x => x.ParentID == item.MenuID && x.IsForEmployee == true).OrderBy(x => x.DisplayOrder).ToList();
                            if (chields != null && chields.Count() > 0)
                            {
                                var node = JsTree3Node.NewNode(item.MenuID, item.MenuName, false, item.MenuLink, item.MenuIcon);
                                foreach (var itemChild in chields)
                                {
                                    node.children.Add(JsTree3Node.NewNode(itemChild.MenuID, itemChild.MenuName, false, itemChild.MenuLink, itemChild.MenuIcon));
                                }
                                node.state.opened = false;
                                children1.Add(node);
                            }
                            else if (item.IsForEmployee == true)
                            {
                                var node = JsTree3Node.NewNode(item.MenuID, item.MenuName, true, item.MenuLink, item.MenuIcon);
                                node.state.opened = false;
                                children1.Add(node);
                            }
                        }
                    }
                    return(children1);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }