Extract Data Source
- 2 minutes to read
This tutorial shows how to add the DashboardExtractDataSource to an in-memory data source storage, and make it available to users.
In your application, add the SalesOverview.dat file to the App_Data folder from the C:\Users\Public\Documents\DevExpress Demos 24.1\Components\Data directory.
In the dashboard configuration file (for example, DashboardConfig.cs / DashboardConfig.vb), create a public method that returns the configured dashboard’s data source storage (DataSourceInMemoryStorage) and define the Extract Data Source.
using DevExpress.DashboardCommon; public static DataSourceInMemoryStorage CreateDataSourceStorage() { DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage(); DashboardExtractDataSource extractDataSource = new DashboardExtractDataSource("Extract Data Source"); extractDataSource.Name = "Extract Data Source"; dataSourceStorage.RegisterDataSource("extractDataSource ", extractDataSource.SaveToXml()); return dataSourceStorage; }
Call the DashboardConfigurator.SetDataSourceStorage method to configure the data source storage. Use the created CreateDataSourceStorage method as the SetDataSourceStorage parameter and handle the DashboardConfigurator.ConfigureDataConnection event to pass the connection parameters to the Extract Data Source.
using System; using DevExpress.DashboardWeb; public static void RegisterService(RouteCollection routes) { routes.MapDashboardRoute("dashboardControl", "DefaultDashboard"); // ... DashboardConfigurator.Default.SetDataSourceStorage(CreateDataSourceStorage()); DashboardConfigurator.Default.ConfigureDataConnection += Default_ConfigureDataConnection; } private static void Default_ConfigureDataConnection(object sender, ConfigureDataConnectionWebEventArgs e) { if(e.DataSourceName.Contains("Extract Data Source")) { ExtractDataSourceConnectionParameters extractParams = new ExtractDataSourceConnectionParameters(); extractParams.FileName = HostingEnvironment.MapPath(@"~/App_Data/SalesPersonExtract.dat"); e.ConnectionParameters = extractParams; } }
The Extract Data Source is now available in the Web Dashboard:
Users can now bind dashboard items to data in the Web Dashboard’s UI.
Example
The example shows how to make a set of data sources available for users in the Web Dashboard application.