print server with new concept
This commit is contained in:
@@ -34,7 +34,7 @@ public class PrinterQueue
|
||||
{
|
||||
_queue.Enqueue(job);
|
||||
_signal.Release(); // Signal that there's work to do
|
||||
_logger.LogInformation("Job {JobId} queued for printer {PrinterId}. Queue length: {QueueLength}", job.AreaId, PrinterIp, QueueLength);
|
||||
_logger.LogInformation("Job queued for printer {PrinterId}. Queue length: {QueueLength}", PrinterIp, QueueLength);
|
||||
}
|
||||
|
||||
public void Start()
|
||||
@@ -50,7 +50,7 @@ public class PrinterQueue
|
||||
{
|
||||
_priorityQueue.Push(job);
|
||||
_signal.Release();
|
||||
_logger.LogInformation("Job {JobId} priority queued for printer {PrinterId}. Queue length: {QueueLength}", job.AreaId, PrinterIp, QueueLength);
|
||||
_logger.LogInformation("Job priority queued for printer {PrinterId}. Queue length: {QueueLength}", PrinterIp, QueueLength);
|
||||
}
|
||||
private async Task ProcessQueueAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
@@ -68,7 +68,7 @@ public class PrinterQueue
|
||||
|
||||
if (job!=null)
|
||||
{
|
||||
_logger.LogInformation("Processing job {JobId} on printer {PrinterId}", job.AreaId, PrinterIp);
|
||||
_logger.LogInformation("Processing job on printer {PrinterId}", PrinterIp);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -79,18 +79,18 @@ public class PrinterQueue
|
||||
{
|
||||
// Re-queue with retry logic
|
||||
job.RetryCount++;
|
||||
_logger.LogWarning("Job {JobId} failed, retrying ({RetryCount}/3)", job.AreaId, job.RetryCount);
|
||||
_logger.LogWarning("Job failed, retrying ({RetryCount}/3)", job.RetryCount);
|
||||
await Task.Delay(5000, cancellationToken); // Wait before retry
|
||||
EnqueuePriority(job);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogInformation("Job {JobId} completed successfully on printer {PrinterId}", job.AreaId, PrinterIp);
|
||||
_logger.LogInformation("Job completed successfully on printer {PrinterId}", PrinterIp);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error processing job {JobId}", job.AreaId);
|
||||
_logger.LogError(ex, "Error processing job");
|
||||
// Handle exception (retry, log, etc.)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user