/// <summary> /// Load an input file. /// </summary> /// <param name="filePath">name and path of file to load</param> /// <returns>file contents</returns> private static List <IJourneyDetailsType> LoadFile( string filePath) { if (!File.Exists(filePath)) { return(new List <IJourneyDetailsType>()); } int month; int year; try { month = DailyInputFactory.GetMonth(filePath); year = DailyInputFactory.GetYear(filePath); } catch (Exception ex) { Logger.Instance.WriteLog( $"DailyInputFactory File name is invalid {ex}"); return(new List <IJourneyDetailsType>()); } List <JourneyDetailsType> fileList = new List <JourneyDetailsType>(); return(DailyInputFactory.LoadFile( filePath, year, month)); }
/// <summary> /// Load an input file for a given month. /// </summary> /// <param name="path">directory containing the month files</param> /// <param name="month">month to load</param> /// <returns>file contents</returns> public static List <IJourneyDetailsType> LoadMonth( string path, int month) { string filePath = DailyInputFactory.BuildFilePath( path, month); if (string.IsNullOrEmpty(filePath)) { Logger.Instance.WriteLog( $"ERROR: DailyInputFactory: Load Month: Input is invalid (Path-{path}, Month-{month})"); return(new List <IJourneyDetailsType>()); } int year; try { year = DailyInputFactory.GetYear(path); } catch (Exception ex) { Logger.Instance.WriteLog( $"ERROR: DailyInputFactory: Load Month: Input is invalid (Path-{path}, Month-{month})"); return(new List <IJourneyDetailsType>()); } return(DailyInputFactory.LoadFile( filePath, year, month)); }