Skip to content

Commit 7451162

Browse files
auto sync for version 2023.1
1 parent e434a84 commit 7451162

14 files changed

+237
-243
lines changed
Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
using DevExpress.DashboardAspNetCore;
2-
using DevExpress.DashboardCommon;
3-
using DevExpress.DashboardWeb;
4-
using DevExpress.DataAccess.Excel;
5-
using DevExpress.DataAccess.Sql;
6-
using Microsoft.Extensions.FileProviders;
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-
// This method assigns the database schema provider to the Web Dashboard.
20-
// Uncomment one of the following lines depending on the provider.
21-
configurator.SetDBSchemaProvider(new ManualDBSchemaProvider());
22-
//configurator.SetDBSchemaProvider(new LimitDBSchemaProvider());
23-
24-
return configurator;
25-
}
26-
}
27-
}
1+
using DevExpress.DashboardAspNetCore;
2+
using DevExpress.DashboardCommon;
3+
using DevExpress.DashboardWeb;
4+
using DevExpress.DataAccess.Excel;
5+
using DevExpress.DataAccess.Sql;
6+
using Microsoft.Extensions.FileProviders;
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+
// This method assigns the database schema provider to the Web Dashboard.
20+
// Uncomment one of the following lines depending on the provider.
21+
configurator.SetDBSchemaProvider(new ManualDBSchemaProvider());
22+
//configurator.SetDBSchemaProvider(new LimitDBSchemaProvider());
23+
24+
return configurator;
25+
}
26+
}
27+
}
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +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-
}
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: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
1-
using DevExpress.DataAccess.Sql;
2-
using DevExpress.Xpo.DB;
3-
using System.Linq;
4-
5-
namespace WebDashboardAspNetCore {
6-
public class LimitDBSchemaProvider : IDBSchemaProviderEx {
7-
DBSchemaProviderEx provider;
8-
public LimitDBSchemaProvider() {
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-
1+
using DevExpress.DataAccess.Sql;
2+
using DevExpress.Xpo.DB;
3+
using System.Linq;
4+
5+
namespace WebDashboardAspNetCore {
6+
public class LimitDBSchemaProvider : IDBSchemaProviderEx {
7+
DBSchemaProviderEx provider;
8+
public LimitDBSchemaProvider() {
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: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,69 @@
1-
using DevExpress.DataAccess.Sql;
2-
using DevExpress.Xpo.DB;
3-
using System.Collections.Specialized;
4-
5-
namespace WebDashboardAspNetCore {
6-
public class ManualDBSchemaProvider : 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-
ManualDBSchemaProvider.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-
}
1+
using DevExpress.DataAccess.Sql;
2+
using DevExpress.Xpo.DB;
3+
using System.Collections.Specialized;
4+
5+
namespace WebDashboardAspNetCore {
6+
public class ManualDBSchemaProvider : 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+
ManualDBSchemaProvider.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+
}

CS/WebDashboardAspNetCore/NuGet.config

Lines changed: 0 additions & 6 deletions
This file was deleted.

CS/WebDashboardAspNetCore/Program.cs

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
using DevExpress.AspNetCore;
2-
using DevExpress.DashboardAspNetCore;
3-
using DevExpress.DashboardWeb;
4-
using Microsoft.Extensions.FileProviders;
5-
using WebDashboardAspNetCore;
6-
7-
var builder = WebApplication.CreateBuilder(args);
8-
9-
IFileProvider? fileProvider = builder.Environment.ContentRootFileProvider;
10-
IConfiguration? configuration = builder.Configuration;
11-
12-
// Add services to the container.
13-
builder.Services.AddControllersWithViews();
14-
builder.Services.AddRazorPages();
15-
16-
builder.Services.AddDevExpressControls();
17-
builder.Services.AddScoped<DashboardConfigurator>((IServiceProvider serviceProvider) => {
18-
return DashboardUtils.CreateDashboardConfigurator(configuration, fileProvider);
19-
});
20-
21-
var app = builder.Build();
22-
23-
24-
// Configure the HTTP request pipeline.
25-
if (!app.Environment.IsDevelopment())
26-
{
27-
app.UseExceptionHandler("/Home/Error");
28-
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
29-
app.UseHsts();
30-
}
31-
32-
app.UseHttpsRedirection();
33-
app.UseStaticFiles();
34-
35-
app.UseDevExpressControls();
36-
37-
app.UseRouting();
38-
39-
app.UseAuthorization();
40-
app.MapRazorPages();
41-
42-
app.MapDashboardRoute("dashboardControl", "DefaultDashboard");
43-
44-
app.Run();
1+
using DevExpress.AspNetCore;
2+
using DevExpress.DashboardAspNetCore;
3+
using DevExpress.DashboardWeb;
4+
using Microsoft.Extensions.FileProviders;
5+
using WebDashboardAspNetCore;
6+
7+
var builder = WebApplication.CreateBuilder(args);
8+
9+
IFileProvider? fileProvider = builder.Environment.ContentRootFileProvider;
10+
IConfiguration? configuration = builder.Configuration;
11+
12+
// Add services to the container.
13+
builder.Services.AddControllersWithViews();
14+
builder.Services.AddRazorPages();
15+
16+
builder.Services.AddDevExpressControls();
17+
builder.Services.AddScoped<DashboardConfigurator>((IServiceProvider serviceProvider) => {
18+
return DashboardUtils.CreateDashboardConfigurator(configuration, fileProvider);
19+
});
20+
21+
var app = builder.Build();
22+
23+
24+
// Configure the HTTP request pipeline.
25+
if (!app.Environment.IsDevelopment())
26+
{
27+
app.UseExceptionHandler("/Home/Error");
28+
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
29+
app.UseHsts();
30+
}
31+
32+
app.UseHttpsRedirection();
33+
app.UseStaticFiles();
34+
35+
app.UseDevExpressControls();
36+
37+
app.UseRouting();
38+
39+
app.UseAuthorization();
40+
app.MapRazorPages();
41+
42+
app.MapDashboardRoute("dashboardControl", "DefaultDashboard");
43+
44+
app.Run();

0 commit comments

Comments
 (0)