The requested page is not available for the requested platform. You are viewing the content for Default platform.

DashboardExtractDataSource Class

An extract data source that is a local snapshot of data.

Namespace: DevExpress.DashboardCommon

Assembly: DevExpress.Dashboard.v19.1.Core.dll

Declaration

public class DashboardExtractDataSource :
    IDashboardDataSource,
    IDashboardComponent,
    IComponent,
    IDisposable,
    ISupportInitialize,
    ISupportPrefix,
    IDashboardDataSourceInternal,
    IDataComponent,
    IServiceContainer,
    IServiceProvider,
    ISensitiveInfoContainer
Public Class DashboardExtractDataSource
    Implements IDashboardDataSource,
               IDashboardComponent,
               IComponent,
               IDisposable,
               ISupportInitialize,
               ISupportPrefix,
               IDashboardDataSourceInternal,
               IDataComponent,
               IServiceContainer,
               IServiceProvider,
               ISensitiveInfoContainer

Remarks

Data extracts allow you to obtain data from the existing data source (such as DashboardSqlDataSource, DashboardEFDataSource, DashboardObjectDataSource, etc.) and save this data locally. You can use this data source type as any regular data source.

Note

Note that data extracts cannot be created for the OLAP Data Source.

Data Types Supported by DashboardExtractDataSource

Note that DashboardExtractDataSource can process data fields of the following types when creating a data extract.

Examples

This example demonstrates how to create the Extract data source, replace existing dashboard data sources with Extract data sources and update the Extract data file.

The DashboardViewer loads a dashboard. The dashboard is initially bound to the Microsoft SQL Server database file (.mdf) with the DashboardSqlDataSource.

The CreateExtractAndSave method creates the DashboardExtractDataSource based on the original data source, adds the newly created data source to the dashboard, iterates over dashboard items to change the data source settings, and finally saves the modified dashboard and the Extract data file.

The UpdateExtract method calls the DashboardExtractDataSource.UpdateExtractFile() method for each Extract data source in the dashboard.

Note

The complete sample project WinForms - Dashboard with Extract Data Source is available in the DevExpress Examples repository.

using DevExpress.DashboardCommon;
using DevExpress.DashboardWin;
using System.Linq;

namespace ExtractDataSourceExample
{
    public partial class Form1 : DevExpress.XtraEditors.XtraForm
    {
        public Form1()
        {
            InitializeComponent();
            dashboardViewer1.CustomizeDashboardTitle += DashboardViewer1_CustomizeDashboardTitle;
            dashboardViewer1.LoadDashboard("DashboardTest.xml");
        }

        private void CreateExtractAndSave()
        {
            DataSourceCollection dsCollection = new DataSourceCollection();
            dsCollection.AddRange(dashboardViewer1.Dashboard.DataSources.Where(d => !(d is DashboardExtractDataSource)));
            foreach (var ds in dsCollection)
            {
                    DashboardExtractDataSource extractDataSource = new DashboardExtractDataSource();
                    extractDataSource.ExtractSourceOptions.DataSource = ds;

                    if (ds is DashboardSqlDataSource)
                        extractDataSource.ExtractSourceOptions.DataMember = ((DashboardSqlDataSource)(ds)).Queries[0].Name;

                extractDataSource.FileName = "Extract_" + ds.Name + ".dat";
                    extractDataSource.UpdateExtractFile();
                    foreach (DataDashboardItem item in dashboardViewer1.Dashboard.Items)
                        if (item.DataSource == ds)
                            item.DataSource = extractDataSource;
            }
            dashboardViewer1.Dashboard.DataSources.RemoveRange(dsCollection);
            dashboardViewer1.Dashboard.SaveToXml("Dashboard_Extract.xml");
        }

        private void UpdateExtract()
        {
            dashboardViewer1.ReloadData();
            foreach (var ds in dashboardViewer1.Dashboard.DataSources.Where(d => d is DashboardExtractDataSource))
            {
                ((DashboardExtractDataSource)ds).UpdateExtractFile();
            }
        }

        private void DashboardViewer1_CustomizeDashboardTitle(object sender, CustomizeDashboardTitleEventArgs e)
        {
            DashboardToolbarItem itemUpdate = new DashboardToolbarItem(
                (args) => UpdateExtract())
            {
                Caption = "Update Extract Data Source",
            };
            e.Items.Add(itemUpdate);

            DashboardToolbarItem itemSave = new DashboardToolbarItem(
                (args) => CreateExtractAndSave())
            {
                Caption = "Create Extract Data Source",
            };
            e.Items.Insert(0,itemSave);
        }
    }
}

Inheritance

Object
DashboardExtractDataSource
See Also