diff --git a/NEW/src/JdeScoping.Core/Interfaces/ISearchNotificationService.cs b/NEW/src/JdeScoping.Core/Interfaces/ISearchNotificationService.cs new file mode 100644 index 0000000..8d9f3d4 --- /dev/null +++ b/NEW/src/JdeScoping.Core/Interfaces/ISearchNotificationService.cs @@ -0,0 +1,24 @@ +using JdeScoping.Core.Models.Search; + +namespace JdeScoping.Core.Interfaces; + +/// +/// Interface for SignalR notifications - lives in Core to avoid dependency issues. +/// Implementation lives in Host/Api layer. +/// +public interface ISearchNotificationService +{ + /// + /// Notifies clients of search status update. + /// + /// The search with updated status. + /// Cancellation token. + Task NotifySearchUpdateAsync(Search search, CancellationToken ct = default); + + /// + /// Notifies clients of work processor status change. + /// + /// Status message. + /// Cancellation token. + Task NotifyStatusAsync(string status, CancellationToken ct = default); +} diff --git a/NEW/src/JdeScoping.DataSync/Contracts/ISearchExecutionService.cs b/NEW/src/JdeScoping.DataSync/Contracts/ISearchExecutionService.cs new file mode 100644 index 0000000..a03a99d --- /dev/null +++ b/NEW/src/JdeScoping.DataSync/Contracts/ISearchExecutionService.cs @@ -0,0 +1,17 @@ +using JdeScoping.Core.Models.Search; + +namespace JdeScoping.DataSync.Contracts; + +/// +/// Interface for search execution pipeline orchestration. +/// +public interface ISearchExecutionService +{ + /// + /// Executes the complete search pipeline: query, Excel generation, result storage. + /// Handles status transitions and notifications. + /// + /// The search to execute. + /// Cancellation token. + Task ExecuteSearchAsync(Search search, CancellationToken ct = default); +} diff --git a/NEW/src/JdeScoping.DataSync/Contracts/ISearchRepository.cs b/NEW/src/JdeScoping.DataSync/Contracts/ISearchRepository.cs new file mode 100644 index 0000000..08a2037 --- /dev/null +++ b/NEW/src/JdeScoping.DataSync/Contracts/ISearchRepository.cs @@ -0,0 +1,40 @@ +using JdeScoping.Core.Models.Search; + +namespace JdeScoping.DataSync.Contracts; + +/// +/// Repository interface for Search table operations. +/// +public interface ISearchRepository +{ + /// + /// Gets the next queued search ordered by SubmitDT (FIFO). + /// + /// Cancellation token. + /// The next queued search, or null if none. + Task GetNextQueuedSearchAsync(CancellationToken ct = default); + + /// + /// Resets partial searches (Running but not Ended) back to Queued status. + /// Called at service startup to handle interrupted operations. + /// + /// Cancellation token. + /// Count of reset searches. + Task ResetPartialSearchesAsync(CancellationToken ct = default); + + /// + /// Marks search as Running with StartDT = now. + /// + /// Search ID. + /// Cancellation token. + Task StartSearchAsync(int searchId, CancellationToken ct = default); + + /// + /// Marks search as Ended (success) or Error (failure) with EndDT and optional Results. + /// + /// Search ID. + /// Whether search completed successfully. + /// Excel file bytes (null on failure). + /// Cancellation token. + Task CompleteSearchAsync(int searchId, bool success, byte[]? results, CancellationToken ct = default); +} diff --git a/NEW/src/JdeScoping.DataSync/Options/WorkProcessorOptions.cs b/NEW/src/JdeScoping.DataSync/Options/WorkProcessorOptions.cs new file mode 100644 index 0000000..9db4eb0 --- /dev/null +++ b/NEW/src/JdeScoping.DataSync/Options/WorkProcessorOptions.cs @@ -0,0 +1,37 @@ +using System.ComponentModel.DataAnnotations; + +namespace JdeScoping.DataSync.Options; + +/// +/// Configuration options for the WorkProcessor background service. +/// +public class WorkProcessorOptions +{ + /// + /// Configuration section name. + /// + public const string SectionName = "WorkProcessor"; + + /// + /// Whether the work processor is enabled. Default: true. + /// + public bool Enabled { get; set; } = true; + + /// + /// Interval between work cycles. Default: 5 seconds. + /// + [Range(typeof(TimeSpan), "00:00:01", "01:00:00")] + public TimeSpan WorkInterval { get; set; } = TimeSpan.FromSeconds(5); + + /// + /// Search execution timeout. Default: 30 minutes. + /// + [Range(typeof(TimeSpan), "00:01:00", "04:00:00")] + public TimeSpan SearchTimeout { get; set; } = TimeSpan.FromMinutes(30); + + /// + /// Number of days to retain DataUpdate records. Default: 30. + /// + [Range(1, 365)] + public int PurgeRetentionDays { get; set; } = 30; +}