Question

I want to get an idea about how can i capture the data audit trail of SSRS report getting rendered in Asp.net reportviwer.

I dont want the execution log. Example my report take department as input and give all details of employee working in that department.

Now my requirement is that, lets say i run the report for department a and get some employee then i have to log a audit trail saying i have seen records of so and so employee.

I was thinking that from SSRS itself i can insert the record which are retrieved or to be rendered but what if rendering failed, my log will still say that i have seen the record even before it appearing on ASP.Net page. Second way is that i have to make another call after data is rendered with same parameter and then log the result which can give me wrong result as data might have changed in that small interval.

secondly is there a way to track the save and print event On asp.net reportviewer control

looking forward for ideas. Thanks in advance.

Était-ce utile?

La solution

Reporting Services may not be the solution for you if you want to add behaviour to data access. Reports are best as a display of data, not having side effects.

That said, probably the best you can do is to audit the rendering process using custom code. For instance, when you go to display the employee code you call a function recording that it was displayed and by who:

Function AuditEmployeeAccess(EmployeeCode As String) As String
    ' Connect to database, audit access (off the top of my head, could be bad)
    Dim con As New SqlConnection
    Dim cmd As New SqlCommand
    con.ConnectionString = "Data Source=MyServer;Initial Catalog=AuditDb;User ID=username;Password=password"
    con.Open()
    ' Don't do this, use parameters
    cmd.CommandText = ("insert into audit (AuditEmployeeCode, AccessEmployeeCode) values ('" + Globals!UserId.Value + "', '" + EmployeeCode  + "')")
    cmd.Connection = con
    cmd.ExecuteNonQuery()
    con.Close()

    ' Return the employee code for display in the report        
    Return EmployeeCode
End Function

then instead of the cell holding the field value, it uses the expression:

=Code.AuditEmployeeAccess(Fields!EmployeeCode.Value)

Now this will audit whenever the employee code renders rather than when it is looked at. For instance, if the report is 5 pages long but the viewer only looks at the first two pages the access will still be audited for those on page 5.

For this reason you are probably better off creating a custom screen rather than using a report.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top