diff --git a/queue/src/fiskaltrust.Middleware.Localization.QueueDE/Helpers/MigrationHelper.cs b/queue/src/fiskaltrust.Middleware.Localization.QueueDE/Helpers/MigrationHelper.cs index e435d0d6c..81d252a6a 100644 --- a/queue/src/fiskaltrust.Middleware.Localization.QueueDE/Helpers/MigrationHelper.cs +++ b/queue/src/fiskaltrust.Middleware.Localization.QueueDE/Helpers/MigrationHelper.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Threading.Tasks; using fiskaltrust.ifPOS.v1; using fiskaltrust.Middleware.Contracts.Repositories; @@ -44,7 +45,7 @@ public static async Task FinishMigrationAync(ftQueue queue, ftQueueItem queueIte await actionJournalRepository.InsertAsync(actionJournal).ConfigureAwait(false); } - public static bool IsMigrationInProgress(IMiddlewareQueueItemRepository queueItemRepository) + public static bool IsMigrationInProgress(IMiddlewareQueueItemRepository queueItemRepository, IMiddlewareActionJournalRepository actionJournalRepository) { var queueItem = queueItemRepository.GetLastQueueItemAsync().Result; if(queueItem == null) @@ -54,6 +55,12 @@ public static bool IsMigrationInProgress(IMiddlewareQueueItemRepository queueIte var request = JsonConvert.DeserializeObject(queueItem.request); if ((request.ftReceiptCase & 0xFFFF) == 0x0019) { + var actionJournal = actionJournalRepository.GetByQueueItemId(queueItem.ftQueueItemId).FirstOrDefaultAsync().Result; + + if(actionJournal == null) + { + return false; + } return true; } return false; diff --git a/queue/src/fiskaltrust.Middleware.Localization.QueueDE/SignProcessorDE.cs b/queue/src/fiskaltrust.Middleware.Localization.QueueDE/SignProcessorDE.cs index 6d79f3831..ea31949a0 100644 --- a/queue/src/fiskaltrust.Middleware.Localization.QueueDE/SignProcessorDE.cs +++ b/queue/src/fiskaltrust.Middleware.Localization.QueueDE/SignProcessorDE.cs @@ -28,6 +28,7 @@ public SignProcessorDE( IConfigurationRepository configurationRepository, IMiddlewareJournalDERepository journalDERepository, IMiddlewareQueueItemRepository queueItemRepository, + IMiddlewareActionJournalRepository actionJournalRepository, ITransactionPayloadFactory transactionPayloadFactory, IRequestCommandFactory requestCommandFactory, ILogger logger) @@ -37,7 +38,7 @@ public SignProcessorDE( _transactionPayloadFactory = transactionPayloadFactory; _requestCommandFactory = requestCommandFactory; _logger = logger; - _migrationDone = MigrationHelper.IsMigrationInProgress(queueItemRepository); + _migrationDone = MigrationHelper.IsMigrationInProgress(queueItemRepository, actionJournalRepository); } public async Task<(ReceiptResponse receiptResponse, List actionJournals)> ProcessAsync(ReceiptRequest request, ftQueue queue, ftQueueItem queueItem) diff --git a/queue/test/fiskaltrust.Middleware.Localization.QueueDE.IntegrationTest/SignProcessorDETests/Helpers/RequestCommandFactoryHelper.cs b/queue/test/fiskaltrust.Middleware.Localization.QueueDE.IntegrationTest/SignProcessorDETests/Helpers/RequestCommandFactoryHelper.cs index 2285b09a7..6dedc7263 100644 --- a/queue/test/fiskaltrust.Middleware.Localization.QueueDE.IntegrationTest/SignProcessorDETests/Helpers/RequestCommandFactoryHelper.cs +++ b/queue/test/fiskaltrust.Middleware.Localization.QueueDE.IntegrationTest/SignProcessorDETests/Helpers/RequestCommandFactoryHelper.cs @@ -74,6 +74,7 @@ public static SignProcessorDE ConstructSignProcessor( configurationRepository, journalDERepository, queueItemRepository, + actionJournalRepository, transactionPayloadFactory, new RequestCommandFactory(services.BuildServiceProvider()), logger