/// <summary> /// Processing Air Travel Data /// </summary> /// <param name="inputFolderPath"></param> /// <param name="outputFolderPath"></param> /// <returns></returns> public bool ProcessAirTravelData(string inputFolderPath, string outputFolderPath) { ICheckPoint checkPoint = new CheckPoint(); //List<string> reports = new List<string>(); try { if (!inputFolderPath.IsValidPath()) throw new CustomException(string.Format(AirlineConstants.InvalidSourcePath, inputFolderPath)); string[] files = Directory.GetFiles(inputFolderPath); foreach (string filePath in files) { FileInfo info = new FileInfo(filePath); var outputFolderName = string.Format(@"{0}\Report_{1}", outputFolderPath, info.Name); var travelDetail = this.GetAirTravelData(filePath); if (travelDetail == null) { //Log Console.WriteLine(string.Format(AirlineConstants.InvalidData, filePath)); continue; } var report = this.GetSummaryReport(travelDetail); if (!outputFolderPath.IsValidPath() || string.IsNullOrEmpty(report)) { //Log Console.WriteLine(string.Format(AirlineConstants.InvalidOutputPathErrorMessage, report)); continue; } using (StreamWriter sw = new StreamWriter(outputFolderName)) { //Log Console.WriteLine(string.Format(AirlineConstants.SuccessMessage, report, outputFolderName)); sw.WriteLine(report); } //reports.Add(report); }; } catch (CustomException) { throw; } return true; }
static void Main(string[] args) { ICheckPoint checkPoint = new CheckPoint(); try { var dataFolders = DataFolders.DataFolderList; string inputFolderPath = dataFolders.GetPathValue(AirlineConstants.Input); string outputFolderPath = dataFolders.GetPathValue(AirlineConstants.Output); checkPoint.ProcessAirTravelData(inputFolderPath, outputFolderPath); } catch (CustomException ex) { Console.WriteLine(string.Format("Exception :{0}", ex.Message)); //throw; } Console.ReadLine(); }