AlexFreitas


I'm grasping for straws here, so any help would be appreciated.

So we are migrating from Crystal to MS Reporting Services.  Over on the Crystal world we had a custom report page that would gather rpt parameters and schedule the rpt to run immediately.  I was told by my manager (who happened to be the one that wrote the code for Crystal...) that the reason for that was because Crystal didn't handle too many requests at once and would eventually lock up and all users would be out of luck.  So, if there are 20 users generating rpts, instead of all of them having to wait for all reports to be done to see theirs, they would queue up and get their report on their turn.  Also, if I am the 20th user to run a report, I'd have to wait in line until everyone was done with this approach.

The code examples I have seen suggest that I a) create a project with the report viewer or b)build a link to pass to the viewer in the RS or c) use the render method using a web service.  These all make sense to me and seem straight forward to do.  Our Crystal way definitely does not sound like the best solution, but since this guy thinks he knows what he's talking about and he is now my manager, this is my requirement.  Run the MS RS reports in a scheduled basis (but really on demand) using a web service.

So, here's my code and my questions:

I add a reference to the web service:

dim rs as New ReportService

rs.Credentials=System.Net.CredentialCache.DefaultCredentials

'get the report object and parameters...

dim definition as New ScheduleDefinition

definition.StartDate = Date.Now

definition.EndDateSpecified = False

'after this line, a new schedule is created on the report server's Schedule table

Dim scheduleID as String = rs.CreateSchedule("rptName",definition)

The idea is to keep reposting the page and keep getting the schedule status displaying a loading image on the page.  Once the schedule runs and the report is generated, I redirect the user to the report.  I do this using javascript refreshing the page every 2 seconds.  I save the scheduleId in a session variable to later retrieve it.  Next time I refresh the page, I call a checkStatus routine:

dim rs as ReportingServices = session("rs")

dim status=rs.GetScheduleProperties(session("scheduleId")).Status

for some reason, after I hit the previous line, the status go from Active to Expired ( ), the row in the table updates to NextRunTime='1970-01-01' and the schedule never runs( ).

Has anyone else in the world done anything remotely similar to this

Sorry for the long post.  Thanks,

--Alex



Re: reporting services web services schedule reports

Daniel Reib


The reason it is expired is because the schedule never had time to fire. You ask for it to fire now and but by the time SQL Agent gets the request the event will not fire. You would want to wait at least one minute, more to be safe.

However, the whole approach seems flawed. I'd suggest you instead look into using report snapshot executions. You can then schedule the reports to retrieve their data at any time, and then when users go to view them they will only have to render the reports.

I would also advise attempting to use the server as is, rather then devise some scheme to serialze report access. If your manager is insistant on running the reports in order, why do you need to schedule them Just hold the user request until it is their turn, or are you planning on mailing the report I am not sure I understand what you expect to happen when the schedule fires.