Exemplo n.º 1
0
 public static void DeleteRole(RoleInfo role)
 {
     if ((role != null) && !IsBuiltInRole(role.Name))
     {
         Roles.DeleteRole(role.Name);
     }
 }
Exemplo n.º 2
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     if (string.IsNullOrEmpty(this.Page.Request.QueryString["roleId"]))
     {
         base.GotoResourceNotFound();
         return;
     }
     this.RequestRoleId    = this.Page.Request.QueryString["roleId"];
     this.btnSet1.Click   += new System.EventHandler(this.btnSet_Click);
     this.btnSetTop.Click += new System.EventHandler(this.btnSet_Click);
     if (!this.Page.IsPostBack)
     {
         System.Guid guid = new System.Guid(this.RequestRoleId);
         if (System.Text.RegularExpressions.Regex.IsMatch(this.RequestRoleId, "[A-Z0-9]{8}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{12}", System.Text.RegularExpressions.RegexOptions.IgnoreCase))
         {
             Hidistro.Membership.Core.RoleInfo role = Hidistro.Membership.Core.RoleHelper.GetRole(guid);
             this.lblRoleName.Text = role.Name;
         }
         if (this.Page.Request.QueryString["Status"] == "1")
         {
             this.ShowMsg("设置部门权限成功", true);
         }
         this.LoadData(guid);
     }
 }
Exemplo n.º 3
0
        private void btnEditRoles_Click(object sender, System.EventArgs e)
        {
            Hidistro.Membership.Core.RoleInfo roleInfo = new Hidistro.Membership.Core.RoleInfo();
            if (string.IsNullOrEmpty(this.txtEditRoleName.Text.Trim()))
            {
                this.ShowMsg("部门名称不能为空,长度限制在60个字符以内", false);
                return;
            }
            if (string.Compare(this.txtRoleName.Value, this.txtEditRoleName.Text) != 0 && Hidistro.Membership.Core.RoleHelper.RoleExists(this.txtEditRoleName.Text.Trim().Replace(",", "")))
            {
                this.ShowMsg("已经存在相同的部门名称", false);
                return;
            }
            roleInfo.RoleID      = new System.Guid(this.txtRoleId.Value);
            roleInfo.Name        = Globals.HtmlEncode(this.txtEditRoleName.Text.Trim()).Replace(",", "");
            roleInfo.Description = Globals.HtmlEncode(this.txtEditRoleDesc.Text.Trim());
            ValidationResults validationResults = Validation.Validate <Hidistro.Membership.Core.RoleInfo>(roleInfo, new string[]
            {
                "ValRoleInfo"
            });
            string text = string.Empty;

            if (!validationResults.IsValid)
            {
                foreach (ValidationResult current in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults)
                {
                    text += Formatter.FormatErrorMessage(current.Message);
                }
                this.ShowMsg(text, false);
                return;
            }
            Hidistro.Membership.Core.RoleHelper.UpdateRole(roleInfo);
            this.BindUserGroup();
        }
Exemplo n.º 4
0
 public static RoleInfo PopulateRoleFromIDataReader(IDataReader reader)
 {
     RoleInfo info = new RoleInfo();
     info.RoleID = (Guid) reader["RoleID"];
     info.Name = (string) reader["Name"];
     info.Description = reader["Description"] as string;
     return info;
 }
Exemplo n.º 5
0
        protected void btnSubmitRoles_Click(object sender, System.EventArgs e)
        {
            string text        = Globals.HtmlEncode(this.txtAddRoleName.Text.Trim()).Replace(",", "");
            string description = Globals.HtmlEncode(this.txtRoleDesc.Text.Trim());

            if (string.IsNullOrEmpty(text) || text.Length > 60)
            {
                this.ShowMsg("部门名称不能为空,长度限制在60个字符以内", false);
                return;
            }
            if (Hidistro.Membership.Core.RoleHelper.RoleExists(text))
            {
                this.ShowMsg("已经存在相同的部门名称", false);
                return;
            }
            Hidistro.Membership.Core.RoleHelper.AddRole(text);
            Hidistro.Membership.Core.RoleInfo role = Hidistro.Membership.Core.RoleHelper.GetRole(text);
            role.Name        = text;
            role.Description = description;
            ValidationResults validationResults = Validation.Validate <Hidistro.Membership.Core.RoleInfo>(role, new string[]
            {
                "ValRoleInfo"
            });
            string text2 = string.Empty;

            if (!validationResults.IsValid)
            {
                foreach (ValidationResult current in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults)
                {
                    text2 += Formatter.FormatErrorMessage(current.Message);
                }
                this.ShowMsg(text2, false);
                return;
            }
            Hidistro.Membership.Core.RoleHelper.UpdateRole(role);
            this.BindUserGroup();
            this.ShowMsg("成功添加了一个部门", true);
        }
