cancel
Showing results for 
Search instead for 
Did you mean: 

How to properly close and dispose of reports loaded by PSReportFactory

Former Member
0 Kudos

Hello,

I would like to know if there is a way to close and dispose of a report loaded via the CrystalProcessingServer2011 (PSReportFactory in code).

Previously I had used a report client document as my source and could get a reference to this to close and dispose of on the page unload.

However now the crystal report viewer's source is loaded via reportFactory.OpenReportSource(rptID) (reportFactory is PSReportFactory).

ReportSource (or ISCRReportSource) don't provide any methods for closing or disposing.

Currently I'm simply setting the Session variable holding this source to null on unload and hoping the ProcessingServer would close at it's own

convenience.

I would appreciate if someone could suggest a method to explicitly close and dispose of this report source.

Thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

Hi Paul

This is managed by Enterprise.  All you should need to do is log off of the enterprise session:

EnterpriseSession.Logoff();

- Ludek

Senior Support Engineer AGS Product Support, Global Support Center Canada

Follow us on Twitter

Former Member
0 Kudos

Thanks for your Response Ludek,

Currently the application is set up that the user is able to load, view and close several reports within

one session, a logon token is created from the enterprise session (EnterpriseSession.LogonTokenMgr.CreateLogonTokenEx()) for use.

All report requests during a session are served using this logon token

I release their logon token when they finally logoff from the application.

I'm trying to dispose of each report as the user switches to view a different one. While it's released in session, I see (via CMC) that this builds up on the crystal server.

You bring up a good point about EnterpriseSession.Logoff() I hadn't noticed this previously.

Questions:

  • Would using EnterpriseSession.Logoff() automatically release tokens created from this EnterpriseSession?
    • If so, wouldn't this prematurely invalidate the session and force having to create a new one for each report load?
    • If not, then I see how this could work
  • I am currently releasing the token when the user logs off (EnterpriseSession.LogonTokenMgr.ReleaseToken(Session["LogonToken"]), I suppose I should also include EnterpriseSession.Logoff() after this?

Thanks again.

former_member183750
Active Contributor
0 Kudos

Hi Paul

EnterpriseSession.Logoff() would automatically release tokens created from an EnterpriseSession and thus invalidates the session. So, you have to be very cautious in using it.

As far as using the EnterpriseSession.Logoff() after releasing the token. When the token is released, it can not be reused. If you use EnterpriseSession.Logoff() the token still exists and thus could be reused to log the user back on if need be. Releasing the token and then using EnterpriseSession.Logoff() will not hurt, but should not be necessary.




- Ludek

Former Member
0 Kudos

Thanks for the Info Ludek,

I would bother you once more for clarification, following from your statements.

EnterpriseSession.Logoff() would release a token created from it and dispose of reports loaded for this enterpriseSession. However the token would still exist and could be used to logon once more to this enterpriseSession.

  • Is it then safe to say that the release of tokens by EnterpriseSession.Logoff() is not as permanent as using EnterpriseSession.LogonTokenMgr.ReleaseToken(Session["LogonToken"]?
    • Following from this, is it ok to use EnterpriseSession.Logoff() when a user is done with a report and then simply logon with the token ( enterpriseSession = sessionMgr.LogonWithToken(Session["LogonToken"].ToString()) when they need to load another report?
    • Then at final logoff from Page Session, LogonTokenMgr.ReleaseToken(...) is used to permanently release the token.

Thanks.

former_member183750
Active Contributor
0 Kudos

Hi Paul


Following from this, is it ok to use EnterpriseSession.Logoff() when a user is done with a report and then simply logon with the token ( enterpriseSession = sessionMgr.LogonWithToken(Session["LogonToken"].ToString()) when they need to load another report?

Yes, that is correct.


Then at final logoff from Page Session, LogonTokenMgr.ReleaseToken(...) is used to permanently release the token.

That is the way I have done some of my sample apps. And as far as I can tell, they work just fine.

- Ludek

Former Member
0 Kudos

Thank you Ludek I was able to test this process flow and saw that, I could succesfully logon and logoff and back on again(via EnterpriseSession) and that the reports loaded fine.

However on EnterpriseSession.Logoff, I still note that the reports loaded are listed in CMC as open jobs under the CrystalReports2011ProcessingServer metrics. In fact they are still shown here after the complete logoff where I release the token saved to session and only finally go away after some unknown amount of time.

Is there no way to maybe explicitly tell the CrystalReports2011ProcessingServer (EnterpriseService reportService = enterpriseSession.GetService("PSReportFactory");) to close/dispose of the reports that it has open?

I appreciate your patience and advice.

Sincerely

former_member183750
Active Contributor
0 Kudos

Hi Paul

As far as I know there is no explicit API that would unload that object (I did ask ). I guess that is where the managed part comes in. E.g.; Enterprise / BI manages this for you. I think you will find that the objects will be released at 20 minutes.

Now, the time out can be adjusted in the properties of the Processing Server - look for "Idle Job Timeout".

- Ludek

DellSC
Active Contributor
0 Kudos

However, be careful not to put the Idle Job Timeout too low as it will affect user's ability to page through reports.  Say, for example, that you set it to 1 minute.  If a user is viewing a report and gets a phone call that lasts more than a minute, this setting might cause an error when the user tries to go to the next page of the report.

So, you'll need to find the right "balance" in terms of where to set this.  Most of my clients never change it from the default value.

-Dell

Former Member
0 Kudos

Ah I see, I'd experiment. Thanks for investigating this for me, much obliged.

Answers (0)