9 Commits
9 changed files with 96 additions and 11 deletions
+25
View File
@@ -0,0 +1,25 @@
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/.idea
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
+11
View File
@@ -0,0 +1,11 @@
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY . .
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \
dotnet publish --self-contained false -o /app
FROM mcr.microsoft.com/dotnet/aspnet:10.0 AS final
WORKDIR /app
COPY --from=build /app .
ENTRYPOINT ["dotnet", "PdfService.dll"]
+24
View File
@@ -0,0 +1,24 @@
namespace PdfService;
public class ExceptionHandlerMiddleware
{
private readonly RequestDelegate _next;
public ExceptionHandlerMiddleware(RequestDelegate next)
{
_next = next;
}
public async Task InvokeAsync(HttpContext context)
{
try
{
await _next(context);
}
catch (Exception ex)
{
SentrySdk.CaptureException(ex);
throw;
}
}
}
Binary file not shown.
+10 -2
View File
@@ -1,14 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="dotenv.net" Version="4.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Stimulsoft.Reports.Engine.NetCore" Version="2025.2.3" /> <PackageReference Include="Sentry" Version="6.0.0" />
<PackageReference Include="Stimulsoft.Reports.Engine.NetCore" Version="2023.1.1" />
</ItemGroup>
<ItemGroup>
<Content Include="..\.dockerignore">
<Link>.dockerignore</Link>
</Content>
</ItemGroup> </ItemGroup>
</Project> </Project>
+13
View File
@@ -1,11 +1,24 @@
using System.Data; using System.Data;
using dotenv.net;
using Microsoft.AspNetCore.WebUtilities; using Microsoft.AspNetCore.WebUtilities;
using Newtonsoft.Json; using Newtonsoft.Json;
using PdfService; using PdfService;
DotEnv.Load();
Stimulsoft.Base.StiLicense.Key =
"6vJhGtLLLz2GNviWmUTrhSqnOItdDwjBylQzQcAOiHkO46nMQvol4ASeg91in+mGJLnn2KMIpg3eSXQSgaFOm15+0lhekKip+wRGMwXsKpHAkTvorOFqnpF9rchcYoxHXtjNDLiDHZGTIWq6D/2q4k/eiJm9fV6FdaJIUbWGS3whFWRLPHWCBsWnalqTdZlP9knjaWclfjmUKf2Ksc5btMD6pmR7ZHQfHXfdgYK7tLR1rqtxYxBzOPq3LIBvd3spkQhKb07LTZQoyQ3vmRSMALmJSS6ovIS59XPS+oSm8wgvuRFqE1im111GROa7Ww3tNJTA45lkbXX+SocdwXvEZyaaq61Uc1dBg+4uFRxvyRWvX5WDmJz1X0VLIbHpcIjdEDJUvVAN7Z+FW5xKsV5ySPs8aegsY9ndn4DmoZ1kWvzUaz+E1mxMbOd3tyaNnmVhPZeIBILmKJGN0BwnnI5fu6JHMM/9QR2tMO1Z4pIwae4P92gKBrt0MqhvnU1Q6kIaPPuG2XBIvAWykVeH2a9EP6064e11PFCBX4gEpJ3XFD0peE5+ddZh+h495qUc1H2B";
SentrySdk.Init(options =>
{
options.Dsn = Environment.GetEnvironmentVariable("SENTRY_DSN");
});
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
var app = builder.Build(); var app = builder.Build();
app.UseMiddleware<ExceptionHandlerMiddleware>();
app.MapPost("/Print", async (HttpContext context) => app.MapPost("/Print", async (HttpContext context) =>
{ {
var request = context.Request; var request = context.Request;
+1 -9
View File
@@ -1,6 +1,5 @@
using Stimulsoft.Base;
using Stimulsoft.Report; using Stimulsoft.Report;
using Stimulsoft.Report.Dictionary; using Stimulsoft.Report.Export;
namespace PdfService; namespace PdfService;
@@ -12,13 +11,6 @@ public static class Reporter
report.LoadFromString(reportTemplate); report.LoadFromString(reportTemplate);
report.RegBusinessObject("Data", data); report.RegBusinessObject("Data", data);
var currentDirectory = Path.GetFullPath(Path.Combine(Environment.CurrentDirectory, @"../../.."));
var fileContent = File.ReadAllBytes(Path.Combine(currentDirectory, "Fonts", "IRANSansWeb.ttf"));
var resource = new StiResource("IRANSansMonoSpacedNum", "IRANSansMonoSpacedNum", false, StiResourceType.FontTtf, fileContent, false);
report.Dictionary.Resources.Add(resource);
StiFontCollection.AddResourceFont(resource.Name, resource.Content, "ttf", resource.Alias);
report.Render(false); report.Render(false);
var stream = new MemoryStream(); var stream = new MemoryStream();
+2
View File
@@ -0,0 +1,2 @@
SENTRY_DSN=https://d3fd87d14e555556d3f76e42d94a63a0@sentry.rayvarz.center/10
STIMULSOFT_LICENSE_KEY=6vJhGtLLLz2GNviWmUTrhSqnOItdDwjBylQzQcAOiHkgpgFGkUl79uxVs8X+uspx6K+tqdtOB5G1S6PFPRrlVNvMUiSiNYl724EZbrUAWwAYHlGLRbvxMviMExTh2l9xZJ2xc4K1z3ZVudRpQpuDdFq+fe0wKXSKlB6okl0hUd2ikQHfyzsAN8fJltqvGRa5LI8BFkA/f7tffwK6jzW5xYYhHxQpU3hy4fmKo/BSg6yKAoUq3yMZTG6tWeKnWcI6ftCDxEHd30EjMISNn1LCdLN0/4YmedTjM7x+0dMiI2Qif/yI+y8gmdbostOE8S2ZjrpKsgxVv2AAZPdzHEkzYSzx81RHDzZBhKRZc5mwWAmXsWBFRQol9PdSQ8BZYLqvJ4Jzrcrext+t1ZD7HE1RZPLPAqErO9eo+7Zn9Cvu5O73+b9dxhE2sRyAv9Tl1lV2WqMezWRsO55Q3LntawkPq0HvBkd9f8uVuq9zk7VKegetCDLb0wszBAs1mjWzN+ACVHiPVKIk94/QlCkj31dWCg8YTrT5btsKcLibxog7pv1+2e4yocZKWsposmcJbgG0
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="LocalPackages" value="./packages" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>