Beispiel #1
0
        public bool RemoveRole(string rolename)
        {
            QcRole role = this.lstRoles.FirstOrDefault(r => r.roleenum.RoleName == rolename);

            if (role != null)
            {
                role.DeleteFromDb();
                InitRoles();
            }
            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// 重载,完成分组编码和分组名称的转换
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>

        void InitRoles()
        {
            lstRoleEnums = new List <QcRoleEnum>();
            lstRoles     = new List <QcRole>();
            var sql = "select * from QC_USE_ROLE where 用户ID='" + this.UserID + "'";

            foreach (var v in DbHelper.Query(sql))
            {
                var qp = new QcRole(v);

                var qpe = QcRoleEnum.GetRoleFromCode(v.Field <string>("角色编码"));
                qp.roleenum = qpe;
                lstRoles.Add(qp);
                lstRoleEnums.Add(qpe);
            }
            RefreshPermission();
        }
Beispiel #3
0
        public bool AddRole(string rolename, string content = "")
        {
            QcRoleEnum role = QcRoleEnum.GetRoleFromName(rolename);

            if (role != null)
            {
                var qr = new QcRole();
                qr["用户ID"]  = this.Code;
                qr["角色编码"]  = role.RoleCode;
                qr["备注"]    = content;
                qr.roleenum = role;
                bool ret = qr.Update();
                if (ret)
                {
                    InitRoles();
                }
                return(ret);
            }
            return(false);
        }
Beispiel #4
0
 void Messagner_DataUpdate(object sender, QcMessagerDataUpdateEventArg e)
 {
     if (e.Node.TableName == "QC_USE_ROLE")
     {
         var qup = e.Node as QcRole;
         if (e.Node is QcNewNode)
         {
             qup = new QcRole(e.Node.GetRow());
         }
         var qre = QcRoleEnum.RolesEnums.FirstOrDefault(
             t => t.RoleCode == qup.RoleCode);
         if (qre != null)
         {
             qre.InitPermission();
         }
         if (qup.UserID == User.UserID)
         {
             this.InitRoles();
         }
     }
     else if (e.Node.TableName == "QC_USE_PERMISSION")
     {
         var qp = e.Node as QcPermission;
         if (e.Node is QcNewNode)
         {
             qp = new QcPermission(e.Node.GetRow());
         }
         var qre = QcRoleEnum.RolesEnums.FirstOrDefault(
             t => t.RoleCode == qp.RoleCode);
         if (qre != null)
         {
             qre.InitPermission();
         }
         var re = RoleEnums.FirstOrDefault(t => t.RoleCode == qp.RoleCode);
         if (re != null)
         {
             re.InitPermission();
             this.RefreshPermission();
         }
     }
 }