uploaded new name

This commit is contained in:
2025-09-22 20:34:15 +03:00
parent dd1772222d
commit 921ea43834
14 changed files with 180 additions and 64 deletions

View File

@@ -1,9 +1,9 @@
# Quality Recticel Print Service - PowerShell Implementation
# Quality Label Printing Service - PowerShell Implementation
# Native Windows solution with no external dependencies
param(
[int]$Port = 8765,
[string]$LogFile = "$env:ProgramFiles\QualityRecticel\PrintService\print_service.log"
[string]$LogFile = "$env:ProgramFiles\QualityLabelPrinting\PrintService\print_service.log"
)
# Ensure log directory exists
@@ -109,10 +109,11 @@ function Send-HttpResponse {
$Context.Response.StatusCode = $StatusCode
$Context.Response.ContentType = "$ContentType; charset=utf-8"
# Add CORS headers
# Add comprehensive CORS headers
$Context.Response.Headers.Add("Access-Control-Allow-Origin", "*")
$Context.Response.Headers.Add("Access-Control-Allow-Methods", "GET, POST, OPTIONS")
$Context.Response.Headers.Add("Access-Control-Allow-Headers", "Content-Type, Authorization")
$Context.Response.Headers.Add("Access-Control-Allow-Methods", "GET, POST, OPTIONS, PUT, DELETE")
$Context.Response.Headers.Add("Access-Control-Allow-Headers", "Content-Type, Authorization, Accept, Origin, X-Requested-With")
$Context.Response.Headers.Add("Access-Control-Max-Age", "86400")
if ($Body) {
$buffer = [System.Text.Encoding]::UTF8.GetBytes($Body)
@@ -129,7 +130,7 @@ function Send-HttpResponse {
# Main HTTP server function
function Start-PrintService {
Write-ServiceLog "Starting Quality Recticel Print Service on port $Port"
Write-ServiceLog "Starting Quality Label Printing Service on port $Port"
try {
# Create HTTP listener
@@ -153,12 +154,19 @@ function Start-PrintService {
Write-ServiceLog "$method $url"
# Handle CORS preflight requests first
if ($method -eq "OPTIONS") {
Write-ServiceLog "Handling CORS preflight request for $url"
Send-HttpResponse -Context $context -StatusCode 200
continue
}
# Handle different endpoints
switch -Regex ($url) {
"^/health$" {
$healthData = @{
status = "healthy"
service = "Quality Recticel Print Service"
service = "Quality Label Printing Service"
version = "1.0"
timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
platform = "Windows PowerShell"
@@ -207,11 +215,6 @@ function Start-PrintService {
}
}
"^/options$" {
# Handle CORS preflight
Send-HttpResponse -Context $context -StatusCode 200
}
default {
$errorResponse = @{
success = $false
@@ -250,7 +253,7 @@ function Start-PrintService {
}
# Service entry point
Write-ServiceLog "Quality Recticel Print Service starting..."
Write-ServiceLog "Quality Label Printing Service starting..."
# Handle service stop gracefully
Register-EngineEvent -SourceIdentifier PowerShell.Exiting -Action {