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; }
public static void SaveDashboard(this IObjectSpace objectSpace, DevExpress.DashboardCommon.Dashboard dashboard, IDashboardDefinition template, MemoryStream memoryStream) { dashboard.SynchronizeModel(objectSpace, template); dashboard.SaveToXml(memoryStream); dashboard.ApplyModel(FilterEnabled.Always, template, objectSpace); }