예제 #1
0
파일: RBACRole.cs 프로젝트: Abnertd/public
        public virtual bool EditRBACRole(RBACRoleInfo entity)
        {
            string    SqlAdd = null;
            DataTable DtAdd  = null;
            DataRow   DrAdd  = null;

            SqlAdd = "SELECT * FROM RBAC_Role WHERE RBAC_Role_ID = " + entity.RBAC_Role_ID;
            DtAdd  = DBHelper.Query(SqlAdd);
            try
            {
                if (DtAdd.Rows.Count > 0)
                {
                    DrAdd = DtAdd.Rows[0];
                    DrAdd["RBAC_Role_ID"]          = entity.RBAC_Role_ID;
                    DrAdd["RBAC_Role_Name"]        = entity.RBAC_Role_Name;
                    DrAdd["RBAC_Role_Description"] = entity.RBAC_Role_Description;
                    DrAdd["RBAC_Role_IsSystem"]    = entity.RBAC_Role_IsSystem;
                    DrAdd["RBAC_Role_Site"]        = entity.RBAC_Role_Site;
                    DBHelper.SaveChanges(SqlAdd, DtAdd);

                    SaveRolePrivilege(entity.RBAC_Role_ID, entity.RBACPrivilegeInfos);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex) {
                throw ex;
            }
            finally {
                DtAdd.Dispose();
            }
            return(true);
        }
예제 #2
0
파일: User.cs 프로젝트: Abnertd/public
        public virtual IList <RBACRoleInfo> GetRoleListByUser(int User_ID)
        {
            IList <RBACRoleInfo> entitys = null;
            RBACRoleInfo         entity  = null;
            string SqlList = "SELECT A.RBAC_Role_ID, A.RBAC_Role_Name, A.RBAC_Role_Description, A.RBAC_Role_IsSystem";

            SqlList += " FROM RBAC_Role AS A INNER JOIN RBAC_UserRole AS B ON A.RBAC_Role_ID = B.RBAC_UserRole_RoleID";
            SqlList += " WHERE B.RBAC_UserRole_UserID =" + User_ID;
            DataTable Dt = DBHelper.Query(SqlList);

            if (Dt.Rows.Count > 0)
            {
                entitys = new List <RBACRoleInfo>();
                foreach (DataRow dr in Dt.Rows)
                {
                    entity = new RBACRoleInfo();
                    entity.RBAC_Role_ID          = Tools.NullInt(dr["RBAC_Role_ID"]);
                    entity.RBAC_Role_Name        = Tools.NullStr(dr["RBAC_Role_Name"]);
                    entity.RBAC_Role_Description = Tools.NullStr(dr["RBAC_Role_Description"]);
                    entity.RBAC_Role_IsSystem    = Tools.NullInt(dr["RBAC_Role_IsSystem"]);
                    entity.RBACPrivilegeInfos    = MyRole.GetPrivilegeListByRole(entity.RBAC_Role_ID);
                    entitys.Add(entity);
                    entity = null;
                }
            }
            return(entitys);
        }
예제 #3
0
파일: RBACRole.cs 프로젝트: Abnertd/public
        public virtual bool AddRBACRole(RBACRoleInfo entity)
        {
            string    SqlAdd = null;
            DataTable DtAdd  = null;
            DataRow   DrAdd  = null;

            SqlAdd = "SELECT TOP 0 * FROM RBAC_Role";
            DtAdd  = DBHelper.Query(SqlAdd);
            DrAdd  = DtAdd.NewRow();

            DrAdd["RBAC_Role_ID"]          = entity.RBAC_Role_ID;
            DrAdd["RBAC_Role_Name"]        = entity.RBAC_Role_Name;
            DrAdd["RBAC_Role_Description"] = entity.RBAC_Role_Description;
            DrAdd["RBAC_Role_IsSystem"]    = entity.RBAC_Role_IsSystem;
            DrAdd["RBAC_Role_Site"]        = entity.RBAC_Role_Site;

            DtAdd.Rows.Add(DrAdd);
            try {
                DBHelper.SaveChanges(SqlAdd, DtAdd);

                SaveRolePrivilege(GetLastRoleID(entity.RBAC_Role_Name), entity.RBACPrivilegeInfos);
                return(true);
            }
            catch (Exception ex) {
                throw ex;
            }
            finally {
                DtAdd.Dispose();
            }
        }
예제 #4
0
파일: RBACRole.cs 프로젝트: Abnertd/public
        public virtual IList <RBACRoleInfo> GetRBACRoles(QueryInfo Query)
        {
            int PageSize;
            int CurrentPage;
            IList <RBACRoleInfo> entitys = null;
            RBACRoleInfo         entity = null;
            string        SqlList, SqlField, SqlOrder, SqlParam, SqlTable;
            SqlDataReader RdrList = null;

            try
            {
                CurrentPage = Query.CurrentPage;
                PageSize    = Query.PageSize;
                SqlTable    = "RBAC_Role";
                SqlField    = "*";
                SqlParam    = DBHelper.GetSqlParam(Query.ParamInfos);
                SqlOrder    = DBHelper.GetSqlOrder(Query.OrderInfos);
                SqlList     = DBHelper.GetSqlPage(SqlTable, SqlField, SqlParam, SqlOrder, CurrentPage, PageSize);
                RdrList     = DBHelper.ExecuteReader(SqlList);
                if (RdrList.HasRows)
                {
                    entitys = new List <RBACRoleInfo>();
                    while (RdrList.Read())
                    {
                        entity = new RBACRoleInfo();
                        entity.RBAC_Role_ID          = Tools.NullInt(RdrList["RBAC_Role_ID"]);
                        entity.RBAC_Role_Name        = Tools.NullStr(RdrList["RBAC_Role_Name"]);
                        entity.RBAC_Role_Description = Tools.NullStr(RdrList["RBAC_Role_Description"]);
                        entity.RBAC_Role_IsSystem    = Tools.NullInt(RdrList["RBAC_Role_IsSystem"]);
                        entity.RBAC_Role_Site        = Tools.NullStr(RdrList["RBAC_Role_Site"]);
                        entity.RBACPrivilegeInfos    = null;
                        entitys.Add(entity);
                        entity = null;
                    }
                }

                if (entitys != null)
                {
                    foreach (RBACRoleInfo RoleInfo in entitys)
                    {
                        RoleInfo.RBACPrivilegeInfos = GetPrivilegeListByRole(RoleInfo.RBAC_Role_ID);
                    }
                }

                return(entitys);
            }
            catch (Exception ex) {
                throw ex;
            }
            finally {
                if (RdrList != null)
                {
                    RdrList.Close();
                    RdrList = null;
                }
            }
        }
예제 #5
0
파일: RBACRole.cs 프로젝트: Abnertd/public
 public virtual bool EditRBACRole(RBACRoleInfo entity, RBACUserInfo UserPrivilege)
 {
     if (RBAC.CheckPrivilege(UserPrivilege, "4df5eb30-ee06-49a4-b119-4c72e5dfaebc"))
     {
         return(MyDAL.EditRBACRole(entity));
     }
     else
     {
         throw new TradePrivilegeException("没有权限,权限代码:4df5eb30-ee06-49a4-b119-4c72e5dfaebc错误");
     }
 }
예제 #6
0
파일: RBACRole.cs 프로젝트: Abnertd/public
 public virtual bool AddRBACRole(RBACRoleInfo entity, RBACUserInfo UserPrivilege)
 {
     if (RBAC.CheckPrivilege(UserPrivilege, "71268a79-72ee-4892-a8f8-cf02b13c312a"))
     {
         return(MyDAL.AddRBACRole(entity));
     }
     else
     {
         throw new TradePrivilegeException("没有权限,权限代码:71268a79-72ee-4892-a8f8-cf02b13c312a错误");
     }
 }
예제 #7
0
파일: RBACRole.cs 프로젝트: Abnertd/public
    public void AddRBACRole()
    {
        int    RBAC_Role_ID          = tools.CheckInt(Request.Form["RBAC_Role_ID"]);
        string RBAC_Role_Name        = tools.CheckStr(Request.Form["RBAC_Role_Name"]);
        string RBAC_Role_Description = tools.CheckStr(Request.Form["RBAC_Role_Description"]);
        int    RBAC_Role_IsSystem    = tools.CheckInt(Request.Form["RBAC_Role_IsSystem"]);

        string[] strPrivilege = tools.CheckStr(Request.Form["privilege_id"]).Split(',');
        IList <RBACPrivilegeInfo> privilegeList = new List <RBACPrivilegeInfo>();
        RBACPrivilegeInfo         privilege;

        foreach (string privilege_id in strPrivilege)
        {
            if (privilege_id != "")
            {
                privilege = new RBACPrivilegeInfo();
                privilege.RBAC_Privilege_ID = privilege_id;
                privilegeList.Add(privilege);
                privilege = null;
            }
        }

        RBACRoleInfo entity = new RBACRoleInfo();

        entity.RBAC_Role_ID          = RBAC_Role_ID;
        entity.RBAC_Role_Name        = RBAC_Role_Name;
        entity.RBAC_Role_Description = RBAC_Role_Description;
        entity.RBAC_Role_IsSystem    = RBAC_Role_IsSystem;
        entity.RBAC_Role_Site        = "CN";
        entity.RBACPrivilegeInfos    = privilegeList;

        privilegeList = null;

        if (MyBLL.AddRBACRole(entity, Public.GetUserPrivilege()))
        {
            Public.Msg("positive", "操作成功", "操作成功", true, "RBAC_Role_add.aspx");
        }
        else
        {
            Public.Msg("error", "错误信息", "操作失败,请稍后重试", false, "{back}");
        }
    }
예제 #8
0
파일: RBACRole.cs 프로젝트: Abnertd/public
        public virtual RBACRoleInfo GetRBACRoleByID(int ID)
        {
            RBACRoleInfo  entity  = null;
            SqlDataReader RdrList = null;

            try {
                string SqlList;
                SqlList = "SELECT * FROM RBAC_Role WHERE RBAC_Role_ID = " + ID;
                RdrList = DBHelper.ExecuteReader(SqlList);
                if (RdrList.Read())
                {
                    entity = new RBACRoleInfo();
                    entity.RBAC_Role_ID          = Tools.NullInt(RdrList["RBAC_Role_ID"]);
                    entity.RBAC_Role_Name        = Tools.NullStr(RdrList["RBAC_Role_Name"]);
                    entity.RBAC_Role_Description = Tools.NullStr(RdrList["RBAC_Role_Description"]);
                    entity.RBAC_Role_IsSystem    = Tools.NullInt(RdrList["RBAC_Role_IsSystem"]);
                    entity.RBAC_Role_Site        = Tools.NullStr(RdrList["RBAC_Role_Site"]);
                    entity.RBACPrivilegeInfos    = null;
                }

                RdrList.Close();
                RdrList = null;

                if (entity != null)
                {
                    entity.RBACPrivilegeInfos = GetPrivilegeListByRole(entity.RBAC_Role_ID);
                }

                return(entity);
            }
            catch (Exception ex) {
                throw ex;
            }
            finally {
                if (RdrList != null)
                {
                    RdrList.Close();
                    RdrList = null;
                }
            }
        }
예제 #9
0
파일: RBACRole.cs 프로젝트: Abnertd/public
    public string DisplayResourceGroup(int Role_ID)
    {
        StringBuilder strHTML = new StringBuilder();

        IList <RBACPrivilegeInfo> privileges = null;
        RBACRoleInfo roleInfo = GetRBACRoleByID(Role_ID);

        if (roleInfo != null)
        {
            privileges = roleInfo.RBACPrivilegeInfos;
        }

        QueryInfo Query = new QueryInfo();

        Query.PageSize = 0;
        Query.ParamInfos.Add(new ParamInfo("AND", "str", "RBACResourceGroupInfo.RBAC_ResourceGroup_Site", "=", "CN"));
        Query.OrderInfos.Add(new OrderInfo("RBACResourceGroupInfo.RBAC_ResourceGroup_ID", "DESC"));
        IList <RBACResourceGroupInfo> entitys = MyResGrp.GetRBACResourceGroups(Query, Public.GetUserPrivilege());

        Query = null;
        if (entitys != null)
        {
            strHTML.Append("<table cellspacing=\"5\" cellpadding=\"0\" border=\"0\">");
            foreach (RBACResourceGroupInfo entity in entitys)
            {
                strHTML.Append("<tr>");
                strHTML.Append("    <td style=\"font-size:14px;font-weight:bold;border-bottom:1px solid #ccc;\">" + entity.RBAC_ResourceGroup_Name + "</td>");
                strHTML.Append("</tr>");

                strHTML.Append("<tr>");
                strHTML.Append("    <td style=\"padding-left:14px;\">" + DisplayResource(entity.RBAC_ResourceGroup_ID, privileges) + "</td>");
                strHTML.Append("</tr>");
            }
            strHTML.Append("</table>");
        }
        entitys = null;
        return(strHTML.ToString());
    }