Telerik Forums
Reporting Forum
1 answer
299 views
Hello,

I am having difficulty writing a method that will render my report as a PDf so that I can attach it to an e-mail. Here is my code:

[HttpPost]
[Route("api/supportingreports/email/{reportName}")]
public bool SendReportViaEmail(string reportName)
{
    // TODO verify user access to report
    try
    {
        var reportProcessor = new ReportProcessor();
        var report = new Report {DocumentName = HttpContext.Current.Server.MapPath(string.Format("{0}{1}.trdx", FileUtility.ReportPath, reportName))};
 
        var instanceReportSource = new InstanceReportSource {ReportDocument = report};
        instanceReportSource.Parameters.Add(new Parameter("userId", 3));
        instanceReportSource.Parameters.Add(new Parameter("eventId", 0));
        instanceReportSource.Parameters.Add(new Parameter("exceptionId", 14));
        instanceReportSource.Parameters.Add(new Parameter("employeeId", 3860));
 
        var result = reportProcessor.RenderReport("PDF", instanceReportSource, new Hashtable());
 
        var fileName = report.Name + "." + result.Extension;
        var path = Path.GetTempPath();
        var filePath = Path.Combine(path, fileName);
 
        var mailMessage = new MailMessage {From = new MailAddress(ConfigurationManager.AppSettings["fromAddress"])};
 
        using (var fs = new FileStream(filePath, FileMode.Create))
        {
            fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
            fs.Seek(0, SeekOrigin.Begin);
            var a = new Attachment(fs, report.Name + "." + result.Extension);
            mailMessage.Attachments.Add(a);
 
            mailMessage.To.Add(new MailAddress("cbohatka@aztekweb.com"));
            mailMessage.Subject = "TEST";
 
            var smtpClient = new SmtpClient();
            smtpClient.Send(mailMessage);
        }
    }
    catch (Exception ex)
    {
        Debug.WriteLine(ex.Message);
        throw;
    }
 
    return true; // dummy return
}

I am receiving a PDF attached to my e-mail but it is smaller than expected and display an error message.

Thanks in advance!
Nasko
Telerik team
 answered on 16 Dec 2014
3 answers
178 views
Hi!

We are using the Telerik reports and Kendo charts as part of our project. Though we have successfully able to use Kendo charts in our project, we have some issues with respect to using Telerik Report Viewer on MVC application.

With respect to the same one of my colleague has created an thread earlier some time back for support. Since he has used his own account to get the suggestions Telerik had requested him to use 'valid support subscription' account.

Here is his link:

http://www.telerik.com/account/support-tickets/view-ticket.aspx?threadid=877256


Due to we're busy with other things we could not reply to you earlier.

As it's mention in that thread, we had followed the same steps to get the Report Viewer to enable on MVC, but we could not. Right now I am trying to attach isolated project files as zip file with 167 kb size file, since only image type files are allowed to attach, I am not able to send the code. May I know any other way to send you the files?

Hope for the positive response from you at the earliest!

Thanks!



Venkat
Top achievements
Rank 1
 answered on 16 Dec 2014
4 answers
442 views
Hi Telerik, I am currently creating a report that will be generated using a Web Service. I am loading the XML Data through entering its path (can come from local machine / HTTP source) through xml.Load("path"). It returns the XML file as String (I'm not sure if this is good or bad). Now, how am I going to connect a Telerik 
Report to the XML file that was returned by the method that I have created on the Web Service? This is my first time creating a Web Service. I'm using VB as my programming language. Hope someone can help me thanks!
Lea
Top achievements
Rank 1
 answered on 15 Dec 2014
2 answers
61 views
Hi all,

I am trying to put together a report where my objects has child collections, then those child collection objects have child collections and so on. Many levels of depth.

The problem I am having is not being able to insert a page break where I want it.

The object structure is:

Sites
---- SiteFunctions
-------- Actions
-------- Procedures
-------- Recoveries

So:
1. The data source for the report is set to Sites
2. From there I was using a List control in the page detail bound to SiteFunctions
3. From there I was using Table controls to list out Actions, Procedures & Recoveries

My problem is I am unable to get a page break inserted after the Recoveries have been listed out.

Can anybody give me some guidance on how to structure the report and get the page break in where I want it?
I find the documentation is very limited except for the most basic of reports and no decent tutorials available to explain the concepts.



1
1
1





Paul
Top achievements
Rank 1
 answered on 15 Dec 2014
1 answer
104 views
Hi, here is the simple code:

        
void ReportToDefault(Report report)
        {
            if (report == null) return;
 
            System.Drawing.Printing.PrintController standardPrintController =
                                    new System.Drawing.Printing.StandardPrintController();
            Telerik.Reporting.Processing.ReportProcessor reportProcessor
                                                = new Telerik.Reporting.Processing.ReportProcessor();
            reportProcessor.PrintController = standardPrintController;
            try
            {
                reportProcessor.PrintReport(report, Properties.Settings.Default.defaultPrinter);
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); }
        }

