Skip to content

Commit 6ae9f50

Browse files
committed
add solution
1 parent f7fbb94 commit 6ae9f50

40 files changed

+2948
-0
lines changed

CS/ReportingApp.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.11.35219.272
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReportingApp", "ReportingApp\ReportingApp.csproj", "{2D82E0C5-8869-4BF5-A72D-945B49D76B98}"
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+
{2D82E0C5-8869-4BF5-A72D-945B49D76B98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{2D82E0C5-8869-4BF5-A72D-945B49D76B98}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{2D82E0C5-8869-4BF5-A72D-945B49D76B98}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{2D82E0C5-8869-4BF5-A72D-945B49D76B98}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System.Threading.Tasks;
2+
using ReportingApp.Services;
3+
using Microsoft.AspNetCore.Mvc;
4+
5+
namespace ReportingApp.Controllers {
6+
public class AIController : ControllerBase {
7+
IAIAssistantProvider AIAssistantProvider { get; set; }
8+
9+
public AIController(IAIAssistantProvider assistantProvider) {
10+
AIAssistantProvider = assistantProvider;
11+
}
12+
13+
public async Task<string> CreateUserAssistant() {
14+
var assistantName = await AIAssistantProvider.CreateAssistant(AssistantType.UserAssistant);
15+
return assistantName;
16+
}
17+
18+
public async Task<string> GetAnswer([FromForm] string chatId, [FromForm] string text) {
19+
var assistant = AIAssistantProvider.GetAssistant(chatId);
20+
return await assistant.GetAnswerAsync(text);
21+
}
22+
23+
public ActionResult CloseChat([FromForm] string chatId) {
24+
AIAssistantProvider.DisposeAssistant(chatId);
25+
return Ok();
26+
}
27+
}
28+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System.Collections.Generic;
2+
using DevExpress.DataAccess.Sql;
3+
using DevExpress.XtraReports.Web.ReportDesigner.Services;
4+
using DevExpress.XtraReports.Web.WebDocumentViewer;
5+
using Microsoft.AspNetCore.Mvc;
6+
7+
namespace ReportingApp.Controllers {
8+
public class HomeController : Controller {
9+
public IActionResult Index() {
10+
return View();
11+
}
12+
public IActionResult Error() {
13+
Models.ErrorModel model = new Models.ErrorModel();
14+
return View(model);
15+
}
16+
17+
public IActionResult ReportDesigner(
18+
[FromServices] IReportDesignerModelBuilder reportDesignerModelBuilder,
19+
[FromQuery] string reportName) {
20+
// Create a SQL data source with the specified connection string.
21+
SqlDataSource ds = new SqlDataSource("NWindConnectionString");
22+
// Create a SQL query to access the Products data table.
23+
SelectQuery query = SelectQueryFluentBuilder.AddTable("Products").SelectAllColumnsFromTable().Build("Products");
24+
ds.Queries.Add(query);
25+
ds.RebuildResultSchema();
26+
27+
reportName = string.IsNullOrEmpty(reportName) ? "TestReport" : reportName;
28+
var designerModel = reportDesignerModelBuilder
29+
.Report(reportName)
30+
.DataSources(x => {
31+
x.Add("Northwind", ds);
32+
})
33+
.BuildModel();
34+
return View(designerModel);
35+
}
36+
37+
public IActionResult DocumentViewer(
38+
[FromServices] IWebDocumentViewerClientSideModelGenerator viewerModelGenerator,
39+
[FromQuery] string reportName) {
40+
reportName = string.IsNullOrEmpty(reportName) ? "TestReport" : reportName;
41+
var viewerModel = viewerModelGenerator.GetModel(reportName, CustomWebDocumentViewerController.DefaultUri);
42+
return View(viewerModel);
43+
}
44+
}
45+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using DevExpress.AspNetCore.Reporting.QueryBuilder;
2+
using DevExpress.AspNetCore.Reporting.QueryBuilder.Native.Services;
3+
using DevExpress.AspNetCore.Reporting.ReportDesigner;
4+
using DevExpress.AspNetCore.Reporting.ReportDesigner.Native.Services;
5+
using DevExpress.AspNetCore.Reporting.WebDocumentViewer;
6+
using DevExpress.AspNetCore.Reporting.WebDocumentViewer.Native.Services;
7+
8+
namespace ReportingApp.Controllers {
9+
public class CustomReportDesignerController : ReportDesignerController {
10+
public CustomReportDesignerController(IReportDesignerMvcControllerService controllerService) : base(controllerService) {
11+
}
12+
}
13+
14+
public class CustomQueryBuilderController : QueryBuilderController {
15+
public CustomQueryBuilderController(IQueryBuilderMvcControllerService controllerService) : base(controllerService) {
16+
}
17+
}
18+
19+
public class CustomWebDocumentViewerController : WebDocumentViewerController {
20+
public CustomWebDocumentViewerController(IWebDocumentViewerMvcControllerService controllerService) : base(controllerService) {
21+
}
22+
}
23+
}
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 ReportingApp.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.
21.6 MB
Binary file not shown.

CS/ReportingApp/Data/nwind.db

644 KB
Binary file not shown.

0 commit comments

Comments
 (0)