Initial commit: LAAPC Print Service - Windows service with multi-tray printing, IPC queue management, PDF testing support, and self-installing CLI

This commit is contained in:
Jason
2026-05-14 16:59:59 -05:00
commit cce9248089
23 changed files with 2974 additions and 0 deletions
+57
View File
@@ -0,0 +1,57 @@
namespace PrintService.Models;
/// <summary>
/// Application settings loaded from appsettings.json
/// </summary>
public class AppSettings
{
/// <summary>
/// Path to monitor for incoming capture files
/// </summary>
public string CapturesPath { get; set; } = "Captures";
/// <summary>
/// Path for queued files (after moving from Captures)
/// </summary>
public string QueuePath { get; set; } = "Queue";
/// <summary>
/// Path for failed jobs
/// </summary>
public string ErrorPath { get; set; } = "Errors";
/// <summary>
/// Default archive path
/// </summary>
public string ArchivePath { get; set; } = "Archive";
/// <summary>
/// Maximum retry attempts before moving to error folder
/// </summary>
public int MaxRetryAttempts { get; set; } = 3;
/// <summary>
/// Debounce delay in milliseconds for file system watcher
/// </summary>
public int DebounceDelayMs { get; set; } = 200;
/// <summary>
/// Named pipe name for IPC communication
/// </summary>
public string PipeName { get; set; } = "PrintServicePipe";
/// <summary>
/// Document type configurations
/// </summary>
public List<DocumentConfig> DocumentTypes { get; set; } = new();
/// <summary>
/// Queue state file path
/// </summary>
public string QueueStateFile { get; set; } = "queue_state.json";
/// <summary>
/// Enable detailed logging
/// </summary>
public bool VerboseLogging { get; set; } = false;
}
+91
View File
@@ -0,0 +1,91 @@
namespace PrintService.Models;
/// <summary>
/// Configuration for document types
/// </summary>
public class DocumentConfig
{
/// <summary>
/// Name/identifier of the document type
/// </summary>
public string Name { get; set; } = string.Empty;
/// <summary>
/// Printer name to send to
/// </summary>
public string PrinterName { get; set; } = string.Empty;
/// <summary>
/// Sequence of tray numbers to use (1-based, e.g., [3, 4, 1, 2])
/// These will be mapped to physical PaperSource indexes
/// </summary>
public int[] TraySequence { get; set; } = Array.Empty<int>();
/// <summary>
/// Font name to use for rendering
/// </summary>
public string FontName { get; set; } = "Courier New";
/// <summary>
/// Font size in points
/// </summary>
public float FontSize { get; set; } = 10f;
/// <summary>
/// Vertical offset adjustment (in pixels)
/// </summary>
public int VerticalOffset { get; set; } = 0;
/// <summary>
/// Horizontal offset adjustment (in pixels)
/// </summary>
public int HorizontalOffset { get; set; } = 0;
/// <summary>
/// Text transformation rules (regex patterns to remove/replace)
/// </summary>
public List<TextTransform> Transformations { get; set; } = new();
/// <summary>
/// Whether to archive files after printing (true) or delete them (false)
/// </summary>
public bool ArchiveAfterPrint { get; set; } = true;
/// <summary>
/// Archive folder path (if ArchiveAfterPrint is true)
/// </summary>
public string? ArchivePath { get; set; }
/// <summary>
/// Output folder for PDF files (when using "Microsoft Print to PDF")
/// If specified, PDFs will be saved to this folder automatically
/// </summary>
public string? OutputPath { get; set; }
/// <summary>
/// Skip post-processing (archive/delete) to leave files in queue for repeated testing
/// Useful for development and testing scenarios
/// </summary>
public bool SkipPostProcessing { get; set; } = false;
}
/// <summary>
/// Text transformation rule
/// </summary>
public class TextTransform
{
/// <summary>
/// Regex pattern to match
/// </summary>
public string Pattern { get; set; } = string.Empty;
/// <summary>
/// Replacement text (empty string to remove)
/// </summary>
public string Replacement { get; set; } = string.Empty;
/// <summary>
/// Description of what this transformation does
/// </summary>
public string Description { get; set; } = string.Empty;
}
+74
View File
@@ -0,0 +1,74 @@
namespace PrintService.Models;
/// <summary>
/// Represents a print job in the queue
/// </summary>
public class PrintJob
{
/// <summary>
/// Unique identifier for the job
/// </summary>
public Guid Id { get; set; } = Guid.NewGuid();
/// <summary>
/// Path to the original capture file
/// </summary>
public string SourceFilePath { get; set; } = string.Empty;
/// <summary>
/// Path to the queued file (after being moved with GUID name)
/// </summary>
public string QueuedFilePath { get; set; } = string.Empty;
/// <summary>
/// Document type (invoice, order, delivery, etc.)
/// </summary>
public string DocumentType { get; set; } = string.Empty;
/// <summary>
/// Optional order number
/// </summary>
public string? OrderNumber { get; set; }
/// <summary>
/// When the job was created
/// </summary>
public DateTime CreatedAt { get; set; } = DateTime.Now;
/// <summary>
/// When the job was last updated
/// </summary>
public DateTime UpdatedAt { get; set; } = DateTime.Now;
/// <summary>
/// Current status of the job
/// </summary>
public PrintJobStatus Status { get; set; } = PrintJobStatus.Pending;
/// <summary>
/// Number of times this job has been attempted
/// </summary>
public int RetryCount { get; set; } = 0;
/// <summary>
/// Last error message if failed
/// </summary>
public string? LastError { get; set; }
/// <summary>
/// Original filename before moving to queue
/// </summary>
public string OriginalFilename { get; set; } = string.Empty;
}
/// <summary>
/// Status of a print job
/// </summary>
public enum PrintJobStatus
{
Pending,
Processing,
Completed,
Failed,
RetryScheduled
}