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

Programmatically creating silverlight reports

6 Answers 112 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 30 Jun 2015, 12:56 AM

I am following the example in the C# silverlight sample as well as the documentation on this page: http://www.telerik.com/help/reporting/silverlight-report-viewer-embedding_the_silverlight_viewer.html

 

I have an application I am modifying that has existing reports that are essentially paged data grids. What I want to do is create a telerik report to display the data in each datagrid. I am trying to use the technique in the ListBound report that uses the cars list. I have the data on hand in a dto list already, and am trying to pass the information to a report that will display in the silverlight reportviewer.

Here is my code - rptEventSummaryDataSource is an object that is inherited from List:

 

                   //Create the data source
                    rptEventSummaryDataSource theData = new rptEventSummaryDataSource(dataSource as List<IdentityEvents_DTO>);
                   //Set the report name
                    rptViewer.Report = "NLx.TelerikReports.rptEventSummary , NLx.TelerikReports";
                   //Set the data source for the report
                    rptViewer.DataContext = theData;
                   //Refresh to make the data display
                    rptViewer.RefreshReport();

I have the data sources defined in the same project as my viewer since I need to reference them, but my reports are defined in another project - NLx.TelerikReports - and the references have been set in my projects as well as the web project that launches the silverlight app. I also had to define the data sources in the reports project so that here was a definition with which to create the report.

Long and short of it is I cannot get anything to display and I have been killing myself on this for over 24 hours. Any help is greatly appreciated. What I need to do for a start is display Lists of already retrieved data and pass the list off to a report for display.

 

6 Answers, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 30 Jun 2015, 12:22 PM
Hello Brian,

The Silverlight.ReportViewer Class does not have a DataContext property. The DataContext Property used in your code is inherited from the base System.Windows.Controls.Control Class and cannot be used to set the data source of the report, as it serves a different purpose.

In addition, it is not possible to modify the report definition programmatically when you are using a type name ("NLx.TelerikReports.rptEventSummary , NLx.TelerikReports") to reference the report.

The report viewer does not display a report due to both of the above stated reasons.

Since the Silverlight Report Viewer works with the Telerik Reporting WCF Service to access the report engine on the server side, the task to modify or create a report programmatically is not a trivial one. Our suggestion is to pass the data source to your report while designing the report via an ObjectDataSource Component.
However, if you still need to create the report definition programmatically, you will need to do so inside a custom report resolver, as elaborated in the How to: Implement and use custom IReportResolver help article.

Regards,
Nasko
Telerik
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
0
Brian
Top achievements
Rank 1
answered on 02 Jul 2015, 06:25 PM

Nasko,

I backed off everything. What I want to do is get something working,  then go from there. My project structure is fairly complex - there are multiple silverlight classes with a main silverlight project.

I created a C# project to hold my Telerik report defs and datasources, set it up with the correct references and then used the main silverlight project to launch the report. My xaml control in the childwindow is as follows: 

 <telerik:ReportViewer Grid.Row="0" x:Name="rptViewer"                                                               ReportServiceUri="../ReportService.svc"
                       Width="960" />

 I open the report in a childwindow control using the following code in the constructor for the childwindow. Case statement is used because there will be many more reports :)

switch (ReportName)
{
   case "rptEventSummary":
        rptViewer.Report =
"NLx.TelerikReports.Reports.rptEventSummary , NLx.TelerikReports";
        rptViewer.RefreshReport();
        
break;
}

 The report is defined as using an objectdatasource - this is located in the same class lib as the report. I defined it thus: 

public class dsEventSummary
 {
        
private NLxDomainService svc;
        
public IQueryable<IdentityEvents_DTO> getData()
        {
            svc =
new NLxDomainService();
            
return svc.TelerikTestEvent();
         }
  }
  

I was able to use this datasource to define my report. When I run the report, I still get the following error:

 A report can't be created from NLx.TelerikReports.Reports.rptEventSummary , NLx.TelerikReports

One thing I did notice, when I open up the ReportService.svc file which I have attached - the environment appears to be unable to resolve the ReportService. I have checked that the DLLs are the correct version and are referenced - basically it matches the CSharp.ReportExamples.VS2010 solution I downloaded from the Telerik site.

 

0
Brian
Top achievements
Rank 1
answered on 02 Jul 2015, 07:32 PM

