private void parseChildTreeData(Hashtable pHash, SMC_Functions parent_fncs, SMC_FunctionRoleDao frDao, int RoleId) { IList <SMC_Functions> funcs = SMC_FunctionsDao.QueryFunctionsByUpperFNIDForUnitManager(parent_fncs.FN_ID); if (funcs != null && funcs.Count > 0) { List <Hashtable> objs = new List <Hashtable>(); foreach (SMC_Functions fn in funcs) { Hashtable hash = new Hashtable(); hash["id"] = fn.FN_ID; hash["name"] = fn.FN_Name; hash["checked"] = frDao.IsFunctionInRole(fn.FN_ID, RoleId); parseChildTreeData(hash, fn, frDao, RoleId); objs.Add(hash); } if (objs.Count > 0) { pHash["children"] = objs; } } }
public virtual Hashtable QueryFunctionsTreeDataByUnit(string Unit_ID, int Role_ID) { try { SMC_FunctionRoleDao frDao = new SMC_FunctionRoleDao(AppConfig.statisticDBKey); IList <SMC_Functions> funcs = SMC_FunctionsDao.QueryFunctionsByUpperFNIDForUnitManager(0);//SMC_FunctionsDao.QueryFunctionsByUnitID(Unit_ID, 0); Hashtable phash = new Hashtable(); phash["id"] = 0; phash["name"] = "请选择权限"; phash["open"] = true; phash["checked"] = false; List <Hashtable> objs = new List <Hashtable>(); if (funcs != null && funcs.Count > 0) { foreach (SMC_Functions fn in funcs) { Hashtable hash = new Hashtable(); bool isFnInRole = frDao.IsFunctionInRole(fn.FN_ID, Role_ID); hash["id"] = fn.FN_ID; hash["name"] = fn.FN_Name; hash["open"] = true; hash["checked"] = isFnInRole; parseChildTreeData(hash, fn, frDao, Role_ID); objs.Add(hash); } } phash["children"] = objs; return(phash); } catch (DalException ex) { throw new BOException("QueryFunctionsByUnitID", ex); } }