What is the best practice: to create the report processor and controller each time a doc is printed in background (for instance if it's kinda printing manager, and it receives requests to print from different apps), or better to instantiate the both classes once on the app start up and then just call Print Report?
Is it ok if several Print controllers and processors are active and several threads?
The idea is simple.. if we have the intensive doc-to-print feedback, then what's the better way to be sure the general App is not hanging on while printing is not over?

Thank you!
KS
Top achievements
Rank 1
 answered on 13 Dec 2014
1 answer
126 views
We have two accounts and two computers. The versions of Telerik Reporting on both computers are not the same. Computer 1 currently has Q2 2013 SP1. Computer 2 has Q3 2013. I would like to update computer 1 to the same version  as computer 2. However, we are not ready to update to the latest available release.

Is there a way we can upgrade computer 1 to Q3 2013?


Thank you,
Jack
​
Nasko
Telerik team
 answered on 12 Dec 2014
1 answer
212 views
Is it at all possible, when writing an assembly to be referenced by the standalone designer, to pull information from the designer itself, like maybe the open report file name, etc.
Nasko
Telerik team
 answered on 12 Dec 2014
1 answer
762 views
Hello

I have a big Report with a lot of objects ( > 100'000) get processed in a report. This works fine on the first time but the memory usage is very high. (>200mb). I inspected a lot of possible reasons and found out that the all my objects in the datasource for my report get cached by the reportviewer. As i'm loading the data from a database after interaction from a user (filter, export etc.) i don't need this cache. 
Because of the cache the memory is not getting released until the cache is released and that could be a long time. So if i run my report multiple times i got in trouble with the high memory usage ( > 2.5 GB).

What can i do? I tried to move the cache (http://www.telerik.com/help/reporting/configuring-telerik-reporting-session-state.html) to the file system but this is not working as expected.

Best regards
Stef
Telerik team
 answered on 12 Dec 2014
2 answers
185 views
I'm referring to http://www.telerik.com/help/reporting/object-data-source-how-to-bind-to-data-set.html just in case my other post will have a reply that I need to use *.aspx for report in MVC for data set...

Right now, I can open the report but it is showing no data. If SELECT Name, ProductCategoryID FROM Production.ProductCategory where ProductCategoryID < 4, it will actually show 3 row of data (direct query from database), but instead, what I get is a repeat of the header 3 times. If I omit the where statement from the sql query, it will show 4 row of data, and the web page report also will show the header 4 times...

I'll appreciate help (or working project file Q3 2014, visual studio 2013)

Default.cs
========


        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                var objectDataSource = new Telerik.Reporting.ObjectDataSource();
                objectDataSource.DataSource = GetAllData(); // GetData returns a DataSet with three tables

                objectDataSource.DataMember = "ProductCategory";

                //Telerik.Reporting.Report report = new Telerik.Reporting.Report();
                Report2 report = new Report2(); //added this instead...

                report.DataSource = objectDataSource;

                Telerik.Reporting.InstanceReportSource reportSource = new Telerik.Reporting.InstanceReportSource();
                reportSource.ReportDocument = report;

                reportViewer1.ReportSource = reportSource;

                reportViewer1.RefreshReport();
            }
        }


        static DataSet GetAllData()
        {
            const string connectionString =
                "Data Source=.;Initial Catalog=AdventureWorks;Integrated Security=True";

            string selectCommandText = "SELECT Name, ProductCategoryID FROM Production.ProductCategory where ProductCategoryID < 4;;" +
                "SELECT Name, ProductCategoryID FROM Production.ProductSubcategory;" +
                "SELECT Name, ProductNumber FROM Production.Product;";

            SqlDataAdapter adapter = new SqlDataAdapter(selectCommandText, connectionString);
            DataSet dataSet = new DataSet();

            adapter.Fill(dataSet);

            dataSet.Tables[0].TableName = "ProductCategory";
            dataSet.Tables[1].TableName = "ProductSubcategory";
            dataSet.Tables[2].TableName = "Product";
            return dataSet;
        }
Nasko
Telerik team
 answered on 12 Dec 2014
9 answers
1.1K+ views
Our scenario is as follows:

We have a web page that acts as a generic report container. The web page is passed a numeric ReportID which it uses to look up the file name of a tdrx file which it subsequently loads into the viewer as a URIReportSource. This gives us the ability to modify our reports without having to publish a new binary to the web server.

We would like for our report container page to be able to turn off the visibility of certain parameters, however no matter which ReportViewer event we capture (we tried them all), the Report property of the viewer is always blank, so we have no programmatic access to the parameter collection of the report object. All of the examples we have found of hiding report parameters use compiled reports rather than URI report sources and the methodologies applied do not work in our usage scenario.

How do we programmatically hide parameters for a URIReportSource-based report?

We are running version 7.0.13.228 of the web report viewer.
Stef
Telerik team
 answered on 11 Dec 2014
Top users last month
Anislav
Top achievements
Rank 6
Silver
Bronze
Bronze
Jianxian
Top achievements
Rank 1
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Jim
Top achievements
Rank 2
Iron
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?