protected override async Task ProcessEventAsync(LocationsCreatedMessage message, CancellationToken cancellationToken)
        {
            var userId = message.UserId;

            try
            {
                using (var stream = await azureBlobService.DownloadFile(userId))
                {
                    if (stream != null)
                    {
                        stream.Position = 0;
                        var folderPath = Path.Combine(Directory.GetCurrentDirectory(), userId);
                        Directory.CreateDirectory(Path.Combine(folderPath));
                        var uploadedFilePath = Path.Combine(folderPath, Path.GetRandomFileName());
                        await using (Stream fileStream = new FileStream(uploadedFilePath, FileMode.Create))
                        {
                            await stream.CopyToAsync(fileStream);
                        }

                        var extractedDirectoryPath = Directory.CreateDirectory(Path.Combine(folderPath, "data"));
                        ZipFile.ExtractToDirectory(uploadedFilePath, extractedDirectoryPath.FullName);

                        var jsonData = GetJsonFilePath(extractedDirectoryPath.FullName);
                        await userLocationsService.CreateUserLocationsAsync(userId, jsonData);

                        Directory.Delete(folderPath, true);
                        await azureBlobService.DeleteFile(userId);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.LogError(ex, $"Processing failed for user - {userId}");
            }
        }
Exemplo n.º 2
0
 public override Task SendMessageAsync(LocationsCreatedMessage messageBody)
 {
     return(base.SendMessageAsync(messageBody));
 }
Exemplo n.º 3
0
 protected abstract Task ProcessEventAsync(LocationsCreatedMessage message, CancellationToken cancellationToken);