/// <summary> /// 获取用户有权限的菜单 /// </summary> /// <param name="yhsession"></param> /// <returns></returns> public static List <Model.cd> getAuthCd(YhSession yhsession) { DAL.gn gndal = new DAL.gn(); //获取用户有权限的功能 int[] gnids = gndal.getGnidsByYhmc(yhsession.yh.yhmc); //string gnidsStr = String.Join(",", gnids); List <int> gnidList = gnids.ToList(); //通过用户有权限的功能得到用户有权限的菜单 DAL.cd cddal = new DAL.cd(); //List<Model.cd> cds = cddal.getModelList(" gnid in(" + gnidsStr + ")"); List <Model.cd> cds = cddal.getModelList(""); List <Model.cd> yhcds = cds.FindAll(delegate(Model.cd cd) { if (cd.gnid.HasValue) { return(gnidList.Contains(cd.gnid.Value)); } else { return(false); } }); //获取上级菜单并添加菜单记录 List <Model.cd> x1 = cds.FindAll(delegate(Model.cd cd) { return(yhcds.FindAll(b => b.sjcdid == cd.cdid).Count > 0); }); yhcds.AddRange(x1); return(yhcds); }
/// <summary> /// 校验用户权限 /// </summary> /// <param name="yhmc"></param> /// <param name="ctrl"></param> /// <param name="action"></param> /// <returns></returns> public bool checkYhqx(string yhmc, string ctrl, string action) { DAL.gn gndal = new DAL.gn(); int[] gnids = gndal.getGnidsByYhmc(yhmc); Model.gn gn = gndal.getModelByName(ctrl, action); if (gnids.Contains(gn.gnid)) { return(true); } return(false); }