Skip to content

Commit c8cd51d

Browse files
Initial commit
0 parents commit c8cd51d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+18752
-0
lines changed
Binary file not shown.

asp-net-core-server/.vs/AspNetCoreDashboardBackend/config/applicationhost.config

Lines changed: 1021 additions & 0 deletions
Large diffs are not rendered by default.
20 KB
Binary file not shown.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Dashboard>
3+
<Title Text="New Dashboard" />
4+
<DataSources>
5+
<ObjectDataSource Name="ObjectDataSource" ComponentName="objectDataSource1">
6+
<DataSource Type="ProductSales, AspNetCoreDashboardBackend, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
7+
<DataMember>GetProductSales</DataMember>
8+
</ObjectDataSource>
9+
</DataSources>
10+
<Items>
11+
<Grid ComponentName="gridDashboardItem2" Name="Source Data" DataSource="objectDataSource1">
12+
<DataItems>
13+
<Dimension DataMember="Category" DefaultId="DataItem1" />
14+
<Dimension DataMember="Product" DefaultId="DataItem2" />
15+
<Dimension DataMember="OrderID" DefaultId="DataItem0" />
16+
<Measure DataMember="Sales" DefaultId="DataItem3">
17+
<NumericFormat FormatType="Currency" />
18+
</Measure>
19+
<Dimension DataMember="OrderDate" DateTimeGroupInterval="None" DefaultId="DataItem4" />
20+
</DataItems>
21+
<GridColumns>
22+
<GridDimensionColumn>
23+
<Dimension DefaultId="DataItem0" />
24+
</GridDimensionColumn>
25+
<GridDimensionColumn>
26+
<Dimension DefaultId="DataItem1" />
27+
</GridDimensionColumn>
28+
<GridDimensionColumn>
29+
<Dimension DefaultId="DataItem2" />
30+
</GridDimensionColumn>
31+
<GridDimensionColumn>
32+
<Dimension DefaultId="DataItem4" />
33+
</GridDimensionColumn>
34+
<GridMeasureColumn>
35+
<Measure DefaultId="DataItem3" />
36+
</GridMeasureColumn>
37+
</GridColumns>
38+
<GridOptions />
39+
</Grid>
40+
</Items>
41+
<LayoutTree>
42+
<LayoutGroup>
43+
<LayoutItem DashboardItem="gridDashboardItem2" />
44+
</LayoutGroup>
45+
</LayoutTree>
46+
</Dashboard>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="DevExpress.AspNetCore.Dashboard.de" Version="20.2.5" />
9+
</ItemGroup>
10+
11+
</Project>
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+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<ActiveDebugProfile>IIS Express</ActiveDebugProfile>
5+
</PropertyGroup>
6+
</Project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
public class ProductSales {
5+
public int OrderID { get; set; }
6+
public string Category { get; set; }
7+
public string Product { get; set; }
8+
public int Sales { get; set; }
9+
public DateTime OrderDate { get; set; }
10+
11+
public static List<ProductSales> GetProductSales() {
12+
List<ProductSales> data = new List<ProductSales>();
13+
14+
data.Add(new ProductSales() { OrderID = 1, Category = "Beverages", Product = "Chai", Sales = 10, OrderDate = DateTime.Today });
15+
data.Add(new ProductSales() { OrderID = 2, Category = "Beverages", Product = "Chai", Sales = 15, OrderDate = DateTime.Today });
16+
data.Add(new ProductSales() { OrderID = 3, Category = "Beverages", Product = "Coffee", Sales = 35, OrderDate = DateTime.Today.AddMonths(3) });
17+
data.Add(new ProductSales() { OrderID = 4, Category = "Beverages", Product = "Coffee", Sales = 20, OrderDate = DateTime.Today.AddMonths(3) });
18+
data.Add(new ProductSales() { OrderID = 5, Category = "Confections", Product = "Chocolate", Sales = 40, OrderDate = DateTime.Today.AddMonths(3) });
19+
data.Add(new ProductSales() { OrderID = 6, Category = "Confections", Product = "Chocolate", Sales = 55, OrderDate = DateTime.Today.AddMonths(7) });
20+
data.Add(new ProductSales() { OrderID = 7, Category = "Confections", Product = "Biscuits", Sales = 25, OrderDate = DateTime.Today.AddMonths(7) });
21+
data.Add(new ProductSales() { OrderID = 8, Category = "Confections", Product = "Biscuits", Sales = 35, OrderDate = DateTime.Today.AddMonths(7) });
22+
23+
return data;
24+
}
25+
}

