// 获取菜单树的值 public static string GetTreeValue(string employeeID, Dictionary <string, int> selectedIDs) { List <string> allUsers = new List <string>(); allUsers = GenesysBLL.Proc_GetCfgAdmin().Select(item => item.employee_id).ToList(); if (!string.IsNullOrEmpty(employeeID)) { allUsers = allUsers.FindAll(id => id.IndexOf(employeeID, StringComparison.CurrentCultureIgnoreCase) != -1); } string root = "所有用户"; if (root == null) { return(string.Empty); } JSONTree tree = new JSONTree(root, root); string parent = null; foreach (string eid in allUsers) { parent = root; int checkedSign = 0; if (selectedIDs.ContainsKey(eid)) { checkedSign = selectedIDs[eid]; } tree.Root.AppendNode(parent, eid, eid, eid, true, true, checkedSign); } return(tree.ToString()); }
// 获取菜单树的值 public static string GetTreeValue(Dictionary <string, int> selectedIDs) { List <SPhone_Module> modules = new List <SPhone_Module>(); using (var db = DCHelper.SPhoneContext()) { modules = db.SPhone_Module.ToList(); } SPhone_Module root = new SPhone_Module() { ModuleID = Guid.Empty, ModuleName = "应用模块", ParentModuleID = Guid.Empty }; if (root == null) { return(string.Empty); } JSONTree tree = new JSONTree(root.ModuleID.ToString(), root.ModuleName); SPhone_Module parent = null; foreach (SPhone_Module item in modules.OrderBy(item => item.CreateTime)) { parent = modules.Find(o => o.ModuleID == item.ParentModuleID); if (parent == null) { parent = root; } int checkedSign = 0; string id = item.ModuleID.ToString(); if (selectedIDs.ContainsKey(id)) { checkedSign = selectedIDs[id]; } bool showCheckbox = !item.ParentModuleID.Equals(Guid.Empty); tree.Root.AppendNode(item.ParentModuleID.ToString(), id, item.ModuleName , id, true, showCheckbox, checkedSign); } return(tree.ToString()); }