Skip to content

Commit cc18b49

Browse files
committed
add cs solution
1 parent 9b385cc commit cc18b49

28 files changed

+59721
-0
lines changed

CS/WebDashboardAspNetCore.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.2.32516.85
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebDashboardAspNetCore", "WebDashboardAspNetCore\WebDashboardAspNetCore.csproj", "{966BF9A7-C908-4E71-87D2-3AF486D7D380}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{966BF9A7-C908-4E71-87D2-3AF486D7D380}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{966BF9A7-C908-4E71-87D2-3AF486D7D380}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{966BF9A7-C908-4E71-87D2-3AF486D7D380}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{966BF9A7-C908-4E71-87D2-3AF486D7D380}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {3E745CA4-B1FD-4343-968E-90B576A4A45E}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using DevExpress.DashboardAspNetCore;
2+
using DevExpress.DashboardWeb;
3+
using Microsoft.Extensions.Configuration;
4+
using Microsoft.Extensions.DependencyInjection;
5+
using Microsoft.Extensions.FileProviders;
6+
using System;
7+
8+
namespace WebDashboardAspNetCore {
9+
public static class DashboardUtils {
10+
public static DashboardConfigurator CreateDashboardConfigurator(IConfiguration configuration, IFileProvider fileProvider) {
11+
DashboardConfigurator configurator = new DashboardConfigurator();
12+
configurator.SetConnectionStringsProvider(new DashboardConnectionStringsProvider(configuration));
13+
14+
DashboardFileStorage dashboardFileStorage = new DashboardFileStorage(fileProvider.GetFileInfo("Data/Dashboards").PhysicalPath);
15+
configurator.SetDashboardStorage(dashboardFileStorage);
16+
17+
configurator.SetDataSourceStorage(new DataSourceInMemoryStorage());
18+
19+
configurator.SetDBSchemaProvider(new CustomDBSchemaProvider());
20+
// configurator.SetDBSchemaProvider(new MyDBSchemaProvider());
21+
22+
23+
return configurator;
24+
}
25+
}
26+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using DevExpress.DashboardAspNetCore;
2+
using DevExpress.DashboardWeb;
3+
using Microsoft.AspNetCore.DataProtection;
4+
5+
namespace WebDashboardAspNetCore.Controllers {
6+
public class DefaultDashboardController : DashboardController {
7+
public DefaultDashboardController(DashboardConfigurator configurator, IDataProtectionProvider dataProtectionProvider = null)
8+
: base(configurator, dataProtectionProvider) {
9+
}
10+
}
11+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using DevExpress.DataAccess.Sql;
2+
using DevExpress.Xpo.DB;
3+
using System.Collections.Specialized;
4+
5+
namespace WebDashboardAspNetCore {
6+
public class CustomDBSchemaProvider : IDBSchemaProviderEx {
7+
DBTable[] tables;
8+
public void LoadColumns(SqlDataConnection connection, params DBTable[] tables) {
9+
// Loads the specified columns in the Categories and Products tables.
10+
foreach (DBTable table in tables) {
11+
if (table.Name == "Categories" && table.Columns.Count == 0) {
12+
DBColumn categoryIdColumn = new DBColumn { Name = "CategoryID", ColumnType = DBColumnType.Int32 };
13+
table.AddColumn(categoryIdColumn);
14+
DBColumn categoryNameColumn = new DBColumn { Name = "CategoryName", ColumnType = DBColumnType.String };
15+
table.AddColumn(categoryNameColumn);
16+
}
17+
if (table.Name == "Products" && table.Columns.Count == 0) {
18+
DBColumn categoryIdColumn = new DBColumn { Name = "CategoryID", ColumnType = DBColumnType.Int32 };
19+
table.AddColumn(categoryIdColumn);
20+
DBColumn productNameColumn = new DBColumn { Name = "ProductName", ColumnType = DBColumnType.String };
21+
table.AddColumn(productNameColumn);
22+
23+
// Links the tables by the CategoryID field.
24+
DBForeignKey foreignKey = new DBForeignKey(
25+
new[] { categoryIdColumn },
26+
"Categories",
27+
CustomDBSchemaProvider.CreatePrimaryKeys("CategoryID"));
28+
table.ForeignKeys.Add(foreignKey);
29+
}
30+
}
31+
}
32+
33+
public static StringCollection CreatePrimaryKeys(params string[] names) {
34+
StringCollection collection = new StringCollection();
35+
collection.AddRange(names);
36+
return collection;
37+
}
38+
39+
public DBTable[] GetTables(SqlDataConnection connection, params string[] tableList) {
40+
// Loads only the Categories and Products tables for the NWindConnectionString connection.
41+
if (connection.Name == "NWindConnectionString") {
42+
if (tables != null) {
43+
return tables;
44+
}
45+
tables = new DBTable[2];
46+
47+
DBTable categoriesTable = new DBTable("Categories");
48+
tables[0] = categoriesTable;
49+
50+
DBTable productsTable = new DBTable("Products");
51+
tables[1] = productsTable;
52+
} else
53+
tables = new DBTable[0];
54+
55+
LoadColumns(connection, tables);
56+
return tables;
57+
}
58+
59+
public DBTable[] GetViews(SqlDataConnection connection, params string[] viewList) {
60+
DBTable[] views = new DBTable[0];
61+
return views;
62+
}
63+
64+
public DBStoredProcedure[] GetProcedures(SqlDataConnection connection, params string[] procedureList) {
65+
DBStoredProcedure[] storedProcedures = new DBStoredProcedure[0];
66+
return storedProcedures;
67+
}
68+
}
69+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Dashboard>
3+
<Title Text="New Dashboard" />
4+
<DataSources>
5+
<SqlDataSource Name="Categories" ComponentName="sqlDataSource1">
6+
<Connection Name="NWindConnectionString" FromAppConfig="true" />
7+
<Query Type="SelectQuery" Name="Categories">
8+
<Tables>
9+
<Table Name="Categories" />
10+
</Tables>
11+
<Columns>
12+
<Column Table="Categories" Name="CategoryID" />
13+
<Column Table="Categories" Name="CategoryName" />
14+
</Columns>
15+
</Query>
16+
<ConnectionOptions CloseConnection="true" />
17+
</SqlDataSource>
18+
</DataSources>
19+
</Dashboard>
644 KB
Binary file not shown.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using DevExpress.DataAccess.Sql;
2+
using DevExpress.Xpo.DB;
3+
using System.Linq;
4+
5+
namespace WebDashboardAspNetCore {
6+
public class MyDBSchemaProvider : IDBSchemaProviderEx {
7+
DBSchemaProviderEx provider;
8+
public MyDBSchemaProvider() {
9+
this.provider = new DBSchemaProviderEx();
10+
}
11+
12+
public DBTable[] GetTables(SqlDataConnection connection, params string[] tableList) {
13+
// Returns only the tables which names start with the letter C.
14+
return provider.GetTables(connection, tableList)
15+
.Where(table => table.Name.StartsWith("C"))
16+
.ToArray();
17+
}
18+
19+
public DBTable[] GetViews(SqlDataConnection connection, params string[] viewList) {
20+
// Returns only the views which names start with Sales.
21+
return provider.GetViews(connection, viewList)
22+
.Where(view => view.Name.StartsWith("Sales"))
23+
.ToArray();
24+
}
25+
26+
public DBStoredProcedure[] GetProcedures(SqlDataConnection connection, params string[] procedureList) {
27+
// Returns only the stored procedures with zero argumnents.
28+
return provider.GetProcedures(connection, procedureList)
29+
.Where(storedProcedure => storedProcedure.Arguments.Count == 0)
30+
.ToArray();
31+
}
32+
33+
public void LoadColumns(SqlDataConnection connection, params DBTable[] tables) {
34+
// Loads all columns in tables.
35+
provider.LoadColumns(connection, tables);
36+
37+
}
38+
}
39+
}
40+
41+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration>
3+
<packageSources>
4+
<add key="DevExpress-Local" value="C:\Program Files (x86)\DevExpress 21.2\Components\System\Components\packages" />
5+
</packageSources>
6+
</configuration>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@page
2+
3+
<div style="position: absolute; left: 0; top: 0; right: 0; bottom: 0;">
4+
@(Html.DevExpress().Dashboard("dashboardControl1")
5+
.ControllerName("DefaultDashboard")
6+
.Width("100%")
7+
.Height("100%")
8+
.OnBeforeRender("onBeforeRender")
9+
)
10+
</div>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
3+
<html>
4+
<head>
5+
<meta charset="UTF-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
7+
<title>Dashboard Web Application</title>
8+
9+
<link href="css/site.min.css" rel="stylesheet" />
10+
11+
<script type="text/javascript">
12+
function onBeforeRender(dashboardControl) {
13+
dashboardControl.registerExtension(new DevExpress.Dashboard.DashboardPanelExtension(dashboardControl, { dashboardThumbnail: "./DashboardThumbnail/{0}.png" }));
14+
}
15+
</script>
16+
</head>
17+
<body>
18+
@RenderBody()
19+
20+
<script src="js/site.min.js"></script>
21+
</body>
22+
</html>

0 commit comments

Comments
 (0)