Beispiel #1
0
        public void ConvertHorses(Latekick.BOL.Latekick.Race race, XElement xeHorses)
        {
            DataTable dtEntries = RaceDAL.GetEntries(xeHorses);

            race.RaceInfo.NumberOfHorses = dtEntries.Rows.Count;
            race.Entry = new Entry[race.RaceInfo.NumberOfHorses];

            int e = 0;

            #region entry + stats
            foreach (DataRow dr in dtEntries.Rows)
            {
                Latekick.BOL.Latekick.Entry entry = new Latekick.BOL.Latekick.Entry();
                entry.HorseName = dr.ItemArray[dtEntries.Columns.IndexOf("HorseName")].ToString();
                try { entry.Draw = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Draw")].ToString()); }
                catch { }
                entry.SaddleClothNo = dr.ItemArray[dtEntries.Columns.IndexOf("SaddleClothNo")].ToString();
                entry.JockeyName    = dr.ItemArray[dtEntries.Columns.IndexOf("JockeyName")].ToString();
                entry.TrainerName   = dr.ItemArray[dtEntries.Columns.IndexOf("TrainerName")].ToString();
                entry.OwnerName     = dr.ItemArray[dtEntries.Columns.IndexOf("OwnerName")].ToString();
                try { entry.Weight = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Weight")].ToString()); }
                catch { }
                //entry.ApprenticeAllowance = -1;
                entry.Equipment  = dr.ItemArray[dtEntries.Columns.IndexOf("Equipment")].ToString();
                entry.Medication = dr.ItemArray[dtEntries.Columns.IndexOf("Medication")].ToString();
                entry.Sire       = dr.ItemArray[dtEntries.Columns.IndexOf("Sire")].ToString();
                entry.Dam        = dr.ItemArray[dtEntries.Columns.IndexOf("Dam")].ToString();
                entry.DamSire    = dr.ItemArray[dtEntries.Columns.IndexOf("DamSire")].ToString();
                entry.Gender     = dr.ItemArray[dtEntries.Columns.IndexOf("Gender")].ToString();
                //entry.Age = race.RaceDate.Year - (brisentry.YearOfBirth + (brisentry.YearOfBirth > 90 ? 1900 : 2000));
                try { entry.ML = double.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("ML")].ToString()); }
                catch { }
                entry.ProjectedRatings = new ProjectedRatings();
                entry.RunningStyle     = new RunningStyle();

                entry.Stats = new Stats();

                try { entry.Stats.LifeTime_Runs = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Lifetime_Runs")].ToString()); }
                catch { }
                try { entry.Stats.LifeTime_Win = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Lifetime_Win")].ToString()); }
                catch { }
                try { entry.Stats.LifeTime_Place = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Lifetime_Place")].ToString()); }
                catch { }
                try { entry.Stats.LifeTime_Show = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Lifetime_Show")].ToString()); }
                catch { }

                try { entry.Stats.ThisYear_Runs = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_ThisYear_Runs")].ToString()); }
                catch { }
                try { entry.Stats.ThisYear_Win = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_ThisYear_Win")].ToString()); }
                catch { }
                try { entry.Stats.ThisYear_Place = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_ThisYear_Place")].ToString()); }
                catch { }
                try { entry.Stats.ThisYear_Show = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_ThisYear_Show")].ToString()); }
                catch { }

                try { entry.Stats.LastYear_Runs = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_LastYear_Runs")].ToString()); }
                catch { }
                try { entry.Stats.LastYear_Win = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_LastYear_Win")].ToString()); }
                catch { }
                try { entry.Stats.LastYear_Place = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_LastYear_Place")].ToString()); }
                catch { }
                try { entry.Stats.LastYear_Show = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_LastYear_Show")].ToString()); }
                catch { }

                try { entry.Stats.Course_Runs = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Course_Runs")].ToString()); }
                catch { }
                try { entry.Stats.Course_Win = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Course_Win")].ToString()); }
                catch { }
                try { entry.Stats.Course_Place = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Course_Place")].ToString()); }
                catch { }
                try { entry.Stats.Course_Show = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Course_Show")].ToString()); }
                catch { }

                try { entry.Stats.Dirt_Runs = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Dirt_Runs")].ToString()); }
                catch { }
                try { entry.Stats.Dirt_Win = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Dirt_Win")].ToString()); }
                catch { }
                try { entry.Stats.Dirt_Place = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Dirt_Place")].ToString()); }
                catch { }
                try { entry.Stats.Dirt_Show = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Dirt_Show")].ToString()); }
                catch { }

                try { entry.Stats.Turf_Runs = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Turf_Runs")].ToString()); }
                catch { }
                try { entry.Stats.Turf_Win = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Turf_Win")].ToString()); }
                catch { }
                try { entry.Stats.Turf_Place = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Turf_Place")].ToString()); }
                catch { }
                try { entry.Stats.Turf_Show = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Turf_Show")].ToString()); }
                catch { }

                try { entry.Stats.AW_Runs = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_AW_Runs")].ToString()); }
                catch { }
                try { entry.Stats.AW_Win = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_AW_Win")].ToString()); }
                catch { }
                try { entry.Stats.AW_Place = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_AW_Place")].ToString()); }
                catch { }
                try { entry.Stats.AW_Show = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_AW_Show")].ToString()); }
                catch { }

                try { entry.Stats.Wet_Runs = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Mud_Runs")].ToString()) + int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Soft_Runs")].ToString()); }
                catch { }
                try { entry.Stats.Wet_Win = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Mud_Win")].ToString()) + int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Soft_Win")].ToString()); }
                catch { }
                try { entry.Stats.Wet_Place = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Mud_Place")].ToString()) + int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Soft_Place")].ToString()); }
                catch { }
                try { entry.Stats.Wet_Show = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Mud_Show")].ToString()) + int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Soft_Show")].ToString()); }
                catch { }

                try { entry.Stats.Distance_Runs = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_DistanceDirt_Runs")].ToString()) + int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_DistanceTurf_Runs")].ToString()); }
                catch { }
                try { entry.Stats.Distance_Win = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_DistanceDirt_Win")].ToString()) + int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_DistanceTurf_Win")].ToString()); }
                catch { }
                try { entry.Stats.Distance_Place = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_DistanceDirt_Place")].ToString()) + int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_DistanceTurf_Place")].ToString()); }
                catch { }
                try { entry.Stats.Distance_Show = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_DistanceDirt_Show")].ToString()) + int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_DistanceTurf_Show")].ToString()); }
                catch { }

                try { entry.Stats.Jockey_30d_Runs = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Jockey_30d_Runs")].ToString()); }
                catch { }
                try { entry.Stats.Jockey_30d_Win = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Jockey_30d_Win")].ToString()); }
                catch { }
                try { entry.Stats.Jockey_30d_Place = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Jockey_30d_Place")].ToString()); }
                catch { }
                try { entry.Stats.Jockey_30d_Show = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Jockey_30d_Show")].ToString()); }
                catch { }

                try { entry.Stats.Trainer_30d_Runs = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Trainer_30d_Runs")].ToString()); }
                catch { }
                try { entry.Stats.Trainer_30d_Win = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Trainer_30d_Win")].ToString()); }
                catch { }
                try { entry.Stats.Trainer_30d_Place = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Trainer_30d_Place")].ToString()); }
                catch { }
                try { entry.Stats.Trainer_30d_Show = int.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Trainer_30d_Show")].ToString()); }
                catch { }

                entry.Earnings = new Earnings();
                try { entry.Earnings.EarningsLifeTime = (int)double.Parse(dr.ItemArray[dtEntries.Columns.IndexOf("Stats_Lifetime_Earnings")].ToString()); }
                catch { }

                race.Entry[e] = entry;
                e++;
            }
            #endregion
        }
Beispiel #2
0
        public void ConvertHorses(List <Latekick.BOL.Brisnet.Bris_Entry> entries)
        {
            foreach (Latekick.BOL.Latekick.Race race in LK.Race)
            {
                var entries_thisrace = from brisentry in entries
                                       where brisentry.RaceNumber == int.Parse(race.RaceNumber)
                                       orderby brisentry.SaddleCloth ascending
                                       select brisentry;
                race.RaceInfo.NumberOfHorses = entries_thisrace.Count();
                race.Entry = new Entry[race.RaceInfo.NumberOfHorses];

                int e = 0;
                foreach (Latekick.BOL.Brisnet.Bris_Entry brisentry in entries_thisrace)
                {
                    Latekick.BOL.Latekick.Entry entry = new Latekick.BOL.Latekick.Entry();
                    if (Enum.IsDefined(typeof(State), brisentry.BreedingLocation))
                    {
                        entry.HorseName = brisentry.HorseName;
                    }
                    else
                    {
                        entry.HorseName = brisentry.HorseName + " (" + brisentry.BreedingLocation + ")";
                    }
                    entry.Draw                = brisentry.Draw;
                    entry.SaddleClothNo       = brisentry.SaddleCloth;
                    entry.JockeyName          = brisentry.JockeyName;
                    entry.TrainerName         = brisentry.TrainerName;
                    entry.OwnerName           = brisentry.OwnerName;
                    entry.Weight              = brisentry.HorseWeight;
                    entry.ApprenticeAllowance = brisentry.ApprenticeAllowance;
                    entry.Equipment           = ParseEquipmentCode(brisentry.EquipmentChange);
                    entry.Medication          = ParseMedicationCode(brisentry.Medication1);
                    entry.Sire                = brisentry.Sire;
                    entry.Dam                        = brisentry.Dam;
                    entry.DamSire                    = brisentry.DamSire;
                    entry.Gender                     = brisentry.Gender;
                    entry.Age                        = race.RaceDate.Year - (brisentry.YearOfBirth + (brisentry.YearOfBirth > 90 ? 1900 : 2000));
                    entry.ML                         = brisentry.ML;
                    entry.ProjectedRatings           = new ProjectedRatings();
                    entry.RunningStyle               = new RunningStyle();
                    entry.RunningStyle.RunStyle_BRIS = brisentry.RunStyle;

                    entry.Stats = new Stats();
                    entry.Stats.LifeTime_Runs  = brisentry.Horse_LifeTime_Starts;
                    entry.Stats.LifeTime_Win   = brisentry.Horse_LifeTime_Win;
                    entry.Stats.LifeTime_Place = brisentry.Horse_LifeTime_Place;
                    entry.Stats.LifeTime_Show  = brisentry.Horse_LifeTime_Show;

                    entry.Stats.ThisYear_Runs  = brisentry.Horse_CurrentYear_Starts;
                    entry.Stats.ThisYear_Win   = brisentry.Horse_CurrentYear_Win;
                    entry.Stats.ThisYear_Place = brisentry.Horse_CurrentYear_Place;
                    entry.Stats.ThisYear_Show  = brisentry.Horse_CurrentYear_Show;

                    entry.Stats.LastYear_Runs  = brisentry.Horse_LastYear_Starts;
                    entry.Stats.LastYear_Win   = brisentry.Horse_LastYear_Win;
                    entry.Stats.LastYear_Place = brisentry.Horse_LastYear_Place;
                    entry.Stats.LastYear_Show  = brisentry.Horse_LastYear_Show;

                    entry.Stats.Course_Runs  = brisentry.Horse_Track_Starts;
                    entry.Stats.Course_Win   = brisentry.Horse_Track_Win;
                    entry.Stats.Course_Place = brisentry.Horse_Track_Place;
                    entry.Stats.Course_Show  = brisentry.Horse_Track_Show;

                    entry.Stats.Dirt_Runs  = 0;
                    entry.Stats.Dirt_Win   = 0;
                    entry.Stats.Dirt_Place = 0;
                    entry.Stats.Dirt_Show  = 0;

                    entry.Stats.Turf_Runs  = brisentry.Horse_Turf_Starts;
                    entry.Stats.Turf_Win   = brisentry.Horse_Turf_Win;
                    entry.Stats.Turf_Place = brisentry.Horse_Turf_Place;
                    entry.Stats.Turf_Show  = brisentry.Horse_Turf_Show;

                    entry.Stats.AW_Runs  = brisentry.Horse_LifeTime_AW_Starts;
                    entry.Stats.AW_Win   = brisentry.Horse_LifeTime_AW_Win;
                    entry.Stats.AW_Place = brisentry.Horse_LifeTime_AW_Place;
                    entry.Stats.AW_Show  = brisentry.Horse_LifeTime_AW_Show;

                    entry.Stats.Wet_Runs  = brisentry.Horse_Wet_Starts;
                    entry.Stats.Wet_Win   = brisentry.Horse_Wet_Win;
                    entry.Stats.Wet_Place = brisentry.Horse_Wet_Place;
                    entry.Stats.Wet_Show  = brisentry.Horse_Wet_Show;

                    entry.Stats.Distance_Runs  = brisentry.Horse_Distance_Starts;
                    entry.Stats.Distance_Win   = brisentry.Horse_Distance_Win;
                    entry.Stats.Distance_Place = brisentry.Horse_Distance_Place;
                    entry.Stats.Distance_Show  = brisentry.Horse_Distance_Show;

                    entry.Stats.Jockey_LastYear  = brisentry.Jockey_LastYear;
                    entry.Stats.Jockey_ThisYear  = brisentry.Jockey_ThisYear;
                    entry.Stats.Trainer_LastYear = brisentry.Trainer_LastYear;
                    entry.Stats.Trainer_ThisYear = brisentry.Trainer_ThisYear;

                    entry.Stats.Trainer_Runs_Meet  = brisentry.TrainerStarts;
                    entry.Stats.Trainer_Win_Meet   = brisentry.TrainerWin;
                    entry.Stats.Trainer_Place_Meet = brisentry.TrainerPlace;
                    entry.Stats.Trainer_Show_Meet  = brisentry.TrainerShow;

                    entry.Stats.Jockey_Runs_Meet  = brisentry.JockeyStarts;
                    entry.Stats.Jockey_Win_Meet   = brisentry.JockeyWin;
                    entry.Stats.Jockey_Place_Meet = brisentry.JockeyPlace;
                    entry.Stats.Jockey_Show_Meet  = brisentry.JockeyShow;

                    entry.Earnings = new Earnings();
                    entry.Earnings.EarningsLifeTime = brisentry.Horse_LifeTime_Earnings;


                    var lWorkouts = new List <Workout>();
                    for (int w = 1; w <= 12; w++)
                    {
                        Workout liWork = new Workout();
                        liWork.WorkDate = DateTime.Parse(brisentry.GetType().GetField("WorkDate_" + w).GetValue(brisentry).ToString());

                        if (liWork.WorkDate == new DateTime(1974, 12, 3))
                        {
                            break;
                        }

                        liWork.WorkTrack       = brisentry.GetType().GetField("WorkTrack_" + w).GetValue(brisentry).ToString();
                        liWork.WorkSurface     = ParseSurfaceType(brisentry.GetType().GetField("WorkSurface_" + w).GetValue(brisentry).ToString());
                        liWork.WorkDistance    = Math.Abs(Math.Round(double.Parse(brisentry.GetType().GetField("WorkDistance_" + w).GetValue(brisentry).ToString()) / 220, 1));
                        liWork.WorkGoing       = brisentry.GetType().GetField("WorkGoing_" + w).GetValue(brisentry).ToString().ToUpper();
                        liWork.WorkDescription = brisentry.GetType().GetField("WorkDescription_" + w).GetValue(brisentry).ToString();
                        liWork.WorkTime        = Math.Abs(double.Parse(brisentry.GetType().GetField("WorkTime_" + w).GetValue(brisentry).ToString()));
                        liWork.WorkRank        = brisentry.GetType().GetField("WorkRank_" + w).GetValue(brisentry).ToString() + "/" + brisentry.GetType().GetField("WorkCount_" + w).GetValue(brisentry).ToString();

                        lWorkouts.Add(liWork);
                    }
                    Latekick.BOL.Latekick.Workouts workouts = new Latekick.BOL.Latekick.Workouts();
                    workouts.Workout = lWorkouts.ToArray();

                    if (lWorkouts.Count == 0)
                    {
                        entry.Workouts         = new Workouts();
                        entry.Workouts.Workout = new Workout[0] {
                        };
                    }
                    else
                    {
                        entry.Workouts = workouts;
                    }

                    race.Entry[e] = entry;
                    e++;
                }
            }
        }