RoleFunctionHelper

 /// <summary>
        /// Role function.
        /// </summary>
        public class RoleFunction {
            public string FunctionCode { get; set; }
            public string Description { get; set; }
            public PermissionType AuthorizationDefinition { get; set; }
            public PermissionType Permission { get; set; }

            #region Permissions

            /// <summary>
            /// Get or set read permission.
            /// </summary>
            public bool CanRead {
                get { return (Permission & PermissionType.Read) == PermissionType.Read; }
                set {
                    if (value)
                        Permission = Permission | PermissionType.Read;
                    else
                        Permission = Permission ^ PermissionType.Read;
                }
            }

            /// <summary>
            /// Get or set update permission.
            /// </summary>
            public bool CanUpdate {
                get { return (Permission & PermissionType.Update) == PermissionType.Update; }
                set {
                    if (value)
                        Permission = Permission | PermissionType.Update;
                    else
                        Permission = Permission ^ PermissionType.Update;
                }
            }

            /// <summary>
            /// Get or set create permission.
            /// </summary>
            public bool CanCreate {
                get { return (Permission & PermissionType.Create) == PermissionType.Create; }
                set {
                    if (value)
                        Permission = Permission | PermissionType.Create;
                    else
                        Permission = Permission ^ PermissionType.Create;
                }
            }

            /// <summary>
            /// Get or set delete permission.
            /// </summary>
            public bool CanDelete {
                get { return (Permission & PermissionType.Delete) == PermissionType.Delete; }
                set {
                    if (value)
                        Permission = Permission | PermissionType.Delete;
                    else
                        Permission = Permission ^ PermissionType.Delete;
                }
            }

            /// <summary>
            /// Get or set approve permission.
            /// </summary>
            public bool CanApprove {
                get { return (Permission & PermissionType.Approve) == PermissionType.Approve; }
                set {
                    if (value)
                        Permission = Permission | PermissionType.Approve;
                    else
                        Permission = Permission ^ PermissionType.Approve;
                }
            }

            /// <summary>
            /// Get or set scheduling permission.
            /// </summary>
            public bool CanSchedule {
                get { return (Permission & PermissionType.Scheduling) == PermissionType.Scheduling; }
                set {
                    if (value)
                        Permission = Permission | PermissionType.Scheduling;
                    else
                        Permission = Permission ^ PermissionType.Scheduling;
                }
            }

            /// <summary>
            /// Get or set production permission.
            /// </summary>
            public bool HasProductionPermission {
                get { return (Permission & PermissionType.Operation) == PermissionType.Operation; }
                set {
                    if (value)
                        Permission = Permission | PermissionType.Operation;
                    else
                        Permission = Permission ^ PermissionType.Operation;
                }
            }

            /// <summary>
            /// Get or set special permission.
            /// </summary>
            public bool HasSpecialPermission {
                get { return (Permission & PermissionType.Special) == PermissionType.Special; }
                set {
                    if (value)
                        Permission = Permission | PermissionType.Special;
                    else
                        Permission = Permission ^ PermissionType.Special;
                }
            }

            /// <summary>
            /// Get or set printing permission.
            /// </summary>
            public bool CanPrint {
                get { return (Permission & PermissionType.Printing) == PermissionType.Printing; }
                set {
                    if (value)
                        Permission = Permission | PermissionType.Printing;
                    else
                        Permission = Permission ^ PermissionType.Printing;
                }
            }

            #endregion
        }

        #endregion

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值