Add Report Designer Feature
This commit is contained in:
parent
e8098ff43f
commit
aed9fb5051
7 changed files with 165 additions and 45 deletions
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
36
BMA.EHR.Report.Service/wwwroot/designer.html
Normal file
36
BMA.EHR.Report.Service/wwwroot/designer.html
Normal 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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue