IDashboardStorage Interface
When implemented by a class, represents a storage of dashboards.
Namespace: DevExpress.DashboardWeb
Assembly: DevExpress.Dashboard.v19.2.Web.dll
Declaration
public interface IDashboardStorage
Public Interface IDashboardStorage
The following members return IDashboardStorage objects:
Use the DashboardConfigurator.SetDashboardStorage method to create a storage that will contain dashboards. You can use predefined dashboard storages (DashboardFileStorage or DashboardInMemoryStorage) or you can implement the IDashboardStorage/IEditableDashboardStorage interface to provide your own logic for managing dashboards in the Web Dashboard.
Example
The following example shows how to create a custom dashboard storage for ASPxDashboard by implementing the IEditableDashboardStorage interface. In this example, a DataSet is used as an in-memory storage of dashboards. This DataSet can be used later to save dashboards in the database using DataAdapter.
Imports System
Imports System.Collections.Generic
Imports System.Data
Imports System.Linq
Imports System.Web
Namespace WebDesigner_CustomDashboardStorage
Public Class DashboardStorageDataSet
Inherits DataSet
Public Sub New()
Dim table As New DataTable("Dashboards")
Dim idColumn As New DataColumn("DashboardID", GetType(Int32))
idColumn.AutoIncrement = True
idColumn.AutoIncrementSeed = 1
idColumn.Unique = True
idColumn.AllowDBNull = False
table.Columns.Add(idColumn)
table.Columns.Add("DashboardXml", GetType(String))
table.Columns.Add("DashboardName", GetType(String))
table.PrimaryKey = New DataColumn() {idColumn}
Me.Tables.Add(table)
End Sub
End Class
End Namespace
Imports System.Collections.Generic
Imports System.Data
Imports System.Xml.Linq
Imports DevExpress.DashboardWeb
Namespace WebDesigner_CustomDashboardStorage
Public Class CustomDashboardStorage
Implements IEditableDashboardStorage
Private dashboards As New DashboardStorageDataSet()
' Adds a dashboard with the specified ID and name to a DataSet.
' Note that the 'DashboardID' column is an auto-increment column that is used to store unique dashboard IDs.
Public Function AddDashboard(ByVal dashboard As XDocument, ByVal dashboardName As String) As String Implements IEditableDashboardStorage.AddDashboard
Dim newRow As DataRow = dashboards.Tables(0).NewRow()
newRow("DashboardName") = dashboardName
newRow("DashboardXml") = dashboard
dashboards.Tables(0).Rows.Add(newRow)
Return newRow("DashboardID").ToString()
End Function
' Gets information about dashboards available in a DataSet.
Public Function GetAvailableDashboardsInfo() As IEnumerable(Of DashboardInfo) Implements IEditableDashboardStorage.GetAvailableDashboardsInfo
Dim dashboardInfos As New List(Of DashboardInfo)()
For Each row As DataRow In dashboards.Tables(0).Rows
Dim dashboardInfo As New DashboardInfo()
dashboardInfo.ID = row("DashboardID").ToString()
dashboardInfo.Name = row("DashboardName").ToString()
dashboardInfos.Add(dashboardInfo)
Next row
Return dashboardInfos
End Function
' Loads a dashboard corresponding to the specified ID.
Public Function LoadDashboard(ByVal dashboardID As String) As XDocument Implements IEditableDashboardStorage.LoadDashboard
Dim currentRow As DataRow = dashboards.Tables(0).Rows.Find(dashboardID)
Dim dashboardXml As XDocument = XDocument.Parse(currentRow("DashboardXml").ToString())
Return dashboardXml
End Function
' Saves the dashboard with the specified ID to a DataSet.
Public Sub SaveDashboard(ByVal dashboardID As String, ByVal dashboard As XDocument) Implements IEditableDashboardStorage.SaveDashboard
Dim currentRow As DataRow = dashboards.Tables(0).Rows.Find(dashboardID)
currentRow("DashboardXml") = dashboard
End Sub
End Class
End Namespace
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
namespace WebDesigner_CustomDashboardStorage
{
public class DashboardStorageDataSet: DataSet
{
public DashboardStorageDataSet()
{
DataTable table = new DataTable("Dashboards");
DataColumn idColumn = new DataColumn("DashboardID", typeof(Int32));
idColumn.AutoIncrement = true;
idColumn.AutoIncrementSeed = 1;
idColumn.Unique = true;
idColumn.AllowDBNull = false;
table.Columns.Add(idColumn);
table.Columns.Add("DashboardXml", typeof(string));
table.Columns.Add("DashboardName", typeof(string));
table.PrimaryKey = new DataColumn[] {idColumn};
this.Tables.Add(table);
}
}
}
using System.Collections.Generic;
using System.Data;
using System.Xml.Linq;
using DevExpress.DashboardWeb;
namespace WebDesigner_CustomDashboardStorage {
public class CustomDashboardStorage : IEditableDashboardStorage {
DashboardStorageDataSet dashboards = new DashboardStorageDataSet();
// Adds a dashboard with the specified ID and name to a DataSet.
// Note that the 'DashboardID' column is an auto-increment column that is used to store unique dashboard IDs.
public string AddDashboard(XDocument dashboard, string dashboardName) {
DataRow newRow = dashboards.Tables[0].NewRow();
newRow["DashboardName"] = dashboardName;
newRow["DashboardXml"] = dashboard;
dashboards.Tables[0].Rows.Add(newRow);
return newRow["DashboardID"].ToString();
}
// Gets information about dashboards available in a DataSet.
public IEnumerable<DashboardInfo> GetAvailableDashboardsInfo() {
List<DashboardInfo> dashboardInfos = new List<DashboardInfo>();
foreach (DataRow row in dashboards.Tables[0].Rows) {
DashboardInfo dashboardInfo = new DashboardInfo();
dashboardInfo.ID = row["DashboardID"].ToString();
dashboardInfo.Name = row["DashboardName"].ToString();
dashboardInfos.Add(dashboardInfo);
}
return dashboardInfos;
}
// Loads a dashboard corresponding to the specified ID.
public XDocument LoadDashboard(string dashboardID) {
DataRow currentRow = dashboards.Tables[0].Rows.Find(dashboardID);
XDocument dashboardXml = XDocument.Parse(currentRow["DashboardXml"].ToString());
return dashboardXml;
}
// Saves the dashboard with the specified ID to a DataSet.
public void SaveDashboard(string dashboardID, XDocument dashboard) {
DataRow currentRow = dashboards.Tables[0].Rows.Find(dashboardID);
currentRow["DashboardXml"] = dashboard;
}
}
}
See Also