Exemplo n.º 6
0
        private void grdGroupList_RowDeleting(object sender, System.Web.UI.WebControls.GridViewDeleteEventArgs e)
        {
            System.Web.UI.WebControls.Label label = (System.Web.UI.WebControls.Label) this.grdGroupList.Rows[e.RowIndex].FindControl("lblRoleName");
            string text = label.Text;

            if (Hidistro.Membership.Core.RoleHelper.IsBuiltInRole(text))
            {
                this.ShowMsg("系统默认创建的部门不能删除", false);
                return;
            }
            Hidistro.Membership.Core.RoleInfo role = new Hidistro.Membership.Core.RoleInfo();
            role = Hidistro.Membership.Core.RoleHelper.GetRole((System.Guid) this.grdGroupList.DataKeys[e.RowIndex].Value);
            try
            {
                Hidistro.Membership.Core.RoleHelper.DeleteRole(role);
                this.BindUserGroup();
                this.ShowMsg("成功删除了选择的部门", true);
            }
            catch
            {
                this.ShowMsg("删除失败,该部门下已有管理员", true);
            }
        }
Exemplo n.º 7
0
 public static void UpdateRole(RoleInfo role)
 {
     if (((role != null) && !IsBuiltInRole(role.Name)) && ((role.Name != null) && (role.Name.Length != 0)))
     {
         MemberRoleProvider.Instance().UpdateRole(role);
     }
 }
Exemplo n.º 8
0
 public abstract void UpdateRole(RoleInfo role);
Exemplo n.º 9
0
 public override void UpdateRole(RoleInfo role)
 {
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE aspnet_Roles SET RoleName = @Name, LoweredRoleName = Lower(@Name), Description = @Description WHERE RoleId = @RoleId");
     this.database.AddInParameter(sqlStringCommand, "Name", DbType.String, role.Name);
     this.database.AddInParameter(sqlStringCommand, "Description", DbType.String, role.Description);
     this.database.AddInParameter(sqlStringCommand, "RoleId", DbType.Guid, role.RoleID);
     this.database.ExecuteNonQuery(sqlStringCommand);
 }
Exemplo n.º 10
0
 private void btnEditRoles_Click(object sender, EventArgs e)
 {
     RoleInfo target = new RoleInfo();
     if (string.IsNullOrEmpty(txtEditRoleName.Text.Trim()))
     {
         ShowMsg("部门名称不能为空,长度限制在60个字符以内", false);
     }
     else if ((string.Compare(txtRoleName.Value, txtEditRoleName.Text) == 0) || !RoleHelper.RoleExists(txtEditRoleName.Text.Trim()))
     {
         target.RoleID = new Guid(txtRoleId.Value);
         target.Name = Globals.HtmlEncode(txtEditRoleName.Text.Trim());
         target.Description = Globals.HtmlEncode(txtEditRoleDesc.Text.Trim());
         ValidationResults results = Hishop.Components.Validation.Validation.Validate<RoleInfo>(target, new string[] { "ValRoleInfo" });
         string msg = string.Empty;
         if (!results.IsValid)
         {
             foreach (ValidationResult result in (IEnumerable<ValidationResult>)results)
             {
                 msg = msg + Formatter.FormatErrorMessage(result.Message);
             }
             ShowMsg(msg, false);
         }
         else
         {
             RoleHelper.UpdateRole(target);
             BindUserGroup();
         }
     }
     else
     {
         ShowMsg("已经存在相同的部门名称", false);
     }
 }
Exemplo n.º 11
0
 private void grdGroupList_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     Label label = (Label)grdGroupList.Rows[e.RowIndex].FindControl("lblRoleName");
     if (RoleHelper.IsBuiltInRole(label.Text))
     {
         ShowMsg("系统默认创建的部门不能删除", false);
     }
     else
     {
         RoleInfo role = new RoleInfo();
         role = RoleHelper.GetRole((Guid)grdGroupList.DataKeys[e.RowIndex].Value);
         try
         {
             RoleHelper.DeleteRole(role);
             BindUserGroup();
             ShowMsg("成功删除了选择的部门", true);
         }
         catch
         {
             ShowMsg("删除失败,该部门下已有管理员", true);
         }
     }
 }
Exemplo n.º 12
0
 public abstract void UpdateRole(RoleInfo role);