Imports System.Data.OleDb
Partial Class WebForm1
Inherits System.Web.UI.Page
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Public Function GetToken(ByVal iSecurityLevel As Integer) As String
Dim sMode As String = GetSecurityTokenMode()
If sMode = "1" Or sMode = "2" Or sMode = "3" Then
Dim sSql As String = "exec GetSecurityToken @SecurityLevel=" & iSecurityLevel
Return GetSingleSqlValue(sSql)
End If
Return ""
End Function
Public Function GetSecurityTokenMode() As String
Return GetSetting("SecurityTokenMode")
End Function
Private Function GetSetting(ByVal sKey As String) As String
Dim sSql As String = "SELECT ParamValue FROM AppSettings WHERE Param ='" & sKey & "'"
Return GetSingleSqlValue(sSql)
End Function
Public Function GetSingleSqlValue(ByVal sSql As String) As String
Dim sRet As String
Dim cn As OleDbConnection = GetConnection()
Dim cmd As New OleDbCommand(sSql, cn)
Try
sRet = cmd.ExecuteScalar()
Catch ex As Exception
Throw New Exception(ex.Message & "; SQL: " & sSql)
End Try
cn.Close()
Return sRet
End Function
Private Function GetConnection() As OleDbConnection
Dim sFilePath As String = Server.MapPath("xmla.udl")
Dim sConnectionString As String = "File Name=" & sFilePath
Dim cn As OleDbConnection = New OleDbConnection(sConnectionString)
Try
cn.Open()
Catch ex As Exception
Throw New Exception("Could not connect to the database. Please double click " & sFilePath & " and point it to ReportPortal database. Make sure to save the connection and check the option to 'Allow saving password'.")
End Try
Return cn
End Function
Public Function GetUserList() As String
Dim sSql As String = "SELECT UserId, UserName FROM AppUser"
Dim cmd As OleDbCommand = New OleDbCommand(sSql, GetConnection())
Dim dr As OleDbDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
Dim sb As New System.Text.StringBuilder
'Details
While dr.Read
Dim sUserId As String = dr.GetValue(dr.GetOrdinal("UserId"))
Dim sUserName As String = dr.GetValue(dr.GetOrdinal("UserName"))
sb.Append("<option value=" & sUserId & ">" & sUserName & "</option>" & vbCrLf)
End While
dr.Close()
Return sb.ToString
End Function