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.:
report.DataContext = calendar.Schedule.Resources;
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:
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