Esempio n. 1
0
        public async Task DoWorkAsync()
        {
            try
            {
                var customerDataBatch = await _csvHelper
                                        .LoadFromFileAsync <Customer>(_customerDataFilePath, _sentMessageIds.Count, _batchSize);

                if (customerDataBatch == null)
                {
                    throw new ArgumentNullException();
                }

                var emailsBatch = CustomerDataToEmail(customerDataBatch);

                if (emailsBatch == null)
                {
                    throw new NullReferenceException();
                }

                await SendBatchAsync(emailsBatch, CancellationToken);
            }
            catch (ArgumentNullException e)
            {
                _logger.Exception(e, "There is no customer data to process");
                throw e;
            }
            catch (NullReferenceException e)
            {
                _logger.Exception(e, "There are no emails to send");
                throw e;
            }
            catch (Exception e)
            {
                _logger.Exception(e);
                throw e;
            }
        }