I need to create some queries and these queries will be used to create graphs in a dashboard. The queries are a lot of calculations and are nonpersistent classes.
First I created the class and only about this I have HPerformance_ListView and HPerformance_DetailView but I don't have a data provider to populate it. The system tries to populate it from EF context, that is not possible.
[NavigationItem]
[NonPersistent]
public class HPerformance
{
public decimal Valor { get; set; }
public decimal Meta { get; set; }
public decimal Percentual { get; set; }
}
And the query class
public class MetasVendas
{
public MetasVendas()
{
fromDate = DateTime.Now.AddMonths(-1);
toDate = DateTime.Now;
revenda = 0;
}
public DateTime fromDate { get; set; }
public DateTime toDate { get; set; }
public long revenda { get; set; }
public BindingList<HPerformance> _hPerformance()
{
var r = _calculoMetaEValor();
var rr = r.GroupBy(g => true).Select(s => new HPerformance()
{
Valor = s.Sum(v => v.TotalUSacess + v.TotalUSradio),
Meta = s.Sum(v => v.Meta),
Percentual = s.Sum(vv => vv.TotalUSacess + vv.TotalUSradio) / s.Sum(vv => vv.Meta)
});
return new BindingList<HPerformance>(rr.ToList());
}
In the dashboard controller this is the code that I don't know how to handle. My example doesn't work
public partial class DashboardDealerGoalExecute : ViewController<DashboardView>
{
void parametersViewItem_ControlCreated(object sender, EventArgs e)
{
DashboardViewItem viewItem = (DashboardViewItem)sender;
if (viewItem.Id == "HPerformance")
{
ListView _hPerformance = (ListView)viewItem.InnerView;
if (parameters != null && parameters.Dealer != null)
{
BindingList<HPerformance> hp =
new MetasVendas()
{
fromDate = parameters.FromDate,
toDate = parameters.ToDate,
revenda = parameters.Dealer.ID
}._hPerformance();
_hPerformance.CurrentObject = hp;
}
}
HPerformance
is a dashboard item and is connected to HPerformance
class (1st code). How do I setup HPerformance_ListView
to be populated by _hPerformance()
method?
Thanks, Marco Castro