예제 #1
0
 /// <summary>
 ///  创建权限类
 /// </summary>
 /// <param name="code">权限编码</param>
 /// <param name="type">操作类型</param>
 /// <param name="permissionenum">权限枚举</param>
 /// <param name="content">备注</param>
 private QcPermissionEnum(string permissionenum, string type = "", string content = "") :
     base(null, "QC_USE_PERMISSIONENUM")
 {
     PermisssionCode = QcPermissionEnum.GetNextCode();
     OperationType   = type;
     PermisssionEnum = permissionenum;
     Content         = content;
 }
예제 #2
0
 /// <summary>
 /// 检测用户是否具有某种权限
 /// </summary>
 /// <param name="PermissionName"></param>
 /// <param name="optype"></param>
 /// <returns></returns>
 public bool HasPermission(string PermissionName, string optype = "")
 {
     QcPermissionEnum.Regsiter(PermissionName, optype);
     if (PermissionEnums.Any(p => p.PermisssionEnum == PermissionName))
     {
         return(true);
     }
     return(false);
 }
예제 #3
0
        /// <summary>
        /// 初始化权限列表,
        /// </summary>
        static private void InitPermission()
        {
            m_lstPermission = new List <QcPermissionEnum>();
            var permissions = DbHelper.Query("select * from QC_USE_PERMISSIONENUM");

            foreach (var v in permissions)
            {
                var qp = new QcPermissionEnum(v);
                Permissions.Add(qp);
            }
        }
예제 #4
0
        public List <QcPermissionEnum> InitPermission()
        {
            List <QcPermissionEnum> lstPermissionEnum = new List <QcPermissionEnum>();
            var sql = "select * from QC_USE_PERMISSION where 角色编码='" + this.RoleCode + "'";

            foreach (var v in DbHelper.Query(sql))
            {
                var qp  = new QcPermission(v);
                var qpe = QcPermissionEnum.GetPermissionFromCode(v.Field <string>("权限编码"));
                qp.PermissionEnum = qpe;
                lstPermissionEnum.Add(qpe);
            }
            return(lstPermissionEnum);
        }
예제 #5
0
        /// <summary>
        /// 注册一个新的权限类型,可以直接调用,中程序请求该类程序验证时,会被创建到角色表
        /// </summary>
        /// <param name="name">权限枚举</param>
        /// <param name="optype">操作类型</param>
        /// <returns></returns>
        static public bool Regsiter(string name, string optype = "默认")
        {
            if (Permissions.Any(t => t.PermisssionEnum == name))
            {
                return(false);
            }
            QcPermissionEnum p = new QcPermissionEnum(name, optype);

            if (p.Update())
            {
                Permissions.Add(p);
                return(true);
            }
            return(false);
        }
예제 #6
0
        public bool AddPermission(string Permission, string content = "")
        {
            QcPermissionEnum pe = QcPermissionEnum.GetPermissionFromName(Permission);

            if (pe != null)
            {
                QcPermission p = new QcPermission();
                p.RoleCode        = this.RoleCode;
                p.PermisssionCode = pe.PermisssionCode;
                p.Content         = content;
                bool ret = p.Update();
                if (ret)
                {
                    return(ret);
                }
            }
            return(false);
        }
예제 #7
0
        public bool RemovePermission(string PermissionName)
        {
            QcPermissionEnum pe = QcPermissionEnum.GetPermissionFromName(PermissionName);

            if (pe != null)
            {
                string sql = "delete  QC_USE_PERMISSION where 角色编码='" + this.RoleCode
                             + "' and 权限编码='" + pe.Code + "'";
                if (DbHelper.Execute(sql))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            return(false);
        }
예제 #8
0
        public override bool Update(QcDbTransaction trans = null)
        {
            if (IsNew())
            {
                this.Code = QcPermissionEnum.GetNextCode();
            }
            bool ret = base.Update(trans);

            if (ret == false && IsNew())
            {
                this.Code = "";
            }
            //新建的加入到列表
            if (ret && !Permissions.Contains(this))
            {
                Permissions.Add(this);
            }
            return(ret);
        }