Пример #1
0
        /// <summary>
        /// Import the times from <paramref name="fileName"/>
        /// </summary>
        /// <param name="fileName">file containing times</param>
        /// <param name="commonIo">common IO manager</param>
        /// <returns>collection of race times.</returns>
        public static List <RaceTimeType> Import(
            string fileName,
            ICommonIo commonIo)
        {
            List <RaceTimeType> rawImportedTimes = new List <RaceTimeType>();
            List <string>       rawTimes         = commonIo.ReadFile(fileName);

            if (rawTimes == null ||
                rawTimes.Count == 0)
            {
                return(rawImportedTimes);
            }

            foreach (string line in rawTimes)
            {
                string rawTime = ImportParkrunTimerFactory.TranslateRawTime(line);

                List <int> timeDetails = ImportParkrunTimerFactory.TranslateTimeString(rawTime);

                if (timeDetails.Count != ImportParkrunTimerFactory.NumberOfSectionsInATime)
                {
                    continue;
                }

                rawImportedTimes.Add(
                    ImportParkrunTimerFactory.CalculateTime(
                        timeDetails[1],
                        timeDetails[2]));
            }

            return(rawImportedTimes);
        }
Пример #2
0
        /// <summary>
        /// Import the times from <paramref name="fileName"/>
        /// </summary>
        /// <param name="fileName">file containing times</param>
        /// <param name="commonIo">common Io manager</param>
        /// <returns>collection of race times.</returns>
        public static List <RaceTimeType> Import(
            string fileName,
            ICommonIo commonIo)
        {
            List <RaceTimeType> rawImportedTimes = new List <RaceTimeType>();
            List <string>       rawTimes         = commonIo.ReadFile(fileName);

            if (rawTimes == null ||
                rawTimes.Count < 3)
            {
                return(rawImportedTimes);
            }

            char splitChar = ',';

            for (int index = 2; index < rawTimes.Count; ++index)
            {
                string[] resultLine = rawTimes[index].Split(splitChar);
                if (resultLine.Length == 3)
                {
                    RaceTimeType time = new RaceTimeType(resultLine[2]);
                    rawImportedTimes.Add(time);
                }
            }

            return(rawImportedTimes);
        }
Пример #3
0
        /// <summary>
        /// Import the times from <paramref name="fileName"/>
        /// </summary>
        /// <param name="fileName">file containing times</param>
        /// <param name="commonIo">common Io manager</param>
        /// <param name="logger">program logger</param>
        /// <returns>collection of race times.</returns>
        public static List <RawPositionResults> Import(
            string fileName,
            ICommonIo commonIo,
            IJHcLogger logger)
        {
            List <RawPositionResults> rawImportedPositions = new List <RawPositionResults>();
            List <string>             rawPositions         = commonIo.ReadFile(fileName);

            foreach (string positionAthleteData in rawPositions)
            {
                char splitChar = ',';

                string[] resultLine = positionAthleteData.Split(splitChar);

                // Ensure this line is not the first one and its valid.
                if (string.Equals(resultLine[0], StartString) ||
                    resultLine.Length != ImportParkrunPositionFactory.NumberOfSectionsInAValdEntry)
                {
                    continue;
                }

                // Ensure that the interesting data is not empty.
                if (string.IsNullOrEmpty(resultLine[0]) ||
                    string.IsNullOrEmpty(resultLine[1]) ||
                    !ResultsDecoder.IsPositionValue(resultLine[1]))
                {
                    continue;
                }

                int?position =
                    ResultsDecoder.ConvertPositionValue(
                        resultLine[1]);

                RawPositionResults result =
                    new RawPositionResults(
                        resultLine[0],
                        (int)position);

                rawImportedPositions.Add(result);
            }

            rawImportedPositions =
                rawImportedPositions
                .OrderBy(position => position.Position)
                .ToList();

            return(rawImportedPositions);
        }
Пример #4
0
        /// <summary>
        /// Import the times from <paramref name="fileName"/>
        /// </summary>
        /// <param name="fileName">file containing times</param>
        /// <param name="commonIo">common IO manager</param>
        /// <returns>collection of race times.</returns>
        public static List <RaceTimeType> Import(
            string fileName,
            ICommonIo commonIo)
        {
            List <RaceTimeType> rawImportedTimes = new List <RaceTimeType>();
            List <string>       rawTimes         = commonIo.ReadFile(fileName);

            if (rawTimes == null ||
                rawTimes.Count == 0)
            {
                return(rawImportedTimes);
            }

            foreach (string rawTime in rawTimes)
            {
                RaceTimeType time = new RaceTimeType(rawTime);
                rawImportedTimes.Add(time);
            }

            return(rawImportedTimes);
        }