From aed9fb5051fbd5c2d2644a4efc2b189fe20cd4c9 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Mon, 28 Aug 2023 11:02:28 +0700 Subject: [PATCH] Add Report Designer Feature --- .../BMA.EHR.Report.Service.csproj | 3 + .../Controllers/ReportDesignerController.cs | 17 ++++ BMA.EHR.Report.Service/Program.cs | 33 +++++++- .../Properties/launchSettings.json | 82 +++++++++++-------- BMA.EHR.Report.Service/appsettings.json | 25 +++++- BMA.EHR.Report.Service/wwwroot/designer.html | 36 ++++++++ BMA.EHR.Solution.sln | 14 ++-- 7 files changed, 165 insertions(+), 45 deletions(-) create mode 100644 BMA.EHR.Report.Service/Controllers/ReportDesignerController.cs create mode 100644 BMA.EHR.Report.Service/wwwroot/designer.html diff --git a/BMA.EHR.Report.Service/BMA.EHR.Report.Service.csproj b/BMA.EHR.Report.Service/BMA.EHR.Report.Service.csproj index 81eba980..06c0b58a 100644 --- a/BMA.EHR.Report.Service/BMA.EHR.Report.Service.csproj +++ b/BMA.EHR.Report.Service/BMA.EHR.Report.Service.csproj @@ -41,7 +41,10 @@ + + + diff --git a/BMA.EHR.Report.Service/Controllers/ReportDesignerController.cs b/BMA.EHR.Report.Service/Controllers/ReportDesignerController.cs new file mode 100644 index 00000000..1bbdf12a --- /dev/null +++ b/BMA.EHR.Report.Service/Controllers/ReportDesignerController.cs @@ -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) + { + } + } +} diff --git a/BMA.EHR.Report.Service/Program.cs b/BMA.EHR.Report.Service/Program.cs index 92f93f72..0ae0e309 100644 --- a/BMA.EHR.Report.Service/Program.cs +++ b/BMA.EHR.Report.Service/Program.cs @@ -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(); builder.Services.AddHealthChecks(); + + // For Telerik Report Designer + builder.Services.TryAddSingleton(sp => + new ReportServiceConfiguration + { + ReportingEngineConfiguration = ResolveSpecificReportingConfiguration(sp.GetService()), + HostAppId = "ReportingCoreApp", + Storage = new FileStorage(), + ReportSourceResolver = new TypeReportSourceResolver().AddFallbackResolver + (new UriReportSourceResolver(Path.Combine(sp.GetService().ContentRootPath, "Reports"))) + }); + builder.Services.TryAddSingleton(sp => new ReportDesignerServiceConfiguration + { + DefinitionStorage = new FileDefinitionStorage(Path.Combine(sp.GetService().ContentRootPath, "Reports"), new[] { "Resources", "Shared Data Sources" }), + ResourceStorage = new ResourceStorage(Path.Combine(sp.GetService().ContentRootPath, "Reports", "Resources")), + SharedDataSourceStorage = new FileSharedDataSourceStorage(Path.Combine(sp.GetService().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"); diff --git a/BMA.EHR.Report.Service/Properties/launchSettings.json b/BMA.EHR.Report.Service/Properties/launchSettings.json index 985a5c8f..f41c4b5e 100644 --- a/BMA.EHR.Report.Service/Properties/launchSettings.json +++ b/BMA.EHR.Report.Service/Properties/launchSettings.json @@ -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, diff --git a/BMA.EHR.Report.Service/appsettings.json b/BMA.EHR.Report.Service/appsettings.json index 254ef302..2d0fadb9 100644 --- a/BMA.EHR.Report.Service/appsettings.json +++ b/BMA.EHR.Report.Service/appsettings.json @@ -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" + } + ] + } } \ No newline at end of file diff --git a/BMA.EHR.Report.Service/wwwroot/designer.html b/BMA.EHR.Report.Service/wwwroot/designer.html new file mode 100644 index 00000000..d32e628f --- /dev/null +++ b/BMA.EHR.Report.Service/wwwroot/designer.html @@ -0,0 +1,36 @@ + + + + Telerik Web Report Designer + + + + + + + + +
+ loading... +
+ + + + + + + + + + + \ No newline at end of file diff --git a/BMA.EHR.Solution.sln b/BMA.EHR.Solution.sln index 72be7ede..003c2a21 100644 --- a/BMA.EHR.Solution.sln +++ b/BMA.EHR.Solution.sln @@ -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}