[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

asp.net fifo crystal reports pdf email

Posted on 2005-04-08
10
Medium Priority
?
1,092 Views
Last Modified: 2010-08-05
I need some advice. I have a crystal report in a file and I am using asp.net 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.

0
Comment
Question by:carolinaspinner
  • 7
  • 3
10 Comments
 
LVL 33

Expert Comment

by:raterus
ID: 13740808
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!
0
 

Author Comment

by:carolinaspinner
ID: 13740907
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.
0
 

Author Comment

by:carolinaspinner
ID: 13741017
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
            crReportDocument.Load("C:\Inetpub\wwwroot\CRForms\myReport.rpt")
        pfds = crReportDocument.DataDefinition.ParameterFields
        pfd = pfds.Item("@YourID_2")
        pv = pfd.CurrentValues
        pdv = New CrystalDecisions.Shared.ParameterDiscreteValue
        pdv.Value = contactID
        pv.Add(pdv)
        pfd.ApplyCurrentValues(pv)

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

        Dim applyCRLog As New ApplyCRLogin

        With applyCRLog
            ._dbName = mydbName
            ._passWord = myPwd
            ._serverName = myServerName
            ._userID = myID
            .ApplyInfo(crReportDocument)
        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)
            Loop
 ->           crReportDocument.Dispose()
            Dim sendEmail As New Mailer
            'emailAddr
            sendEmail.SendEmail("you@yoursite.com", "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
            'setOptions
            With myExportOptions
                .DestinationOptions = crdiskFileDestinationOptions
                .ExportDestinationType = ExportDestinationType.DiskFile
                .ExportFormatType = ExportFormatType.PortableDocFormat
            End With
            'exportReport
            crFile.Export()
->            crFile.Dispose()
            'File.Delete(fname)
            Return True
->        Catch ex As Exception
            Return False
        End Try
    End Function


End Class

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:carolinaspinner
ID: 13741220
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?
0
 
LVL 33

Expert Comment

by:raterus
ID: 13741613
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.

--Michael
0
 

Author Comment

by:carolinaspinner
ID: 13741706
Thanks, Raterus I'll check your suggestion when I can go back to my machine.
0
 

Author Comment

by:carolinaspinner
ID: 13752487
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.
0
 

Author Comment

by:carolinaspinner
ID: 13754708
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 http://www.crystaldecisions.com/net/licensing."

Have you ever had that problem raterus.
0
 
LVL 33

Accepted Solution

by:
raterus earned 500 total points
ID: 13755208
No, I haven't experienced that problem.  I have the full-blown version of VS.net 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?
0
 

Author Comment

by:carolinaspinner
ID: 13756333
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.
Thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question