Skip to content

Commit

Permalink
Replace DataSourceName with ConnectionName
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderKovalenko committed Dec 24, 2021
1 parent 415a8e2 commit 8dfb8ac
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
2 changes: 1 addition & 1 deletion asp-net-core-server/App_Data/Dashboards/products.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Dashboard>
<Title Text="Products" />
<DataSources>
<JsonDataSource Name="Categories" RootElement="Products" ComponentName="jsonDataSource1">
<JsonDataSource Name="Categories" RootElement="Products" ComponentName="jsonDataSource1" ConnectionName="jsonCategories">
<Source SourceType="DevExpress.DataAccess.Json.UriJsonSource" />
<Schema>
<Node Name="root" Type="System.Object" Selected="true" NodeType="Object">
Expand Down
4 changes: 2 additions & 2 deletions asp-net-core-server/App_Data/Dashboards/support.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Dashboard>
<Title Text="Support" />
<DataSources>
<JsonDataSource Name="Support" RootElement="Employee" ComponentName="jsonDataSource1">
<JsonDataSource Name="Support" RootElement="Employee" ComponentName="jsonDataSource1" ConnectionName="jsonSupport">
<Source SourceType="DevExpress.DataAccess.Json.UriJsonSource" />
<Schema>
<Node Name="root" Type="System.Object" Selected="true" NodeType="Object">
Expand All @@ -15,7 +15,7 @@
</Node>
</Schema>
</JsonDataSource>
<JsonDataSource Name="Categories" RootElement="Products" ComponentName="jsonDataSource2">
<JsonDataSource Name="Categories" RootElement="Products" ComponentName="jsonDataSource2" ConnectionName="jsonCategories">
<Source SourceType="DevExpress.DataAccess.Json.UriJsonSource" />
<Schema>
<Node Name="root" Type="System.Object" Selected="true" NodeType="Object">
Expand Down
25 changes: 25 additions & 0 deletions asp-net-core-server/AspNetCoreDashboardBackend.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31424.327
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCoreDashboardBackend", "AspNetCoreDashboardBackend.csproj", "{049A572F-600B-4C5D-A2F5-96913EF7D7BA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{049A572F-600B-4C5D-A2F5-96913EF7D7BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{049A572F-600B-4C5D-A2F5-96913EF7D7BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{049A572F-600B-4C5D-A2F5-96913EF7D7BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{049A572F-600B-4C5D-A2F5-96913EF7D7BA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8844C35E-CB17-42D3-BB76-F53442BE61DE}
EndGlobalSection
EndGlobal
8 changes: 6 additions & 2 deletions asp-net-core-server/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,28 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
endpoints.MapControllers().RequireCors("CorsPolicy");
});
}

public DataSourceInMemoryStorage CreateDataSourceStorage() {
DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();
DashboardJsonDataSource jsonDataSourceSupport = new DashboardJsonDataSource("Support");
jsonDataSourceSupport.ConnectionName = "jsonSupport";
jsonDataSourceSupport.RootElement = "Employee";
dataSourceStorage.RegisterDataSource("jsonDataSourceSupport", jsonDataSourceSupport.SaveToXml());
DashboardJsonDataSource jsonDataSourceCategories = new DashboardJsonDataSource("Categories");
jsonDataSourceCategories.ConnectionName = "jsonCategories";
//jsonDataSourceCategories.RootElement = "";
dataSourceStorage.RegisterDataSource("jsonDataSourceCategories", jsonDataSourceCategories.SaveToXml());
return dataSourceStorage;
}

private void Configurator_ConfigureDataConnection(object sender, ConfigureDataConnectionWebEventArgs e) {
if (e.DataSourceName.Contains("Support")) {
if (e.ConnectionName == "jsonSupport") {
Uri fileUri = new Uri(FileProvider.GetFileInfo("App_Data/Support.json").PhysicalPath, UriKind.RelativeOrAbsolute);
JsonSourceConnectionParameters jsonParams = new JsonSourceConnectionParameters();
jsonParams.JsonSource = new UriJsonSource(fileUri);
e.ConnectionParameters = jsonParams;
}
if (e.DataSourceName.Contains("Categories")) {
if (e.ConnectionName == "jsonCategories") {
Uri fileUri = new Uri(FileProvider.GetFileInfo("App_Data/Categories.json").PhysicalPath, UriKind.RelativeOrAbsolute);
JsonSourceConnectionParameters jsonParams = new JsonSourceConnectionParameters();
jsonParams.JsonSource = new UriJsonSource(fileUri);
Expand Down

0 comments on commit 8dfb8ac

Please sign in to comment.