public static DevExpress.DashboardCommon.Dashboard CreateDashBoard(this IDashboardDefinition template, IObjectSpace objectSpace, FilterEnabled filterEnabled) { var dashboard = new DevExpress.DashboardCommon.Dashboard(); try { if (!string.IsNullOrEmpty(template.Xml)) { dashboard = LoadFromXml(template); dashboard.ApplyModel(filterEnabled, template, objectSpace); } foreach (var typeWrapper in template.DashboardTypes.Select(wrapper => new { wrapper.Type, Caption = GetCaption(wrapper) })) { var wrapper = typeWrapper; var dsource = dashboard.DataSources.FirstOrDefault(source => source.Name.Equals(wrapper.Caption)); var objects = objectSpace.CreateDashboardDataSource(wrapper.Type); if (dsource != null) { dsource.Data = objects; } else if (!dashboard.DataSources.Contains(ds => ds.Name.Equals(wrapper.Caption))) { dashboard.AddDataSource(typeWrapper.Caption, objects); } } } catch (Exception e) { dashboard.Dispose(); Tracing.Tracer.LogError(e); } return(dashboard); }
public static DevExpress.DashboardCommon.Dashboard CreateDashBoard(this IDashboardDefinition template, IObjectSpace objectSpace, FilterEnabled filterEnabled) { var dashboard = new DevExpress.DashboardCommon.Dashboard(); try { if (!string.IsNullOrEmpty(template.Xml)) { dashboard = LoadFromXml(template); dashboard.ApplyModel(filterEnabled, template, objectSpace); } foreach (var typeWrapper in template.DashboardTypes.Select(wrapper => new { wrapper.Type, Caption = GetCaption(wrapper) })) { var wrapper = typeWrapper; var dsource = dashboard.DataSources.FirstOrDefault(source => source.Name.Equals(wrapper.Caption)); var objects = objectSpace.CreateDashboardDataSource(wrapper.Type); if (dsource != null) { dsource.Data = objects; } else if (!dashboard.DataSources.Contains(ds => ds.Name.Equals(wrapper.Caption))) { dashboard.AddDataSource(typeWrapper.Caption, objects); } } } catch (Exception e) { dashboard.Dispose(); Tracing.Tracer.LogError(e); } return dashboard; }
void DataLoading(object sender, DataLoadingWebEventArgs e) { if (e.Data == null) { var dsType = Definition.DashboardTypes.First(t => t.Caption == e.DataSourceName).Type; e.Data = _objectSpace.CreateDashboardDataSource(dsType); } }