Add Report Designer Feature

This commit is contained in:
Suphonchai Phoonsawat 2023-08-28 11:02:28 +07:00
parent e8098ff43f
commit aed9fb5051
7 changed files with 165 additions and 45 deletions

View file

@ -41,7 +41,10 @@
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
<PackageReference Include="Telerik.Reporting" Version="17.1.23.718" />
<PackageReference Include="Telerik.Reporting.JsonSerialization" Version="17.1.23.718" />
<PackageReference Include="Telerik.Reporting.OpenXmlRendering" Version="17.1.23.718" />
<PackageReference Include="Telerik.Reporting.Services.AspNetCore" Version="17.1.23.718" />
<PackageReference Include="Telerik.WebReportDesigner.Services" Version="17.1.23.718" />
</ItemGroup>
<ItemGroup>

View file

@ -0,0 +1,17 @@
using Microsoft.AspNetCore.Mvc;
using Telerik.Reporting.Services;
using Telerik.WebReportDesigner.Services;
using Telerik.WebReportDesigner.Services.Controllers;
namespace BMA.EHR.Report.Service.Controllers
{
[Route("api/reportdesigner")]
public class ReportDesignerController : ReportDesignerControllerBase
{
public ReportDesignerController(IReportDesignerServiceConfiguration reportDesignerServiceConfiguration,
IReportServiceConfiguration reportServiceConfiguration)
: base(reportDesignerServiceConfiguration, reportServiceConfiguration)
{
}
}
}

View file

@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.AspNetCore.Mvc.Versioning;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.IdentityModel.Logging;
using Microsoft.IdentityModel.Tokens;
using Serilog;
@ -15,6 +16,9 @@ using Serilog.Exceptions;
using Serilog.Sinks.Elasticsearch;
using System.Reflection;
using System.Text;
using Telerik.Reporting.Cache.File;
using Telerik.Reporting.Services;
using Telerik.WebReportDesigner.Services;
var builder = WebApplication.CreateBuilder(args);
{
@ -92,6 +96,25 @@ var builder = WebApplication.CreateBuilder(args);
builder.Services.ConfigureOptions<ConfigureSwaggerOptions>();
builder.Services.AddHealthChecks();
// For Telerik Report Designer
builder.Services.TryAddSingleton<IReportServiceConfiguration>(sp =>
new ReportServiceConfiguration
{
ReportingEngineConfiguration = ResolveSpecificReportingConfiguration(sp.GetService<IWebHostEnvironment>()),
HostAppId = "ReportingCoreApp",
Storage = new FileStorage(),
ReportSourceResolver = new TypeReportSourceResolver().AddFallbackResolver
(new UriReportSourceResolver(Path.Combine(sp.GetService<IWebHostEnvironment>().ContentRootPath, "Reports")))
});
builder.Services.TryAddSingleton<IReportDesignerServiceConfiguration>(sp => new ReportDesignerServiceConfiguration
{
DefinitionStorage = new FileDefinitionStorage(Path.Combine(sp.GetService<IWebHostEnvironment>().ContentRootPath, "Reports"), new[] { "Resources", "Shared Data Sources" }),
ResourceStorage = new ResourceStorage(Path.Combine(sp.GetService<IWebHostEnvironment>().ContentRootPath, "Reports", "Resources")),
SharedDataSourceStorage = new FileSharedDataSourceStorage(Path.Combine(sp.GetService<IWebHostEnvironment>().ContentRootPath, "Reports", "Shared Data Sources")),
SettingsStorage = new FileSettingsStorage(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Telerik Reporting"))
});
}
var app = builder.Build();
@ -113,7 +136,7 @@ var app = builder.Build();
app.MapHealthChecks("/health");
app.UseHttpsRedirection();
app.UseCors();
app.UseAuthentication();
@ -131,6 +154,14 @@ var app = builder.Build();
app.Run();
}
static IConfiguration ResolveSpecificReportingConfiguration(IWebHostEnvironment environment)
{
var reportingConfigFileName = Path.Combine(environment.ContentRootPath, "appsettings.json");
return new ConfigurationBuilder()
.AddJsonFile(reportingConfigFileName, true)
.Build();
}
void ConfigureLogs()
{
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");

View file

@ -1,41 +1,51 @@
{
"profiles": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5156"
"profiles": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5156"
},
"https": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7164;http://localhost:5156"
},
"report-designer": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "designer.html",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7164;http://localhost:5156"
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"publishAllPorts": true,
"useSSL": true
}
},
"https": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7164;http://localhost:5156"
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"publishAllPorts": true,
"useSSL": true
}
},
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,

View file

