Beispiel #1
0
        private void ValidateRequest(ProcessFileRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            if (string.IsNullOrWhiteSpace(request.DownloadUrl))
            {
                throw new ArgumentNullException(nameof(request.DownloadUrl));
            }
        }
Beispiel #2
0
        public async Task Handle(ProcessFileRequest request)
        {
            ValidateRequest(request);

            using Stream zippedStream = await this.fileDownloader.Download(request.DownloadUrl);

            using Stream unzippedStream = this.zipService.UnZip(zippedStream);

            using StreamReader streamReader = new StreamReader(unzippedStream);

            while (!streamReader.EndOfStream)
            {
                var gdeltEvent = this.csvToGdeltEventConverter.ConvertCsvLineToGdeltEvent(streamReader.ReadLine(), '\t');

                await this.queueService.Queue(gdeltEvent);
            }
        }