Esempio n. 1
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            var th = new Thread(async() =>
            {
                WorkerLog.Instance.Information($"Starting {nameof(FileChunkExportWorker)}");
                var queue = _workerQueueContainer.ToSendChunks.Reader;
                while (await queue.WaitToReadAsync() || !stoppingToken.IsCancellationRequested)
                {
                    var chunkPackage = await queue.ReadAsync();
                    await _transmissionService.SendFileChunk(chunkPackage.filechunk, chunkPackage.recipient);
                }
            });

            th.Start();

            await Task.Delay(Timeout.Infinite);
        }
Esempio n. 2
0
        private async Task RetryFailedTransmissionFileChunks()
        {
            WorkerLog.Instance.Information($"Retrying to send filechunks that have failed");
            var failedChunksResult = await _transmissionRepository.GetFailedFileChunkTransmission();

            if (failedChunksResult.WasSuccessful)
            {
                foreach (var fc in failedChunksResult.Data)
                {
                    var wasSuccessful = await _transmissionService.SendFileChunk(fc.Item1, fc.Item2);

                    if (wasSuccessful)
                    {
                        await _transmissionRepository.DeleteFailedFileChunkTransmission(fc.Item1.Id, fc.Item2.Id);
                    }
                }
            }
        }