CaysnPrintServer 1.0.5-g8b39ac119e

This is a prerelease version of CaysnPrintServer.
dotnet add package CaysnPrintServer --version 1.0.5-g8b39ac119e
                    
NuGet\Install-Package CaysnPrintServer -Version 1.0.5-g8b39ac119e
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CaysnPrintServer" Version="1.0.5-g8b39ac119e" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CaysnPrintServer" Version="1.0.5-g8b39ac119e" />
                    
Directory.Packages.props
<PackageReference Include="CaysnPrintServer" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CaysnPrintServer --version 1.0.5-g8b39ac119e
                    
#r "nuget: CaysnPrintServer, 1.0.5-g8b39ac119e"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CaysnPrintServer@1.0.5-g8b39ac119e
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CaysnPrintServer&version=1.0.5-g8b39ac119e&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=CaysnPrintServer&version=1.0.5-g8b39ac119e&prerelease
                    
Install as a Cake Tool

CaysnPrintServer

A reliable CAYSN thermal printer server for ASP.NET Core with job queuing, print confirmation, and real-time notifications.

Features

  • Job Queue — persistent print job queue backed by Entity Framework Core with automatic retry and exponential backoff
  • Print Confirmation — two-phase protocol (passive listen + limited active polling) confirms physical print completion via CAYSN auto-reply
  • SignalR Hub — real-time job status notifications pushed to connected clients
  • REST API — endpoints for submitting jobs (template or raw ESC/POS), querying status, and health checks
  • Templates — register named ESC/POS templates with placeholder substitution; render at print time
  • Health Monitoring — background service that periodically checks printer reachability and exposes per-printer health status
  • Webhooks — optional global webhook URL called on job completion/failure

Quick Start

1. Implement the abstractions

DbContext — your EF Core context must implement ICaysnPrintDbContext:

public class AppDbContext : DbContext, ICaysnPrintDbContext
{
    public DbSet<CaysnPrintJob> CaysnPrintJobs => Set<CaysnPrintJob>();

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.ApplyCaysnPrintJobConfiguration();

        // Optional: add FK to your own Printer entity
        modelBuilder.Entity<CaysnPrintJob>()
            .HasOne<Printer>()
            .WithMany()
            .HasForeignKey(e => e.PrinterId)
            .OnDelete(DeleteBehavior.Restrict);
    }
}

Printer provider — implement IPrinterProvider to supply printer connection details:

public class MyPrinterProvider : IPrinterProvider
{
    public Task<ICaysnPrinter?> GetPrinterAsync(int printerId, CancellationToken ct = default)
    {
        // Return your printer entity adapted to ICaysnPrinter
    }

    public Task<IReadOnlyList<ICaysnPrinter>> GetActivePrintersAsync(CancellationToken ct = default)
    {
        // Return all enabled printers
    }
}

2. Register services

builder.Services.AddCaysnPrintService<AppDbContext, MyPrinterProvider>(options =>
{
    options.MaxConcurrentJobs = 5;
    options.PrintConfirmationTimeoutMs = 15000;
    options.ApiPrefix = "/api/print";
    options.HubPath = "/hubs/print";

    // SQL Server uses local time; PostgreSQL uses UTC (default)
    options.UseUtcTimestamps = false; // set to false for SQL Server

    // Register ESC/POS templates
    options.RegisterTemplate("receipt", (printer, data) =>
    {
        // Build ESC/POS byte array using ESCPOS_NET
    });
});

3. Map endpoints

var app = builder.Build();

app.UseCaysnPrintService();       // Adds middleware
app.MapCaysnPrintService();       // Maps REST + SignalR endpoints

Requirements

  • .NET 10 / ASP.NET Core
  • Entity Framework Core (any relational provider)
  • CAYSN thermal printer accessible on TCP port 9100
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.5-g8b39ac119e 41 1/30/2026
1.0.4-g9a370141e2 42 1/30/2026
1.0.3-g9a370141e2 39 1/30/2026
1.0.2-g0733037fb4 46 1/30/2026
1.0.1-g0733037fb4 40 1/30/2026
1.0.0-g0733037fb4 40 1/30/2026