The MindFusion Forums
MindFusion.Reporting >> WPF >> New to reporting.
https://mindfusion.eu/Forum/YaBB.pl?num=1517225694

Message started by Dom@Hadley on Jan 29th, 2018 at 11:34am

Title: New to reporting.
Post by Dom@Hadley on Jan 29th, 2018 at 11:34am
Hi

I'm evaluating the Reporting tool for use in our application and we have currently purchased the scheduling tool for WPF. 
I've been through the help file for reporting and see there are two ways to use it.  We've opted not to link it directly with the Schedule as this would cause an additional overhead.  What I really want to know, which is not clear in the examples, is for each set of data I must set up a datarange with a header and footer.  E.g. if I am printing a plan of the schedule and we have three resources in the schedule, how can I separate each resource onto a separate page within the report?

Title: Re: New to reporting.
Post by Meppy on Jan 29th, 2018 at 1:44pm
Hi,

A sample demonstrating how to integrate the Reporting for WPF with the Scheduling for WPF can be downloaded from the link below:

https://mindfusion.eu/_samples/_sample_WpfReportingPlannerIntegration.zip

The sample demonstrates a simple report bound to a Schedule. The report lists the resources in the bound schedule in a master data range and the items under each resource in a nested data range. You can play around with the report to extend it. If you have additional questions, I will be happy to assist.

Regards,
Meppy

Title: Re: New to reporting.
Post by Dom@Hadley on Jan 29th, 2018 at 4:23pm
Hi Meppy
Many thanks for your example but this example ties it to the schedule which we cannot do.  Our schedule  resources and calendar items are too basic for the report we want to build.  Our data dictionary comes from the database not the schedule.  Each single appointment has a list of data in the database that is not in the Calendar Item.  I hope you understand.
Cheers
Dom

Title: Re: New to reporting.
Post by Meppy on Jan 30th, 2018 at 7:22am
Hi,

The purpose of the sample is to illustrate how to bind the report to a data source. You can extend it with a data source different than the schedule. If you provide me with more information about your data source, I can help you extend the report to accommodate it.

Regards,
Meppy

Title: Re: New to reporting.
Post by Dom@Hadley on Jan 31st, 2018 at 12:56pm
Hi Meppy

My datasource is an observablecollection of custom object  which is from a sql server View using EntityFramework.  The view returns a full list of all the details of the plan for the day chosen by the user.  There are four resources on each day (currently) and each work request (appointment) contains multiple work orders.  The report is  to provide a list of work orders for the day for each resource. The database resources  are tied to the Schedule's Resources by Id. 
Many thanks
Dom

Title: Re: New to reporting.
Post by Meppy on Feb 1st, 2018 at 9:03am
Hi,

Here is how you should modify the existing sample to accommodate it to your scenario:

1. Leave the DataContext of the report as is, i.e.:


Code (]report.DataContext = calendar.Schedule.Resources;[/code):

This is to ensure that the report lists the work orders for the day grouped by resource.

2. Rename the ItemsRange in ListBoundReport.xaml to OrdersRange to indicate that this data range will now show orders, rather than appointments.

3. In the Report.QueryDetails event handler, check if the DataRange being populated is the OrdersRange. Then obtain the Resource whose orders are being queried through the MasterRow property of the event argument. Finally, assign the Details property of the event argument to an enumerable of all orders associated with this resource for the respective day. For example, you can do this by using Linq on the EntityFramework object representing the list of work orders for the respective day:

[code]report.QueryDetails += (s, e) =>
{
     DataRange sender = s as DataRange;
     if (sender != null)
     {
           if (sender.Name == "OrdersRange")
           {
                 var resource = e.MasterRow as Resource;
                 e.Details = orderCollection.Where(order => IsAssociatedWithResource(order, resource));
           }
     }
};

The above code assumes that orderCollection is a list/enumerable of all work orders for the day and that IsAssociatedWithResource method returns true if the specified order belongs to the specified resource. The implementation of this method depends on how your orders are associated with the resource.

4. Finally, modify the DataRange.ItemTemplate of the ItemsRange data range in ListBoundReport.xaml to include the desired fields of the work order in the report. Currently this ItemTemplate contains a single label, bound to the HeaderText of an appointment. Now that we are binding to work orders, you should modify the ItemTemplate accordingly.

I hope this helps.

Regards,
Meppy

Title: Re: New to reporting.
Post by Dom@Hadley on Feb 1st, 2018 at 3:10pm
Thanks  :)

The MindFusion Forums » Powered by YaBB 2.6.11!
YaBB Forum Software © 2000-2024. All Rights Reserved.