Esempio n. 1
0
        public FileDataset ParseIntoFileDataset(FileDatasetType datasetType, DateTime monthOfDataset)
        {
            var peopleWithScores = new List <PersonWithScores>();

            using (var reader = new StreamReader(FileName))
            {
                reader.ReadLine(); //ignore the first line as is just headers.

                //now read the rest of the file to the end and add people based on that.
                while (!reader.EndOfStream)
                {
                    var row = reader.ReadLine().Trim();
                    if (string.IsNullOrEmpty(row))
                    {
                        continue;
                    }

                    peopleWithScores.Add(new PersonWithScores(row));
                }
            }

            return(new FileDataset(peopleWithScores, FileName, datasetType, monthOfDataset));
        }
Esempio n. 2
0
        public FileDataset(List <PersonWithScores> peopleWithScores, string fullFileName, FileDatasetType datasetType, DateTime monthOfDataset)
        {
            this.PeopleWithScores = peopleWithScores;
            this.DatasetType      = datasetType;
            this.DateOfScores     = monthOfDataset;

            var fileName = Path.GetFileNameWithoutExtension(fullFileName);

            //filename format is sportname_export-1234567890.csv so can derive sportname and export date from it
            SportName = fileName.Split('_')[0];
        }
Esempio n. 3
0
        public FileDataset(List <PersonWithScores> peopleWithScores, string fullFileName, FileDatasetType datasetType)
        {
            this.PeopleWithScores = peopleWithScores;
            this.DatasetType      = datasetType;
            var fileName = Path.GetFileNameWithoutExtension(fullFileName);

            //assume scores are being done for last month, or the month before dependant on enum value.
            int datasetMonthOffset = datasetType == FileDatasetType.CurrentMonth ? -1 : -2;

            var lastmonth = DateTime.Now.AddMonths(datasetMonthOffset);

            DateOfScores = lastmonth;

            //filename format is sportname_export-1234567890.csv so can derive sportname and export date from it
            SportName = fileName.Split('_')[0];

            long epochSeconds = long.Parse(fileName.Split('-')[1]);
        }