コード例 #1
0
ファイル: UserAccount.cs プロジェクト: foxbill/xbase-2018.01
        public bool existsUser(string userId)
        {
            DatabaseAdmin dba = SecuritySettings.getDBA();
            DbCommand     cmd = dba.getSqlStringCommand(SecurityDataScripts.CheckUserExistsSQL);

            dba.addInParameter(cmd, "@user_id", DbType.String, userId);
            object o = dba.executeScalar(cmd);

            return(o != null);
        }
コード例 #2
0
ファイル: UserAccount.cs プロジェクト: foxbill/xbase-2018.01
        public void appendUserRole(string userId, string roleId)
        {
            DatabaseAdmin dba = SecuritySettings.getDBA();
            DbCommand     cmd = dba.getSqlStringCommand(SecurityDataScripts.CheckUserRolesSQl);

            dba.addInParameter(cmd, "@roleId", DbType.String, roleId);
            dba.addInParameter(cmd, "@userId", DbType.String, userId);
            object c = dba.executeScalar(cmd);

            if ((int)c < 1)
            {
                cmd = dba.getSqlStringCommand(SecurityDataScripts.AppendUserRolesSQl);
                dba.addInParameter(cmd, "@roleId", DbType.String, roleId);
                dba.addInParameter(cmd, "@userId", DbType.String, userId);
            }
            dba.execNonQuery(cmd);
        }
コード例 #3
0
ファイル: RoleManager.cs プロジェクト: foxbill/xbase-2018.01
        public static PermissionTypes getRoleObjectPermission(string roleId, string objectId)
        {
            DatabaseAdmin dba = SecuritySettings.getDBA();
            DbCommand     cmd = dba.getSqlStringCommand(SecurityDataScripts.RoleObjectPermissionSql);

            dba.addInParameter(cmd, "@roleId", DbType.String, roleId);
            dba.addInParameter(cmd, "@objectId", DbType.String, objectId);
            object ret = dba.executeScalar(cmd);

            if (ret != null && ret is int)
            {
                return((PermissionTypes)ret);
            }
            else
            {
                return(PermissionTypes.None);
            }
        }
コード例 #4
0
ファイル: UserAccount.cs プロジェクト: foxbill/xbase-2018.01
        public bool appendRoles(UserRoleIds userRoleIds)
        {
            string        userId = userRoleIds.UserId;
            DatabaseAdmin dba    = SecuritySettings.getDBA();

            for (int i = 0; i < userRoleIds.RoleIds.Count; i++)
            {
                DbCommand cmd    = dba.getSqlStringCommand(SecurityDataScripts.CheckUserRolesSQl);
                string    roleId = userRoleIds.RoleIds[i];
                dba.addInParameter(cmd, "@roleId", DbType.String, roleId);
                dba.addInParameter(cmd, "@userId", DbType.String, userId);
                object c = dba.executeScalar(cmd);
                if ((int)c < 1)
                {
                    cmd = dba.getSqlStringCommand(SecurityDataScripts.AppendUserRolesSQl);
                    dba.addInParameter(cmd, "@roleId", DbType.String, roleId);
                    dba.addInParameter(cmd, "@userId", DbType.String, userId);
                }
                dba.execNonQuery(cmd);
            }
            return(true);
        }