Esempio n. 1
0
        public void ConvertWorkouts(Entry entry, XElement xeWorkouts)
        {
            DataTable dtWorkouts = RaceDAL.GetWorkouts(xeWorkouts);
            var       lWorkouts  = new List <Workout>();

            for (int w = 1; w <= dtWorkouts.Rows.Count; w++)
            {
                Workout liWork = new Workout();
                try
                {
                    liWork.WorkDate    = LK.RaceDate.AddDays(-int.Parse(dtWorkouts.Rows[w - 1].ItemArray[dtWorkouts.Columns.IndexOf("DaysBack")].ToString()));
                    liWork.WorkDaysAgo = dtWorkouts.Rows[w - 1].ItemArray[dtWorkouts.Columns.IndexOf("DaysBack")].ToString();
                    string worktext = dtWorkouts.Rows[w - 1].ItemArray[dtWorkouts.Columns.IndexOf("worktext")].ToString();

                    if (worktext.Substring(worktext.Length - 1) == "g")
                    {
                        liWork.WorkFromGate = 1;
                        worktext            = worktext.Substring(0, worktext.Length - 2);
                    }
                    if (worktext.Substring(worktext.Length - 1).ToUpper() == "H" || worktext.Substring(worktext.Length - 1).ToUpper() == "B")
                    {
                        liWork.WorkDescription = worktext.Substring(worktext.Length - 1, 1);
                    }
                    else
                    {
                        liWork.WorkDescription = "";
                        worktext = worktext + " ";
                    }
                    liWork.WorkTrack    = worktext.Substring(worktext.IndexOf(")") + 1, worktext.IndexOf(":") - worktext.IndexOf(")") - 1);;
                    liWork.WorkSurface  = worktext.Substring(worktext.IndexOf("(") - 1, 1);
                    liWork.WorkDistance = int.Parse(worktext.Substring(0, worktext.IndexOf("(") - 1));
                    liWork.WorkGoing    = worktext.Substring(worktext.IndexOf("(") + 1, 2);;

                    liWork.WorkTime = double.Parse(worktext.Substring(worktext.IndexOf(":") + 1, worktext.Length - worktext.IndexOf(":") - 2).Trim());
                    if (liWork.WorkTime >= 100 && liWork.WorkTime < 200)
                    {
                        liWork.WorkTime = liWork.WorkTime - 40;
                    }
                    if (liWork.WorkTime > 200)
                    {
                        liWork.WorkTime = liWork.WorkTime - 80;
                    }
                    liWork.WorkRank = int.Parse(dtWorkouts.Rows[w - 1].ItemArray[dtWorkouts.Columns.IndexOf("Ranking")].ToString()) + "/" + dtWorkouts.Rows[w - 1].ItemArray[dtWorkouts.Columns.IndexOf("RankGroup")].ToString();
                    lWorkouts.Add(liWork);
                }
                catch (Exception e2)
                {
                }
            }
            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;
            }
        }
Esempio n. 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++;
                }
            }
        }