@@ -15,87 +15,4 @@ public interface ICronScheduledTask
1515 /// Examples: "Daily@08:30", "Monday@08:30", "Sunday@00:00"
1616 /// </summary>
1717 string Schedule { get ; }
18-
19- /// <summary>
20- /// Executes the scheduled job logic.
21- /// </summary>
22- Task ExecuteAsync ( ) ;
23- }
24-
25-
26- /// <summary>
27- /// A daily scheduled task for routine maintenance (e.g., database cleanup, log rotation).
28- /// Runs every day at 04:00 AM UTC.
29- /// </summary>
30- public class DailyMaintenanceTask : ICronScheduledTask
31- {
32- private readonly ILogger < DailyMaintenanceTask > _logger ;
33-
34- public DailyMaintenanceTask ( ILogger < DailyMaintenanceTask > logger )
35- {
36- _logger = logger ;
37- }
38-
39- // --- ICronScheduledTask Implementation ---
40- public string Name => "Daily Maintenance & Cleanup" ;
41- public string Schedule => "Daily@04:00" ; // Run every day at 4:00 AM UTC
42- // ----------------------------------------
43-
44- public async Task ExecuteAsync ( )
45- {
46- _logger . LogInformation ( "Executing Daily Maintenance Task: Running routine cleanup." ) ;
47-
48- // --- Actual Scheduled Logic ---
49- await Task . Delay ( 100 ) ; // Simulate asynchronous database cleanup or file deletion
50- // Note: For a real cleanup task, you would inject and use a repository here.
51- // ------------------------------
52-
53- _logger . LogInformation ( "Daily Maintenance Task completed successfully." ) ;
54- }
55- }
56-
57- /// <summary>
58- /// Scheduled task for generating a report every Monday morning.
59- /// </summary>
60- public class BiWeeklyReportTaskMonday : ICronScheduledTask
61- {
62- private readonly ILogger < BiWeeklyReportTaskMonday > _logger ;
63-
64- public BiWeeklyReportTaskMonday ( ILogger < BiWeeklyReportTaskMonday > logger )
65- {
66- _logger = logger ;
67- }
68-
69- public string Name => "Bi-Weekly Report (Monday)" ;
70- public string Schedule => "Monday@08:30" ; // Run every Monday at 8:30 AM UTC
71-
72- public async Task ExecuteAsync ( )
73- {
74- _logger . LogInformation ( "Executing Monday Report Task: Compiling weekly progress report." ) ;
75- await Task . Delay ( 100 ) ; // Simulate report generation
76- _logger . LogInformation ( "Monday Report Task completed successfully." ) ;
77- }
78- }
79-
80- /// <summary>
81- /// Scheduled task for generating a report every Friday morning.
82- /// </summary>
83- public class BiWeeklyReportTaskFriday : ICronScheduledTask
84- {
85- private readonly ILogger < BiWeeklyReportTaskFriday > _logger ;
86-
87- public BiWeeklyReportTaskFriday ( ILogger < BiWeeklyReportTaskFriday > logger )
88- {
89- _logger = logger ;
90- }
91-
92- public string Name => "Bi-Weekly Report (Friday)" ;
93- public string Schedule => "Friday@08:30" ; // Run every Friday at 8:30 AM UTC
94-
95- public async Task ExecuteAsync ( )
96- {
97- _logger . LogInformation ( "Executing Friday Report Task: Compiling end-of-week summary report." ) ;
98- await Task . Delay ( 100 ) ; // Simulate report generation
99- _logger . LogInformation ( "Friday Report Task completed successfully." ) ;
100- }
10118}
0 commit comments