private void LoadPermission() { BLLJuActivity juActivityBll = new BLLJuActivity(); ZentCloud.BLLPermission.BLLMenuPermission permissionBll = new ZentCloud.BLLPermission.BLLMenuPermission(""); StringBuilder sb = new StringBuilder(); int columCount = 3; int _w = 740 / columCount; List <ArticleCategory> cateList = juActivityBll.GetList <ArticleCategory>(string.Format("WebsiteOwner='{0}' And CategoryType='{1}' Order by Sort", juActivityBll.WebsiteOwner, "Permission")); foreach (var cateitem in cateList) { List <ZentCloud.BLLPermission.Model.PermissionInfo> pmsGroup = permissionBll.GetList <ZentCloud.BLLPermission.Model.PermissionInfo>(string.Format(" PermissionCateId={0} order by PermissionID DESC", cateitem.AutoID)); if (pmsGroup.Count > 0) { sb.AppendFormat("<fieldset style=\"padding: 0px 10px 10px 10px; margin-top:10px; \">"); sb.AppendFormat("<legend><input id=\"cb_{0}\" title=\"{1}\" type=\"checkbox\" name=\"checktype\" class=\"positionTop2\" value=\"{0}\" /> <label title=\"{1}\" for=\"cb_{0}\">{1}</label></legend>", cateitem.AutoID, cateitem.CategoryName); sb.AppendFormat("<ul style=\"width:100%;\">"); for (int i = 0; i < pmsGroup.Count; i++) { sb.AppendFormat("<li style=\"width:{0}px;float:left;overflow:hidden;white-space: nowrap;text-overflow: ellipsis;\">", _w); sb.AppendFormat(string.Format(@"<input id=""cb_{0}"" title=""{2}"" type=""checkbox"" name=""checksingle"" class=""positionTop2"" value=""{0}"" /> <label title=""{2}"" for=""cb_{0}"">{1}</label><br />", pmsGroup[i].PermissionID, pmsGroup[i].PermissionName, string.IsNullOrWhiteSpace(pmsGroup[i].PermissionDescription) ? pmsGroup[i].PermissionName : pmsGroup[i].PermissionDescription)); sb.AppendFormat("</li>"); } sb.AppendFormat("</ul>"); sb.AppendFormat("</fieldset>"); } } string cateIds = ZentCloud.Common.MyStringHelper.ListToStr(cateList.Select(p => p.AutoID).ToList(), "", ","); if (string.IsNullOrWhiteSpace(cateIds)) { cateIds = "-1"; } List <ZentCloud.BLLPermission.Model.PermissionInfo> pmsGroup1 = new ZentCloud.BLLPermission.BLLMenuPermission("").GetList <ZentCloud.BLLPermission.Model.PermissionInfo>(string.Format(" PermissionCateId Not In ({0}) order by PermissionID DESC", cateIds)); if (pmsGroup1.Count > 0) { sb.AppendFormat("<fieldset style=\"0px 10px 10px 10px; margin-top:10px;\">"); sb.AppendFormat("<legend><input id=\"cb_{0}\" title=\"{1}\" type=\"checkbox\" name=\"checktype\" class=\"positionTop2\" value=\"{0}\" /> <label title=\"{1}\" for=\"cb_{0}\">{1}</label></legend>", 0, "未分类"); sb.AppendFormat("<ul style=\"width:100%;\">"); for (int i = 0; i < pmsGroup1.Count; i++) { sb.AppendFormat("<li style=\"width:{0}px;float:left;overflow:hidden;white-space: nowrap;text-overflow: ellipsis;\">", _w); sb.AppendFormat(string.Format(@"<input id=""cb_{0}"" title=""{2}"" type=""checkbox"" name=""checksingle"" class=""positionTop2"" value=""{0}"" /> <label title=""{2}"" for=""cb_{0}"">{1}</label><br />", pmsGroup1[i].PermissionID, pmsGroup1[i].PermissionName, string.IsNullOrWhiteSpace(pmsGroup1[i].PermissionDescription) ? pmsGroup1[i].PermissionName : pmsGroup1[i].PermissionDescription)); sb.AppendFormat("</li>"); } sb.AppendFormat("</ul>"); sb.AppendFormat("</fieldset>"); } PermissionHtml = sb.ToString(); }
/// <summary> /// 检查站点是否包含某个权限Key /// </summary> /// <param name="userId">账户</param> /// <param name="permissionKey">权限key </param> /// <returns></returns> public bool CheckPermissionKey(string userId, ZentCloud.BLLPermission.Enums.PermissionSysKey permissionKey) { string permissionKeyStr = EnumToString(permissionKey); BLLMenuPermission bllMenuper = new BLLMenuPermission(""); List <PermissionInfo> pmsList = new List <PermissionInfo>(); string strPsmIds = "0"; List <long> psmIds = bllMenuper.GetUserAllPmsID(userId); if (psmIds.Count() > 0) { strPsmIds = MyStringHelper.ListToStr(psmIds, "'", ","); } pmsList = bllMenuper.GetList <PermissionInfo>(string.Format(" PermissionKey>'' AND PermissionID in ({0})", strPsmIds)); //过滤掉已经禁止的权限 var disPmsList = GetMultPermissionRelationList("'" + userId + "'", 9); pmsList = pmsList.Where(p => disPmsList.Count(dis => dis.PermissionID == p.PermissionID) == 0).ToList(); if (pmsList != null) { return(pmsList.Count(p => p.PermissionKey == permissionKeyStr) > 0); } return(false); }