We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

RDL and Shared DataSources

Thread ID:

Created:

Updated:

Platform:

Replies:

119473 Jun 26,2015 04:55 AM Jul 13,2015 09:24 AM ASP.NET MVC 7
loading
Tags: ReportViewer
Andrea Perazzolo
Asked On June 26, 2015 04:55 AM

Hi,
I just defined a RDL Report that has a connection to a shared DataSource(*.rds file).
I want to copy the file in the App_Data directory, eand change the connection when I am in  the Test environment and when I am in the Production environment.
There is a way to specify this other than the DataSourceCredentials?

    Thanks in advance

    Andrea Perazzolo


Soundara Rajan S [Syncfusion]
Replied On June 29, 2015 07:09 AM

Hi Andrea,

Thanks for using Syncfusion products.

I just defined a RDL Report that has a connection to a shared DataSource(*.rds file).
I want to copy the file in the App_Data directory, eand change the connection when I am in the Test environment and when I am in the Production environment.
You can modify/edit the report datasource or other section of report by accessing the report definition. You have to serialize the report and modify the desired property of the report definition, modified report definition need to be saved in to stream or file, before loading the report to ReportWriter/ReportViewer.
We have prepared a sample to modify the ReportDefinition dynamically and It can be downloaded from the following location.
http://www.syncfusion.com/downloads/support/forum/119473/ModifyDatasourceReference1670620741.zip

There is a way to specify this other than the DataSourceCredentials?

If we modify the datasource reference, then we have to provide the credential of the modify datasource as shown by below code snippet,

reportOption.ReportModel.DataSourceCredentials.Add(new DataSourceCredentials("NorthWindIO", "ssrs1", "RDLReport1"));



Please let us know, if you have any concerns.

Regards,
Soundara Rajan S.

Andrea Perazzolo
Replied On June 30, 2015 08:45 AM

Hi,
thanks for the answer.
So there is not a way to use a Shared Data Source that can be updated once when I put the application in production.
There is a way to pass to the ReportViewer the stream of the reportdefinition transformed or have I to write back a phisical file everytime I load a report.
In that case the best solution will be a procedure to change the reports one time when I publish them, but is risky if I forget a single one.
I was hoping in anything automatic to use.

     Thanks in advance

    Andrea Perazzolo

Soundara Rajan S [Syncfusion]
Replied On July 1, 2015 07:10 PM

Hi Andrea,

Thanks for your response.

So there is not a way to use a Shared Data Source that can be updated once when I put the application in production.
We could not modify the shared datasource used in report dynamically. If you need to modify shared datasource dynamically, then you have to edit the report definition.
There is a way to pass to the ReportViewer the stream of the reportdefinition transformed or have I to write back a phisical file everytime I load a report.
In that case the best solution will be a procedure to change the reports one time when I publish them, but is risky if I forget a single one.
I was hoping in anything automatic to use.
we have already exposed a Stream property in ReportViewerModel to load modified report stream in ReportViewer. Using this property, you can load modified report stream without saving into physical file, but we have some issues while assigning the report steam property and we have logged issue report on this. A support incident to track the status of this defect has been created under your account. Please log on to our support website to check for further updates

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents

Please let us know, if you have any concerns.

Regards,
Soundara Rajan S.

Andrea Perazzolo
Replied On July 2, 2015 02:38 AM

Hi,
my question regarding the shared datasource is not how to change it, but how to use it when the report is not published in Report Server and loaded in the App_Data directory.
I have copied the file .rds in the same directory, but when I try to load the report in the reportviewer, there is an error in the rendering that says that cannot find datasource.
If it is possible to use it, could you provide me a working example?

    Thanks in advance

    Andrea Perazzolo

Soundara Rajan S [Syncfusion]
Replied On July 4, 2015 02:41 PM

Hi Andrea,

Thanks for your response.

my question regarding the shared datasource is not how to change it, but how to use it when the report is not published in Report Server and loaded in the App_Data directory.
I have copied the file .rds in the same directory, but when I try to load the report in the reportviewer, there is an error in the rendering that says that cannot find datasource.
If it is possible to use it, could you provide me a working example?
We could not read the shared datasource information from local physical location through ReportViewer control, but we can able to read shared datasource from App_Data location and assign the shared datasource information to report datasource while loading the report. We have prepared sample based on this and it can be downloaded from below location,
http://www.syncfusion.com/downloads/support/forum/119473/ReportViewerDemo-1111710594.zip

Please let us know, if you have any concerns.

Regards,
Soundara Rajan S.

Andrea Perazzolo
Replied On July 10, 2015 11:23 AM

HI,
I installed the patch you provided, but I am not able to set the Report Definition using the Stream Property insted writing the new file as in your example.
Could you please provide me a working sample that shows how to do it correctly?

    Thanks in advance

    Andrea Perazzolo

Soundara Rajan S [Syncfusion]
Replied On July 13, 2015 09:24 AM

Hi Andrea,

Thanks for your response.

We have tested the issue with provided patch, but we are unable to reproduce this issue and it’s working fine in our end. We request to you ensure to set the stream property through ReportModel in WebAPI IReportController as shown by below code snippet,

public void OnInitReportOptions(ReportViewerOptions reportOption)

{

reportOption.ReportModel.Stream = this.SerializeReport(reportOption.ReportModel.ReportPath);

reportOption.ReportModel.ReportPath = null;

}


private Stream SerializeReport(string path)

{

Syncfusion.RDL.DOM.ReportDefinition reportDefinition = new Syncfusion.RDL.DOM.ReportDefinition();

FileInfo info = new FileInfo(path);

FileStream stream = new FileStream(info.FullName, FileMode.Open, FileAccess.Read, FileShare.Read);

XElement rdl = XElement.Load(XmlReader.Create(stream));

string Namespace = (from attribute in rdl.Attributes() where attribute.Name.LocalName == "xmlns" select attribute.Value).FirstOrDefault();

string Version = (Regex.IsMatch(Namespace, @"\d{4}") ? Regex.Match(Namespace, @"\d{4}").Value : string.Empty);

XmlSerializer xs = new XmlSerializer(typeof(Syncfusion.RDL.DOM.ReportDefinition), Namespace);

stream.Position = 0;

stream.Close();


using (StringReader reader = new StringReader(rdl.ToString()))

{

reportDefinition = (Syncfusion.RDL.DOM.ReportDefinition)xs.Deserialize(reader);

}


foreach (var datasource in reportDefinition.DataSources)

{


XmlDataDocument xmldoc = new XmlDataDocument();

FileStream _dsStream = new FileStream(new FileInfo(HttpContext.Current.Server.MapPath("~/App_Data/AdventureWorksAS2008R2.rds")).FullName, FileMode.Open, FileAccess.Read, FileShare.Read);

xmldoc.Load(_dsStream);

XmlNode _node = xmldoc.FirstChild.NextSibling;



//Here you can edit the connection properties of the DataSource.

if (!string.IsNullOrEmpty(datasource.DataSourceReference))

{

}

}

stream.Close();

return this.SaveReport(reportDefinition);

}



For your reference, we have prepared sample based on this and it can be downloaded from below location,
http://files2.syncfusion.com/dtsupport/directtrac/140893/ReportViewerDemo1989580498.zip

If you still face any issues on this, then could you please share much more information on this?. It will helpful to analyze this issue and provided the solution earlier.

Please let us know, if you have any queries.

Regards,
Soundara Rajan S.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;