-
Notifications
You must be signed in to change notification settings - Fork 0
/
OrdersChart.ascx.cs
46 lines (40 loc) · 1.58 KB
/
OrdersChart.ascx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Linq;
using System.Web.UI;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Editors;
using DevExpress.ExpressApp.Web;
using DxSample.Module.BusinessObjects;
namespace DxSample.Web {
public partial class OrdersChart : UserControl, IComplexControl {
protected void Page_Load(object sender, EventArgs e) {
string url = this.ResolveClientUrl("~/Scripts/Controls/orders-chart.js");
WebWindow.CurrentRequestWindow.RegisterClientScriptInclude("orders-chart", url);
}
private object GetChartData(IObjectSpace objectSpace) {
string[] countriesToDisplay = new string[] { "Germany", "Mexico", "UK" };
return objectSpace.GetObjectsQuery<Order>()
.Where(o => countriesToDisplay.Contains(o.Customer.Country))
.ToArray()
.GroupBy(o => new
{
date = new DateTime(o.OrderDate.Year, o.OrderDate.Month, 1),
country = o.Customer.Country
})
.Select(og => new
{
arg = og.Key.date,
val = og.Sum(o => o.UnitPrice),
series = og.Key.country
})
.ToArray();
}
#region IComplexControl Members
void IComplexControl.Refresh() {
}
void IComplexControl.Setup(IObjectSpace objectSpace, XafApplication application) {
this.ASPxPanel1.JSProperties.Add("cpChartData", this.GetChartData(objectSpace));
}
#endregion
}
}