Update - I started comparing things a little more closely, and found the properties of the reference were not set to "Copy Local = True" - when i changed those my references resolved themselves and now I am sort of running the report. I changed the report data source so it no longer uses the class I described in my previous post; I chose the domain service as a datasource, and picked my TelerikTestEvent as the member that generates the data for the report. This method looks like:

 

  

public IQueryable<IdentityEvents_DTO> TelerikTestEvent()
 {
 
     var theData = GetEventsFilteredQuery(31, "1/1/2015 05:00", "1/31/2015 05:00", "", null, null, null, null, null, 8,
         null, null, null, null, null, null, 1, null, null, null, null, null, null, null,
         "|29||9||4||22||7||5||24||28||25||3||27||6||13||11||2||26||8||10||17||15||14||16||20||18||21||19|");
     return theData.AsQueryable();
 }

 

At this point I hardcoded all the parameters just so I could get a report working. Now I am getting this error, and when I put a breakpoint into the method it is never hit.

 

Error: System.Reflection.TargetInvocationException : An exception occurred during the operation, making the result invalid.  Check InnerException for exception details.
   at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
   at Telerik.Reporting.Service.SilverlightClient.ListRenderingExtensionsEventArgs.get_Extensions()
   at Telerik.ReportViewer.Silverlight.ReportViewerModel.OnListRenderingExtensionsCompleted(Object sender, ListRenderingExtensionsEventArgs e)

------------- InnerException: -------------

System.ServiceModel.CommunicationException : The remote server returned an error: NotFound.
   at System.ServiceModel.Channels.Remoting.RealProxy.Invoke(Object[] args)
   at proxy_3.EndListRenderingExtensions(IAsyncResult )
   at Telerik.Reporting.Service.SilverlightClient.ReportServiceClient.OnEndListRenderingExtensions(IAsyncResult result)
   at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)

------------- InnerException: -------------

System.Net.WebException : The remote server returned an error: NotFound.
   at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
   at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)

------------- InnerException: -------------

System.Net.WebException : The remote server returned an error: NotFound.
   at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
   at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClassa.<EndGetResponse>b__9(Object sendState)
   at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__0(Object sendState)


0
Nasko
Telerik team
answered on 06 Jul 2015, 11:34 AM
Hello Brian,

Please check the supported object types in the ObjectDataSource Component help article and make sure that the data member method returns a supported object.

Regards,
Nasko
Telerik
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
0
Brian
Top achievements
Rank 1
answered on 06 Jul 2015, 12:13 PM

This is the structure of the DTO that is being returned. Based on what you are saying it should be supported.  

public class IdentityEvents_DTO
 {
     [Key]
     public long EventLogID { get; set; }
     public string details { get; set; }
     public Nullable<long> identityID { get; set; }
     public DateTime ClientTime { set; get; }
     public DateTime ServerTime { set; get; }
     public string eventDefinitionText { get; set; }
     public string sessionIP { get; set; }
     public int? severityID { get; set; }
     public int EventDefinitionID { get; set; }
     public bool HasBinaryData { set; get; }
     public string ProcessName { get; set; }
     public string Category { get; set; }
     public bool HasActions { get; set; }
     public int? CollectedDataType { get; set; }
     public string EventSpecificData { get; set; }
     public long? SessionID { get;set; }
     public string Context { get; set; }
     public bool Flagged { get; set; }
     public string PrimaryDetailMimeType { get; set; }
     public long? PrimaryDetailID { get; set; }
     public bool HasDocuments { get; set; }
     public string DocumentMimeType { get; set; }
     public string EventDefPrimaryCategory { get; set; }
     public string RuleDefPrimaryCategory {get;set;}
     public string Taxonomy{get;set;}
     public string EventDefTags { get; set; }
 
     public string ClientHostname { get; set; }
     public string ClientMac { get; set; }
     public bool HasIncidents { get; set; }
     public string DisplayName { get; set; }
     public string RuleInstanceName { get; set; }
     public bool? IsSensitive { get; set; }
 }

From what I can tell the error looks like it is unable to process because my calling structure is not set up to be async, and I don't know how to do that. I have looked for 2 days without much luck for a solution to this. 

0
Nasko
Telerik team
answered on 09 Jul 2015, 06:38 AM
Hello Brian,

In order to advise further we will need to review and debug a runnable sample project exhibiting the issue. Please open a new support ticket where you can zip and attach the requested sample project.

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