Using ListReports() to control report access

Expand / Collapse
 

Using ListReports() to control report access


Using ListReports() to control report access

The ListReports() method can be found in the global.asax file, once overridden it will control the default report listing behavior.

C#

public class CustomAdHocConfig : Izenda.AdHoc.DatabaseAdHocConfig
{

protected override Izenda.AdHoc.ReportInfo[] ListReports()
{
ArrayList reportNames = new ArrayList();
string sql = String.Format("SELECT Name, CreatedDate, ModifiedDate FROM ArchivedReport ORDER BY Name WHERE UserID='...'", ArchiveTable);

System.Data.IDbCommand command = null;
try
{
command = Izenda.AdHoc.AdHocContext.Driver.CreateCommand(sql);
System.Data.IDataReader reader = command.ExecuteReader();

while (reader.Read())
{
string reportName = reader["Name"].ToString();
DateTime createdDate = (DateTime)reader["CreatedDate"];
DateTime modifiedDate = (DateTime)reader["ModifiedDate"];
if (reportName != "")
reportNames.Add(new Izenda.AdHoc.ReportInfo(reportName, false, createdDate, modifiedDate));
}
}
catch (Exception) { }

if (command.Connection.State == System.Data.ConnectionState.Open)
command.Connection.Close();
return (Izenda.AdHoc.ReportInfo[])reportNames.ToArray(typeof(Izenda.AdHoc.ReportInfo));
}
}

VB.NET

Public Class CustomAdHocConfig

Public Overrides Function ListReports() As Izenda.AdHoc.ReportInfo()
Dim list As New ArrayList
Dim sql As String = String.Format("SELECT Name, CreatedDate, ModifiedDate FROM {0} ORDER BY Name", MyBase.SavedReportsTable)
Dim command As System.Data.IDbCommand = Nothing
Try
command = Izenda.AdHoc.AdHocContext.Driver.CreateCommand(sql)
Dim reader As System.Data.IDataReader = command.ExecuteReader
Do While reader.Read
Dim fullName As String = reader.Item("Name").ToString
Dim createdDate As DateTime = CDate(reader.Item("CreatedDate"))
Dim modifiedDate As DateTime = CDate(reader.Item("ModifiedDate"))
If (Not fullName Is "") Then
list.Add(New Izenda.AdHoc.ReportInfo(fullName, False, createdDate, modifiedDate))
End If
Loop
Catch exception1 As Exception
End Try
If (command.Connection.State = System.Data.ConnectionState.Open) Then
command.Connection.Close
End If
Return DirectCast(list.ToArray(GetType(Izenda.AdHoc.ReportInfo)), Izenda.AdHoc.ReportInfo())
End Function

End Class



Details
Type: Feature
Options