This is a migrated thread and some comments may be shown as answers.

ReportPackager problem - Resource Not Found

4 Answers 187 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Steven Bixby
Top achievements
Rank 1
Steven Bixby asked on 07 Sep 2016, 07:35 PM

For reasons of hiding customer details from other customers, I've elected to create some custom reports for my application using the standalone report designer.  The idea is that I can create any number of customized reports and drop them into place on each customer's machine as appropriate.

I initially used .TRDP format, and it works fine; however, when branching a codeline with SVN, I realized I couldn't merge binary files very well, so I decided to go with .TRDX format for the ability to diff & merge report definitions. 

In turn I created a bit of stand-alone code to run in my build environment that would convert all the TRDX files to TRDP for distribution.

This uses the same method shown on the Telerik Reporting documentation; that is:

            using (var targetStream = File.Create(destfn)) {
                var xmlString = File.ReadAllText(sourceName);
                 reportPackager.Package(xmlString, targetStream);
            }

However, when I do this, and try to load the resulting TRDP in either stand-alone Report Designer or load into my ASP.NET code, I get errors saying "Resource Not Found".

My reports typically have a customer-specific PictureBox, so there's an embedded resource block, which I believe is the issue.

I tried converting my original TRDP and "packaged" TRDP file names to .zip so I could inspect them.   The original TRDP has two XML files and a folder Images with a JPG file - "pictureBox1.Value.JPG".   The packaged TRDP just has two XML files, and there's a very long BASE64-like block, no separate image files.

How can I achieve this goal in an automated fashion?

 

4 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 09 Sep 2016, 02:37 PM
Hello Steven,

Thank you for reporting the problem.
It is reproducible when the TRDX (XML) contains an image in it on converting into a TRDP.
The issue is logged din our system for improvement and your Telerik points are updated as a gratitude for bringing the issue to our attention.


We can suggest you the following workaround:
Instead of reading the XML, you can deserialize the report in order to save it as a TRDP file. For example:
var appPath = HttpContext.Current.Server.MapPath("~/Reports/");
var reportPath = Path.Combine(appPath, reportTRDX);
var newReportPath = Path.Combine(appPath, reportTRDX.Replace(".trdx", ".trdp"));
//if (!System.IO.File.Exists(newReportPath))
//{
//    //package TRDX
//    var reportPackager = new ReportPackager();
//    using (var targetStream = System.IO.File.Create(newReportPath))
//    {
 
 
//        var xmlString = System.IO.File.ReadAllText(reportPath);
//        reportPackager.Package(xmlString, targetStream);
//    }
//}
 
System.Xml.XmlReaderSettings settings = new System.Xml.XmlReaderSettings();
settings.IgnoreWhitespace = true;
 
using (System.Xml.XmlReader xmlReader = System.Xml.XmlReader.Create(reportPath, settings))
{
    Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer =
        new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();
 
    Telerik.Reporting.Report reportInstance = (Telerik.Reporting.Report)
        xmlSerializer.Deserialize(xmlReader);
 
    var reportPackager = new ReportPackager();
    using (var targetStream = System.IO.File.Create(newReportPath))
    {
        reportPackager.Package(reportInstance, targetStream);
    }
}
return new UriReportSource { Uri = newReportPath };
For more details about the settings, please check Report Packaging and Serializing Report Definition in XML.


Let us know if you need further help.

Regards,
Stef
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Steven Bixby
Top achievements
Rank 1
answered on 09 Sep 2016, 03:20 PM
I will try this a little later today, in crisis mode at the moment.  Thank you for the potential workaround!
0
Steven Bixby
Top achievements
Rank 1
answered on 09 Sep 2016, 03:58 PM
This worked fine, thank you!
0
Stef
Telerik team
answered on 10 Sep 2016, 09:50 AM
Hi Steven,

Thank you for this update.
We will aim to update the compression of TRDX files for consecutive releases, after the official R3 3016 as it is expected in less than a week.

Regards,
Stef
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Steven Bixby
Top achievements
Rank 1
Answers by
Stef
Telerik team
Steven Bixby
Top achievements
Rank 1
Share this question
or