asp-net-core-server/Program.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Hosting;
6+
using Microsoft.Extensions.Configuration;
7+
using Microsoft.Extensions.Hosting;
8+
using Microsoft.Extensions.Logging;
9+
10+
namespace AspNetCoreDashboardBackend {
11+
public class Program {
12+
public static void Main(string[] args) {
13+
CreateHostBuilder(args).Build().Run();
14+
}
15+
16+
public static IHostBuilder CreateHostBuilder(string[] args) =>
17+
Host.CreateDefaultBuilder(args)
18+
.ConfigureWebHostDefaults(webBuilder => {
19+
webBuilder.UseStartup<Startup>();
20+
});
21+
}
22+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:49747/",
7+
"sslPort": 44337
8+
}
9+
},
10+
"profiles": {
11+
"IIS Express": {
12+
"commandName": "IISExpress",
13+
"launchBrowser": true,
14+
"environmentVariables": {
15+
"ASPNETCORE_ENVIRONMENT": "Development"
16+
}
17+
},
18+
"AspNetCoreDashboardBackend": {
19+
"commandName": "Project",
20+
"launchBrowser": true,
21+
"environmentVariables": {
22+
"ASPNETCORE_ENVIRONMENT": "Development"
23+
},
24+
"applicationUrl": "https://localhost:5001;http://localhost:5000"
25+
}
26+
}
27+
}

asp-net-core-server/Startup.cs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
using DevExpress.AspNetCore;
2+
using DevExpress.DashboardAspNetCore;
3+
using DevExpress.DashboardCommon;
4+
using DevExpress.DashboardWeb;
5+
using Microsoft.AspNetCore.Builder;
6+
using Microsoft.AspNetCore.Hosting;
7+
using Microsoft.Extensions.Configuration;
8+
using Microsoft.Extensions.DependencyInjection;
9+
using Microsoft.Extensions.FileProviders;
10+
11+
namespace AspNetCoreDashboardBackend {
12+
public class Startup {
13+
// This method gets called by the runtime. Use this method to add services to the container.
14+
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
15+
16+
public Startup(IConfiguration configuration, IWebHostEnvironment hostingEnvironment) {
17+
Configuration = configuration;
18+
FileProvider = hostingEnvironment.ContentRootFileProvider;
19+
}
20+
21+
public IConfiguration Configuration { get; }
22+
public IFileProvider FileProvider { get; }
23+
24+
// This method gets called by the runtime. Use this method to add services to the container.
25+
public void ConfigureServices(IServiceCollection services) {
26+
// Configures services to use the Web Dashboard Control.
27+
services
28+
.AddCors(options => {
29+
options.AddPolicy("CorsPolicy", builder => {
30+
builder.AllowAnyOrigin();
31+
builder.AllowAnyMethod();
32+
builder.WithHeaders("Content-Type");
33+
});
34+
})
35+
.AddDevExpressControls()
36+
.AddControllers()
37+
.AddDefaultDashboardController(configurator => {
38+
configurator.SetDashboardStorage(new DashboardFileStorage(FileProvider.GetFileInfo("App_Data/Dashboards").PhysicalPath));
39+
configurator.SetDataSourceStorage(CreateDataSourceStorage());
40+
});
41+
}
42+
43+
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
44+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
45+
var supportedCultures = new[] { "en-US", "de-DE" };
46+
var opts = new RequestLocalizationOptions()
47+
.SetDefaultCulture(supportedCultures[1])
48+
.AddSupportedCultures(supportedCultures)
49+
.AddSupportedUICultures(supportedCultures);
50+
opts.RequestCultureProviders.Clear();
51+
app.UseRequestLocalization(opts);
52+
53+
// Registers the DevExpress middleware.
54+
app.UseDevExpressControls();
55+
app.UseRouting();
56+
app.UseCors("CorsPolicy");
57+
app.UseEndpoints(endpoints => {
58+
// Maps the dashboard route.
59+
EndpointRouteBuilderExtension.MapDashboardRoute(endpoints, "api/dashboard");
60+
// Requires CORS policies.
61+
endpoints.MapControllers().RequireCors("CorsPolicy");
62+
});
63+
}
64+
65+
public DataSourceInMemoryStorage CreateDataSourceStorage() {
66+
DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();
67+
DashboardObjectDataSource objDataSource = new DashboardObjectDataSource("ObjectDataSource", typeof(ProductSales));
68+
objDataSource.DataMember = "GetProductSales";
69+
dataSourceStorage.RegisterDataSource("objectDataSource", objDataSource.SaveToXml());
70+
return dataSourceStorage;
71+
}
72+
}
73+
}

0 commit comments

Comments
 (0)