/// <summary> /// Event which is raised when the Background Worker is started. /// </summary> /// <param name="sender">Sender object for the event.</param> /// <param name="args">Event args for the event.</param> private void UploadFile(object sender, DoWorkEventArgs args) { string connectionString = _configManager.GetConnectionString(); if (!string.IsNullOrEmpty(connectionString)) { IFileDataReader fileReader = new FileDataReader(); IFileDataWriter fileWriter = new FileDataWriter(connectionString); System.Diagnostics.Stopwatch stopWatch = System.Diagnostics.Stopwatch.StartNew(); string fileExtension = System.IO.Path.GetExtension(SelectedFileName); if (fileExtension == ".csv") { foreach (var v in fileReader.ReadDataFromCSV(SelectedFileName)) { fileWriter.WriteDataToSQL("AccountTransactionData", v.DataTable, GetColumnMappings()); _fileUploaderBackgroundWorker.ReportProgress((int)CalculatePercentage(v.TotalBytes, v.BytesRead), string.Format("{0} Lines Processed, {1} Lines Imported", v.LinesProcessed, v.LinesImported)); SkippedLinesMessage = ProcessSkippedLines(v.SkippedLines); } logger.Info(string.Format("Processing of File Completed in {0} seconds", stopWatch.Elapsed.Seconds)); } else if (fileExtension == ".xlsx") { //Call the ReadDataFromExcel method. } } else { logger.Error("Connection String not valid in the config file"); _messageBoxService.ShowMessageBox("Please check the Connection string in Configuration file", "AccountTransactionUploadApp"); } }