Ejemplo n.º 1
0
        private List <Order> LoadOrdersForDate(DateTime date)
        {
            string filePath = $"{FilePathStart}{date.Month:00}{date.Day:00}{date.Year:0000}.*"; //TODO fix filepath

            string[] actualFilePath = Directory.GetFiles(@".", filePath);
            if (!actualFilePath.Any())
            {
                return(new List <Order>());
            }
            if (actualFilePath.Length > 1)
            {
                throw new Exception($"Multiple files found for date: {date}");
            }

            IFileHandler fileHandler;

            switch (Path.GetExtension(actualFilePath[0]))
            {
            case ".json":
                fileHandler = new JsonFileHandler(FilePathStart);
                break;

            case ".csv":
                fileHandler = new CsvFileHandler(FilePathStart);
                break;

            case ".xml":
                fileHandler = new XmlFileHandler(FilePathStart);
                break;

            default:
                throw new Exception($"File type not reconized for date: {date}");
            }
            return(fileHandler.LoadFromFile(date));
        }
Ejemplo n.º 2
0
        private List<Order> LoadOrdersForDate(DateTime date)
        {
            string filePath = $"{FilePathStart}{date.Month:00}{date.Day:00}{date.Year:0000}.*"; //TODO fix filepath
            string[] actualFilePath = Directory.GetFiles(@".",filePath);
            if (!actualFilePath.Any())
            {
                return new List<Order>();
            }
            if (actualFilePath.Length > 1)
            {
                throw new Exception($"Multiple files found for date: {date}");
            }

            IFileHandler fileHandler;
            switch (Path.GetExtension(actualFilePath[0]))
            {
                case ".json":
                    fileHandler = new JsonFileHandler(FilePathStart);
                    break;
                case ".csv":
                    fileHandler = new CsvFileHandler(FilePathStart);
                    break;
                case ".xml":
                    fileHandler = new XmlFileHandler(FilePathStart);
                    break;
                default:
                    throw new Exception($"File type not reconized for date: {date}");
            }
            return fileHandler.LoadFromFile(date);
        }