ExtractDriverStorage Class

A storage of drivers used to manage writing/reading operations for data extracts.

Namespace: DevExpress.DashboardCommon

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

Syntax

public static class ExtractDriverStorage

By default, the DashboardExtractDataSource stores data within a file. If necessary, you add a custom logic for writing/reading extract data by implementing the ICustomExtractDriver interface. After you have implemented a custom driver, you can use it in two ways.

Examples

This example demonstrates how to create a custom driver that will be used to encrypt/decrypt extract data by implementing the ICustomExtractDriver interface. The following methods are implemented for this interface.

using DevExpress.DashboardCommon;
using DevExpress.DataAccess.ConnectionParameters;
using DevExpress.DataAccess.Sql;
using DevExpress.XtraEditors;

namespace Dashboard_CustomExtractDriver {
    public partial class Form1 : XtraForm {
        public Form1() {
            InitializeComponent();
            ExtractDriverStorage.DefaultDriver = new ExtractEncryptionDriver();

            DashboardSqlDataSource sqlDataSource = new DashboardSqlDataSource();
            sqlDataSource.DataProcessingMode = DataProcessingMode.Client;
            Access2007ConnectionParameters connectionParams = new Access2007ConnectionParameters(@"..\..\Data\Northwind.accdb", "");
            sqlDataSource.ConnectionParameters = connectionParams;

            SelectQuery selectQuery = SelectQueryFluentBuilder
                .AddTable("Invoices")
                .SelectColumns("ExtendedPrice", "Quantity", "OrderDate", "ProductName")
                .Build("Query 1");
            sqlDataSource.Queries.Add(selectQuery);
            sqlDataSource.Fill();   

            DashboardExtractDataSource extractDataSource = new DashboardExtractDataSource();
            extractDataSource.ExtractSourceOptions.DataSource = sqlDataSource;
            extractDataSource.ExtractSourceOptions.DataMember = "Query 1";
            extractDataSource.FileName = @".\InvoicesExtract.dat";
            extractDataSource.UpdateExtractFile();

            Dashboard dashboard = new Dashboard();
            dashboard.DataSources.Add(extractDataSource);

            PivotDashboardItem pivot = new PivotDashboardItem();
            pivot.DataSource = extractDataSource;
            pivot.Values.AddRange(new Measure("ExtendedPrice"), new Measure("Quantity"));
            pivot.Columns.Add(new Dimension("OrderDate", DateTimeGroupInterval.Year));
            pivot.Rows.Add(new Dimension("ProductName"));  
            dashboard.Items.Add(pivot);

            dashboardViewer1.Dashboard = dashboard;
        }
    }
}
Imports System
Imports System.Collections.Generic
Imports System.Security.Cryptography
Imports DevExpress.DashboardCommon

Namespace Dashboard_CustomExtractDriver
    Public Class ExtractEncryptionDriver
        Implements ICustomExtractDriver
        Public Function CreateReadSession(ByVal resourceName As String) As  _
            IDriverReadSession Implements ICustomExtractDriver.CreateReadSession
            Return New EncryptionReadSession(FileExtractDriver.Instance.CreateReadSession(resourceName))
        End Function
        Public Function CreateWriteSession(ByVal resourceName As String) As  _
            IDriverWriteSession Implements ICustomExtractDriver.CreateWriteSession
            Return New EncryptionWriteSession(FileExtractDriver.Instance.CreateWriteSession(resourceName))
        End Function
    End Class

    Public Class EncryptionWriteSession
        Implements IDriverWriteSession
        Private writeSession As IDriverWriteSession
        Public Sub New(ByVal writeSession As IDriverWriteSession)
            Me.writeSession = writeSession
        End Sub
        Public Sub Dispose() Implements System.IDisposable.Dispose
            writeSession.Dispose()
        End Sub
        Public Sub SetPage(ByVal pageID As Guid, ByVal data() As Byte) Implements IDriverWriteSession.SetPage
            writeSession.SetPage(pageID, Encrypt(data))
        End Sub
        Private Function Encrypt(ByVal page() As Byte) As Byte()
            Dim entropy() As Byte = {1, 2, 3}
            Dim encryptedPage() As Byte = ProtectedData.Protect(page, entropy, DataProtectionScope.CurrentUser)
            Return encryptedPage
        End Function
    End Class

    Public Class EncryptionReadSession
        Implements IDriverReadSession
        Private readSession As IDriverReadSession
        Public Sub New(ByVal readSession As IDriverReadSession)
            Me.readSession = readSession
        End Sub
        Public Sub Dispose() Implements System.IDisposable.Dispose
            readSession.Dispose()
        End Sub
        Private Function Decrypt(ByVal page() As Byte) As Byte()
            Dim entropy() As Byte = {1, 2, 3}
            Dim decryptedPage() As Byte = ProtectedData.Unprotect(page, entropy, DataProtectionScope.CurrentUser)
            Return decryptedPage
        End Function
        Public Function GetPage(ByVal pageID As Guid) As Byte() Implements IDriverReadSession.GetPage
            Return Decrypt(readSession.GetPage(pageID))
        End Function
        Public Function GetPageIDs() As IEnumerable(Of Guid) Implements IDriverReadSession.GetPageIDs
            Return readSession.GetPageIDs()
        End Function
    End Class
End Namespace
Imports DevExpress.DashboardCommon
Imports DevExpress.DataAccess.ConnectionParameters
Imports DevExpress.DataAccess.Sql
Imports DevExpress.XtraEditors

Namespace Dashboard_CustomExtractDriver
    Partial Public Class Form1
        Inherits XtraForm

        Public Sub New()
            InitializeComponent()
            ExtractDriverStorage.DefaultDriver = New ExtractEncryptionDriver()

            Dim sqlDataSource As New DashboardSqlDataSource()
            sqlDataSource.DataProcessingMode = DataProcessingMode.Client
            Dim connectionParams As New Access2007ConnectionParameters("..\..\Data\Northwind.accdb", "")
            sqlDataSource.ConnectionParameters = connectionParams

            Dim selectQuery As SelectQuery = SelectQueryFluentBuilder.AddTable("Invoices").
                SelectColumns("ExtendedPrice", "Quantity", "OrderDate", "ProductName").Build("Query 1")
            sqlDataSource.Queries.Add(selectQuery)
            sqlDataSource.Fill()

            Dim extractDataSource As New DashboardExtractDataSource()
            extractDataSource.ExtractSourceOptions.DataSource = sqlDataSource
            extractDataSource.ExtractSourceOptions.DataMember = "Query 1"
            extractDataSource.FileName = ".\InvoicesExtract.dat"
            extractDataSource.UpdateExtractFile()

            Dim dashboard As New Dashboard()
            dashboard.DataSources.Add(extractDataSource)

            Dim pivot As New PivotDashboardItem()
            pivot.DataSource = extractDataSource
            pivot.Values.AddRange(New Measure("ExtendedPrice"), New Measure("Quantity"))
            pivot.Columns.Add(New Dimension("OrderDate", DateTimeGroupInterval.Year))
            pivot.Rows.Add(New Dimension("ProductName"))
            dashboard.Items.Add(pivot)

            dashboardViewer1.Dashboard = dashboard
        End Sub
    End Class
End Namespace

Inheritance

Object
ExtractDriverStorage

See Also