コード例 #1
0
ファイル: RBACRole.cs プロジェクト: Abnertd/public
    public string DisplayPrivilege(int Resource_ID, IList <RBACPrivilegeInfo> privileges)
    {
        StringBuilder strHTML = new StringBuilder();
        QueryInfo     Query   = new QueryInfo();

        Query.PageSize = 0;
        Query.ParamInfos.Add(new ParamInfo("AND", "int", "RBACPrivilegeInfo.RBAC_Privilege_ResourceID", "=", Resource_ID.ToString()));
        Query.OrderInfos.Add(new OrderInfo("RBACPrivilegeInfo.RBAC_Privilege_Name", "DESC"));
        IList <RBACPrivilegeInfo> entitys = MyPri.GetRBACPrivileges(Query, Public.GetUserPrivilege());

        Query = null;
        if (entitys != null)
        {
            strHTML.Append("<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">");
            strHTML.Append("<tr>");
            strHTML.Append("    <td>");
            foreach (RBACPrivilegeInfo entity in entitys)
            {
                strHTML.Append("<input type=\"checkbox\" name=\"privilege_id\" id=\"privilege_id" + Resource_ID + "_all" + entity.RBAC_Privilege_ID + "\" value=\"" + entity.RBAC_Privilege_ID + "\" " + PrivilegeChecked(entity.RBAC_Privilege_ID, privileges) + "/>" + entity.RBAC_Privilege_Name + "&nbsp;");
            }
            strHTML.Append("    </td>");
            strHTML.Append("</tr>");
            strHTML.Append("</table>");
        }
        return(strHTML.ToString());
    }
コード例 #2
0
    public string GetRBACPrivileges()
    {
        int       RBAC_Privilege_ResourceID = tools.CheckInt(Request.QueryString["RBAC_Privilege_ResourceID"]);
        string    keyword = tools.CheckStr(Request["keyword"]);
        QueryInfo Query   = new QueryInfo();

        Query.PageSize    = tools.CheckInt(Request["rows"]);
        Query.CurrentPage = tools.CheckInt(Request["page"]);
        Query.ParamInfos.Add(new ParamInfo("AND", "int", "RBACPrivilegeInfo.RBAC_Privilege_IsActive", "=", "1"));
        Query.OrderInfos.Add(new OrderInfo(tools.CheckStr(Request["sidx"]), tools.CheckStr(Request["sord"])));

        if (RBAC_Privilege_ResourceID > 0)
        {
            Query.ParamInfos.Add(new ParamInfo("AND", "int", "RBACPrivilegeInfo.RBAC_Privilege_ResourceID", "=", RBAC_Privilege_ResourceID.ToString()));
        }
        if (keyword != "")
        {
            Query.ParamInfos.Add(new ParamInfo("AND(", "str", "RBACPrivilegeInfo.RBAC_Privilege_ID", "like", keyword));
            Query.ParamInfos.Add(new ParamInfo("OR)", "str", "RBACPrivilegeInfo.RBAC_Privilege_Name", "like", keyword));
        }
        PageInfo pageinfo = MyBLL.GetPageInfo(Query, Public.GetUserPrivilege());

        RBACResourceInfo ResInfo;

        IList <RBACPrivilegeInfo> entitys = MyBLL.GetRBACPrivileges(Query, Public.GetUserPrivilege());

        if (entitys != null)
        {
            StringBuilder jsonBuilder = new StringBuilder();
            jsonBuilder.Append("{\"page\":" + pageinfo.CurrentPage + ",\"total\":" + pageinfo.PageCount + ",\"records\":" + pageinfo.RecordCount + ",\"rows\"");
            jsonBuilder.Append(":[");
            foreach (RBACPrivilegeInfo entity in entitys)
            {
                ResInfo = MyResBLL.GetRBACResourceByID(entity.RBAC_Privilege_ResourceID, Public.GetUserPrivilege());

                jsonBuilder.Append("{\"RBACPrivilegeInfo.RBAC_Privilege_ID\":\"" + entity.RBAC_Privilege_ID + "\",\"cell\":[");
                //各字段
                jsonBuilder.Append("\"");
                jsonBuilder.Append(entity.RBAC_Privilege_ID);
                jsonBuilder.Append("\",");

                jsonBuilder.Append("\"");
                jsonBuilder.Append(entity.RBAC_Privilege_Name);
                jsonBuilder.Append("\",");

                jsonBuilder.Append("\"");
                if (ResInfo != null)
                {
                    jsonBuilder.Append(ResInfo.RBAC_Resource_Name);
                }
                else
                {
                    jsonBuilder.Append(entity.RBAC_Privilege_ResourceID);
                }
                jsonBuilder.Append("\",");

                jsonBuilder.Append("\"");
                jsonBuilder.Append(entity.RBAC_Privilege_Addtime);
                jsonBuilder.Append("\",");

                jsonBuilder.Append("\"");

                if (Public.CheckPrivilege("51be7b46-e0f7-46dd-b0b2-a462fcb907ae"))
                {
                    jsonBuilder.Append("<img src=\\\"/images/icon_edit.gif\\\" alt=\\\"修改\\\"> <a href=\\\"privilege_list.aspx?action=renew&rbac_privilege_id=" + entity.RBAC_Privilege_ID + "\\\" title=\\\"修改\\\">修改</a>");
                }

                if (Public.CheckPrivilege("1030465e-7113-4db6-9b3c-da21aca07748"))
                {
                    jsonBuilder.Append(" <img src=\\\"/images/icon_del.gif\\\"  alt=\\\"删除\\\"> <a href=\\\"javascript:void(0);\\\" onclick=\\\"confirmdelete('privilege_do.aspx?action=move&rbac_privilege_id=" + entity.RBAC_Privilege_ID + "')\\\" title=\\\"删除\\\">删除</a>");
                }

                jsonBuilder.Append("\",");

                jsonBuilder.Remove(jsonBuilder.Length - 1, 1);
                jsonBuilder.Append("]},");
            }
            jsonBuilder.Remove(jsonBuilder.Length - 1, 1);
            jsonBuilder.Append("]");
            jsonBuilder.Append("}");
            return(jsonBuilder.ToString());
        }
        else
        {
            return(null);
        }
    }