Skip to content

Commit 219d990

Browse files
committed
add cs solution
1 parent fb4230c commit 219d990

Some content is hidden

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

51 files changed

+15040
-0
lines changed

CS/DXWebApplication1.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.9.34607.119
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DXWebApplication1", "DXWebApplication1\DXWebApplication1.csproj", "{B137BF99-C7DE-4914-8B73-89FC3715137F}"
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+
{B137BF99-C7DE-4914-8B73-89FC3715137F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{B137BF99-C7DE-4914-8B73-89FC3715137F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{B137BF99-C7DE-4914-8B73-89FC3715137F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{B137BF99-C7DE-4914-8B73-89FC3715137F}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using DevExpress.AspNetCore.Reporting.WebDocumentViewer;
2+
using DevExpress.XtraReports.Web.Extensions;
3+
using DevExpress.XtraReports.Web.ParametersPanel;
4+
using DevExpress.XtraReports.Web.WebDocumentViewer;
5+
using Microsoft.AspNetCore.Hosting;
6+
using Microsoft.AspNetCore.Mvc;
7+
using System.IO;
8+
using System.Threading.Tasks;
9+
10+
namespace DXWebApplication1.Controllers {
11+
public class HomeController : Controller {
12+
public IActionResult Index() {
13+
return View();
14+
}
15+
public IActionResult Error() {
16+
Models.ErrorModel model = new Models.ErrorModel();
17+
return View(model);
18+
}
19+
20+
21+
public IActionResult DocumentViewer(
22+
[FromServices] IWebDocumentViewerClientSideModelGenerator viewerModelGenerator,
23+
[FromQuery] string reportName) {
24+
reportName = string.IsNullOrEmpty(reportName) ? "ParametersPanelReport001" : reportName;
25+
var viewerModel = viewerModelGenerator.GetModel(reportName, CustomWebDocumentViewerController.DefaultUri);
26+
return View(viewerModel);
27+
}
28+
29+
public async Task<IActionResult> ExportReport(
30+
[FromServices] IReportParametersSerializer reportParametersSerializer,
31+
[FromForm] string serializedParameters,
32+
[FromForm] string reportUrl) {
33+
var report = await reportParametersSerializer.ApplyParametersStateAsync(reportUrl, serializedParameters);
34+
using var stream = new MemoryStream();
35+
report.ExportToPdf(stream);
36+
return File(stream.ToArray(), "application/pdf");
37+
}
38+
39+
public IActionResult ParametersPanel(
40+
[FromQuery] string reportName,
41+
[FromServices] IReportParametersPanelClientSideModelGenerator clientSideModelGenerator) {
42+
var reportNameToOpen = reportName ?? "ParametersPanelReport001";
43+
ReportParametersPanelModel parametersPanelModel = clientSideModelGenerator.GetModel(reportNameToOpen, WebDocumentViewerController.DefaultUri);
44+
return View("ParametersPanel", parametersPanelModel);
45+
}
46+
}
47+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using DevExpress.AspNetCore.Reporting.WebDocumentViewer;
2+
using DevExpress.AspNetCore.Reporting.WebDocumentViewer.Native.Services;
3+
4+
namespace DXWebApplication1.Controllers {
5+
public class CustomWebDocumentViewerController : WebDocumentViewerController {
6+
public CustomWebDocumentViewerController(IWebDocumentViewerMvcControllerService controllerService) : base(controllerService) {
7+
}
8+
}
9+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
<PropertyGroup>
3+
<TargetFramework>net6.0</TargetFramework>
4+
<DefaultItemExcludes>Reports\**</DefaultItemExcludes>
5+
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
6+
<DockerfileFile>Dockerfile</DockerfileFile>
7+
<UserSecretsId>7bffbdbd-957d-40bc-92c8-236f2904aaee</UserSecretsId>
8+
<DockerfileContext>.</DockerfileContext>
9+
<DockerfileBuildArguments>--secret id=dxnuget,source=secrets.dev.yaml</DockerfileBuildArguments>
10+
</PropertyGroup>
11+
<ItemGroup>
12+
<Compile Remove="Reports\**" />
13+
<Content Remove="Reports\**" />
14+
<EmbeddedResource Remove="Reports\**" />
15+
<None Remove="Reports\**" />
16+
</ItemGroup>
17+
<ItemGroup>
18+
<None Remove="Data\nwind.db" />
19+
<None Remove="Data\reportsData.db" />
20+
</ItemGroup>
21+
<ItemGroup>
22+
<Content Include="Data\nwind.db">
23+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
24+
</Content>
25+
<Content Include="Data\reportsData.db">
26+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
27+
</Content>
28+
</ItemGroup>
29+
<ItemGroup>
30+
<Content Update="Data\nwind.json">
31+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
32+
</Content>
33+
</ItemGroup>
34+
<ItemGroup>
35+
<Compile Remove="node_modules\**" />
36+
<Content Remove="node_modules\**" />
37+
<EmbeddedResource Remove="node_modules\**" />
38+
<None Remove="node_modules\**" />
39+
</ItemGroup>
40+
<Target Name="DebugEnsureNodeEnv" BeforeTargets="LibraryManagerRestore" Condition="!Exists('node_modules') ">
41+
<!-- Ensure Node.js is installed -->
42+
<Exec Command="node --version" ContinueOnError="true">
43+
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
44+
</Exec>
45+
<Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." />
46+
<Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
47+
<Exec Command="npm install" />
48+
</Target>
49+
<ItemGroup>
50+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.31" />
51+
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
52+
<PackageReference Include="DevExpress.AspNetCore.Reporting" Version="24.1-*" />
53+
<PackageReference Include="DevExpress.Drawing.Skia" Version="24.1-*" />
54+
<PackageReference Include="BuildBundlerMinifier" Version="3.2.449" />
55+
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="2.1.175" />
56+
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.118" />
57+
</ItemGroup>
58+
</Project>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using System.Linq;
2+
using Microsoft.EntityFrameworkCore;
3+
4+
namespace DXWebApplication1.Data {
5+
public class SqlDataConnectionDescription : DataConnection { }
6+
public class JsonDataConnectionDescription : DataConnection { }
7+
public abstract class DataConnection {
8+
public int Id { get; set; }
9+
public string Name { get; set; }
10+
public string DisplayName { get; set; }
11+
public string ConnectionString { get; set; }
12+
}
13+
14+
public class ReportItem {
15+
public int Id { get; set; }
16+
public string Name { get; set; }
17+
public string DisplayName { get; set; }
18+
public byte[] LayoutData { get; set; }
19+
}
20+
21+
public class ReportDbContext : DbContext {
22+
public DbSet<JsonDataConnectionDescription> JsonDataConnections { get; set; }
23+
public DbSet<SqlDataConnectionDescription> SqlDataConnections { get; set; }
24+
public DbSet<ReportItem> Reports { get; set; }
25+
public ReportDbContext(DbContextOptions<ReportDbContext> options) : base(options) {
26+
}
27+
public void InitializeDatabase() {
28+
Database.EnsureCreated();
29+
30+
var nwindJsonDataConnectionName = "NWindProductsJson";
31+
if(!JsonDataConnections.Any(x => x.Name == nwindJsonDataConnectionName)) {
32+
var newData = new JsonDataConnectionDescription {
33+
Name = nwindJsonDataConnectionName,
34+
DisplayName = "Northwind Products (JSON)",
35+
ConnectionString = "Uri=Data/nwind.json"
36+
};
37+
JsonDataConnections.Add(newData);
38+
}
39+
40+
41+
var nwindSqlDataConnectionName = "NWindConnectionString";
42+
if(!SqlDataConnections.Any(x => x.Name == nwindSqlDataConnectionName)) {
43+
var newData = new SqlDataConnectionDescription {
44+
Name = nwindSqlDataConnectionName,
45+
DisplayName = "Northwind Data Connection",
46+
ConnectionString = "XpoProvider=SQLite;Data Source=|DataDirectory|Data/nwind.db"
47+
};
48+
SqlDataConnections.Add(newData);
49+
}
50+
51+
var reportsDataConnectionName = "ReportsDataSqlite";
52+
if(!SqlDataConnections.Any(x => x.Name == reportsDataConnectionName)) {
53+
var newData = new SqlDataConnectionDescription {
54+
Name = reportsDataConnectionName,
55+
DisplayName = "Reports Data (Demo)",
56+
ConnectionString = "XpoProvider=SQLite;Data Source=|DataDirectory|Data/reportsData.db"
57+
};
58+
SqlDataConnections.Add(newData);
59+
}
60+
SaveChanges();
61+
}
62+
}
63+
}
32 KB
Binary file not shown.

CS/DXWebApplication1/Data/nwind.db

644 KB
Binary file not shown.

0 commit comments

Comments
 (0)