Ejemplo n.º 1
0
        public static string Read(string file, int?project = null, bool sortbystartdate = false)
        {
            try
            {
                int noOfValueRows;
                //Read the .txt file into data columns.
                var fileDataColumns = FileReader.ReadFileData(file, out noOfValueRows);
                //Create objects out of input data.
                var productData = FileDataHandler.DataToObjects <ProductData>(fileDataColumns, noOfValueRows);

                //Filter data.
                if (project.HasValue)
                {
                    productData = FileDataHandler.FilterBy(productData, project.Value, pd => pd.Project);
                }

                //Sort data.
                if (sortbystartdate)
                {
                    productData = FileDataHandler.SortBy(productData, pd => pd.StartDate, false);
                }

                return(CreateProductDataOutput(productData, fileDataColumns));
            }
            catch (InputException ex)
            {
                throw ex;
            }
        }