// The "import" method calls the handler delegate one time for each line in the file. // The file needs to be tab delimited and contain "columnCount" columns. // If the handler throws an exception, it will be handled gracefully and the error will be outputed to the Console. private static void ImportEnergyToSMART(ParseLineHandler handler, int columnCount) { List <EnergyEstimateImportItem> energyImportItems = GetRefDataFromFile(); int lineNumber = 0; foreach (var energyImportItem in energyImportItems) { try { lineNumber++; Console.WriteLine(string.Format("Importing project #{0}: {1}", lineNumber, energyImportItem.ProjectNumber)); handler(energyImportItem); } catch (Exception ex) { Console.WriteLine("Error on project " + energyImportItem.ProjectNumber); Console.WriteLine(ex.Message); } } }
// The "import" method calls the handler delegate one time for each line in the file. // The file needs to be tab delimited and contain "columnCount" columns. // If the handler throws an exception, it will be handled gracefully and the error will be outputed to the Console. private static void ImportEnergyToSMART(ParseLineHandler handler, int columnCount) { List<EnergyEstimateImportItem> energyImportItems = GetRefDataFromFile(); int lineNumber = 0; foreach (var energyImportItem in energyImportItems) { try { lineNumber++; Console.WriteLine(string.Format("Importing project #{0}: {1}", lineNumber, energyImportItem.ProjectNumber)); handler(energyImportItem); } catch (Exception ex) { Console.WriteLine("Error on project " + energyImportItem.ProjectNumber); Console.WriteLine(ex.Message); } } }