แก้ปัญหา swagger สร้าง page Error เมื่อใช้งาน WebREportDesigner
**** ยังไม่ได้ เลยเอาออกจากระบบไปก่อน *****
This commit is contained in:
parent
9b3efd8981
commit
ec3395d970
7 changed files with 52 additions and 55 deletions
|
|
@ -128,7 +128,7 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
var seq = 1;
|
||||
foreach (var item in appointPeople)
|
||||
{
|
||||
if (!(await CheckIsActiveOfficer(item.CitizenId!)))
|
||||
if (!(await CheckIsActiveOfficerAsync(item.CitizenId!)))
|
||||
{
|
||||
var receiver = new CommandReceiver
|
||||
{
|
||||
|
|
@ -192,7 +192,7 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
var seq = 1;
|
||||
foreach (var item in appointPeople)
|
||||
{
|
||||
if (!(await CheckIsActiveOfficer(item.CitizenId!)))
|
||||
if (!(await CheckIsActiveOfficerAsync(item.CitizenId!)))
|
||||
{
|
||||
var receiver = new CommandReceiver
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,6 +11,10 @@
|
|||
<RootNamespace>BMA.EHR.Report.Service</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Controllers\ReportDesignerController.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="runtimeconfig.template.json" />
|
||||
</ItemGroup>
|
||||
|
|
@ -29,7 +33,7 @@
|
|||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.IdentityModel.Logging" Version="6.32.1" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
|
||||
<PackageReference Include="NSwag.Annotations" Version="13.20.0" />
|
||||
<PackageReference Include="runtime.osx.10.10-x64.CoreCompat.System.Drawing" Version="6.0.5.128" />
|
||||
<PackageReference Include="Sentry.AspNetCore" Version="3.36.0" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
|
||||
|
|
@ -41,10 +45,8 @@
|
|||
<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>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Microsoft.AspNetCore.Mvc.ApiExplorer;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.ApiExplorer;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
|
|
@ -19,6 +20,9 @@ namespace BMA.EHR.Report.Service
|
|||
public void Configure(SwaggerGenOptions options)
|
||||
{
|
||||
// add swagger document for every API version discovered
|
||||
|
||||
|
||||
|
||||
foreach (var description in _provider.ApiVersionDescriptions)
|
||||
{
|
||||
options.EnableAnnotations();
|
||||
|
|
@ -26,8 +30,9 @@ namespace BMA.EHR.Report.Service
|
|||
options.SwaggerDoc(
|
||||
description.GroupName,
|
||||
CreateVersionInfo(description));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
|
||||
{
|
||||
In = ParameterLocation.Header,
|
||||
|
|
|
|||
|
|
@ -1,15 +1,7 @@
|
|||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using BMA.EHR.Application.Repositories.Reports;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Binders;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using DocumentFormat.OpenXml.Drawing;
|
||||
using Telerik.Reporting;
|
||||
using Telerik.Reporting.Processing;
|
||||
using System.IO;
|
||||
|
||||
namespace BMA.EHR.Report.Service.Controllers
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
31
BMA.EHR.Report.Service/OpenApiIgnoreFilter.cs
Normal file
31
BMA.EHR.Report.Service/OpenApiIgnoreFilter.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using NSwag.Annotations;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
using System.Reflection;
|
||||
|
||||
namespace BMA.EHR.Report.Service
|
||||
{
|
||||
public class OpenApiIgnoreFilter: IDocumentFilter
|
||||
{
|
||||
public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
|
||||
{
|
||||
foreach (var apiDescription in context.ApiDescriptions)
|
||||
{
|
||||
var actionDescriptor = apiDescription.ActionDescriptor as ControllerActionDescriptor;
|
||||
if (actionDescriptor != null)
|
||||
{
|
||||
var ignoreAttribute = actionDescriptor.MethodInfo.GetCustomAttribute<OpenApiIgnoreAttribute>();
|
||||
if (ignoreAttribute != null)
|
||||
{
|
||||
var routeKey = "/" + apiDescription.RelativePath.TrimEnd('/');
|
||||
if (swaggerDoc.Paths.ContainsKey(routeKey))
|
||||
{
|
||||
swaggerDoc.Paths.Remove(routeKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,6 @@ 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;
|
||||
|
|
@ -16,9 +15,6 @@ 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,28 +88,16 @@ var builder = WebApplication.CreateBuilder(args);
|
|||
})
|
||||
.AddNewtonsoftJson(x => x.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore);
|
||||
|
||||
builder.Services.AddSwaggerGen();
|
||||
builder.Services.AddSwaggerGen(c =>
|
||||
{
|
||||
c.IgnoreObsoleteActions();
|
||||
c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
|
||||
});
|
||||
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"))
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue