public void Execute(int logFileId, string filePath) { LogFileModel logFile = _logFileRepo.GetById(logFileId); try { // load the contents of the file List <W3CEvent> logEvents; try { logEvents = W3CEnumerable.FromFile(filePath).ToList(); } catch (Exception) { throw new FileFormatException("File is not a valid IIS log file"); } // save the requests _createRequestBatchCommand.Execute(logFileId, logEvents); // update the record count of the log file const string sql = "UPDATE LogFiles SET RecordCount = @RecordCount WHERE Id = @Id"; _dbContext.ExecuteNonQuery(sql, new { Id = logFileId, RecordCount = logEvents.Count }); // delete the file _fileWrap.Delete(filePath); // register the job that marks the file as needing aggregate processing _jobRegistrationService.RegisterResetProcessedLogFileJob(logFile.Id); } catch (Exception ex) { // try and update the status of the log file record, the file will be marked as in an error state logFile.Status = BLL.Lookup.LogFileStatus.Error; logFile.ErrorMsg = ex.Message; string sql = "UPDATE LogFiles SET Status = @Status, ErrorMsg = @ErrorMsg WHERE Id = @Id"; _dbContext.ExecuteNonQuery(sql, logFile); } }