Hi,
I have created a C# windows forms application to export reports programatically. Reports are created using standalone report designer and added in a folder within the application. Reports have a multivalue parameter site whose value is set to AllValues(Fields.Id). AllValues function by default selects all site values. While running the application, report is exported programmatically. But, when I check the report that is created, it has the following message
An error has occurred while processing Report 'GameMetric':
The expression contains undefined function call AllValues().
Following is the piece of code which exports report programmatically.
try
{
Telerik.Reporting.UriReportSource URI = new Telerik.Reporting.UriReportSource();
string reportKey = dt.Rows[i]["report_key"].ToString();
string reportName = dt.Rows[i]["report_name"].ToString();
appendMessage("Run Report: " + reportName, ref message);
if (dt.Rows[i]["CustomFlag"].ToString() != "Y")
URI.Uri = Directory.GetCurrentDirectory() + "\\Reports\\" + reportKey + ".trdx";
else
URI.Uri = Directory.GetCurrentDirectory() + "\\Reports\\" + "Dynamic Report.trdx";
XmlReaderSettings settings = new XmlReaderSettings();
settings.IgnoreWhitespace = true;
using (XmlReader xmlReader = XmlReader.Create(URI.Uri, settings))
{
Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
ReportViewer reportViewer = new ReportViewer();
Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer =
new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();
Telerik.Reporting.Report report = (Telerik.Reporting.Report)xmlSerializer.Deserialize(xmlReader);
string newConn = Common.changeConnectionString(Properties.Settings.Default.ParafaitConnectionString, "ParafaitMultisite");
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
//SetConnectionString(newConn, report);
reportViewer.Report = report;
reportViewer.ReportSource.Parameters.Add("fromdate", fromDate.ToString());
reportViewer.ReportSource.Parameters.Add("todate", toDate.ToString());
//reportViewer.ReportSource.Parameters.Add("offSet", Convert.ToString(ParafaitTimezone.FinalOffset()));
reportViewer.ReportSource.Parameters.Add("user", "Parafait Scheduler");
reportViewer.ReportSource.Parameters.Add("loggedInUserName", "Parafait Scheduler");
reportViewer.ReportSource.Parameters.Add("role", " ");
reportViewer.ReportSource.Parameters.Add("loggedInUserId", Common.getLoggedinUser());
string reportID = dt.Rows[i]["report_id"].ToString();
reportViewer.ReportSource.Parameters.Add("reportID", reportID);
reportViewer.ReportSource.Parameters.Add("isCorporate", "Y");
//reportViewer.RefreshReport();
string fileName = "D:\\Parafait Home\\Reports\\" + reportName + TimeStamp + ".pdf";
try
{
Telerik.Reporting.Processing.RenderingResult renderingResult = reportProcessor.RenderReport("PDF", reportViewer.ReportSource, deviceInfo);
using (FileStream fs = new FileStream(fileName, FileMode.Create))
{
fs.Write(renderingResult.DocumentBytes, 0, renderingResult.DocumentBytes.Length);
}
}
catch (Exception ex)
{
appendMessage(ex.Message, ref message);
}
}
}
catch (Exception ex)
{
appendMessage(ex.Message, ref message);
}
}
appendMessage("Done creating reports", ref message);
I have added the assembly reference in report designer config file.
When I run the same set of reports in a web form it seems to be working without any issues.
What wrong could I have done?
I have created a C# windows forms application to export reports programatically. Reports are created using standalone report designer and added in a folder within the application. Reports have a multivalue parameter site whose value is set to AllValues(Fields.Id). AllValues function by default selects all site values. While running the application, report is exported programmatically. But, when I check the report that is created, it has the following message
An error has occurred while processing Report 'GameMetric':
The expression contains undefined function call AllValues().
Following is the piece of code which exports report programmatically.
try
{
Telerik.Reporting.UriReportSource URI = new Telerik.Reporting.UriReportSource();
string reportKey = dt.Rows[i]["report_key"].ToString();
string reportName = dt.Rows[i]["report_name"].ToString();
appendMessage("Run Report: " + reportName, ref message);
if (dt.Rows[i]["CustomFlag"].ToString() != "Y")
URI.Uri = Directory.GetCurrentDirectory() + "\\Reports\\" + reportKey + ".trdx";
else
URI.Uri = Directory.GetCurrentDirectory() + "\\Reports\\" + "Dynamic Report.trdx";
XmlReaderSettings settings = new XmlReaderSettings();
settings.IgnoreWhitespace = true;
using (XmlReader xmlReader = XmlReader.Create(URI.Uri, settings))
{
Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();
ReportViewer reportViewer = new ReportViewer();
Telerik.Reporting.XmlSerialization.ReportXmlSerializer xmlSerializer =
new Telerik.Reporting.XmlSerialization.ReportXmlSerializer();
Telerik.Reporting.Report report = (Telerik.Reporting.Report)xmlSerializer.Deserialize(xmlReader);
string newConn = Common.changeConnectionString(Properties.Settings.Default.ParafaitConnectionString, "ParafaitMultisite");
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
//SetConnectionString(newConn, report);
reportViewer.Report = report;
reportViewer.ReportSource.Parameters.Add("fromdate", fromDate.ToString());
reportViewer.ReportSource.Parameters.Add("todate", toDate.ToString());
//reportViewer.ReportSource.Parameters.Add("offSet", Convert.ToString(ParafaitTimezone.FinalOffset()));
reportViewer.ReportSource.Parameters.Add("user", "Parafait Scheduler");
reportViewer.ReportSource.Parameters.Add("loggedInUserName", "Parafait Scheduler");
reportViewer.ReportSource.Parameters.Add("role", " ");
reportViewer.ReportSource.Parameters.Add("loggedInUserId", Common.getLoggedinUser());
string reportID = dt.Rows[i]["report_id"].ToString();
reportViewer.ReportSource.Parameters.Add("reportID", reportID);
reportViewer.ReportSource.Parameters.Add("isCorporate", "Y");
//reportViewer.RefreshReport();
string fileName = "D:\\Parafait Home\\Reports\\" + reportName + TimeStamp + ".pdf";
try
{
Telerik.Reporting.Processing.RenderingResult renderingResult = reportProcessor.RenderReport("PDF", reportViewer.ReportSource, deviceInfo);
using (FileStream fs = new FileStream(fileName, FileMode.Create))
{
fs.Write(renderingResult.DocumentBytes, 0, renderingResult.DocumentBytes.Length);
}
}
catch (Exception ex)
{
appendMessage(ex.Message, ref message);
}
}
}
catch (Exception ex)
{
appendMessage(ex.Message, ref message);
}
}
appendMessage("Done creating reports", ref message);
I have added the assembly reference in report designer config file.
When I run the same set of reports in a web form it seems to be working without any issues.
What wrong could I have done?