示例#1
0
        private static string GetValueFromToken(Tokenizer tokenizer, int index)
        {
            string strg = tokenizer[index].Trim();

            // April 26 2009 Change the previous commented chunk of code with the following
            // which considers all the characters instead of the first one

            if (strg.Length <= 0)
            {
                return "0";
            }

            foreach (char c in strg)
            {
                if (c == '.')
                {
                    continue;
                }

                if (c < '0' || c > '9')
                {
                    return "0";
                }
            }
            return strg;
        }
示例#2
0
        public static FractionCall Make(Tokenizer tokenizer, double distance, int positionIndex, int timeIndex, int lengthsIndex)
        {
            try
            {
                double time, lengths;
                int position;
                bool noDataAvailable;

                time = Convert.ToDouble(GetValueFromToken(tokenizer, timeIndex).Trim());
                position = Convert.ToInt32(GetValueFromToken(tokenizer, positionIndex).Trim());

                if (position > 0)
                {
                    lengths = Convert.ToDouble(GetValueFromToken(tokenizer, lengthsIndex).Trim());
                    noDataAvailable = NoDataAvailable(tokenizer, positionIndex);
                }
                else
                {
                    lengths = 0;
                    noDataAvailable = true;
                }
                return new FractionCall(distance, position, time, lengths, noDataAvailable);
            }
            catch
            {
                return new FractionCall(0, 0, 0, 0, true);
            }
        }
示例#3
0
 public static bool NoDataAvailable(Tokenizer tokenizer, int index)
 {
     string strg = tokenizer[index].Trim();
     if ((strg.Length <= 0) || (strg[0] >= 'A' && strg[0] <= 'Z'))
     {
         return true;
     }
     else
     {
         return false;
     }
 }
示例#4
0
        internal BrisHorse(Tokenizer tokenizer)
        {
            _parent = null;
            _parsableText = null;
            _tokenizer = tokenizer;

            string s;
            s = _tokenizer[FieldIndex.NUMBER_OF_DAYS_SINCE_LAST_RACE_FOR_TODAYS_RACE].Trim();
            _daysSinceLastRace = s.Length > 0 ? Convert.ToInt32(s) : 0;

            s = _tokenizer[FieldIndex.CLAIMING_PRICE_OF_HORSE].ToString().Trim();
            _claimingPriceOfTheHorseAsDouble = s.Length > 0 ? Convert.ToDouble(s) : 0.0;

            s = _tokenizer[FieldIndex.CLAIMING_PRICE_OF_RACE].ToString().Trim();
            _claimingPriceOfTheRaceAsDouble = s.Length > 0 ? Convert.ToDouble(s) : 0.0;

            _brisLateAvg = CalcBrisLateAvg();
            _brisCompositeLastThree = CalcBrisCompositeLastThree();
            _bestRating = CalcBestRating();
            _medication = GetMedication();
            _isFirstTimeLasix = Medication.Trim().CompareTo("FL") == 0;
            _brisRunStyle = _tokenizer[FieldIndex.BRIS_RUN_STYLE].ToString();
            _quirinSpeedPoints = CalcQuirinSpeedPoints();
            _primePowerRating = CalcPrimePowerRating();
            if (_tokenizer[FieldIndex.EQUIPMENT_CHANGE].Length > 0)
            {
                _equipment = Convert.ToInt32(_tokenizer[FieldIndex.EQUIPMENT_CHANGE]);
            }
            _currentYearEarnings = GetCurrentYearEarnings();
            _todaysTrackEarnings = GetTodaysTrackEarnings();

            if (_tokenizer[FieldIndex.WEIGHT].Length > 0)
            {
                _weight = Convert.ToInt32(_tokenizer[FieldIndex.WEIGHT].ToString());
            }
            _todaysRaceIsARoute = GetTodaysRaceIsARoute();
            _todaysRaceIsInTurf = GetTodaysRaceIsInTurf();
            _isSynthetic = GetTodaysRaceIsSynthetic();
            _age = GetAge();

            string postTimeStr = _tokenizer[FieldIndex.POST_TIME].ToString();

            _postTime = ConvertPacificMilitaryTimeToEastern(_tokenizer[FieldIndex.POST_TIME].ToString());
        }
