public static void CleanDescriptionFiles(string directory, string exportDirectory, string errorExportDirectory) { FileCollection FileCollection = new FileCollection(); FileCollection.AddFiles(directory, "*.csv"); foreach (string file in FileCollection.Filenames) { string currentFileName = Importer.GetFileName(file); string exportFileName = exportDirectory + currentFileName; string errorFileName = errorExportDirectory + currentFileName; try { CleanupDescriptionFile(file, exportFileName, errorFileName); } catch (Exception ex) { Log.Warning(string.Format("{0}: Could not clean file", currentFileName)); Log.Warning(string.Format("{0}: {1}", currentFileName, ex.Message)); Log.Warning(string.Format("{0}: Stack Trace: {1}", currentFileName, ex.StackTrace)); } } }
private static void CleanupDescriptionFile(string filePath, string exportFilePath, string errorExportFilePath) { var iodpDataTable = Importer.ImportDataTableFromFile(filePath); string currentFileName = Importer.GetFileName(filePath); try { Importer.CheckFile(iodpDataTable); AddMissingColumnsToDescriptionTable(iodpDataTable.DataTable); AddDataToHierarchyColumns(iodpDataTable, Importer.GetFileName(filePath), SectionInfoCollection.ImportAllSections(ConfigurationManager.AppSettings["AllSectionsFile"])); Log.Information($"{currentFileName}: Processed successfully"); } catch (Exception ex) { Log.Warning($"{currentFileName}: {ex.Message}"); exportFilePath = errorExportFilePath; } try { Importer.ExportDataTableAsNewFile(exportFilePath, iodpDataTable.DataTable); } catch (Exception) { throw new Exception($"{currentFileName}: Error exporting to file"); } }