Hi,
Is it possible now to save and load IGR reports into/from database reports in v12.1 ?
regards
You can load a report from a database or any other source by loading it as a stream and providing it to the viewer.
Considering your request, you can use a Report Uri Resolver to map URI to reports and define how they are loaded (e.g. retrieve them from a DB). Here is a guide and sample to learn how to use it.
Also, if you are using client-side rendering you can do something like this to set the viewer once you have loaded the stream (e.g. retrieved from the DB).:
//Load a local report
Stream myReportStream = Application.GetResourceStream(new Uri("SilverlightApplication1;component/Report1.igr", UriKind.Relative)).Stream;
xamReportViewer1.RenderSettings = new ClientRenderSettings { DefinitionStream = myReportStream };
Hope it helps.
Regards,
Miguel
Hi, I'm affraight I can't cope with that without some help :)
I've created following code, is it correct ? I had to put the static interface which I use to get data from database:
public static IDBApi iDBApi;
public void Resolve(Uri reportUri, Action<UriResolverData> result)
{
//TODO: Add report load logic based on the reportUri parameter.
string report = iDBApi.DataBase.GetTable("select ReportBody from Reports where ReportID = 2").Rows[0][0].ToString();
var mStream =
new MemoryStream(ASCIIEncoding.Default.GetBytes(report));
result.Invoke(new UriResolverData(mStream, null));
}
The reporting configuration section is defined in the assembly “InfragisticsWPF4.Reports.Client.v12.1” so you will need to define the configuration section this way:
<configSections>
<section name="infragistics.reports" type="Infragistics.Reports.ReportsConfigurationSection, InfragisticsWPF4.Reports.Client.v12.1"/>
</configSections>
After doing that if your UriResolver is still not called it should be because it is unable to find the assembly “InfragisticsWPF4.Reports.Client.v12.1”. You can solve this by: (1) Using the full qualified name of the assembly when you define the configSection; (2) mark the “InfragisticsWPF4.Reports.Client.v12.1” assembly with Copy Local = True in visual studio.
Please let me know if that fixes your problem.
Thanks,
Leo
Problem solved !!! Much thanks for your help :)
I've got another problem with that. Everything work perfect when I run application from local machine. But problem is when I'll try to view report running application from network share. Error is: Could not find report definition. May it be caused by wrong app.config entries ?
<infragistics.reports> <!-- Add more assemblies to look up for Report Uri Resolvers --> <runtimeAssemblies> <add assembly="InfragisticsWPF4.Reports.Client.v12.1" /> <add assembly="MyApp" /> </runtimeAssemblies> </infragistics.reports>
Why are you including “InfragisticsWPF4.Reports.Client.v12.1” as a runtime assembly? Just the “MyApp” assembly should be included.
I can’t reproduce the problem. Is the code in your URI resolved being invoked? Can you provide me with a solution that reproduces the problem?
Best,
Here's the resolver class. I've put there message box simply to check if it's fired. When I run my app local it's fired. When I run it from share resolver doesn't fires. It looks like MyApp assembly in app.config couldn't be loaded from share or someting ?
[ReportUriResolverExport] public class ReportUriResolver1 : IReportUriResolver { public static idb iDB; public void Resolve(Uri reportUri, Action<UriResolverData> result) { var reportBody = idb.DataBase.GetTable("select ReportBody from Reports where ReportID = " + reportUri.ToString()).Rows[0][0].ToString();
byte[] byteArray = Encoding.UTF8.GetBytes(reportBody); using (var reportStream = new MemoryStream(byteArray)) { var resultUri = new UriResolverData(reportStream, null); result.Invoke(resultUri); } } }
Many thanks. I'll check that
I could reproduce the problem. The problems happen when executing the application using .NET4. There is a bug in the framework when invoking System.Configuration.ConfigurationManager from the network share, it throws a security exception, and therefore the RuntimeAssemblies are not being taken into account. Here is the explanation of the bug. After installing the provided hotfix the problem is resolved. This problem does not occurs in framework 4.5.
Can you avoid running the application from the network share?
Any info ?
Solution ready.
Can you please provide a simple solution that reproduces the problem? For the Uri Provider you can just create a dummy one that displays the messagee and just invokes result.Invoke(null);