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

Error after 2017 upgrade

1 Answer 65 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jonah
Top achievements
Rank 1
Jonah asked on 22 Mar 2017, 02:35 PM

My reports that I am using in an WPF application just to print directly to a printer have some issues after the upgrade. We also had an issues when we upgraded last year.

Here is where the report is called

      string orderIds = "153461,153567,153843,153845,153872,153942,153966,153985,154210,154252,154298,154363,154382,154411,154431,154437,154463,154471,154521,154538,154556,154560,154631,154650,154686,154687";  
var reportProcessor = new Telerik.Reporting.Processing.ReportProcessor();

      var typeReportSource = new Telerik.Reporting.TypeReportSource();
      typeReportSource.TypeName = typeof(Accounting.Reports.RptPostedDeposits).AssemblyQualifiedName;
      typeReportSource.Parameters.Add(new Telerik.Reporting.Parameter("OrderNumbers", orderIds));
      var px = new System.Drawing.Printing.PrinterSettings();
      reportProcessor.PrintReport(typeReportSource, px);

 

 

Then in my Needs_Datasource event of the report I have something like

      if (this.ReportParameters[0].Value.ToString() != "")
      {
        string sqlQuery = "Select O.OrderID, Case When D.PayorName = '' Then CAL.SubAccountName Else " +
          "SUBSTRING(CAL.SubAccountName, 0, 7) + '-' + D.PayorName End as Customer, D.EntryDate, D.PaymentNumber, D.PaymentTypeID, " +
          "D.TotalDeposit, D.AmountAppliedToInvoice, O.GrandTotal, D.PostedToCyma, ISNULL(O.PostedDate, ISNULL(O.ShipDate, GETDATE())) as PostedDate " +
        "From FCMDB.dbo.FcoOrders O " +
        "JOIN FCMDB.dbo.CustAccountLocations CAL ON CAL.AccountLocationsID = o.AccountLocationID " +
        "JOIN FCMDB.dbo.AcctDeposits D ON D.OrderID = O.OrderID " +
        "Where O.OrderID IN (" + ReportParameters[0].Value + ")";
        SqlConnection cn = new SqlConnection(MyConnection);
        cn.Open();
        SqlCommand cmdGet = new SqlCommand(sqlQuery, cn);
        DataTable dtGet = new DataTable();
        dtGet.Load(cmdGet.ExecuteReader());
        cmdGet.Dispose();
        cn.Dispose();

//This line we changed in 2016 because just setting the this.datasource would no longer reference the current report
        (sender as Telerik.Reporting.Processing.Report).DataSource = dtGet;
        //this.DataSource = dtGet;
      }

 

Now I need to access the parameter through the sender object. If I leave it the way it is currently the parameter is blank. Is this something that has been done intentionally? If so why isn't an email or something sent out about it or adding it into the whats new? 

1 Answer, 1 is accepted

Sort by
0
Katia
Telerik team
answered on 23 Mar 2017, 01:07 PM
Hello Jonah,

In the provided code, values of report parameters will not be updated as they are accessed using "this" keyword (report definition). The correct approach would be to use processing report's Parameters collection to get the values of report parameters.

As of R3 2016, accessing the item definition inside events is not supported. In events, you can access and modify only the processing elements Changes on items in report events are not applied.

Example of accessing report parameter of processign report is provided in Using Report Events help article:
void report_NeedDataSource(object sender, EventArgs e)
{
    Telerik.Reporting.Processing.Report processingReport = (Telerik.Reporting.Processing.Report)sender;
    object processingParameterValue = processingReport.Parameters["parameter1"].Value;
    ...
}
Note that processing report parameters are stored in Report.Parameters Property not in Report.ReportParameters.

Regarding your feedback about email notifications with latest changes, currently we do not have such service. This questions was forwarded to the corresponding team for further discussion.


Regards,
Katia
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
Jonah
Top achievements
Rank 1
Answers by
Katia
Telerik team
Share this question
or