| | | 1 | | using Hangfire; |
| | | 2 | | |
| | | 3 | | namespace Services.LabelServices; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Периодически обновляет кэш <c>labels_folder_index_v1</c>, |
| | | 7 | | /// чтобы первый заход на Orders/Index не ждал листинг папки этикеток. |
| | | 8 | | /// </summary> |
| | | 9 | | public class LabelsFolderIndexRefreshJob |
| | | 10 | | { |
| | | 11 | | public const string JobId = "LabelsFolderIndexRefreshJob"; |
| | | 12 | | public const string DefaultCron = "*/10 * * * *"; |
| | | 13 | | public const string QueueName = "main"; |
| | | 14 | | |
| | | 15 | | private readonly ILabelExistenceService _labelExistenceService; |
| | | 16 | | private readonly ILabelCatalogService _labelCatalogService; |
| | | 17 | | |
| | 1 | 18 | | public LabelsFolderIndexRefreshJob( |
| | 1 | 19 | | ILabelExistenceService labelExistenceService, |
| | 1 | 20 | | ILabelCatalogService labelCatalogService) |
| | | 21 | | { |
| | 1 | 22 | | _labelExistenceService = labelExistenceService; |
| | 1 | 23 | | _labelCatalogService = labelCatalogService; |
| | 1 | 24 | | } |
| | | 25 | | |
| | | 26 | | [Queue(QueueName)] |
| | | 27 | | public async Task<string> ExecuteAsync() |
| | | 28 | | { |
| | 1 | 29 | | var count = await _labelExistenceService.RefreshFolderIndexAsync(); |
| | 1 | 30 | | var catalog = await _labelCatalogService.RefreshAsync(); |
| | 1 | 31 | | return $"Labels folder index refreshed ({count} shipment numbers, {catalog.Rows.Count} PDF files)"; |
| | 1 | 32 | | } |
| | | 33 | | } |