示例#5
0
        internal BrisPastPerformance(Tokenizer tokenizer, int index, BrisHorse parent)
        {
            _pt = null;
            _index = index;
            _parent = parent;
            _tokenizer = tokenizer;

            {
                string d = GetToken(FieldIndex.DATE + _index);

                if (d.Length <= 0)
                {
                    _dateAsString = "";
                    _isValid = false;
                    return;
                }
                else
                {
                    int year = Convert.ToInt32(d.Substring(0, 4));
                    int month = Convert.ToInt32(d.Substring(4, 2));
                    int day = Convert.ToInt32(d.Substring(6, 2));

                    if (day < 10)
                    {
                        _dateAsString = " " + day.ToString() + Utilities.GetMonthName(month) + year.ToString().Substring(2, 2);
                    }
                    else
                    {
                        _dateAsString = day.ToString() + Utilities.GetMonthName(month) + year.ToString().Substring(2, 2);
                    }
                }
            }

            _brisRaceShapeFirstCall = GetToken(FieldIndex.BRIS_RACE_SHAPE_FIRST_CALL + _index).Trim();
            _brisRaceShapeSecondCall = GetToken(FieldIndex.BRIS_RACE_SHAPE_SECOND_CALL + _index).Trim();
            _thirdFractionInYards = GetFractionInYardsUsingItsTiming(GetToken(FieldIndex.THIRD_FRACTION + _index).Trim());
            _secondFractionInYards = GetFractionInYardsUsingItsTiming(GetToken(FieldIndex.SECOND_FRACTION + _index).Trim());
            _firstFractionInYards = GetFractionInYardsUsingItsTiming(GetToken(FieldIndex.FIRST_FRACTION + _index).Trim());
            _firstCallPosition = ConvertNonNumericPositionToZero(GetToken(FieldIndex.FIRST_CALL_POSITION + _index));
            _firstCallDistanceFromLeader = ConvertToDistanceFraction(GetToken(FieldIndex.FIRST_CALL_LENGTHS + _index));
            _secondCallPosition = ConvertNonNumericPositionToZero(GetToken(FieldIndex.SECOND_CALL_POSITION + _index));
            _secondCallDistanceFromLeader = ConvertToDistanceFraction(GetToken(FieldIndex.SECOND_CALL_LENGTHS + _index));
            _stretchCallPosition = ConvertNonNumericPositionToZero(GetToken(FieldIndex.STRETCH_POSITION + _index));
            _stretchCallDistanceFromLeader = ConvertToDistanceFraction(GetToken(FieldIndex.STRETCH_LENGTHS + _index));

            {
                string s = GetToken(FieldIndex.DAYS_SINCE_LAST + _index);

                if (s.Length <= 0)
                {
                    _daysSinceLastRace = 0;
                }
                else
                {
                    _daysSinceLastRace = Convert.ToInt32(s);
                }
            }

            try
            {
                int fieldIndex = IsASprint ? FieldIndex.BRIS_2_FURLONG_PACE_FIGURE : FieldIndex.BRIS_4_FURLONG_PACE_FIGURE;
                string s = GetToken(fieldIndex + _index).Trim();
                _brisEarlyPace = s.Length > 0 ? Convert.ToInt32(s) : 0;
            }
            catch
            {
                _brisEarlyPace = 0;
            }

            try
            {
                string s = GetToken(FieldIndex.BRIS_LATE_PACE_FIGURE + _index).Trim();
                _brisLatePace = s.Length > 0 ? Convert.ToInt32(s) + BrisSpeedRatingAsInteger : 0;
            }
            catch
            {
                _brisLatePace = 0;
            }

            {
                string s = GetToken(FieldIndex.BRIS_RACE_RATING + _index).Trim();
                _brisRaceRating = s.Length > 0 ? Convert.ToDouble(s) : -1.0;
            }

            {
                string s = GetToken(FieldIndex.BRIS_CLASS_RATING + _index).Trim();
                _brisClassRating = s.Length > 0 ? Convert.ToDouble(s) : -1.0;
            }

            {
                string s = GetToken(FieldIndex.BRIS_SPEED_RATING + _index).Trim();
                _brisSpeedRatingAsInteger = s.Length > 0 ? Convert.ToInt32(s) : 0;
            }

            _brisSpeedRating = GetToken(FieldIndex.BRIS_SPEED_RATING + _index);
            _finalPosition = ConvertNonNumericPositionToZero(GetToken(FieldIndex.FINISH_POSITION + _index));

            {
                string s = GetToken(FieldIndex.FINISH_LENGTHS + _index).Trim();
                _rawFinalCallDistanceFromLeader = s.Length > 0 ? Convert.ToDouble(s) : 0;
            }

            _finalCallDistanceFromLeader = ConvertToDistanceFraction(GetToken(FieldIndex.FINISH_LENGTHS + _index));
            _trackCondition = GetToken(FieldIndex.TRACK_CONDITION + _index).ToLower();
            _numberOfEntrants = GetToken(FieldIndex.NUMBER_OF_ENTRANTS + _index);
            _postPosition = GetToken(FieldIndex.POST_POSITION + _index);
            _startCallPosition = ConvertNonNumericPositionToZero(GetToken(FieldIndex.START_CALL_POSITION + _index));
            _jockey = Utilities.CapitalizeOnlyFirstLetter((GetToken(FieldIndex.JOCKEY + _index)));
            _raceType = Utilities.CapitalizeOnlyFirstLetter((GetToken(FieldIndex.RACE_TYPE + _index)));
            _ageSexRestrictions = (GetToken(FieldIndex.AGE_SEX_RESTRICTIONS + _index));
            _ageSexRestrictions += "    ";
            {
                string s = GetToken(FieldIndex.FAVORITE_INDICATOR + _index);
                s = s.Trim();
                _wasTheFavorite = s.Length > 0 ? s[0] == '1' : false;
            }

            {
                string s = GetToken(FieldIndex.STATE_BRED_FLAG + _index);
                s = s.Trim().ToUpper();
                _stateBredRestrictedRace = s.Length > 0 ? s[0] == 'S' : false;
            }

            if (WasTheFavorite)
            {
                _odds = "*" + GetToken(FieldIndex.ODDS + _index);
            }
            else
            {
                _odds = GetToken(FieldIndex.ODDS + _index);
            }

            {
                double od = 0;
                double.TryParse(GetToken(FieldIndex.ODDS + _index), out od);
                OddsAsDouble = od;
            }

            _equipment = GetToken(FieldIndex.EQUIPMENT + _index);

            if (null == GetToken(FieldIndex.MEDICATION + _index))
            {
                _medication = "";
            }
            else
            {
                string s = GetToken(FieldIndex.MEDICATION + _index).Trim();
                if (s.Length <= 0)
                {
                    _medication = "";
                }
                else
                {
                    switch (Convert.ToInt32(GetToken(FieldIndex.MEDICATION + _index)))
                    {
                        case 1:
                            _medication = "L";
                            break;
                        case 2:
                            _medication = "B";
                            break;
                        case 3:
                            _medication = "BL";
                            break;
                        default:
                            _medication = "";
                            break;
                    }
                }
            }

            _tripComment = GetToken(FieldIndex.TRIP_COMMENT + _index);
            _weight = GetToken(FieldIndex.WEIGHT + _index);

            _raceClassification = GetToken(FieldIndex.RACE_CLASSIFICATION + _index).ToLower();
            _raceClassification = _raceClassification.Replace("clm", "Clm").Replace("alw", "Alw").Replace("hcp", "Hcp").Replace("md", "Md").Replace("Mdspwt", "MdSpWt").Replace("oc", "OC");
            {
                string p = GetToken(FieldIndex.CLAIMING_PRICE + _index).Trim();
                _claimingPrice = p.Length > 0 ? Convert.ToDouble(p) : 0.0;
            }

            {
                string p = GetToken(FieldIndex.MAX_CLAIMING_PRICE_OF_THE_RACE + _index).Trim();
                _maxClaimingPriceOfTheRace = p.Length > 0 ? Convert.ToDouble(p) : 0.0;
            }

            if (RaceClassification.ToUpper().IndexOf("MDSPWT") >= 0)
            {
                _isMSW = true;
            }
            else if (RaceClassification.ToUpper().IndexOf("MD SP WT") >= 0)
            {
                _isMSW = true;
            }
            else if (RaceClassification.ToUpper().IndexOf("MSW") >= 0)
            {
                _isMSW = true;
            }
            else
            {
                _isMSW = false;
            }

            if (RaceClassification.ToUpper().IndexOf("MDSPWT") >= 0)
            {
                _isMCL = false;
            }
            else if (RaceClassification.ToUpper().IndexOf("MD SP WT") >= 0)
            {
                _isMCL = false;
            }
            else if (RaceClassification.ToUpper().IndexOf("MD") >= 0)
            {
                _isMCL = true;
            }
            else if (RaceClassification.ToUpper().IndexOf("MCL") >= 0)
            {
                _isMCL = true;
            }
            else
            {
                _isMCL = false;
            }

            {
                string s = GetToken(FieldIndex.SURFACE + _index);
                if (s.Length <= 0)
                {
                    _surface = "";
                }
                else if (s[0] == 'D')
                {
                    _surface = "";
                }
                else if (s[0] == 'T')
                {
                    _surface = "T";
                }
                else if (s[0] == 'd')
                {
                    _surface = "id";
                }
                else if (s[0] == 't')
                {
                    _surface = "iT";
                }
                else if (s[0] == 's')
                {
                    _surface = "s";
                }
                else if (s[0] == 'h')
                {
                    _surface = "h";
                }
                else
                {
                    _surface = "";
                }
            }

            {
                string rn = GetToken(FieldIndex.RACE_NUMBER + _index);
                _raceNumber = rn.Length <= 1 ? " " + rn : rn;
            }

            try
            {
                string d = GetToken(FieldIndex.DATE + _index).Trim();

                int year = Convert.ToInt32(d.Substring(0, 4));
                int month = Convert.ToInt32(d.Substring(4, 2));
                int day = Convert.ToInt32(d.Substring(6, 2));
                _date = new DateTime(year, month, day);
            }
            catch
            {
                _date = DateTime.Now;
            }

            {
                string rt = GetToken(FieldIndex.RACE_TRACK + _index);
                if (rt.Length <= 2)
                {
                    _raceTrack = rt + " ";
                }
                else
                {
                    _raceTrack = Utilities.CapitalizeOnlyFirstLetter(GetToken(FieldIndex.RACE_TRACK + _index));
                }
            }

            {
                string s = GetToken(FieldIndex.DISTANCE + _index);
                _aboutDistanceFlag = false;

                if (s.Length <= 0)
                {
                    _distanceAbreviation = "Invalid";
                }
                else
                {
                    int yards = Convert.ToInt32(GetToken(FieldIndex.DISTANCE + _index));
                    if (yards < 0)
                    {
                        _aboutDistanceFlag = true;
                        yards = (-1)*yards;
                    }

                    _distanceAbreviation = Utilities.ConvertYardsToMilesOrFurlongsAbreviation(yards);
                }
            }

            {
                string s = GetToken(FieldIndex.SURFACE + _index);
                if (s.Length <= 0)
                {
                    _isATurfRace = false;
                }
                else if (s[0] == 'T' || s[0] == 't')
                {
                    _isATurfRace = true;
                }
                else
                {
                    _isATurfRace = false;
                }

                _surfaceType = SurfaceType.Dirt;

                if (s.Length > 0)
                {
                    if (s[0] == 'T')
                    {
                        _surfaceType = SurfaceType.Turf;
                    }
                    else if (s[0] == 't')
                    {
                        _surfaceType = SurfaceType.InnerTurf;
                    }
                    else if (s[0] == 'd')
                    {
                        _surfaceType = SurfaceType.InnerDirt;
                    }
                    else
                    {
                        _surfaceType = SurfaceType.Dirt;
                    }
                }
            }

            {
                string s = GetToken(FieldIndex.SURFACE + _index);
                if (s.Length <= 0)
                {
                    _isSynthetic = false;
                }
                else if (s[0] == 'S' || s[0] == 's')
                {
                    _isSynthetic = true;
                }
                else
                {
                    _isSynthetic = false;
                }
            }

            {
                string s = GetToken(FieldIndex.MONEY_POSITION + _index);
                try
                {
                    int p = Convert.ToInt32(s.Trim());
                    _wasTheWinner = (p == 1);
                }
                catch
                {
                    _wasTheWinner = false;
                }
            }

            {
                string s = GetToken(FieldIndex.DISTANCE + _index).Trim();
                _distanceInYards = s.Length > 0 ? Convert.ToInt32(s) : 0;

                if (_distanceInYards < 0)
                    _distanceInYards = (-1)*_distanceInYards;
            }

            _isARoute = ((double) DistanceInYards) >= Hogar.Utilities.MIN_DISTANCE_FOR_ROUTE;
            _isASprint = ((double) DistanceInYards) < Hogar.Utilities.MIN_DISTANCE_FOR_ROUTE;

            {
                if (GetToken(FieldIndex.DISTANCE + _index).Trim().Length > 0)
                {
                    _distance = Utilities.ConvertYardsToMilesOrFurlongs(_distanceInYards);
                }
                else
                {
                    _distance = "";
                }
            }

            _leadersFirstCall = Utilities.ConvertTimeToMMSSFifth(GetToken(FieldIndex.FIRST_FRACTION + _index));
            _leadersSecondCall = Utilities.ConvertTimeToMMSSFifth(GetToken(FieldIndex.SECOND_FRACTION + _index));
            _leadersThirdCall = Utilities.ConvertTimeToMMSSFifth(GetToken(FieldIndex.THIRD_FRACTION + _index));
            _leadersFinalCall = Utilities.ConvertTimeToMMSSFifth(GetToken(FieldIndex.FINAL_TIME + _index));

            _fraction[FractionCall.Level.First] = FractionCall.Make(tokenizer, _firstFractionInYards, FieldIndex.FIRST_CALL_POSITION + _index, FieldIndex.FIRST_FRACTION + _index, FieldIndex.FIRST_CALL_LENGTHS + _index);
            _fraction[FractionCall.Level.Second] = FractionCall.Make(tokenizer, _secondFractionInYards, FieldIndex.START_CALL_POSITION + _index, FieldIndex.SECOND_FRACTION + _index, FieldIndex.SECOND_CALL_LENGTHS + _index);
            _fraction[FractionCall.Level.Stretch] = FractionCall.Make(tokenizer, _thirdFractionInYards, FieldIndex.STRETCH_POSITION + _index, FieldIndex.THIRD_FRACTION + _index, FieldIndex.STRETCH_LENGTHS + _index);
            _fraction[FractionCall.Level.Final] = FractionCall.Make(tokenizer, _distanceInYards, FieldIndex.FINISH_POSITION + _index, FieldIndex.FINAL_TIME + _index, FieldIndex.FINISH_LENGTHS + _index);

            _isValid = true;
        }
示例#6
0
        public BrisWorkouts(Tokenizer tokenizer)
        {
            _tokenizer = tokenizer;

            PopulateWorkouts();
        }
示例#7
0
 public static Workout Make(Tokenizer tokenizer, int index)
 {
     var w = new Workout();
     w._date = tokenizer[FieldIndex.DATE + index].Trim();
     w._time = tokenizer[FieldIndex.TIME + index].Trim();
     w._track = tokenizer[FieldIndex.TRACK + index].Trim();
     w._distance = tokenizer[FieldIndex.DISTANCE + index].Trim();
     w._trackCondition = tokenizer[FieldIndex.TRACK_CONDITION + index].Trim();
     w._description = tokenizer[FieldIndex.DESCRIPTION + index].Trim();
     w._mainOrInnerTrackIndicator = tokenizer[FieldIndex.TRACK_INDICATOR + index].Trim();
     w._numberOfWorkoutsThatDayOnDistance = tokenizer[FieldIndex.NUMBER_OF_WORKOUTS + index].Trim();
     w._rankOfWorkout = tokenizer[FieldIndex.RANK + index].Trim();
     return (w._date.Length > 0 && w._distance.Length > 0) ? w : null;
 }