@ -31,5 +31,28 @@
"SecretKey": "P@ssw0rd",
"BucketName": "bma-recruit"
},
"Protocol": "HTTPS"
"Protocol": "HTTPS",
"telerikReporting": {
"privateFonts": [
{
"fontFamily": "TH SarabunIT๙",
"path": "Fonts/THSarabunIT.ttf"
},
{
"fontFamily": "TH SarabunIT๙",
"path": "Fonts/THSarabunITBold.ttf",
"fontStyle": "Bold"
},
{
"fontFamily": "TH SarabunPSK",
"path": "Fonts/THSarabunNew.ttf",
},
{
"fontFamily": "TH SarabunPSK",
"path": "Fonts/THSarabunNewBold.ttf",
"fontStyle": "Bold"
}
]
}
}

View file

@ -0,0 +1,36 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Telerik Web Report Designer</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<link href="https://fonts.googleapis.com/css?family=Roboto:400,500&display=swap" rel="stylesheet">
</head>
<body>
<div id="webReportDesigner">
loading...
</div>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://kendo.cdn.telerik.com/2020.1.114/js/kendo.all.min.js"></script>
<script src="/api/reportdesigner/resources/js/telerikReportViewer/"></script>
<script src="/api/reportdesigner/designerresources/js/webReportDesigner/"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#webReportDesigner").telerik_WebReportDesigner({
toolboxArea: {
layout: "list" //Change to "grid" to display the contents of the Components area in a flow grid layout.
},
serviceUrl: "/api/reportdesigner",
report: "01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-1.trdp"
}).data("telerik_WebDesigner");
});
</script>
</body>
</html>

View file

@ -19,14 +19,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.Placement.Service",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.OrganizationEmployee.Service", "BMA.EHR.OrganizationEmployee.Service\BMA.EHR.OrganizationEmployee.Service.csproj", "{A54AA069-8B0E-4784-953B-5DA9F9C8285E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.Report.Service", "BMA.EHR.Report.Service\BMA.EHR.Report.Service.csproj", "{AC4B2602-C543-4165-85D7-F6F92F553D80}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.Command.Service", "BMA.EHR.Command.Service\BMA.EHR.Command.Service.csproj", "{E4E905EE-61DF-4451-B063-5C86BC7574CE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.Insignia.Service", "BMA.EHR.Insignia.Service\BMA.EHR.Insignia.Service.csproj", "{04B37ACD-65CF-44ED-BC40-B5E7A71C374B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.Retirement.Service", "BMA.EHR.Retirement.Service\BMA.EHR.Retirement.Service.csproj", "{3FFE378C-387F-42EA-96E2-68E63BB295F9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BMA.EHR.Report.Service", "BMA.EHR.Report.Service\BMA.EHR.Report.Service.csproj", "{26FE7B1C-771B-4940-9F40-326A7AD53F1C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -57,10 +57,6 @@ Global
{A54AA069-8B0E-4784-953B-5DA9F9C8285E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A54AA069-8B0E-4784-953B-5DA9F9C8285E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A54AA069-8B0E-4784-953B-5DA9F9C8285E}.Release|Any CPU.Build.0 = Release|Any CPU
{AC4B2602-C543-4165-85D7-F6F92F553D80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AC4B2602-C543-4165-85D7-F6F92F553D80}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AC4B2602-C543-4165-85D7-F6F92F553D80}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AC4B2602-C543-4165-85D7-F6F92F553D80}.Release|Any CPU.Build.0 = Release|Any CPU
{E4E905EE-61DF-4451-B063-5C86BC7574CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E4E905EE-61DF-4451-B063-5C86BC7574CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E4E905EE-61DF-4451-B063-5C86BC7574CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -73,6 +69,10 @@ Global
{3FFE378C-387F-42EA-96E2-68E63BB295F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3FFE378C-387F-42EA-96E2-68E63BB295F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3FFE378C-387F-42EA-96E2-68E63BB295F9}.Release|Any CPU.Build.0 = Release|Any CPU
{26FE7B1C-771B-4940-9F40-326A7AD53F1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{26FE7B1C-771B-4940-9F40-326A7AD53F1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{26FE7B1C-771B-4940-9F40-326A7AD53F1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{26FE7B1C-771B-4940-9F40-326A7AD53F1C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -85,10 +85,10 @@ Global
{FA618F0C-1AF5-49AB-AE13-C020B403B64F} = {F3C2F68F-8DC8-45A3-825B-24F17867D380}
{81610EF7-AF80-44D8-9263-925C821CF45F} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
{A54AA069-8B0E-4784-953B-5DA9F9C8285E} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
{AC4B2602-C543-4165-85D7-F6F92F553D80} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
{E4E905EE-61DF-4451-B063-5C86BC7574CE} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
{04B37ACD-65CF-44ED-BC40-B5E7A71C374B} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
{3FFE378C-387F-42EA-96E2-68E63BB295F9} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
{26FE7B1C-771B-4940-9F40-326A7AD53F1C} = {FA618F0C-1AF5-49AB-AE13-C020B403B64F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3111A492-1818-4438-B718-75199D8E779A}