private void ProcessOffer(HtmlData htmlData) { try { _logger.Log(LogType.Debug, $"Before getting processor"); var processor = _factory.Get(htmlData.OfferType); _logger.Log(LogType.Debug, $"After getting processor {processor.GetClassName()}"); _logger.Log(LogType.Info, $"Started to extract data from {htmlData.GetClassName()} with Id: {htmlData.Id}"); var offer = processor.Process(htmlData); _logger.Log(LogType.Info, $"Finished to extract data from {htmlData.GetClassName()} with Id: {htmlData.Id}"); _htmlDataRepository.Delete(htmlData); _logger.Log(LogType.Info, $"Removed obsolete data from {htmlData.GetClassName()} with Id: {htmlData.Id}"); using (var transaction = _offerRepository.GetTransaction()) { _offerRepository.Insert(offer, transaction); _logger.Log(LogType.Info, $"Inserted new {offer.GetClassName()} to database"); } } catch (Exception e) { using (var transaction = _htmlDataRepository.GetTransaction()) { htmlData.Status = Status.Failed; _htmlDataRepository.Update(htmlData, transaction); _logger.Log(LogType.Error, $"Failed to extract data from {htmlData.GetClassName()} with Id: {htmlData.Id}|{e.Message}"); } throw; } }