report export no work on user's pc - c#

i created a application with function export report as pdf file, the application can download the report in web format.
i run the application in my pc, it is work, but i try run at user pc, but fail when exporting
Using _report
_report.Load(HttpContext.Current.Server.MapPath("Report/" & "report.rpt"))
_reportname = name & date.now
_report.ParameterFields("name").CurrentValues.Clear()
_report.ParameterFields("name").CurrentValues.AddValue(_name)
_report.SetDatabaseLogon(_gstrID, _gstrPassword, _gstrDataSource, _gstrCatalog)
_report.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, context.Response, True, _reportname)
_report.Export()
_report.Database.Dispose()
_report.Dispose()
any miss take in my code???

There are many things that could be happening here.
First, test it from a completely different computer that the two you have. Test it on the same computer with the problem using a different browser. Optionally, update your version of Adobe Reader on the misbehaving machine and try again.
Next, if you are using IIS 7.5 there is a hotfix concerning downloading PDF files ( http://support.microsoft.com/kb/979543 ) that impacts particular versions of the Adobe PDF Reader plug-in.

Related

PDFTron: Powerpoint ConverToXod not working

In my ASP .Net application, I am using 'PDFTron 6.6.0.38591'.
We are using following code to convert Office documents to XOD:
string fileName = Path.GetFileName(pdfTronServiceRequest.FilePath);
fileName = ConstructConvertionFileName(fileName);
outFileName = Path.Combine(outputPath, fileName);
pdftron.PDF.Convert.ToXod(pdfTronServiceRequest.FilePath, outFileName);
response.Result = outFileName;
This code works well for filetypes like docx, xlsx, however for Powerpoint files, no response is returned(request timed out).
On checking the Task Manager window, we can see that a process for 'POWERPNT.exe' is started. However, this process never ends up itself(unlike that in case of word, excel upload).
Also, if I manually ends up this process, the conversion to XOD is successful and response is coming out correctly.
Also, please note that we are facing this issue only when we deploy the code on our test environments. Locally, PPT upload is working fine.
Let me know if you need any other information.
First, you should be running a licensed version of PowerPoint, not a trial/eval one. In particular, the account (including a Service/App Pool account) needs to have accepted the MS office licensing to make sure Office is a fully licensed product.
Also, is this happening with any ppt file or only certain ones? If certain ones, then try using one of the following two flags.
pdftron.PDF.Convert.Printer.SetMode(mode)
e_printer_only
e_interop_only
Finally, switch to the latest version. Which at the very least should provide a lot more debugging info in the exception message.

Edit Crystal Report 8.5 file in .Net c#

I've got 2 applications:
1. App to prepare data for reporting - C# (.Net 1.1)
2. App to display report - C++ (maybe)
First app send parameters such a report file name, report parameters to second app via command line. Then second app display prepared report.
Now I want to change some report fields. My code in 1st app:
ReportDocument rDoc = new ReportDocument();
rDoc.Load(#"D:\reports\report_1.rpt");
rDoc.Database.Tables[0].Location = "newDBName.schema.oldTableName";
rDoc.SaveAs(#"D:\reports\report_1_modif.rpt",ReportFileFormat.VSNetFileFormat);
I want to modify rpt file because I want to take data from the archive database.
"CrystalDecisions.CrystalReports.Engine" reference version is 9.1.5000.0.
So 2nd app can't use modified rpt file because of incompatible versions. 2nd app can work only with 8.5 file formats.
When I open rpt file in CR Developer I can manually change location and save in 8.5 file format. In this case 2nd program normally works with modified file.
So my question is: "How can I in .Net C# open rpt file 8.5, modify and save in 8.5 format with another name?". Maybe I should use some unmanaged code?
Crystal Reports 8.5 was released in 2001. .Net in 2002.
I solved problem. My approach:
In C# code we update set of synonyms in DB after every user click "show report". After update each synonym still has the same name but follows to another table in different database.
We modified CR 8.5 file by hands: a) changed connection type to OLE DB (Native SQL Client) because of ODBC layer don't support synonyms b) set synonyms as tables locations instead of full table names.
Task solved!
UPD. We need p2soledb.dll to use OLE DB.

Load SSRS Report from file in C# in a service

We are looking into replacing Crystal with SSRS.
I would like to know if it is at all possible to load the .rdl or .rdl.data file in C# and generate the report to a memory stream.
I have seen some examples using the LocalReport, but this seems to be part of either the WinForms or WebForms assemblies.
So what I would like to know is:
Is it possible to load the report from file as part of our service.
Can we then generate the report to a Stream (lets say a memory
stream)
Can I do this without using the WebForms/WinForms assemblies in my
service
Can we achieve this without using the webservice for SSRS
I'm not sure that this is an answer, but lets call it supporting material.
I have this code example from msdn that shows how you can do this by creating a service client and calling a given report as a PDF and saves it to file stream.
http://msdn.microsoft.com/en-us/library/reportexecution2005.reportexecutionservice.render.aspx
The problem I'm currently having is finding the correct client object to interact with after pointing VS to the SSRS service. The object I'm using to interact with the service is:
ReportExecutionServiceSoapClient rs = new ReportExecutionServiceSoapClient();
However, the interface doesn't match my code example. So this is a little closer, but not an answer.
UPDATE: The correct Proxy class generator
Here's the link to how to generate the proxy correctly. You'll need the windows sdk installed (current is 7.1). You can find that on microsoft.com, like I did. Execute the command line and it'll generate a file for you. Include in project:
http://msdn.microsoft.com/en-us/library/ms155134%28v=SQL.110%29.aspx
UPDATE: Got the thing workin
I just had to generate the correct proxy. Ok, so for SSRS 2010, apparently they split report execution and management out into two services. The only one I needed to generate my report from a C# console app was the execution service. Maybe that's totally obvious to everyone but me :) ?
Ok so open up a Windows SDK command shell and put this stuff in it for the execution service:
wsdl /language:CS /n:"Microsoft.SqlServer.ReportExecution" http://<Server Name>/reportserver/reportexecution2010.asmx?wsdl /o:"ReportExecution.cs"
Go to C:\Program Files\Microsoft SDKs\Windows\v7.1 and pick up your ReportExecution.cs file. Copy and paste it in your project.
Then you just have to say this:
Microsoft.SqlServer.ReportExecution.ReportExecutionService rsExec =
new Microsoft.SqlServer.ReportExecution.ReportExecutionService();
rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials;
rsExec.Url = #"http://<ServerName>/reportserver/ReportExecution2005.asmx";
Follow along the example from this link, which is the same one as above, and you should be generating some pretty awesome reports from your handy C# app.

Read csv file client side

I have to read the first couple of lines of a csv file client side to present the user with a preview before uploading a large file.
I'm using c# with ASP.Net (VS2010)
Does anyone know how this can be done? Also that it works in all browsers!?!
(It's not possible to use activeX or so, we do not want our clients to install something!)
A sample code would be great!
Thanks in advance!
Firefox 3.6+ and Chrome (at least version 6, possibly older versions) support the File API which lets you read local files from a file input.
Here's a quick sample:
function handleFile(file) {
var reader = new FileReader();
reader.onload = function(e) {
// Here's where you would parse the first few lines of the CSV file
console.log(e.target.result);
};
reader.readAsText(file);
}
in your html, you would have something like this:
<input type="file" onchange="handleFile(this.files[0])" />
Of course, in real life you should make it degrade gracefully.
The file object has name and type properties that you could use to verify that it's a CSV file if you wanted to be more strict.
There is a W3C proposal for a File API in HTML5. I ran a few browsers against this test, and found that Firefox 3.6, and Chrome 6 support File Reader API and Local Storage. Safari 5 (on Windows) supported Local Storage but not File Reader API. Sorry I couldn't test IE9 as corporate policy has IE6 (?!) nailed in place.
You can't read a local file with vanilla JavaScript.
You could use activeX as a progressive enhancement to those using IE (even though offering an enhanced experience to IE users goes against everything I stand for!).
If you can use Flash, look at Read local file in Flash.

.Net Crystal Report printing application running on termianal service connection errors when session is disconnected

I have created a .Net application to run on an App Server that gets requests for a report and prints out the requested report.
The C# application uses Crystal Reports to load the report and subsequently print it out.
The application is run on Server which is connected to via a Remote Desktop connection under a particular user account (required for old apps). When I disconnect from the Remote Session the application starts raising exceptions such as:
Message: CrystalDecisions.Shared.CrystalReportsException: Load report failed
This type of error is never raised when the Remote Session is active. The server running the app is running Windows Server 2003, my box which creates the connection is Windows XP.
I appreciate this is fairly weird, however I cannot see any problem with the application deployment I have created.
Does anyone know what could be cause this issue?
EDIT: I bit the bullet and created the application as a windows service, obviously this doesn't take long I just wasn't convinced it would solve the problem. Anyway it doesn't!!!
I have also tried removing the multi-thread code that was calling the print function asynchronously. I did this in order to simply the app and narrow down the reason it could fail. Anyway, this didn't improve the situation either!
EDIT: The two errors I get are:
System.Runtime.InteropServices.COMException
(0x80000201): Invalid printer
specified. at
CrystalDecisions.ReportAppServer.Controllers.PrintOutputControllerClass.ModifyPrinterName(String
newVal) at
CrystalDecisions.CrystalReports.Engine.PrintOptions.set_PrinterName(String
value) at
Dsa.PrintServer.Service.Service.PrintCrystalReport(Report
report)
The printer isn't invalid, this is confirmed when 60 seconds later the time ticks and the report is printed successfully.
And
The request could not be submitted for
background processing. at
CrystalDecisions.ReportAppServer.Controllers.ReportSourceClass.GetLastPageNumber(RequestContext
pRequestContext) at
CrystalDecisions.ReportSource.EromReportSourceBase.GetLastPageNumber(ReportPageRequestContext
reqContext) --- End of inner
exception stack trace --- at
CrystalDecisions.ReportAppServer.ConvertDotNetToErom.ThrowDotNetException(Exception
e) at
CrystalDecisions.ReportSource.EromReportSourceBase.GetLastPageNumber(ReportPageRequestContext
reqContext) at
CrystalDecisions.CrystalReports.Engine.FormatEngine.PrintToPrinter(Int32
nCopies, Boolean collated, Int32
startPageN, Int32 endPageN) at
CrystalDecisions.CrystalReports.Engine.ReportDocument.PrintToPrinter(Int32
nCopies, Boolean collated, Int32
startPageN, Int32 endPageN) at
Dsa.PrintServer.Service.Service.PrintCrystalReport(Report
report)
EDIT:
I ran filemon to check if there were any access issue. At the point when the error occurs file mon reports
Request: OPEN | Path: C:\windows\assembly\gac_msil\system\2.0.0.0__b77a5c561934e089\ws2_32.dll | Result: NOT FOUND | Other: Attributes Error
Our particular problem has been solved. Basically when the reports were created they were saved with information about printers. Basically a particular printer had been set for the report and saved.
This printer no longer exists which is why the report had started failing. Basically we had to open the report designer and remove any association with printers in the report.
We have encountered these errors several times in the past few years. Many times I wished for some more specific error message.
First, I would verify that there aren't multiple Crystal Reports versions installed. In our expereince, we found that Crystal Reports 9.0 doesn't seem to play well with 10. Uninstalling version 9 seemed to help some of our customers. If both are installed, I highlly recommend uninstalling both, then re-installing Crystal Reports 10.
One of our earliest Crystal Reports errors was the dreaded "The request could not be submitted for background processing." Reports would work fine for a while, then suddenly they would stop. After looking at the code, I found a place where we were not disposing of a ReportDocument. Correctly disposing this document fixed the issue.
Lately, we hit a spat of "The request could not be submitted for background processing." and "Invalid Printer" errors. One customer's server had several network printers defined by IP address. Printing would work just fine for a while, then suddenly, bam, the customer got the "Invalid Printer" error and called our support.
A fellow developer fixed the "Invalid Printer" problem by doing all of the following things:
Edit and save the .rpt file in Visual Studio 2005. We had been keeping the report format compatible with Crystal Reports 9, because we wanted our changes to be distributable to our customers still using older versions.
Save Crystal Reports files with the "No Printer" option. From the Visual Studio 2005 menu, select Crystal Reports/Design/Printer Setup, then select the "No Printer" check box.
We changed a formula that displayed "Page N of M" from something strange like this:
"Page " + Left (CStr (PageNumber), Length (CStr (PageNumber)) - 3) +
" of " + Left (CStr (TotalPageCount), Length (CStr (TotalPageCount)) - 3)
to this:
"Page " + CStr(PageNumber,0) + " of " + CStr(TotalPageCount,0)
Unfortunately, I have no idea which (any or all) of the above actions may fixed the error. I say "may", because for all I know, the error magically went away because of some IT network change.
Finally, have you read this white paper? While it did not necessarily solve our problems, it was very interesting.
If you create a window service wrapper for your application, it means that it will continue to run regardless of users logged in. It can also be set to start up automatically. I think that because you are using an actual application, and not a windows service it is not actually running once you logout of a session on the server.
Here is an example on Code Project:
http://www.codeproject.com/KB/system/WindowsService.aspx
Are you sure you are "disconnecting' you remote session as opposed to "logging off". I disconnect my sessions to a nt server 2003 all the time and everything to continues to run just fine. Logging off on the other hand will kill the apps running in that session.
What is your o/s server running?
In Order to solve the problem that you have described you need to focus in on what your problem is.
I have recieved the
Message: CrystalDecisions.Shared.CrystalReportsException: Load report failed
a number of times and it is due to the fact that you can't access the report. Either it doesn't exist or in your situation the you are not connected to the machine. The error is not due to anything printing related.
I had an obscure issue that was similar to this, except it was a (shock-horror) automation issue with Excel. I found the application worked fine when I had my remote desktop session connected, but once disconnected, it would give automation errors relating to the default printer.
I believe the issue relates to how the default printer is set when you connect with remote desktop. Assuming you have a .rdp file for initiating your remote desktop session, if you edit it, then select the "Local Resources" tab, you can see whether or not you share your local printer on the remote session.
If it is enabled, this means when you connect, your local default printer becomes the default printer on the remote machine. When you disconnect, your application's default printer will still possibly refer to the now unavailable default printer from your local machine.
You should be able to solve this, by ensuring you don't share your local printer, by deselecting the Printer checkbox from the "Local Resources" tab.
An easier solution would be to disable "printer redirection" on the server. See https://serverfault.com/questions/5646/how-do-i-disable-remote-printers-using-group-policy for more information.
If you are looking in detail how to
add checkboxes into crystal reports on a boolean feild and if the boolean field is false
uncheck else check the checkbox look at this article
http://checkboxcrystalreport.blogspot.com/2009/07/printing-checkbox-in-crystal-report-for.html

Categories

Resources