Imports System.Data.OleDb
Partial Class ReportList
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 GetReportList() As String
Dim sURLIntegration As String = GetSetting("URLIntegration")
If sURLIntegration <> "True" Then
Return "URL Integration is not enabled. Please go to Admin > Settings > Security"
Exit Function
End If
Dim sReportType As String = Request.QueryString("reportType")
Dim sFolderId As String = Request.QueryString("folderId")
Dim bShowEdit As Boolean = (Request.QueryString("edit") = "1")
Dim sSql As String = "SELECT r.ReportId, r.ReportName, r.ReportType, t.DesignImg FROM Report r INNER JOIN ReportType t ON r.ReportType = t.ReportType"
If sFolderId <> "" Then
sSql += " WHERE FolderId = " & sFolderId
ElseIf sReportType <> "" Then
sSql += " WHERE ReportType = " & sReportType
End If
sSql += " ORDER BY ReportName"
Dim cmd As OleDbCommand = New OleDbCommand(sSql, GetConnection())
Dim dr As OleDbDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
Dim sb As New System.Text.StringBuilder
sb.Append("<table border=0>" & vbCrLf)
'Details
While dr.Read
Dim sReportName As String = dr.GetValue(dr.GetOrdinal("ReportName"))
Dim sDesignImg As String = dr.GetValue(dr.GetOrdinal("DesignImg")) & ""
Dim iReportId As String = dr.GetValue(dr.GetOrdinal("ReportId"))
Dim sViewFunction As String = GetJsFunction(iReportId, 0)
Dim sImg As String = "<IMG SRC='images/ext/" & sDesignImg & "' width=18 height=16 BORDER='0'>"
sb.Append("<tr>" & vbCrLf)
sb.Append("<td><a href=""javascript:" & sViewFunction & """>" & sImg & "</a></td>" & vbCrLf)
sb.Append("<td><a href=""javascript:" & sViewFunction & """>" & sReportName & "</a></td>" & vbCrLf)
If bShowEdit Then
Dim sImgEdit As String = "<IMG SRC='images/edit.gif' width=17 height=14 BORDER='0' title='Edit'>"
Dim sDesignFunction As String = GetJsFunction(iReportId, 1)
sb.Append("<td><a href=""javascript:" & sDesignFunction & """>" & sImgEdit & "</a></td>" & vbCrLf)
End If
sb.Append("</tr>" & vbCrLf)
End While
sb.Append("</table>" & vbCrLf)
dr.Close()
Return sb.ToString
End Function
Public Function GetSecurityTokenMode() As String
Return GetSetting("SecurityTokenMode")
End Function
Private Function GetJsFunction(ByVal sReportId As String, _
ByVal iViewMode As Integer) As String
Return "GetReport(" & sReportId & "," & iViewMode & ")"
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
Response.Write("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'.")
Response.End()
End Try
Return cn
End Function
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
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
End Class