Exemple #1
0
 public CynthiaParsForm(string trackCode, int distance, SippPastPerformance pp)
 {
     _trackCode = trackCode;
     _distance = distance;
     _pp = pp;
     _avgDailyVariant = GetAverageDailyVariantFromDb();
     _dailyVariant = _pp.TrackVariant;
     //_adjustedWinersTime = _pp.FinalTime - DiffInSeconds;
     //_adjustedThisHorseTime = _pp.ThisHorseFinalTime - DiffInSeconds;
     InitializeComponent();
 }
Exemple #2
0
 public RunAgainstForm(SippPastPerformance pp)
 {
     _pp = pp;
     InitializeComponent();
 }
Exemple #3
0
        public string CreateSippDailyCard(ShowMessageDelegate showMessage)
        {
            var sdc = SippDailyCard.Make(Utilities.MakeDateTime(_date), TrackCode);

            var jockeys = new List<string>();

            foreach (var race in _race)
            {
                showMessage(string.Format("Processing race number: {0}",race.RaceNumber));

                var r = SippRace.Make(race.RaceNumber,
                                      race.CorrespondingBrisRace.DistanceInYards,
                                      race.CorrespondingBrisRace.Surface,
                                      race.CorrespondingBrisRace.RaceClassification);

                foreach (var horse in race.Horses)
                {
                    if(!horse.Scratched)
                    {
                        showMessage(string.Format("Processing race number: {0} horse number {1}", race.RaceNumber,horse.ProgramNumber));

                        string jockey = horse.CorrespondingBrisHorse.Jockey;
                        string trainer = horse.CorrespondingBrisHorse.TrainersFullName;

                        if(!jockeys.Contains(jockey))
                        {
                            jockeys.Add(jockey);
                        }

                        var h = SippHorse.Make(horse.ProgramNumber,
                                               horse.Name,
                                               horse.MorningLineOdds.GetOddsToOne(),
                                               jockey,
                                               Utilities.CapitalizeOnlyFirstLetter(trainer),
                                               horse.CorrespondingBrisHorse.PrimePowerRating);

                        h.DaysOff = horse.CorrespondingBrisHorse.DaysSinceLastRace;
                        h.ComingFromLongLayOff = horse.FirstAfterLongLayoff;
                        h.ComingFromLayOff = horse.FirstAfterLayoff;
                        h.SecondOfLayoff = horse.SecondAfterLayoff;
                        h.ThirdOfLayoff = horse.ThirdAfterLayoff;
                        h.FirstTimeOut = horse.CorrespondingBrisHorse.IsFirstTimeOut;
                        h.HandicappingFactors.Clear();

                        h.JockeyStatistics = FactorStatisticManager.GlobalStatisticsPerJockey(jockey).ToString();
                        h.TrainerStatistics = FactorStatisticManager.GlobalStatisticsPerTrainer(trainer).ToString();
                        h.JockeyTrainerStatistics = FactorStatisticManager.GlobalStatisticsPerTrainerAndJockey(trainer, jockey).ToString();

                        /////  Records
                        h.LifeTimeRecord= horse.CorrespondingBrisHorse.LifeTimeEarnings;
                        h.CurrentYearRecord= horse.CorrespondingBrisHorse.CurrentYearEarnings;
                        h.PreviousYearRecord= horse.CorrespondingBrisHorse.PreviousYearEarnings;
                        h.TodaysTrackRecord= horse.CorrespondingBrisHorse.TodaysTrackEarnings;
                        h.WetTrackRecord= horse.CorrespondingBrisHorse.WetTrackEarnings;
                        h.TurfTrackRecord = horse.CorrespondingBrisHorse.TurfTrackEarnings;
                        h.TodaysDistanceRecord = horse.CorrespondingBrisHorse.TodaysDistanceEarnings;
                        h.ColorAgeAndSex = horse.CorrespondingBrisHorse.ColorAgeAndSex;
                        h.SireName = horse.CorrespondingBrisHorse.SireInfo;
                        h.Dam = horse.CorrespondingBrisHorse.DamInfo;
                        h.ClaimingPrice = horse.CorrespondingBrisHorse.ClaimingPriceOfTheHorse;
                        h.Owner = horse.CorrespondingBrisHorse.Owner;
                        h.OwnerSilks = horse.CorrespondingBrisHorse.OwnersSilks;
                        h.QuirinSpeedPoints = horse.CorrespondingBrisHorse.QuirinSpeedPoints;
                        h.RunningStyle = horse.CorrespondingBrisHorse.BrisRunStyle;
                        h.MedicationAndWeight = horse.CorrespondingBrisHorse.MedicationAndWeight;
                        h.PostPosition = horse.FinalPosition;

                        ////// Add sire info //////////////////////////
                        string sire1 = horse.CorrespondingBrisHorse.Sire;
                        string sire2 = horse.CorrespondingBrisHorse.DamSire;

                        int i = 0;
                        foreach (DataRow dr in Sire.GetSiresInfo(sire1, sire2).Rows)
                        {
                            var sippSire = new SippSire
                                               {
                                                   Name = dr["Name"].ToString(),
                                                   FirstTimeOutRating = dr["FTS"].ToString(),
                                                   MudRating = dr["MUD"].ToString(),
                                                   TurfRating = dr["TURF"].ToString(),
                                                   AllWeatherRating = dr["AWS"].ToString(),
                                                   AverageDistance = dr["DIST"].ToString()
                                               };

                            switch (i)
                            {
                                case 0:
                                    h.Sire = sippSire;
                                    break;
                                default:
                                    h.DamSire = sippSire;
                                    break;
                            }

                            ++i;
                        }

                        //////////////////////////////////////////////
                        foreach (var factorStatistic in horse.FactorStatisticsForHorse)
                        {
                            var sippHandicappingFactor = SippHandicappingFactor.Make(factorStatistic.Name);
                            sippHandicappingFactor.GeneralStats = SippHandicappingFactorStats.Make(factorStatistic.Starters,factorStatistic.WinPercent,factorStatistic.Roi, factorStatistic.IV);
                            var trainerStats = FactorStatisticManager.Get(factorStatistic.BitMask, horse.CorrespondingBrisHorse.TrainersFullName);
                            sippHandicappingFactor.TrainerStats = SippHandicappingFactorStats.Make(trainerStats.Starters, trainerStats.WinPercent, trainerStats.Roi, trainerStats.IV);
                            h.HandicappingFactors.Add(sippHandicappingFactor);
                        }

                        foreach (var pp in horse.CorrespondingBrisHorse.PastPerformances)
                        {
                            var sipp = new SippPastPerformance();

                            sipp.DaysSincePreviousRace = pp.DaysSinceLastRace;
                            sipp.DaysSinceTodaysRace = pp.DaysSinceThatRace ;
                            sipp.RacingDate = pp.Date;
                            sipp.RaceNumber = Convert.ToInt32(pp.RaceNumber);
                            sipp.TrackCode = pp.TrackCode;
                            sipp.TrackCondition = pp.TrackCondition;
                            sipp.Distance = pp.DistanceAbreviation;
                            sipp.DistanceInYards = pp.DistanceInYards;
                            sipp.AboutDistanceFlag = pp.AboutDistanceFlag;
                            sipp.Surface = pp.Surface;
                            sipp.RaceCondition = Utilities.FormatCondition(pp.RaceClassification, pp.IsStateBredRestrictedRace, pp.AgeSexRestrictions);
                            sipp.FirstCall = pp.LeadersFirstCall;
                            sipp.SecondCall = pp.LeadersSecondCall;
                            sipp.ThirdCall = pp.LeadersThirdCall;
                            sipp.FinalTime = pp.LeadersFinalCall;
                            sipp.WinnersFinalTime = pp.WinnersFinalTime;
                            sipp.ThisHorseFinalTime = pp.ThisHorseFinalTime;
                            sipp.PostPosition = Convert.ToInt32(pp.PostPosition);
                            sipp.FirstCallPosition = pp.FirstCallPosition;
                            sipp.SecondCallPosition = pp.SecondCallPosition;
                            sipp.ThirdCallPosition= pp.StretchCallPosition;
                            sipp.FinalPosition = pp.FinalPosition;
                            sipp.FirstCallLengthsBehind = pp.FirstCallDistanceFromLeader;
                            sipp.SecondCallLengthsBehind = pp.SecondCallDistanceFromLeader;
                            sipp.ThirdCallLengthsBehind = pp.StretchCallDistanceFromLeader  ;
                            sipp.FinalLengthsBehind = pp.FinalCallDistanceFromLeader;
                            sipp.TrackVariant = pp.TrackVariant;
                            sipp.SpeedFigure = pp.BrisSpeedRating;
                            sipp.Jockey = pp.Jockey.Length < 16 ? pp.Jockey : pp.Jockey.Substring(0, 15);
                            sipp.MedicationWeightEquipment = pp.Medication + pp.Weight + pp.Equipment;
                            sipp.Odds= pp.Odds;
                            sipp.FieldSize = Convert.ToInt32(pp.NumberOfEntrants);

                            sipp.WinnersName = Utilities.CapitalizeOnlyFirstLetter(pp.WinnersName);
                            sipp.SecondPlaceFinisherName = Utilities.CapitalizeOnlyFirstLetter(pp.SecondPlaceFinisherName);
                            sipp.ThirdPlaceFinisherName = Utilities.CapitalizeOnlyFirstLetter(pp.ThirdPlaceFinisherName);
                            h.PastPerformances.Add(sipp);
                        }

                        r.AddHorse(h);
                    }
                }

                sdc.AddRace(r);
            }

            //IEnumerable<ImpactValueStat> ImpactValues = JockeyStatistics.Get(jockey).AllStats,
            showMessage("Now Adding the Jockeys Stats");
            foreach (var jockey in jockeys)
            {
                showMessage(string.Format("adding jockey: {0} ", jockey));
                var s = sdc.GetJockeySummarizedStatistics(jockey);

                foreach (var ivs in JockeyStatistics.Get(jockey).AllStats)
                {
                    s.Add(new SippImpactValueStat
                              {
                                  Name = ivs.Name,
                                  IV = ivs.IV,
                                  Roi = ivs.ROI,
                                  Starters = ivs.Starters,
                                  WinPercentage = ivs.WinPercent
                              });
                }
            }

            if(!Directory.Exists(Utilities.SippFilesDirectory))
            {
                Directory.CreateDirectory(Utilities.SippFilesDirectory);
            }

            string filename = string.Format(@"{0}\sipp_{1}_{2}.xml", Utilities.SippFilesDirectory,TrackCode,_date);
            sdc.SaveToXml(filename);
            showMessage(string.Format("File {0} was created successfully", filename));
            return filename;
        }