fifo crystal reports pdf email

I need some advice. I have a crystal report in a file and I am using in a Web Application.

When a user click a button the Crystal Report is exported in another file in the server and then send via email using SMTPServer to other clients.
When two or more users click on the button at about the same time the report is in use for one user then the other user will receive an error message like cannot export crystal report.

To avoid this problem, I did put a try catch method. If the application detects the catch then it process the crystal report again until the report is freed to be process.
It is FIFO and it works but I am not sure it is the best solution.

Is there a better solution, I am afraid that users will wait too long to have there report processed.

Who is Participating?
No, I haven't experienced that problem.  I have the full-blown version of 2003 though, it isn't the development edition.  

If you are using the development libraries in production, I'm sure this goes against the licensing of the product, you probably should do like it suggests and buy more licenses.  I think your best solution would be to upgrade your Crystal Reports version to one meant for production.  Back to your problem though, even with the development license, it looks like it should eventually work, at least within a few seconds of each other.  Have you looked at the event log to see if you can find any of these "OutOfLicense" errors?
Are you sure you are coding the crystal report interaction properly?  Crystal reports is an enterprise level product.  If two people can't run a report at the same time, that is a HUGE problem!  Make sure you are closing any reportdocuments you may be opening in code as soon as you are done with them.  Dispose of them too (I think there is a dispose method).  Close everything you've opened!
carolinaspinnerAuthor Commented:
Yeap I did not do that, so I'll Dispose it. But crystal report knows after the report as been used to free itself for the other user to access it. that means that in the laps of time that the report is used nobody can access it.

Now, I'll will not be able to test it until two days from now. But I like to continue the conversation.
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

carolinaspinnerAuthor Commented:
I did dispose the reports but still to send three report it's running slow about five second. I gave you the sample codes to show you that the reportDocuments are disposed right after using them. Just see the arrow on the left of the codes.

   Dim crReportDocument As New CrystalDecisions.CrystalReports.Engine.ReportDocument
        Dim pv As CrystalDecisions.Shared.ParameterValues
        Dim pdv As CrystalDecisions.Shared.ParameterDiscreteValue
        Dim pfds As CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinitions
        Dim pfd As CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition
 ->       Try
        pfds = crReportDocument.DataDefinition.ParameterFields
        pfd = pfds.Item("@YourID_2")
        pv = pfd.CurrentValues
        pdv = New CrystalDecisions.Shared.ParameterDiscreteValue
        pdv.Value = contactID

        pfds = crReportDocument.DataDefinition.ParameterFields
        pfd = pfds.Item("@MyID_1")
        pv = pfd.CurrentValues
        pdv = New CrystalDecisions.Shared.ParameterDiscreteValue
        pdv.Value = testID

        Dim applyCRLog As New ApplyCRLogin

        With applyCRLog
            ._dbName = mydbName
            ._passWord = myPwd
            ._serverName = myServerName
            ._userID = myID
        End With
        '/////////////////////////////EXPORT FILE/////////
            Dim expFile As New ExportFile
            Dim success As Boolean = False
            Do While success = False
                success = expFile.fileToExport("C:\Inetpub\wwwroot\myFile", crReportDocument)
 ->           crReportDocument.Dispose()
            Dim sendEmail As New Mailer
            sendEmail.SendEmail("", "fromMyCompany", "Test Report", "Thsi is test in body", "C:\Inetpub\wwwroot\ExportedCR\Portabledoc.pdf")
->    Catch ex As Exception
            'if the report is used then retry
            sendMail(testID, contactID, emailAddr)
        End Try

Public Class ExportFile
    Public Function fileToExport(ByVal exportPath As String, ByVal crFile As CrystalDecisions.CrystalReports.Engine.ReportDocument) As Boolean
        Dim myExportOptions As CrystalDecisions.Shared.ExportOptions
             Dim crdiskFileDestinationOptions As DiskFileDestinationOptions
               Dim fname As String
 ->       Try
            fname = exportPath + "Portabledoc.pdf"
            crdiskFileDestinationOptions = New DiskFileDestinationOptions
            crdiskFileDestinationOptions.DiskFileName = fname
            myExportOptions = crFile.ExportOptions
            With myExportOptions
                .DestinationOptions = crdiskFileDestinationOptions
                .ExportDestinationType = ExportDestinationType.DiskFile
                .ExportFormatType = ExportFormatType.PortableDocFormat
            End With
->            crFile.Dispose()
            Return True
->        Catch ex As Exception
            Return False
        End Try
    End Function

End Class

carolinaspinnerAuthor Commented:
I forgot to mention the reports or should I say the report I use was made with CR 9 enterprise edition. So yes I cannot imagine a that the report does not allow multiple user at the same time on one report. Maybe I need to install the CR9 deployment msil on the server. Don't know if that is the issue. What do you think?
I see you are throwing away the exceptions that may be caused when you export the document.  I wouldn't suggest doing this.  Your reports should export, if fileToExport() returns false, there may be a larger problem, and you run the risk of an infinite loop.  At the very least, have a counter in there to only try it like 10 times, with a 1 second delay between attempts.  Also, you may want to check the temp folder on your webserver (ASPNET could be using anything, on my webserver it is c:\windows\temp\, but it could be "c:\documents and settings\computername\aspnet\local settings\temp"  Watch this folder when you export a report, temporary files will be created there, but this should be deleted after the operation.  If they are not, you may have a problem.  Lastly, I like to call .Close and .Dispose when I'm worried about an object leaving open resources.

carolinaspinnerAuthor Commented:
Thanks, Raterus I'll check your suggestion when I can go back to my machine.
carolinaspinnerAuthor Commented:
the loop try 10 times now.I use close and dispose. looking at the temp folder, I can see for example when I am sending three reports for one user, that the report are created then deleted in this folder.

It take about 1 second to create and delete the report in the temp folder but still cannot use the same report at the same time.

I made a mistake earlier on the version of Cristal Report. I have Crystal Report Developer edition. And VS 2003 Developer edition.
carolinaspinnerAuthor Commented:
Here is what I found since I use CR development edition and VS 2003 development edition also. It's maybe what happen.

"While you may allow access to the runtime software by many users, the version of the runtime software provided with Crystal Reports for Visual Studio .NET is a performance-limited edition intended for development purposes and use with Server/Web applications accessed by small groups. If a report is accessed while the server is at its performance limit, the request will be delayed until an existing request finishes. When a request is delayed, the server writes a warning message to the event log. After a finite period of time, the request will time-out. When this happens, the server writes another warning to the event log and throws an OutOfLicense exception. To purchase additional licenses, contact"

Have you ever had that problem raterus.
carolinaspinnerAuthor Commented:
Thanks a lot for your great adviced raterus. I learn a lot.
Two user can run and send email at 1 second per report but it is a HUGE problem as you say earlier.
I'll propose to buy more licence or to upgrade to a CR for production but it's expensive. If this does not work I see if I can produce the same report with Reporting Services.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.