public virtual IVehicle CreateSport() { if (sport == null) { sport = new Sport(new StandardEngine(1300)); } return (IVehicle)sport.Clone(); }
public VehicleManager() { // For simplicity all vehicles use same engine type... saloon = new Saloon(new StandardEngine(1300)); coupe = new Coupe(new StandardEngine(1300)); sport = new Sport(new StandardEngine(1300)); boxVan = new BoxVan(new StandardEngine(1300)); pickup = new Pickup(new StandardEngine(1300)); }
public float PlayAnimation(int anim_index, Sport target_sport) { _target_sport = target_sport; if (_target_sport == Sport.GAELIC_FOOTBALL) { _animator_gaelic_football.speed = 1.0f; _body_gaelic_football.SetActive(true); _target = _body_root_gaelic_football; } else if (_target_sport == Sport.HURLING) { _body_hurling.SetActive(true); _animator_hurling.speed = 1.0f; _target = _body_root_hurling; } else if(_target_sport == Sport.HANDBALL) { Debug.Log("Try to load anim: "+anim_index); _current_skill = anim_index; if (anim_index == 0) { _body_handball_1.SetActive(true); _animator_handball_1.speed = 1.0f; _target = _body_root_handball_1; } else if (anim_index == 1) { _body_handball_2.SetActive(true); _animator_handball_2.speed = 1.0f; _target = _body_root_handball_2; } else if (anim_index == 2) { _body_handball_3.SetActive(true); _animator_handball_3.speed = 1.0f; _target = _body_root_handball_3; } } _active_auto_camera = true; Debug.Log("Play animation: " + anim_index + " [Ok]"); //_animator.animation.clip.averageDuration return 5.0f; }
// Uuden lajin lisäysnapin funktio protected void btnAddNewSport_Click(object sender, EventArgs e) { // Uusi entiteetin instanssi ctx = new G7934Entities(); // Luodaan uusi lajin olio Sport s = new Sport(); // Asetetaan sille nimi tekstikentästä s.Name = txtNewSport.Text; // Lisätään se entiteettiin ctx.Sports.Add(s); // Ja tallennetaan se ctx.SaveChanges(); // Täytetään lajivalikko uudestaan FillDateAndSports(); // Ja asetataan juuri luotu laji valituksi ddlSport.SelectedValue = s.Name; // Piilotetaan lajinlisäyssälät trNewSport.Visible = false; }
public ICollection <LapMesg> GetLapsBasedOnDistance(WorkoutSamples workoutSamples, Dynastream.Fit.DateTime startTime, Sport sport, SubSport subSport) { using var tracing = Tracing.Trace($"{nameof(FitConverter)}.{nameof(GetLapsBasedOnDistance)}") .WithTag(TagKey.Format, FileFormat.Fit.ToString()); var stepsAndLaps = new List <LapMesg>(); if (workoutSamples is null) { return(stepsAndLaps); } var speedMetrics = GetSpeedSummary(workoutSamples); if (speedMetrics is null) { return(stepsAndLaps); } var speedUnit = GetDistanceUnit(speedMetrics?.Display_Unit); var lapMeters = 0; switch (speedUnit) { case DistanceUnit.Kilometers: lapMeters = 1000; break; default: lapMeters = 1600; break; } LapMesg lap = null; ushort stepIndex = 0; var lapDistanceInMeters = 0f; float lapLengthSeconds = 0; for (var secondsSinceStart = 0; secondsSinceStart < speedMetrics.Values.Length; secondsSinceStart++) { if (lap is null || lap.GetTotalElapsedTime() is not null) { // Start new Lap var lapStartTime = new Dynastream.Fit.DateTime(startTime); lapStartTime.Add(secondsSinceStart); lap = new LapMesg(); lap.SetStartTime(lapStartTime); lap.SetMessageIndex(stepIndex); lap.SetEvent(Event.Lap); lap.SetLapTrigger(LapTrigger.Time); lap.SetSport(sport); lap.SetSubSport(subSport); lapLengthSeconds = 0; lapDistanceInMeters = 0f; } var currentSpeedInMPS = ConvertToMetersPerSecond(speedMetrics.GetValue(secondsSinceStart), workoutSamples); lapDistanceInMeters += 1 * currentSpeedInMPS; lapLengthSeconds++; if (lapDistanceInMeters >= lapMeters || secondsSinceStart == speedMetrics.Values.Length - 1) { lap.SetTotalElapsedTime(lapLengthSeconds); lap.SetTotalTimerTime(lapLengthSeconds); lap.SetTotalDistance(lapDistanceInMeters); stepsAndLaps.Add(lap); stepIndex++; } } return(stepsAndLaps); }
public ICollection <LapMesg> GetLaps(PreferredLapType preferredLapType, WorkoutSamples workoutSamples, Dynastream.Fit.DateTime startTime, Sport sport, SubSport subSport) { using var tracing = Tracing.Trace($"{nameof(FitConverter)}.{nameof(GetLaps)}") .WithTag(TagKey.Format, FileFormat.Fit.ToString()); if ((preferredLapType == PreferredLapType.Default || preferredLapType == PreferredLapType.Class_Segments) && workoutSamples.Segment_List.Any()) { return(GetLapsBasedOnSegments(workoutSamples, startTime, sport, subSport)); } return(GetLapsBasedOnDistance(workoutSamples, startTime, sport, subSport)); }
/*Добавление новой записи*/ private void pushData() { try { string sportName = sportNameInputBox.Text; string sportDesciption = sportDescriptionInputBox.Text; if ("".Equals(sportName) && "".Equals(sportDesciption)) { MessageBox.Show("Поле не может быть пустым", "Предупреждение", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Warning); return; } if (tourtab.Sport.Where(x => x.Name.ToLower() == sportName.ToLower()).Select(x => x).Count() > 0) { var result = MessageBox.Show("Такой вид спорта уже есть базе данных. Все равно добавить?", "Предупреждение", buttons: MessageBoxButtons.YesNo, icon: MessageBoxIcon.Warning); if (result == DialogResult.No) { return; } } Sport sport = new Sport { Name = sportName, Description = sportDesciption, Teams = teamVteamCheckBox.Checked }; tourtab.Sport.InsertOnSubmit(sport); tourtab.SubmitChanges(); MessageBox.Show("Данные успешно добавлены", "Сообщение", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Dispose(); } catch (Exception exc) { logger.Error(exc.Message); MessageBox.Show("Произошел сбой", "Сообщение", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error); return; } }
public void UploadSportAsync(Sport mySport) { this.UploadSportAsync(mySport, null); }
public virtual void ReadXML() { string urlPathSport = string.Empty; string urlPathLeague = string.Empty; string urlPathFeed = string.Empty; urlPathSport = Constant.SourceXML.PINNACLESPORTSURL; if (urlPathSport.IndexOf("http://") > -1) { urlPathLeague = Constant.SourceXML.PINNACLELEAGUEURL; urlPathFeed = Constant.SourceXML.PINNACLEFEEDURL; } else { string[] arrPlitUrl = urlPathSport.Split('_'); string timetick = arrPlitUrl[2].Replace(".xml", ""); urlPathLeague = arrPlitUrl[0] + "_league_{0}_"+timetick+".xml"; urlPathFeed = arrPlitUrl[0] + "_feed_{0}_{1}_" + timetick + ".xml"; } _lstSport = new List<Sport>(); _lstEvent = new List<Event>(); _lstMatch = new List<Match>(); _lstBet = new List<Bet>(); _lstChoice = new List<Choice>(); //sport XmlTextReader readerSport = new XmlTextReader(urlPathSport); // Skip non-significant whitespace readerSport.WhitespaceHandling = WhitespaceHandling.Significant; XPathDocument doc = new XPathDocument(readerSport, XmlSpace.Preserve); XPathNavigator nav = doc.CreateNavigator(); XPathExpression exprSport; exprSport = nav.Compile("/rsp/sports/sport"); XPathNodeIterator iteratorSport = nav.Select(exprSport); try { int _sportId = 0; int _eventId = 0; long _matchId = 0; long _betId = 0; long _choiceId = 0; while (iteratorSport.MoveNext()) { XPathNavigator _sportNameNavigator = iteratorSport.Current.Clone(); int feedContentSport = Convert.ToInt32(_sportNameNavigator.GetAttribute("feedContents", "")); if (feedContentSport > 0) { _sportId = Convert.ToInt32(_sportNameNavigator.GetAttribute("id", "")); Sport _sport = new Sport(); _sport.sportId = Convert.ToInt32(_sportNameNavigator.GetAttribute("id", "")); _sport.sportName = _sportNameNavigator.Value; _lstSport.Add(_sport); //league- event XmlTextReader readerLeague = new XmlTextReader(string.Format(urlPathLeague, _sportId)); readerLeague.WhitespaceHandling = WhitespaceHandling.Significant; XPathDocument docLeague = new XPathDocument(readerLeague, XmlSpace.Preserve); XPathNavigator navLeague = docLeague.CreateNavigator(); XPathExpression exprLeague; exprLeague = navLeague.Compile("/rsp/leagues/league"); XPathNodeIterator iteratorLeague = navLeague.Select(exprLeague); while (iteratorLeague.MoveNext()) { XPathNavigator _eventNameNavigator = iteratorLeague.Current.Clone(); int feedContentLeague = Convert.ToInt32(_sportNameNavigator.GetAttribute("feedContents", "")); if (feedContentLeague > 0) { Event _event = new Event(); _eventId = Convert.ToInt32(_eventNameNavigator.GetAttribute("id", "")); _event.eventId = _eventId; _event.sportId = _sportId; _event.eventName = _eventNameNavigator.Value; _lstEvent.Add(_event); //match - home team - awayteam XmlTextReader readerMatch = new XmlTextReader(string.Format(urlPathFeed, _sportId, _eventId)); readerMatch.WhitespaceHandling = WhitespaceHandling.Significant; XPathDocument docMatch = new XPathDocument(readerMatch, XmlSpace.Preserve); XPathNavigator navMatch = docMatch.CreateNavigator(); XPathExpression exprematch; exprematch = navMatch.Compile("/rsp/fd/sports/sport/leagues/league"); XPathNodeIterator iteratorMatch = navMatch.Select(exprematch); while (iteratorMatch.MoveNext()) { XPathNavigator _matchNameNavigator = iteratorMatch.Current.Clone(); XPathExpression exprematchEvent; exprematchEvent = _matchNameNavigator.Compile("events/event"); XPathNodeIterator iteratorMatchEvent = _matchNameNavigator.Select(exprematchEvent); while (iteratorMatchEvent.MoveNext()) { _matchId++; XPathNavigator _matchEventNameNavigator = iteratorMatchEvent.Current.Clone(); Match _match = new Match(); _match.matchId = _matchId; _match.eventId = _eventId; //_match.nameMatch = _matchNameNavigator.GetAttribute("name", ""); _match.homeTeam = _matchEventNameNavigator.SelectSingleNode("homeTeam").SelectSingleNode("name").Value; _match.awayTeam = _matchEventNameNavigator.SelectSingleNode("awayTeam").SelectSingleNode("name").Value; _match.startTime = Convert.ToDateTime(_matchEventNameNavigator.SelectSingleNode("startDateTime").Value); _lstMatch.Add(_match); if (_matchEventNameNavigator.HasChildren) { XPathExpression exprebet; exprebet = _matchEventNameNavigator.Compile("periods/period"); XPathNodeIterator iteratorBet = _matchEventNameNavigator.Select(exprebet); while (iteratorBet.MoveNext()) { _betId++; XPathNavigator _betNameNavigator = iteratorBet.Current.Clone(); Bet _bet = new Bet(); _bet.betId = _betId; _bet.matchId = _matchId; _bet.betName = _betNameNavigator.SelectSingleNode("description").Value; _bet.betCodeID = _bet.betName; _lstBet.Add(_bet); //handicap XPathExpression exprehandicap; exprehandicap = _matchEventNameNavigator.Compile("spreads/spread"); XPathNodeIterator iteratorHandicap = _matchEventNameNavigator.Select(exprehandicap); //total XPathExpression expretotal; expretotal = _matchEventNameNavigator.Compile("totals/total"); XPathNodeIterator iteratorTotal = _matchEventNameNavigator.Select(expretotal); //moneyline XPathExpression expremoneyline; expremoneyline = _matchEventNameNavigator.Compile("moneyLine"); XPathNodeIterator iteratorMoneyLine = _matchEventNameNavigator.Select(expremoneyline); while (iteratorHandicap.MoveNext()) { _choiceId++; XPathNavigator _choiceNameNavigator = iteratorHandicap.Current.Clone(); Choice _choice = new Choice(); _choice.choiceId = _choiceId; _choice.betId = _betId; _choice.choiceCodeId = (long)Constant.ChoiceType.HANDICAP; _choice.choiceCodeName = "HANDICAP"; _choice.choiceName = "spread"; _choice.awaySpread = _choiceNameNavigator.SelectSingleNode("awaySpread").Value; _choice.awayPrice = _choiceNameNavigator.SelectSingleNode("awayPrice").Value; _choice.homeSpread = _choiceNameNavigator.SelectSingleNode("homeSpread").Value; _choice.homePrice = _choiceNameNavigator.SelectSingleNode("homePrice").Value; _lstChoice.Add(_choice); } while (iteratorTotal.MoveNext()) { _choiceId++; XPathNavigator _choiceNameNavigator = iteratorTotal.Current.Clone(); Choice _choice = new Choice(); _choice.choiceId = _choiceId; _choice.betId = _betId; _choice.choiceCodeId = (long)Constant.ChoiceType.TOTAL; _choice.choiceCodeName = "TOTAL"; _choice.choiceName = "total"; _choice.points = _choiceNameNavigator.SelectSingleNode("points").Value; _choice.overPrice = _choiceNameNavigator.SelectSingleNode("overPrice").Value; _choice.underPrice = _choiceNameNavigator.SelectSingleNode("underPrice").Value; _lstChoice.Add(_choice); } while (iteratorMoneyLine.MoveNext()) { _choiceId++; XPathNavigator _choiceNameNavigator = iteratorMoneyLine.Current.Clone(); Choice _choice = new Choice(); _choice.choiceId = _choiceId; _choice.betId = _betId; _choice.choiceCodeId = (long)Constant.ChoiceType.MONEY_LINE; _choice.choiceCodeName = "MONEY_LINE"; _choice.choiceName = "moneyLine"; _choice.awayPrice = _choiceNameNavigator.SelectSingleNode("awayPrice").Value; _choice.homePrice = _choiceNameNavigator.SelectSingleNode("homePrice").Value; _choice.drawPrice = _choiceNameNavigator.SelectSingleNode("drawPrice").Value; _lstChoice.Add(_choice); } } } } } } } } } } catch (Exception ex) { //throw new Exception(ex.Message); } }
public async Task InsertAsync(Sport entity) { await _db.Sports.AddAsync(entity); await _db.SaveChangesAsync(); }
public void FillCompareTable() { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(_allEventsApiUrl); request.Method = "GET"; string json; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); json = reader.ReadToEnd(); reader.Close(); dataStream.Close(); } int added = 0; JObject obj; try { obj = JObject.Parse(json); foreach (var item in obj["events"]) { JObject itemObj = ((JObject)item); JObject eventObj = (JObject)itemObj["event"]; Compare_Events ev = new Compare_Events(); string eventData = eventObj["id"].ToObject <string>(); ev.Home = eventObj["homeName"].ToObject <string>(); ev.Away = eventObj["awayName"].ToObject <string>(); ev.Start = DateHelpers.TimeStampMSToDateTime(eventObj["start"].ToObject <double>()); ev.PrematchEnd = DateHelpers.TimeStampMSToDateTime(eventObj["prematchEnd"].ToObject <double>()); JArray paths = ((JArray)eventObj["path"]); if (!mappings.SportMappings.ContainsKey(paths[0]["name"].ToObject <string>())) { continue; } Sport sport = mappings.SportMappings[paths[0]["name"].ToObject <string>()].DBCopy(context); if (sport != null) { ev.Sport = sport; } else { break; } if (paths.Count == 2) { ev.League = paths[1]["name"].ToObject <string>(); } else if (paths.Count == 3) { ev.Region = paths[1]["name"].ToObject <string>(); ev.League = paths[2]["name"].ToObject <string>(); } ev.SiteID = mappings.ID; context.Compare_Events.Add(ev); } context.SaveChanges(); } catch (Exception ex) { Console.WriteLine("888 invalid json, or changed json formatting"); } }
public virtual void TestSelectUnCommitedObject4() { DeleteBase(BaseName); // Create instance var sport = new Sport("volley-ball"); IOdb odb = null; try { // Open the database odb = Open(BaseName); // Store the object odb.Store(sport); } finally { if (odb != null) { // Close the database odb.Close(); } } // Create instance var volleyball = new Sport("volley-ball"); // Create 4 players var player1 = new Player("olivier", new DateTime(), volleyball); var player2 = new Player("pierre", new DateTime(), volleyball); var player3 = new Player("elohim", new DateTime(), volleyball); var player4 = new Player("minh", new DateTime(), volleyball); // Create two teams var team1 = new Team("Paris"); var team2 = new Team("Montpellier"); // Set players for team1 team1.AddPlayer(player1); team1.AddPlayer(player2); // Set players for team2 team2.AddPlayer(player3); team2.AddPlayer(player4); // Then create a volley ball game for the two teams var game = new Game(new DateTime(), volleyball, team1, team2); odb = null; try { // Open the database odb = Open(BaseName); // Store the object odb.Store(game); } finally { if (odb != null) { // Close the database odb.Close(); } } try { // Open the database odb = Open(BaseName); IQuery query = odb.Query <Player>(); query.Descend("name").Constrain((object)"olivier").Equal(); var players = query.Execute <Player>(); Println("\nStep 3 : Players with name olivier"); var i = 1; // display each object while (players.HasNext()) { Println((i++) + "\t: " + players.Next()); } } finally { if (odb != null) { // Close the database odb.Close(); } } try { // Open the database odb = Open(BaseName); // Let's insert a tennis player var agassi = new Player("André Agassi", new DateTime(), new Sport("Tennis")); var oid = odb.Store(agassi); IQuery query = odb.Query <Player>(); query.Descend("favoriteSport.name").Constrain((object)"volley-ball").Equal(); var players = query.Execute <Player>(); Println("\nStep 4 : Players of Voller-ball"); var i = 1; // display each object while (players.HasNext()) { Println((i++) + "\t: " + players.Next()); } } finally { if (odb != null) { // Close the database odb.Close(); } } DeleteBase(BaseName); }
/// <summary> /// /// </summary> /// <param name="sport"></param> /// <returns></returns> private ISport SportTitabetParse(Constant.SportType sport) { ISport _sport = new Sport(); string urlPath = Constant.SourceXML.TITABETURL; string mainSport = ConfigurationManager.AppSettings["TITANBETMAINSPORT"].ToString(); XmlTextReader reader = new XmlTextReader(urlPath); // Skip non-significant whitespace reader.WhitespaceHandling = WhitespaceHandling.Significant; XPathDocument doc = new XPathDocument(reader, XmlSpace.Preserve); XPathNavigator nav = doc.CreateNavigator(); int sportID = 0; /* * * Cricket * Handball * Horse Racing * Motor Sports * Boxing * Golf * Tennis * */ switch (sport) { case Constant.SportType.CRICKET: sportID = 33948; break; case Constant.SportType.HANDBALL: sportID = 33945; break; case Constant.SportType.HORSE_RACING: sportID = 55882; break; case Constant.SportType.MOTOR_SPORTS: sportID = 0; break; case Constant.SportType.BOXING: sportID = 6638; break; case Constant.SportType.GOLF: sportID = 0; break; case Constant.SportType.TENNIS: sportID = 2490; break; } XPathExpression exprSport; exprSport = nav.Compile("/bookmaker/sport[@id='" + sportID + "']"); XPathNodeIterator iteratorSport = nav.Select(exprSport); while (iteratorSport.MoveNext()) { XPathNavigator _sportNameNavigator = iteratorSport.Current.Clone(); _sport.ID = sportID; _sport.Name = _sportNameNavigator.GetAttribute("name", ""); // League if (_sportNameNavigator.HasChildren) { XPathExpression exprevent; exprevent = _sportNameNavigator.Compile("group"); XPathNodeIterator iteratorEvent = _sportNameNavigator.Select(exprevent); while (iteratorEvent.MoveNext()) { ILeague _league = LeagueTitabetParse(iteratorEvent, _sport.ID); if (_sport.Leagues == null) { _sport.Leagues = new List <ILeague>(); } //check league not null if (_league != null) { _sport.Leagues.Add(_league); } } } } return(_sport); }
private void on_combo_sports_changed(object o, EventArgs args) { if (o == null) return; //Log.WriteLine("changed"); try { //sport = new Sport(UtilGtk.ComboGetActive(combo_sports)); int sportID = Convert.ToInt32(Util.FindOnArray(':', 2, 0, UtilGtk.ComboGetActive(combo_sports), sports)); sport = SqliteSport.Select(sportID); if(Catalog.GetString(sport.Name) == Catalog.GetString(Constants.SportUndefined)) { //if sport is undefined, level should be undefined, and unsensitive try { combo_levels.Active = UtilGtk.ComboMakeActive(levels, Constants.LevelUndefinedID.ToString() + ":" + Catalog.GetString(Constants.LevelUndefined)); level_row_show(false); combo_speciallities.Active = UtilGtk.ComboMakeActive(speciallitiesTranslated, Catalog.GetString(Constants.SpeciallityUndefined)); speciallity_row_show(false); } catch { Log.WriteLine("do later"); } } else if(Catalog.GetString(sport.Name) == Catalog.GetString(Constants.SportNone)) { //if sport is none, level should be sedentary and unsensitive try { combo_levels.Active = UtilGtk.ComboMakeActive(levels, Constants.LevelSedentaryID.ToString() + ":" + Catalog.GetString(Constants.LevelSedentary)); level_row_show(false); combo_speciallities.Active = UtilGtk.ComboMakeActive(speciallitiesTranslated, Catalog.GetString(Constants.SpeciallityUndefined)); speciallity_row_show(false); } catch { Log.WriteLine("do later"); } } else { //sport is not undefined and not none //if level is "sedentary", then change level to "undefined" if(UtilGtk.ComboGetActive(combo_levels) == Constants.LevelSedentaryID.ToString() + ":" + Catalog.GetString(Constants.LevelSedentary)) combo_levels.Active = UtilGtk.ComboMakeActive(levels, Constants.LevelUndefinedID.ToString() + ":" + Catalog.GetString(Constants.LevelUndefined)); //show level combo_levels.Sensitive = true; level_row_show(true); if(sport.HasSpeciallities) { combo_speciallities.Destroy(); createComboSpeciallities(sport.UniqueID); speciallity_row_show(true); } else { Log.Write("hide"); combo_speciallities.Active = UtilGtk.ComboMakeActive(speciallitiesTranslated, Catalog.GetString(Constants.SpeciallityUndefined)); speciallity_row_show(false); } } } catch { //Log.WriteLine("do later"); } Log.WriteLine("at on_combo_sports_changed " + sport.ToString()); //labelUpdate(); }
/* E N S U R E S P O R T L E V E L P O S */ /*---------------------------------------------------------------------------- %%Function: EnsureSportLevelPos %%Qualified: ArbWeb.GameData.GameSlots.EnsureSportLevelPos %%Contact: rlittle Make sure that the sport / level / pos is in the legend (including all the subtotals for the sport/level/pos) ----------------------------------------------------------------------------*/ private void EnsureSportLevelPos(string sSport, string sLevel, string sPos) { Sport sport; bool fNewSport = false; // make sure we know about this sport and this position if (!m_mpSportSport.ContainsKey(sSport)) { sport = new Sport(); m_mpSportSport.Add(sSport, sport); fNewSport = true; } sport = m_mpSportSport[sSport]; bool fNewPos, fNewLevel, fNewLevelPos; sport.EnsurePos(sLevel, sPos, out fNewLevel, out fNewPos, out fNewLevelPos); if (fNewLevelPos) m_plsLegend.Add(String.Format("{0}-{1}-{2}", sSport, sLevel, sPos)); if (fNewSport) m_plsLegend.Add(String.Format("{0}-Total", sSport)); if (fNewLevel) m_plsLegend.Add(String.Format("{0}-{1}-Total", sSport, sLevel)); if (fNewPos) m_plsLegend.Add(String.Format("{0}-{1}", sSport, sPos)); }
public async Task AddAsync(Sport sport) { await _context.Sports.AddAsync(sport); await _context.SaveChangesAsync(); }
public void Remove(Sport sport) { _context.Sports.Remove(sport); _context.SaveChanges(); }
public void FillDB() { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(_allEventsApiUrl); request.Method = "GET"; string json; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); json = reader.ReadToEnd(); reader.Close(); dataStream.Close(); } int added = 0; JObject obj; try { obj = JObject.Parse(json); foreach (var item in obj["events"]) { JObject itemObj = ((JObject)item); JObject eventObj = (JObject)itemObj["event"]; Event ev = new Event(); string eventData = eventObj["id"].ToObject <string>(); ev.Home = eventObj["homeName"].ToObject <string>(); ev.Away = eventObj["awayName"].ToObject <string>(); ev.Start = DateHelpers.TimeStampToDateTime(eventObj["start"].ToObject <double>()); ev.PrematchEnd = DateHelpers.TimeStampToDateTime(eventObj["prematchEnd"].ToObject <double>()); if (ev.IsLive()) { continue; } JArray paths = ((JArray)eventObj["path"]); if (!mappings.SportMappings.ContainsKey(paths[0]["name"].ToObject <string>())) { continue; } Sport sport = mappings.SportMappings[paths[0]["name"].ToObject <string>()].DBCopy(context); if (sport != null) { ev.Sport = sport; } else { break; } if (paths.Count == 2) { ev.League = paths[1]["name"].ToObject <string>(); } else if (paths.Count == 3) { ev.Region = paths[1]["name"].ToObject <string>(); ev.League = paths[2]["name"].ToObject <string>(); } Event dbEvent = DBFinder.FindEvent(ev).DBCopy(context); int eventID; if (dbEvent != null) { continue; } else { context.Events.Add(ev); context.SaveChanges(); EventSiteData data = new EventSiteData(); dbEvent = ev; data.EventID = ev.ID; data.SiteID = mappings.ID; data.Data = eventData; context.EventSiteDatas.Add(data); Int32.TryParse(eventData, out eventID); } if (eventID == 0) { continue; } string offersUrl = GetEventOffersApiUrl(eventID); request = (HttpWebRequest)WebRequest.Create(offersUrl); try { using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); json = reader.ReadToEnd(); reader.Close(); dataStream.Close(); } } catch (WebException ex) { continue; } obj = JObject.Parse(json); foreach (JObject offer in obj["betoffers"]) { string betOfferType = ((JObject)offer["betOfferType"])["name"].ToObject <string>(); string betTarget = ((JObject)offer["criterion"])["label"].ToObject <string>(); if (!mappings.BetTypeMappings.ContainsKey(betOfferType)) { continue; } if (!mappings.BetTargetMappings.ContainsKey(betTarget)) { continue; } BetType type = mappings.BetTypeMappings[betOfferType].DBCopy(context); BetTarget target = mappings.BetTargetMappings[betTarget].DBCopy(context); BetOffer betOffer = new BetOffer(); betOffer.BetTypeID = type.ID; if (target != null) { betOffer.BetTargetID = target.ID; } dbEvent.BetOffers.Add(betOffer); context.SaveChanges(); foreach (JObject outcome in offer["outcomes"]) { Outcome o = new Outcome(); if (!mappings.OutcomeTypeMappings.ContainsKey(outcome["label"].ToObject <string>())) { continue; } o.OutcomeType = mappings.OutcomeTypeMappings[outcome["label"].ToObject <string>()].DBCopy(context); o.Odds = outcome["oddsAmerican"].ToObject <string>(); o.BetOfferID = betOffer.ID; if (outcome.ContainsKey("line")) { o.Line = outcome["line"].ToObject <int>(); } context.Outcomes.Add(o); } } Console.WriteLine("Event added: " + dbEvent.Home + " - " + dbEvent.Away); added++; } context.SaveChanges(); Console.WriteLine("Total: " + added); } catch (Exception ex) { Console.WriteLine("888 invalid json, or changed json formatting"); } }
private bool Equals(Sport other) { return string.Equals(Name, other.Name); }
public override ObservableCollection <Sport> loadSport() { ObservableCollection <Sport> lesSports = new ObservableCollection <Sport>(); //***********************************************RUGBY******************************************************************* Actualite actu = new Actualite("ASM en final ", "En réitérant l'exploit d 'il y a 7 ans, les jaune et bleu ont offert à leurs fidèles supporters le plus beau des cadeaux : la victoire.Une liesse populaire s'est répandue dans les rues de Clermont-Ferrand où même ceux qui avaient choisi de regarder le match chez eux ont rejoint la foule pour célébrer cette victoire tant espérée.Même si la nuit de sommeil risque d'être courte pour beaucoup, il leur faudra conserver quelques forces pour acclamer dimanche après-midi les héros d'un soir.Les dieux du stade sont, en effet, attendus, sur cette même place, dès 17H00 lundi 5 juin, pour recevoir les remerciements et la reconnaissance de ces dizaines de milliers de supporters qui rêvaient de voir enfin revenir le bouclier de Brennus en terre auvergnate."); Sport Rugby = new Sport { Nom = "Rugby", LiActualite = new ObservableCollection <Actualite>(), LiChampionnat = new ObservableCollection <Championnat>() }; lesSports.Add(Rugby); Rugby.AjouterActualite(actu); //*********************************************TOP14******************************************************************** Championnat Top14 = new Championnat("Top 14"); Rugby.AjouterChampionnat(Top14); Utilisateur U1 = new Utilisateur { Nom = "Supp1", Prenom = "Tata", Adresse = "*****@*****.**", Mdp = "tata" }; Equipe Clermont = new Equipe("Clermont-Ferrand", "L'ASM Clermont Auvergne, anciennement AS Montferrand, est un club de rugby à XV français basé à Clermont-Ferrand et actuellement présidé par Éric de Cromières3. L'équipe première est entraînée par le Français Franck Azéma à partir de 2014 après huit saisons sous la houlette du Néo-Zélandais Vern Cotter, et évolue dans le Top 14 et dispute la Coupe d'Europe."); Equipe Toulon = new Equipe("Toulon", "Equipe null"); Equipe Lyon = new Equipe("Lyon", "Retraite de l'asm"); Equipe Toulouse = new Equipe("Toulouse", "Superbe équipe"); Equipe Montpellier = new Equipe("Montpellier", "Equipe null"); Equipe LaRochelle = new Equipe("La Rochelle", "Retraite de l'asm"); Equipe Castres = new Equipe("Castres", "Superbe équipe"); Equipe Racing = new Equipe("Racing-92", "Equipe null"); Equipe StadeFrançais = new Equipe("Stade Français", "Retraite de l'asm"); Equipe Brive = new Equipe("Brive", "Superbe équipe"); Equipe Pau = new Equipe("Pau", "Equipe null"); Equipe Bordeaux = new Equipe("Bordeaux-Bègles", "Retraite de l'asm"); Equipe Grenoble = new Equipe("Grenoble", "Equipe null"); Equipe Bayonne = new Equipe("Bayonne", "Retraite de l'asm"); Top14.AjouteEquipe(Clermont); Top14.AjouteEquipe(Toulon); Top14.AjouteEquipe(Lyon); Top14.AjouteEquipe(Toulouse); Top14.AjouteEquipe(Montpellier); Top14.AjouteEquipe(LaRochelle); Top14.AjouteEquipe(Castres); Top14.AjouteEquipe(Racing); Top14.AjouteEquipe(StadeFrançais); Top14.AjouteEquipe(Brive); Top14.AjouteEquipe(Pau); Top14.AjouteEquipe(Bordeaux); Top14.AjouteEquipe(Grenoble); Top14.AjouteEquipe(Bayonne); Journee Journee1_Top14 = new Journee(1); Journee Journee2_Top14 = new Journee(2); Journee Journee3_Top14 = new Journee(3); Clermont.AjouterCommentaire(U1, "salakakakaakakakakak"); RencontreSportive R1J1_Top14 = new RencontreSportive(Rugby, Top14, Lyon, Brive, 15, 15); RencontreSportive R2J1_Top14 = new RencontreSportive(Rugby, Top14, StadeFrançais, Grenoble, 54, 20); RencontreSportive R3J1_Top14 = new RencontreSportive(Rugby, Top14, LaRochelle, Clermont, 30, 30); RencontreSportive R4J1_Top14 = new RencontreSportive(Rugby, Top14, Castres, Pau, 28, 11); RencontreSportive R5J1_Top14 = new RencontreSportive(Rugby, Top14, Bordeaux, Racing, 15, 9); RencontreSportive R6J1_Top14 = new RencontreSportive(Rugby, Top14, Toulouse, Montpellier, 20, 12); RencontreSportive R7J1_Top14 = new RencontreSportive(Rugby, Top14, Bayonne, Toulon, 15, 0); Journee1_Top14.AjouterRencontreSportive(R1J1_Top14); Journee1_Top14.AjouterRencontreSportive(R2J1_Top14); Journee1_Top14.AjouterRencontreSportive(R3J1_Top14); Journee1_Top14.AjouterRencontreSportive(R4J1_Top14); Journee1_Top14.AjouterRencontreSportive(R5J1_Top14); Journee1_Top14.AjouterRencontreSportive(R6J1_Top14); Journee1_Top14.AjouterRencontreSportive(R7J1_Top14); Top14.CréeClassement(Journee1_Top14); RencontreSportive R1J2_Top14 = new RencontreSportive(Rugby, Top14, Pau, Toulon, 18, 20); RencontreSportive R2J2_Top14 = new RencontreSportive(Rugby, Top14, Bayonne, Castres, 12, 12); RencontreSportive R3J2_Top14 = new RencontreSportive(Rugby, Top14, Grenoble, LaRochelle, 19, 22); RencontreSportive R4J2_Top14 = new RencontreSportive(Rugby, Top14, Brive, StadeFrançais, 28, 20); RencontreSportive R5J2_Top14 = new RencontreSportive(Rugby, Top14, Racing, Lyon, 29, 16); RencontreSportive R6J2_Top14 = new RencontreSportive(Rugby, Top14, Toulouse, Bordeaux, 22, 17); RencontreSportive R7J2_Top14 = new RencontreSportive(Rugby, Top14, Montpellier, Clermont, 22, 26); Journee2_Top14.AjouterRencontreSportive(R1J2_Top14); Journee2_Top14.AjouterRencontreSportive(R2J2_Top14); Journee2_Top14.AjouterRencontreSportive(R3J2_Top14); Journee2_Top14.AjouterRencontreSportive(R4J2_Top14); Journee2_Top14.AjouterRencontreSportive(R5J2_Top14); Journee2_Top14.AjouterRencontreSportive(R6J2_Top14); Journee2_Top14.AjouterRencontreSportive(R7J2_Top14); Top14.CréeClassement(Journee2_Top14); RencontreSportive R1J3_Top14 = new RencontreSportive(Rugby, Top14, StadeFrançais, Clermont, 30, 30); RencontreSportive R2J3_Top14 = new RencontreSportive(Rugby, Top14, Lyon, Grenoble, 32, 13); RencontreSportive R3J3_Top14 = new RencontreSportive(Rugby, Top14, Castres, LaRochelle, 18, 26); RencontreSportive R4J3_Top14 = new RencontreSportive(Rugby, Top14, Pau, Bayonne, 25, 9); RencontreSportive R5J3_Top14 = new RencontreSportive(Rugby, Top14, Toulon, Brive, 21, 25); RencontreSportive R6J3_Top14 = new RencontreSportive(Rugby, Top14, Bordeaux, Montpellier, 15, 32); RencontreSportive R7J3_Top14 = new RencontreSportive(Rugby, Top14, Racing, Toulouse, 28, 14); Journee3_Top14.AjouterRencontreSportive(R1J3_Top14); Journee3_Top14.AjouterRencontreSportive(R2J3_Top14); Journee3_Top14.AjouterRencontreSportive(R3J3_Top14); Journee3_Top14.AjouterRencontreSportive(R4J3_Top14); Journee3_Top14.AjouterRencontreSportive(R5J3_Top14); Journee3_Top14.AjouterRencontreSportive(R6J3_Top14); Journee3_Top14.AjouterRencontreSportive(R7J3_Top14); Top14.CréeClassement(Journee3_Top14); Joueur J1 = new Joueur("Julien", "Bardy", "2éme ligne"); Joueur J2 = new Joueur("Piere", "Ezac", "3éme ligne"); Clermont.ajouterJoueur(J1); Clermont.ajouterJoueur(J2); //********************************************ProD2********************************************************************** Championnat Prod2 = new Championnat("Pro D2"); Rugby.AjouterChampionnat(Prod2); Equipe Montmarsan = new Equipe("Montmarsan", "Retraite de l'asm"); Prod2.AjouteEquipe(Brive); Prod2.AjouteEquipe(Bayonne); Prod2.AjouteEquipe(Montmarsan); //Journee Journee1_ProD2 = new Journee(1); Journee Journee2_ProD2 = new Journee(2); RencontreSportive R1_ProD2 = new RencontreSportive(Rugby, Prod2, Brive, Bayonne, 150, 0); RencontreSportive R2_ProD2 = new RencontreSportive(Rugby, Prod2, Brive, Montmarsan, 15, 0); RencontreSportive R3_ProD2 = new RencontreSportive(Rugby, Prod2, Montmarsan, Bayonne, 15, 0); //RencontreSportive R4_ProD2 = new RencontreSportive(Rugby, Prod2, Brive, Bayonne, 15, 0); Journee2_ProD2.AjouterRencontreSportive(R1_ProD2); Journee2_ProD2.AjouterRencontreSportive(R2_ProD2); Journee2_ProD2.AjouterRencontreSportive(R3_ProD2); //Journee1_ProD2.AjouterRencontreSportive(R4_ProD2); //Prod2.CréeClassement(Journee1_ProD2); Prod2.CréeClassement(Journee2_ProD2); //*************************************FOOT*************************************************** Actualite actu_Foot = new Actualite("ASSE", "null"); Sport Foot = new Sport { Nom = "Foot", LiActualite = new ObservableCollection <Actualite>(), LiChampionnat = new ObservableCollection <Championnat>() }; Championnat Ligue1 = new Championnat("Ligue 1"); Foot.AjouterChampionnat(Ligue1); Championnat Ligue2 = new Championnat("Ligue 2"); Foot.AjouterChampionnat(Ligue2); Equipe ClermontF = new Equipe("Clermont-Ferrand", "Superbe équipe"); Equipe ToulonF = new Equipe("Toulon", "Equipe null"); Equipe LyonF = new Equipe("Lyon", "Retraite de l'asm"); Equipe ToulouseF = new Equipe("Toulouse", "Superbe équipe"); Equipe MontpellierF = new Equipe("Montpellier", "Equipe null"); Equipe LaRochelleF = new Equipe("La Rochelle", "Retraite de l'asm"); Ligue1.AjouteEquipe(ClermontF); Ligue1.AjouteEquipe(ToulonF); Ligue1.AjouteEquipe(LyonF); Ligue1.AjouteEquipe(ToulouseF); Ligue1.AjouteEquipe(MontpellierF); Ligue1.AjouteEquipe(LaRochelleF); Journee Journee1_Ligue1 = new Journee(1); Journee Journee2_Ligue1 = new Journee(2); Journee Journee3_Ligue1 = new Journee(3); Clermont.AjouterCommentaire(U1, "Vraiment une belle équipe , un beau centre de formation"); RencontreSportive R3J1_Ligue1 = new RencontreSportive(Foot, Ligue1, LaRochelleF, ClermontF, 0, 3); RencontreSportive R6J1_Ligue1 = new RencontreSportive(Foot, Ligue1, ToulouseF, MontpellierF, 0, 1); Journee1_Ligue1.AjouterRencontreSportive(R3J1_Ligue1); Journee1_Ligue1.AjouterRencontreSportive(R6J1_Ligue1); Ligue1.CréeClassement(Journee1_Ligue1); lesSports.Add(Foot); Foot.AjouterActualite(actu_Foot); //Rugby.AjouterActualite(actu_Foot); return(lesSports); }
private void on_combo_sports_changed(object o, EventArgs args) { if (o == null) return; //LogB.Information("changed"); try { int sportID = Convert.ToInt32(Util.FindOnArray(':', 2, 0, UtilGtk.ComboGetActive(combo_sports), sports)); sport = SqliteSport.Select(false, sportID); if(Catalog.GetString(sport.Name) == Catalog.GetString(Constants.SportUndefined)) { //if sport is undefined, level should be undefined, and unsensitive try { combo_levels.Active = UtilGtk.ComboMakeActive(levels, Constants.LevelUndefinedID.ToString() + ":" + Catalog.GetString(Constants.LevelUndefined)); combo_levels.Sensitive = false; combo_speciallities.Active = UtilGtk.ComboMakeActive(speciallitiesTranslated, Catalog.GetString(Constants.SpeciallityUndefined)); label_speciallity.Hide(); combo_speciallities.Hide(); } catch { LogB.Warning("do later"); } } else if(Catalog.GetString(sport.Name) == Catalog.GetString(Constants.SportNone)) { //if sport is none, level should be sedentary and unsensitive try { combo_levels.Active = UtilGtk.ComboMakeActive(levels, Constants.LevelSedentaryID.ToString() + ":" + Catalog.GetString(Constants.LevelSedentary)); combo_levels.Sensitive = false; combo_speciallities.Active = UtilGtk.ComboMakeActive(speciallitiesTranslated, Catalog.GetString(Constants.SpeciallityUndefined)); label_speciallity.Hide(); combo_speciallities.Hide(); } catch { LogB.Warning("do later"); } } else { //sport is not undefined and not none //if level is "sedentary", then change level to "undefined" if(UtilGtk.ComboGetActive(combo_levels) == Constants.LevelSedentaryID.ToString() + ":" + Catalog.GetString(Constants.LevelSedentary)) { combo_levels.Active = UtilGtk.ComboMakeActive(levels, Constants.LevelUndefinedID.ToString() + ":" + Catalog.GetString(Constants.LevelUndefined)); } //show level combo_levels.Sensitive = true; if(sport.HasSpeciallities) { combo_speciallities.Destroy(); createComboSpeciallities(sport.UniqueID); label_speciallity.Show(); combo_speciallities.Show(); } else { LogB.Information("hide"); combo_speciallities.Active = UtilGtk.ComboMakeActive(speciallitiesTranslated, Catalog.GetString(Constants.SpeciallityUndefined)); label_speciallity.Hide(); combo_speciallities.Hide(); } } } catch { //LogB.Warning("do later"); } on_entries_required_changed(new object(), new EventArgs()); LogB.Information(sport.ToString()); }
public override void Add(Sport sport) { lesSports.Add(sport); }
public virtual void ReadXML() { string urlPath = Constant.SourceXML.BETCLICKURL; _lstSport = new List<Sport>(); _lstEvent = new List<Event>(); _lstMatch = new List<Match>(); _lstBet = new List<Bet>(); _lstChoice = new List<Choice>(); XmlTextReader reader = new XmlTextReader(urlPath); // Skip non-significant whitespace reader.WhitespaceHandling = WhitespaceHandling.Significant; XPathDocument doc = new XPathDocument(reader, XmlSpace.Preserve); XPathNavigator nav = doc.CreateNavigator(); XPathExpression exprSport; exprSport = nav.Compile("/sports/sport"); XPathNodeIterator iteratorSport = nav.Select(exprSport); try { int _sportId = 0; int _eventId = 0; long _matchId = 0; long _betId = 0; long _choiceId = 0; while (iteratorSport.MoveNext()) { _sportId++; XPathNavigator _sportNameNavigator = iteratorSport.Current.Clone(); Sport _sport = new Sport(); _sport.sportId = _sportId; _sport.sportName = _sportNameNavigator.GetAttribute("name", ""); _lstSport.Add(_sport); if (_sportNameNavigator.HasChildren) { XPathExpression exprevent; exprevent = _sportNameNavigator.Compile("event"); XPathNodeIterator iteratorEvent = _sportNameNavigator.Select(exprevent); while (iteratorEvent.MoveNext()) { _eventId++; XPathNavigator _eventNameNavigator = iteratorEvent.Current.Clone(); Event _event = new Event(); _event.eventId = _eventId; _event.sportId = _sportId; _event.eventName = _eventNameNavigator.GetAttribute("name", ""); _lstEvent.Add(_event); if (_eventNameNavigator.HasChildren) { XPathExpression exprematch; exprematch = _eventNameNavigator.Compile("match"); XPathNodeIterator iteratorMatch = _eventNameNavigator.Select(exprematch); while (iteratorMatch.MoveNext()) { _matchId++; XPathNavigator _matchNameNavigator = iteratorMatch.Current.Clone(); Match _match = new Match(); _match.matchId = _matchId; _match.eventId = _eventId; string[] league = _matchNameNavigator.GetAttribute("name", "").Split('-'); if (league.Length > 1) { _match.homeTeam = league[0].Trim(); _match.awayTeam = league[1].Trim(); } else { _match.homeTeam = _matchNameNavigator.GetAttribute("name", ""); } _match.startTime = Convert.ToDateTime(_matchNameNavigator.GetAttribute("start_date", "")); _lstMatch.Add(_match); if (_matchNameNavigator.HasChildren) { XPathExpression exprebet; exprebet = _matchNameNavigator.Compile("bets/bet"); XPathNodeIterator iteratorBet = _matchNameNavigator.Select(exprebet); while (iteratorBet.MoveNext()) { _betId++; XPathNavigator _betNameNavigator = iteratorBet.Current.Clone(); Bet _bet = new Bet(); _bet.betId = _betId; _bet.matchId = _matchId; _bet.betName = _betNameNavigator.GetAttribute("name", ""); _bet.betCodeID = _betNameNavigator.GetAttribute("code", ""); _lstBet.Add(_bet); if (_betNameNavigator.HasChildren) { XPathExpression exprechoice; exprechoice = _betNameNavigator.Compile("choice"); XPathNodeIterator iteratorChoice = _betNameNavigator.Select(exprechoice); while (iteratorChoice.MoveNext()) { _choiceId++; XPathNavigator _choiceNameNavigator = iteratorChoice.Current.Clone(); Choice _choice = new Choice(); _choice.choiceId = _choiceId; _choice.betId = _betId; _choice.choiceName = _choiceNameNavigator.GetAttribute("name", ""); _choice.odd = _choiceNameNavigator.GetAttribute("odd", ""); _lstChoice.Add(_choice); } } } } } } } } } } catch (Exception ex) { throw new Exception(ex.Message); } }
public List <Match> GetMatchesList() { string xmlData = HttpContext.Current.Server.MapPath("~/App_Data/XMLFile4.xml"); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(xmlData); // Sport foreach (XmlElement sp in xmlDocument.SelectNodes("xmlsports/sport")) { string sportName = sp.GetAttribute("name"); string sportId = sp.GetAttribute("id"); int sportChildNodesCount = sp.ChildNodes.Count; Sport sport = new Sport(sportName, sportId); sport.NumberOfChildNodes = sportChildNodesCount; sports.Add(sport); } // Events int eventsCounter = 0; int currentSportCounter = 0; foreach (XmlElement le in xmlDocument.SelectNodes("xmlsports/sport/event")) { string eventName = le.GetAttribute("name"); string eventId = le.GetAttribute("id"); string isLiveString = le.GetAttribute("islive"); string categoryId = le.GetAttribute("categoryid"); string sportName = sports[currentSportCounter].Name; Sport currentSport = sports[currentSportCounter]; bool isLive = false; if (isLiveString == "true") { isLive = true; } int childNodesCount = le.ChildNodes.Count; Event ev = new Event(eventName, eventId, isLive, categoryId, currentSport); ev.NumberOfChildNodes = childNodesCount; events.Add(ev); sports[currentSportCounter].AddEventToEventsList(ev); eventsCounter++; if (eventsCounter >= sports[currentSportCounter].NumberOfChildNodes) { currentSportCounter++; eventsCounter = 0; } } // Matches int matchesCounter = 0; int currentEventCounter = 0; foreach (XmlElement xe in xmlDocument.SelectNodes("xmlsports/sport/event/match")) { string matchName = xe.GetAttribute("name"); string matchId = xe.GetAttribute("id"); string matchStartDate = xe.GetAttribute("startdate"); string matchTypeString = xe.GetAttribute("matchtype"); MatchType matchType = (MatchType)Enum.Parse(typeof(MatchType), matchTypeString); string eventName = events[currentEventCounter].Name; Event currentEvent = events[currentEventCounter]; int childNodesCount = xe.ChildNodes.Count; Match mh = new Match(matchName, matchId, matchStartDate, matchType, currentEvent); mh.NumberOfChildNodes = childNodesCount; matches.Add(mh); events[currentEventCounter].AddMatchToMatchesList(mh); matchesCounter++; if (matchesCounter >= events[currentEventCounter].NumberOfChildNodes) { currentEventCounter++; matchesCounter = 0; } } // Bets int betsCounter = 0; int currentMatchCounter = 0; foreach (XmlElement xe in xmlDocument.SelectNodes("xmlsports/sport/event/match/bet")) { string betName = xe.GetAttribute("name"); string betId = xe.GetAttribute("id"); string isLiveString = xe.GetAttribute("islive"); string matchName = matches[currentMatchCounter].Name; Match currentMatch = matches[currentMatchCounter]; if (currentMatch.NumberOfChildNodes <= 0) { while (matches[currentMatchCounter].NumberOfChildNodes <= 0 && currentMatchCounter < (matches.Count - 1)) { currentMatchCounter++; } currentMatch = matches[currentMatchCounter]; } bool isLive = false; if (isLiveString == "true") { isLive = true; } int childNodesCount = xe.ChildNodes.Count; Bet be = new Bet(betName, betId, isLive, currentMatch); be.NumberOfChildNodes = childNodesCount; bets.Add(be); matches[currentMatchCounter].AddBetToBetsList(be); betsCounter++; if (betsCounter >= matches[currentMatchCounter].NumberOfChildNodes) { currentMatchCounter++; betsCounter = 0; } } // Odds int oddsCounter = 0; int currentBetCounter = 0; foreach (XmlElement xe in xmlDocument.SelectNodes("xmlsports/sport/event/match/bet/odd")) { string oddName = xe.GetAttribute("name"); string oddId = xe.GetAttribute("id"); string oddValueString = xe.GetAttribute("value"); float oddValue = float.Parse(oddValueString); string betName = bets[currentBetCounter].Name; Bet currentBet = bets[currentBetCounter]; if (currentBet.NumberOfChildNodes <= 0) { while (bets[currentBetCounter].NumberOfChildNodes <= 0 && currentBetCounter < (bets.Count - 1)) { currentBetCounter++; } currentBet = bets[currentBetCounter]; } Odd od = new Odd(oddName, oddId, oddValue, currentBet); string specialBetValue; if (xe.HasAttribute("specialbetvalue")) { specialBetValue = xe.GetAttribute("specialbetvalue"); } odds.Add(od); bets[currentBetCounter].AddOddToOddsList(od); oddsCounter++; if (oddsCounter >= bets[currentBetCounter].NumberOfChildNodes) { currentBetCounter++; oddsCounter = 0; } } // todo: add foreach for odd return(matches); }
public System.IAsyncResult BeginUploadSport(Sport mySport, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("UploadSport", new object[] { mySport}, callback, asyncState); }
private static void LoadData() { var context = new SportsBettingContext(); context.Configuration.AutoDetectChangesEnabled = false; var xmlDoc = XDocument.Load(@"http://vitalbet.net/sportxml"); var sports = from sport in xmlDoc.Descendants("Sport") select new { SportName = sport.Attribute("Name").Value, SportOriginId = Convert.ToInt32(sport.Attribute("ID").Value), Events = (from ev in sport.Descendants("Event") select new { EventName = ev.Attribute("Name").Value, EventOriginId = Convert.ToInt32(ev.Attribute("ID").Value), Matches = (from m in ev.Descendants("Match") select new { MatchName = m.Attribute("Name").Value, MatchOriginId = Convert.ToInt32(m.Attribute("ID").Value), StartDate = Convert.ToDateTime(m.Attribute("StartDate").Value), MatchType = m.Attribute("MatchType").Value, Bets = (from b in m.Descendants("Bet") select new { BetName = b.Attribute("Name").Value, BettOriginId = Convert.ToInt32(b.Attribute("ID").Value), Odds = (from o in b.Descendants("Odd") select new { OddName = o.Attribute("Name").Value, OriginId = Convert.ToInt32(o.Attribute("ID").Value), OddValue = float.Parse(o.Attribute("Value").Value), SpecialBetValue = o.Attribute("SpecialBetValue") != null ? (float.Parse(o.Attribute("SpecialBetValue").Value)) : 0 }) }) }) }) }; foreach (var sp in sports) { Sport sport = new Sport { SportName = sp.SportName, SportOriginId = sp.SportOriginId }; context.Sports.AddOrUpdate(spp => spp.SportOriginId); foreach (var ev in sp.Events) { SportEvent eventa = new SportEvent(); eventa.EventName = ev.EventName; eventa.EventOriginId = ev.EventOriginId; eventa.Sport = sport; context.SportEvents.AddOrUpdate(spe => spe.EventOriginId); foreach (var mm in ev.Matches .Where(m => m.StartDate >= DateTime.Now && m.StartDate <= DateTime.Now.AddDays(1) && m.Bets.Count() != 0)) { Match match = new Match { MatchName = mm.MatchName, MatchOriginId = mm.MatchOriginId, MatchType = mm.MatchType, StartDate = mm.StartDate, SportEvent = eventa }; context.Matches.AddOrUpdate(mat => mat.MatchOriginId); foreach (var b in mm.Bets) { Bet bet = new Bet { BetName = b.BetName, BettOriginId = b.BettOriginId, Match = match, }; context.Bets.AddOrUpdate(mb => mb.BettOriginId); foreach (var o in b.Odds) { Odd odd = new Odd { OriginId = o.OriginId, OddValue = o.OddValue, OddName = o.OddName, SpecialBetValue = o.SpecialBetValue, Bet = bet }; context.Odds.AddOrUpdate(od => od.OriginId); } } } } } context.SaveChanges(); }
private Dictionary <int, Tuple <WorkoutStepMesg, LapMesg> > GetWorkoutStepsAndLaps(WorkoutSamples workoutSamples, Dynastream.Fit.DateTime startTime, Sport sport, SubSport subSport) { using var tracing = Tracing.Trace($"{nameof(FitConverter)}.{nameof(GetWorkoutStepsAndLaps)}") .WithTag(TagKey.Format, FileFormat.Fit.ToString()); var stepsAndLaps = new Dictionary <int, Tuple <WorkoutStepMesg, LapMesg> >(); if (workoutSamples is null) { return(stepsAndLaps); } var cadenceTargets = workoutSamples.Target_Performance_Metrics?.Target_Graph_Metrics?.FirstOrDefault(w => w.Type == "cadence")?.Graph_Data; if (cadenceTargets is null) { return(stepsAndLaps); } uint previousCadenceLower = 0; uint previousCadenceUpper = 0; ushort stepIndex = 0; var duration = 0; float lapDistanceInMeters = 0; WorkoutStepMesg workoutStep = null; LapMesg lapMesg = null; var speedMetrics = GetSpeedSummary(workoutSamples); foreach (var secondSinceStart in workoutSamples.Seconds_Since_Pedaling_Start) { var index = secondSinceStart <= 0 ? 0 : secondSinceStart - 1; duration++; if (speedMetrics is object && index < speedMetrics.Values.Length) { var currentSpeedInMPS = ConvertToMetersPerSecond(speedMetrics.GetValue(index), workoutSamples); lapDistanceInMeters += 1 * currentSpeedInMPS; } var currentCadenceLower = index < cadenceTargets.Lower.Length ? (uint)cadenceTargets.Lower[index] : 0; var currentCadenceUpper = index < cadenceTargets.Upper.Length ? (uint)cadenceTargets.Upper[index] : 0; if (currentCadenceLower != previousCadenceLower || currentCadenceUpper != previousCadenceUpper) { if (workoutStep != null && lapMesg != null) { workoutStep.SetDurationValue((uint)duration * 1000); // milliseconds var lapEndTime = new Dynastream.Fit.DateTime(startTime); lapEndTime.Add(secondSinceStart); lapMesg.SetTotalElapsedTime(duration); lapMesg.SetTotalTimerTime(duration); lapMesg.SetTimestamp(lapEndTime); lapMesg.SetEventType(EventType.Stop); lapMesg.SetTotalDistance(lapDistanceInMeters); stepsAndLaps.Add(stepIndex, new Tuple <WorkoutStepMesg, LapMesg>(workoutStep, lapMesg)); stepIndex++; duration = 0; lapDistanceInMeters = 0; } workoutStep = new WorkoutStepMesg(); workoutStep.SetDurationType(WktStepDuration.Time); workoutStep.SetMessageIndex(stepIndex); workoutStep.SetTargetType(WktStepTarget.Cadence); workoutStep.SetCustomTargetValueHigh(currentCadenceUpper); workoutStep.SetCustomTargetValueLow(currentCadenceLower); workoutStep.SetIntensity(currentCadenceUpper > 60 ? Intensity.Active : Intensity.Rest); lapMesg = new LapMesg(); var lapStartTime = new Dynastream.Fit.DateTime(startTime); lapStartTime.Add(secondSinceStart); lapMesg.SetStartTime(lapStartTime); lapMesg.SetWktStepIndex(stepIndex); lapMesg.SetMessageIndex(stepIndex); lapMesg.SetEvent(Event.Lap); lapMesg.SetLapTrigger(LapTrigger.Time); lapMesg.SetSport(sport); lapMesg.SetSubSport(subSport); previousCadenceLower = currentCadenceLower; previousCadenceUpper = currentCadenceUpper; } } return(stepsAndLaps); }
private void on_combo_sports_changed(object o, EventArgs args) { if (o == null) { return; } //LogB.Information("changed"); try { int sportID = Convert.ToInt32(Util.FindOnArray(':', 2, 0, UtilGtk.ComboGetActive(combo_sports), sports)); sport = SqliteSport.Select(false, sportID); if (Catalog.GetString(sport.Name) == Catalog.GetString(Constants.SportAny)) { //if sport is undefined, level should be undefined, and unsensitive try { combo_levels.Active = UtilGtk.ComboMakeActive(levels, Constants.LevelUndefinedID.ToString() + ":" + Catalog.GetString(Constants.LevelUndefined)); combo_levels.Sensitive = false; combo_speciallities.Active = UtilGtk.ComboMakeActive(speciallitiesTranslated, Catalog.GetString(Constants.SpeciallityUndefined)); label_speciallity.Hide(); combo_speciallities.Hide(); } catch { LogB.Warning("do later"); } } else if (Catalog.GetString(sport.Name) == Catalog.GetString(Constants.SportNone)) { //if sport is none, level should be sedentary and unsensitive try { combo_levels.Active = UtilGtk.ComboMakeActive(levels, Constants.LevelSedentaryID.ToString() + ":" + Catalog.GetString(Constants.LevelSedentary)); combo_levels.Sensitive = false; combo_speciallities.Active = UtilGtk.ComboMakeActive(speciallitiesTranslated, Catalog.GetString(Constants.SpeciallityUndefined)); label_speciallity.Hide(); combo_speciallities.Hide(); } catch { LogB.Warning("do later"); } } else { //sport is not undefined and not none //if level is "sedentary", then change level to "undefined" if (UtilGtk.ComboGetActive(combo_levels) == Constants.LevelSedentaryID.ToString() + ":" + Catalog.GetString(Constants.LevelSedentary)) { combo_levels.Active = UtilGtk.ComboMakeActive(levels, Constants.LevelUndefinedID.ToString() + ":" + Catalog.GetString(Constants.LevelUndefined)); } //show level combo_levels.Sensitive = true; if (sport.HasSpeciallities) { combo_speciallities.Destroy(); createComboSpeciallities(sport.UniqueID); label_speciallity.Show(); combo_speciallities.Show(); } else { LogB.Information("hide"); combo_speciallities.Active = UtilGtk.ComboMakeActive(speciallitiesTranslated, Catalog.GetString(Constants.SpeciallityUndefined)); label_speciallity.Hide(); combo_speciallities.Hide(); } } } catch { //LogB.Warning("do later"); } on_entries_required_changed(new object(), new EventArgs()); LogB.Information(sport.ToString()); }
public ICollection <LapMesg> GetLapsBasedOnSegments(WorkoutSamples workoutSamples, Dynastream.Fit.DateTime startTime, Sport sport, SubSport subSport) { using var tracing = Tracing.Trace($"{nameof(FitConverter)}.{nameof(GetLapsBasedOnSegments)}") .WithTag(TagKey.Format, FileFormat.Fit.ToString()); var stepsAndLaps = new List <LapMesg>(); if (workoutSamples is null) { return(stepsAndLaps); } ushort stepIndex = 0; var speedMetrics = GetSpeedSummary(workoutSamples); if (workoutSamples.Segment_List.Any()) { var totalElapsedTime = 0; foreach (var segment in workoutSamples.Segment_List) { var lapStartTime = new Dynastream.Fit.DateTime(startTime); lapStartTime.Add(segment.Start_Time_Offset); totalElapsedTime += segment.Length; var lapMesg = new LapMesg(); lapMesg.SetStartTime(lapStartTime); lapMesg.SetMessageIndex(stepIndex); lapMesg.SetEvent(Event.Lap); lapMesg.SetLapTrigger(LapTrigger.Time); lapMesg.SetSport(sport); lapMesg.SetSubSport(subSport); lapMesg.SetTotalElapsedTime(segment.Length); lapMesg.SetTotalTimerTime(segment.Length); var startIndex = segment.Start_Time_Offset; var endIndex = segment.Start_Time_Offset + segment.Length; var lapDistanceInMeters = 0f; for (int i = startIndex; i < endIndex; i++) { if (speedMetrics is object && i < speedMetrics.Values.Length) { var currentSpeedInMPS = ConvertToMetersPerSecond(speedMetrics.GetValue(i), workoutSamples); lapDistanceInMeters += 1 * currentSpeedInMPS; } } lapMesg.SetTotalDistance(lapDistanceInMeters); stepsAndLaps.Add(lapMesg); stepIndex++; } } return(stepsAndLaps); }
public static void WrapIn(this SportDto dto, Sport sport) { sport.Name = dto.Name; }
public OddsCheckerWebAsyncOddsStrategy(Sport sport, IBookmakerRepository bookmakerRepository, IFixtureRepository fixtureRepository, IWebRepositoryProviderAsync webRepositoryProvider) : base(sport, bookmakerRepository, fixtureRepository, webRepositoryProvider) { }
public async Task <List <Team> > GetTeamsBySportAsync(Sport sport) { return(await _context.Teams.Include(s => s.UserTeams).Where(s => s.TeamSportType == sport).ToListAsync()); }
public void Update(Sport sport) { _context.Sports.Update(sport); _context.SaveChanges(); }
protected override void Seed(Projectwerk.Vermeersch.f.Data.TriatlonContext context) { var role1 = new Role { Rolenaam = "Gast" }; var role2 = new Role { Rolenaam = "Lid" }; var role3 = new Role { Rolenaam = "Admin" }; var roles = new List <Role> { role1, role2, role3 }; roles.ForEach(r => context.Roles.AddOrUpdate(x => x.Rolenaam, r)); context.SaveChanges(); var sex1 = new Sex { Geslacht = "M" }; var sex2 = new Sex { Geslacht = "V" }; var sexes = new List <Sex> { sex1, sex2 }; sexes.ForEach(s => context.Sexes.AddOrUpdate(x => x.Geslacht, s)); context.SaveChanges(); var afstand1 = new Afstand { Lengte = "Sprint" }; var afstand2 = new Afstand { Lengte = "Kwart" }; var afstand3 = new Afstand { Lengte = "Half" }; var afstand4 = new Afstand { Lengte = "Volledig" }; var afstanden = new List <Afstand> { afstand1, afstand2, afstand3, afstand4 }; afstanden.ForEach(a => context.Afstanden.AddOrUpdate(x => x.Lengte, a)); context.SaveChanges(); var sport1 = new Sport { soortSport = "Triatlon" }; var sport2 = new Sport { soortSport = "Duatlon" }; var sporten = new List <Sport> { sport1, sport2 }; sporten.ForEach(s => context.Sporten.AddOrUpdate(x => x.soortSport, s)); context.SaveChanges(); var wedstrijd1 = new Wedstrijd { Plaats = "oostkamp", Datum = DateTime.Parse("15-01-2018"), AfstandId = afstanden.Single(a => a.Lengte == "Kwart").Id, SportId = sporten.Single(s => s.soortSport == "Triatlon").Id, Stayer = false //Deelnemers = new List<Putter>(), //Resultaten = new List<Resultaat>() }; var wedstrijd2 = new Wedstrijd { Plaats = "oostkamp", Datum = DateTime.Parse("15-01-2018"), Stayer = true, AfstandId = afstand1.Id, SportId = sporten.Single(s => s.soortSport == "Triatlon").Id }; var wedstrijd3 = new Wedstrijd { Plaats = "moerbrugge", Datum = DateTime.Parse("18-02-2018"), Stayer = false, AfstandId = afstand3.Id, SportId = sporten.Single(s => s.soortSport == "Triatlon").Id }; var wedstrijd4 = new Wedstrijd { Plaats = "waardamme", Datum = DateTime.Parse("25-02-2018"), Stayer = true, AfstandId = afstand2.Id, SportId = sporten.Single(s => s.soortSport == "Triatlon").Id }; var wedstrijd5 = new Wedstrijd { Plaats = "waardamme", Datum = DateTime.Parse("25-02-2018"), Stayer = true, AfstandId = afstand2.Id, SportId = sporten.Single(s => s.soortSport == "Duatlon").Id }; var wedstrijden = new List <Wedstrijd> { wedstrijd1, wedstrijd2, wedstrijd3, wedstrijd4, wedstrijd5 }; wedstrijden.ForEach(w => context.Wedstrijden.AddOrUpdate(x => new { x.Plaats, x.AfstandId, x.SportId }, w)); context.SaveChanges(); var p1 = new Putter { SexID = sexes.Single(s => s.Geslacht == "M").Id, RoleID = roles.Single(r => r.Rolenaam == "Admin").Id, Naam = "Vermeersch", Voornaam = "Filip", Licentie = true, Paswoord = "fluppe", Gebruikersnaam = "fluppe", Email = "*****@*****.**", Woonplaats = "Brugge", Geboortedatum = DateTime.Parse("16-02-1972"), Wedstrijden = new List <Wedstrijd>() { wedstrijd1, wedstrijd3, wedstrijd4 } }; var p2 = new Putter { SexID = sexes.Single(s => s.Geslacht == "M").Id, RoleID = roles.Single(r => r.Rolenaam == "Lid").Id, Naam = "Bonamie", Voornaam = "Davey", Licentie = false, Woonplaats = "Oostkamp", Wedstrijden = new List <Wedstrijd>() { wedstrijd1, wedstrijd3, wedstrijd4 }, Geboortedatum = DateTime.Parse("14-10-1986"), Paswoord = "davey", Gebruikersnaam = "davey", // Resultaten = new List<Resultaat>() { } }; var p3 = new Putter { SexID = sexes.Single(s => s.Geslacht == "V").Id, RoleID = roles.Single(r => r.Rolenaam == "Lid").Id, Naam = "Dufour", Voornaam = "Sjoukje", Licentie = true, Woonplaats = "Brugge", Wedstrijden = new List <Wedstrijd>() { wedstrijd5 }, Geboortedatum = DateTime.Parse("05-10-1987"), Paswoord = "sjoukje", Gebruikersnaam = "sjoukje" }; var p4 = new Putter { SexID = sexes.Single(s => s.Geslacht == "M").Id, RoleID = roles.Single(r => r.Rolenaam == "Lid").Id, Naam = "Hillewaere", Voornaam = "Dries", Licentie = true, Woonplaats = "Oostkamp", Wedstrijden = new List <Wedstrijd>() { wedstrijd2 }, Geboortedatum = DateTime.Parse("26-02-1977"), Paswoord = "dries", Gebruikersnaam = "dries" }; var p5 = new Putter { SexID = sexes.Single(s => s.Geslacht == "M").Id, RoleID = roles.Single(r => r.Rolenaam == "Lid").Id, Naam = "Pollet", Voornaam = "Marc", Licentie = true, Woonplaats = "Varsenare", Wedstrijden = new List <Wedstrijd>() { wedstrijd2, wedstrijd3 }, Geboortedatum = DateTime.Parse("19-08-1969"), Paswoord = "marc", Gebruikersnaam = "marc" }; var p6 = new Putter { SexID = sexes.Single(s => s.Geslacht == "V").Id, RoleID = roles.Single(r => r.Rolenaam == "Lid").Id, Naam = "Sap", Voornaam = "Julie", Licentie = true, Woonplaats = "Beernem", // Wedstrijden = new List<Wedstrijd>(), Geboortedatum = DateTime.Parse("10-06-1992"), Paswoord = "julie", Gebruikersnaam = "julie" }; var p7 = new Putter { SexID = sexes.Single(s => s.Geslacht == "M").Id, RoleID = roles.Single(r => r.Rolenaam == "Lid").Id, Naam = "Buffel", Voornaam = "Bruno", Licentie = true, Woonplaats = "Baliebrugge", //Wedstrijden = new List<Wedstrijd>(), Geboortedatum = DateTime.Parse("14-10-1976"), Paswoord = "bruno", Gebruikersnaam = "bruno" }; var p8 = new Putter { SexID = sexes.Single(s => s.Geslacht == "M").Id, RoleID = roles.Single(r => r.Rolenaam == "Lid").Id, Naam = "Stubbe", Voornaam = "Joeri", Licentie = true, Woonplaats = "Oostkamp", // Wedstrijden = new List<Wedstrijd>(), Geboortedatum = DateTime.Parse("04-10-1978"), Paswoord = "joeri", Gebruikersnaam = "joeri" }; var p9 = new Putter { SexID = sexes.Single(s => s.Geslacht == "M").Id, RoleID = roles.Single(r => r.Rolenaam == "Lid").Id, Naam = "Vandenberghe", Voornaam = "Nico", Licentie = true, Woonplaats = "Dudzele", // Wedstrijden = new List<Wedstrijd>(), Geboortedatum = DateTime.Parse("05-11-1978"), Paswoord = "nico", Gebruikersnaam = "nico" }; var p10 = new Putter { SexID = sexes.Single(s => s.Geslacht == "M").Id, RoleID = roles.Single(r => r.Rolenaam == "Lid").Id, Naam = "Van Ryckeghem", Voornaam = "Guy", Licentie = true, Woonplaats = "Oostkamp", // Wedstrijden = new List<Wedstrijd>(), Paswoord = "guy", Gebruikersnaam = "guy" }; var putters = new List <Putter> { p1, p2, p3, p4, p5, p6, p7, p8, p9, p10 }; putters.ForEach(p => context.Putters.AddOrUpdate(x => new { x.Voornaam, x.Naam }, p)); context.SaveChanges(); var r1 = new Resultaat { PutterID = p1.Id, UitslagAlgemeen = 40, UitslagCategorie = 3, WedstrijdId = wedstrijd1.Id }; var r2 = new Resultaat { PutterID = p2.Id, UitslagAlgemeen = 30, UitslagCategorie = 7, WedstrijdId = wedstrijd1.Id }; var r3 = new Resultaat { PutterID = p4.Id, UitslagAlgemeen = 20, UitslagCategorie = 4, WedstrijdId = wedstrijd2.Id }; var r4 = new Resultaat { PutterID = p5.Id, UitslagAlgemeen = 25, UitslagCategorie = 6, WedstrijdId = wedstrijd2.Id }; var r5 = new Resultaat { PutterID = p1.Id, UitslagAlgemeen = 18, UitslagCategorie = 2, WedstrijdId = wedstrijd3.Id }; var r6 = new Resultaat { PutterID = p2.Id, UitslagAlgemeen = 16, UitslagCategorie = 4, WedstrijdId = wedstrijd3.Id }; var r7 = new Resultaat { PutterID = p5.Id, UitslagAlgemeen = 11, UitslagCategorie = 2, WedstrijdId = wedstrijd3.Id }; var r8 = new Resultaat { PutterID = p1.Id, UitslagAlgemeen = 24, UitslagCategorie = 3, WedstrijdId = wedstrijd4.Id }; var r9 = new Resultaat { PutterID = p2.Id, UitslagAlgemeen = 44, UitslagCategorie = 3, WedstrijdId = wedstrijd4.Id }; var r10 = new Resultaat { PutterID = p3.Id, UitslagAlgemeen = 33, UitslagCategorie = 1, WedstrijdId = wedstrijd5.Id }; var resultaten = new List <Resultaat> { r1, r2, r3, r4, r5, r6, r7, r8, r9, r10 }; resultaten.ForEach(r => context.Resultaten.AddOrUpdate(x => new { x.PutterID, x.WedstrijdId }, r)); context.SaveChanges(); }
public void Insert(Sport entity) { _db.Sports.Add(entity); _db.SaveChanges(); }
public SportPostPut(Sport s) { SportId = s.SportId; }
public Skill_data(int anim_index, float anim_duration, float recording_duration, string anim_name, string display_name, string description_trial, Compare.Utilities.Properties.Activity compare_activity, Camera_view camera_view, Sport target_sport) { _anim_index = anim_index; _anim_duration = anim_duration; _recording_duration = recording_duration; _anim_name = anim_name; _display_name = display_name; _description_trial = description_trial; _compare_activity = compare_activity; _camera_view = camera_view; _target_sport = target_sport; _score = 0.0f; }
public SportDto(Sport sport) { this.sport = sport; this.markets = new List <IMarket>(this.sport.Markets.Select(x => new MarketDto(x))); }
public int UploadSport(Sport mySport) { int id = -1; //upload if doesn't exists (uploaded before by this or other evaluator) if(! Sqlite.Exists(Constants.SportTable, mySport.Name)) id = mySport.InsertAtDB(false); return id; //uniqueID of sport at server }
private Sport CreateFutbolTeam() { Sport futbol = new Sport("Futbol"); return(futbol); }
private void fillDialog() { int mySportID; int mySpeciallityID; int myLevelID; if(adding) { //now dateTime is undefined until user changes it dateTime = DateTime.MinValue; label_date.Text = Catalog.GetString("Undefined"); mySportID = currentSession.PersonsSportID; mySpeciallityID = currentSession.PersonsSpeciallityID; myLevelID = currentSession.PersonsPractice; } else { //PERSON STUFF entry1.Text = currentPerson.Name; if (currentPerson.Sex == Constants.M) { radiobutton_man.Active = true; } else { radiobutton_woman.Active = true; } dateTime = currentPerson.DateBorn; if(dateTime == DateTime.MinValue) label_date.Text = Catalog.GetString("Undefined"); else label_date.Text = dateTime.ToLongDateString(); //country stuff if(currentPerson.CountryID != Constants.CountryUndefinedID) { string [] countryString = SqliteCountry.Select(currentPerson.CountryID); combo_continents.Active = UtilGtk.ComboMakeActive(continentsTranslated, Catalog.GetString(countryString[3])); combo_countries.Active = UtilGtk.ComboMakeActive(countriesTranslated, Catalog.GetString(countryString[1])); } TextBuffer tb1 = new TextBuffer (new TextTagTable()); tb1.Text = currentPerson.Description; textview_description.Buffer = tb1; serverUniqueID = currentPerson.ServerUniqueID; //PERSONSESSION STUFF PersonSession myPS = SqlitePersonSession.Select(currentPerson.UniqueID, currentSession.UniqueID); spinbutton_height.Value = myPS.Height; spinbutton_weight.Value = myPS.Weight; weightIni = myPS.Weight; //store for tracking if changes mySportID = myPS.SportID; mySpeciallityID = myPS.SpeciallityID; myLevelID = myPS.Practice; TextBuffer tb2 = new TextBuffer (new TextTagTable()); tb2.Text = myPS.Comments; textview_ps_comments.Buffer = tb2; } sport = SqliteSport.Select(false, mySportID); combo_sports.Active = UtilGtk.ComboMakeActive(sportsTranslated, sport.ToString()); combo_speciallities.Active = UtilGtk.ComboMakeActive(speciallitiesTranslated, SqliteSpeciallity.Select(false, mySpeciallityID)); combo_levels.Active = UtilGtk.ComboMakeActive(levels, myLevelID + ":" + Util.FindLevelName(myLevelID)); }
public virtual void ReadXML() { string urlPath = Constant.SourceXML.TITABETURL; string mainSport = ConfigurationManager.AppSettings["TITANBETMAINSPORT"].ToString(); _lstSport = new List<Sport>(); _lstEvent = new List<Event>(); _lstMatch = new List<Match>(); _lstBet = new List<Bet>(); _lstChoice = new List<Choice>(); XmlTextReader reader = new XmlTextReader(urlPath); // Skip non-significant whitespace reader.WhitespaceHandling = WhitespaceHandling.Significant; XPathDocument doc = new XPathDocument(reader, XmlSpace.Preserve); XPathNavigator nav = doc.CreateNavigator(); string[] arrMainSportId = mainSport.Split(','); try { int _sportId = 0; int _eventId = 0; long _matchId = 0; long _betId = 0; long _choiceId = 0; foreach (string sportid in arrMainSportId) { XPathExpression exprSport; exprSport = nav.Compile("/bookmaker/sport[@id='" + sportid + "']"); XPathNodeIterator iteratorSport = nav.Select(exprSport); while (iteratorSport.MoveNext()) { XPathNavigator _sportNameNavigator = iteratorSport.Current.Clone(); _sportId++; Sport _sport = new Sport(); _sport.sportId = _sportId; _sport.sportName = _sportNameNavigator.GetAttribute("name", ""); _lstSport.Add(_sport); if (_sportNameNavigator.HasChildren) { XPathExpression exprevent; exprevent = _sportNameNavigator.Compile("group"); XPathNodeIterator iteratorEvent = _sportNameNavigator.Select(exprevent); while (iteratorEvent.MoveNext()) { _eventId++; XPathNavigator _eventNameNavigator = iteratorEvent.Current.Clone(); Event _event = new Event(); _event.eventId = _eventId; _event.sportId = _sportId; _event.eventName = _eventNameNavigator.GetAttribute("name", ""); _lstEvent.Add(_event); if (_eventNameNavigator.HasChildren) { XPathExpression exprematch; exprematch = _eventNameNavigator.Compile("event"); XPathNodeIterator iteratorMatch = _eventNameNavigator.Select(exprematch); while (iteratorMatch.MoveNext()) { _matchId++; XPathNavigator _matchNameNavigator = iteratorMatch.Current.Clone(); Match _match = new Match(); _match.matchId = _matchId; _match.eventId = _eventId; string[] league = _matchNameNavigator.GetAttribute("name", "").Split('-'); if (league.Length > 1) { _match.homeTeam = league[0].Trim(); _match.awayTeam = league[1].Trim(); } else { _match.homeTeam = _matchNameNavigator.GetAttribute("name", ""); } _match.startTime = Convert.ToDateTime(_matchNameNavigator.GetAttribute("date", "")); _lstMatch.Add(_match); if (_matchNameNavigator.HasChildren) { string OddTypeString = string.Empty; switch (_sportId) { case 1: OddTypeString = Constant.TitanBetOddTypeID.CRICKET; break; case 2: OddTypeString = Constant.TitanBetOddTypeID.HANDBALL; break; case 3: OddTypeString = Constant.TitanBetOddTypeID.HORSERACING; break; case 4: OddTypeString = Constant.TitanBetOddTypeID.MOTORSPORTS; break; case 5: OddTypeString = Constant.TitanBetOddTypeID.BOXING; break; case 6: OddTypeString = Constant.TitanBetOddTypeID.GOLF; break; case 7: OddTypeString = Constant.TitanBetOddTypeID.TENNIS; break; case 8: OddTypeString = Constant.TitanBetOddTypeID.FOOTBALL; break; } string[] arrOddTypeId = OddTypeString.Split(','); foreach (string oddTypeId in arrOddTypeId) { XPathExpression exprebet; exprebet = _matchNameNavigator.Compile("market[@tid='"+oddTypeId+"']"); XPathNodeIterator iteratorBet = _matchNameNavigator.Select(exprebet); while (iteratorBet.MoveNext()) { _betId++; XPathNavigator _betNameNavigator = iteratorBet.Current.Clone(); Bet _bet = new Bet(); _bet.betId = _betId; _bet.matchId = _matchId; _bet.betName = _betNameNavigator.GetAttribute("name", ""); _bet.betCodeID = _betNameNavigator.GetAttribute("tid", ""); _lstBet.Add(_bet); if (_betNameNavigator.HasChildren) { XPathExpression exprechoice; exprechoice = _betNameNavigator.Compile("outcome"); XPathNodeIterator iteratorChoice = _betNameNavigator.Select(exprechoice); while (iteratorChoice.MoveNext()) { _choiceId++; XPathNavigator _choiceNameNavigator = iteratorChoice.Current.Clone(); Choice _choice = new Choice(); _choice.choiceId = _choiceId; _choice.betId = _betId; _choice.choiceCodeId = (long)Constant.ChoiceType.OTHER; _choice.choiceCodeName = "OTHER"; _choice.choiceName = _choiceNameNavigator.GetAttribute("name", ""); _choice.odd = _choiceNameNavigator.GetAttribute("odds", ""); _choice.american_odd = _choiceNameNavigator.GetAttribute("american_odds", ""); _choice.fra_odd = _choiceNameNavigator.GetAttribute("fra_odds", ""); _lstChoice.Add(_choice); } } } } } } } } } } } } catch (Exception ex) { throw new Exception(ex.Message); } }
private void on_sport_add_accepted(object o, EventArgs args) { genericWin.Button_accept.Clicked -= new EventHandler(on_sport_add_accepted); string newSportName = genericWin.EntrySelected; if(Sqlite.Exists(false, Constants.SportTable, newSportName) || newSportName == Catalog.GetString(Constants.SportUndefined) || //let's save problems newSportName == Catalog.GetString(Constants.SportNone) //let's save problems ) new DialogMessage(Constants.MessageTypes.WARNING, string.Format( Catalog.GetString("Sorry, this sport '{0}' already exists in database"), newSportName)); else { int myID = SqliteSport.Insert(false, "-1", newSportName, true, //dbconOpened, , userDefined false, ""); //hasSpeciallities, graphLink Sport mySport = new Sport(myID, newSportName, true, false, ""); //hasSpeciallities, graphLink sports = SqliteSport.SelectAll(); //create sports translated, only with translated stuff sportsTranslated = new String[sports.Length]; int i = 0; foreach(string row in sports) { string [] myStrFull = row.Split(new char[] {':'}); sportsTranslated[i++] = myStrFull[2]; } //sort array (except second row) System.Array.Sort(sportsTranslated, 2, sportsTranslated.Length-2); UtilGtk.ComboUpdate(combo_sports, sportsTranslated, mySport.ToString()); combo_sports.Active = UtilGtk.ComboMakeActive(sportsTranslated, mySport.ToString()); //on_combo_sports_changed(combo_sports, new EventArgs()); } }
protected override void Seed(Context context) { var result1 = new Result() { Rank = 1 }; context.Results.Add(result1); var result2 = new Result() { Rank = 2 }; context.Results.Add(result2); var result3 = new Result() { Rank = 3 }; context.Results.Add(result3); var result4 = new Result() { Rank = 4 }; context.Results.Add(result4); var result5 = new Result() { Rank = 5 }; context.Results.Add(result5); var result6 = new Result() { Rank = 6 }; context.Results.Add(result6); var athlete1 = new Athlete() { FirstName = "Bob", LastName = "Marley", Naissance = new DateTime(1991, 02, 11) }; context.Athletes.Add(athlete1); var athlete2 = new Athlete() { FirstName = "Jacques", LastName = "Plante", Naissance = new DateTime(1992, 07, 08) }; context.Athletes.Add(athlete2); var athlete3 = new Athlete() { FirstName = "Yves", LastName = "Morissette", Naissance = new DateTime(1993, 01, 03) }; context.Athletes.Add(athlete3); var athlete4 = new Athlete() { FirstName = "Elvis", LastName = "Presley", Naissance = new DateTime(1994, 05, 24) }; context.Athletes.Add(athlete4); var athlete5 = new Athlete() { FirstName = "Chuck", LastName = "Noris", Naissance = new DateTime(1995, 02, 15) }; context.Athletes.Add(athlete5); var sport1 = new Sport() { Name = "Athlétisme", }; context.Sports.Add(sport1); var sport2 = new Sport() { Name = "Lutte", }; context.Sports.Add(sport2); var competition1 = new Competition() { Location = "Stade Athlétisme", SportId = 1, CompetitionDate = new DateTime(2018, 3, 1) }; competition1.AddAthlete(athlete4, result1); competition1.AddAthlete(athlete1, result2); competition1.AddAthlete(athlete5, result3); competition1.AddAthlete(athlete2, result4); context.Competitions.Add(competition1); var competition2 = new Competition() { Location = "Amphithéatre", SportId = 2, CompetitionDate = new DateTime(2018, 3, 2) }; competition2.AddAthlete(athlete5, result1); competition2.AddAthlete(athlete3, result2); competition2.AddAthlete(athlete1, result3); competition2.AddAthlete(athlete2, result4); context.Competitions.Add(competition2); context.SaveChanges(); }
public static Sport Select(int uniqueID) { dbcon.Open(); dbcmd.CommandText = "SELECT * FROM " + Constants.SportTable + " WHERE uniqueID == " + uniqueID; Log.WriteLine(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); reader.Read(); Sport mySport = new Sport( uniqueID, reader[1].ToString(), //name Util.IntToBool(Convert.ToInt32(reader[2])), //userDefined Util.IntToBool(Convert.ToInt32(reader[3])), //hasSpeciallities reader[4].ToString() //graphLink ); reader.Close(); dbcon.Close(); return mySport; }
public async Task GenerateOffer() { var date = DateTime.Now; var yesterday = date.AddDays(-1).ToString("yyyy-MM-dd"); var tommorow = date.AddDays(1).ToString("yyyy-MM-dd"); string url = $"https://sportdataprovider.volcanobet.me/api/public/prematch/SportEvents?SportId=1&from={yesterday}T23:00:00.000Z&to={tommorow}T06:00:00.000Z&timezone=-60&clientType=WebConsumer&v=1.1.496-rc6&lang=sr-Latn-EN"; string html; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.AutomaticDecompression = DecompressionMethods.GZip; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) using (Stream stream = response.GetResponseStream()) using (StreamReader reader = new StreamReader(stream)) { html = reader.ReadToEnd(); } var offer = JsonConvert.DeserializeObject <OfferModel>(html); var sport = await _context.Sport.Where(s => s.Name == offer.Sport.Name).FirstOrDefaultAsync(); if (sport == null) { sport = new Sport(); sport.Name = offer.Sport.Name; _context.AddRange(sport); _context.SaveChanges(); } foreach (var location in offer.Locations) { foreach (var league in location.Leagues) { var leagueDatabase = await _context.League.Where(l => l.Name == $"{location.Name} - {league.Name}") .SingleOrDefaultAsync(); if (leagueDatabase == null) { leagueDatabase = new League(); leagueDatabase.Name = $"{location.Name} - {league.Name}"; leagueDatabase.Sport = sport; _context.League.AddRange(leagueDatabase); _context.SaveChanges(); } foreach (var eventDate in league.EventDateGroups) { foreach (var eventDateEvent in eventDate.Events) { var matchModel = new Match(); matchModel.Competition = league.Name; matchModel.Id = eventDateEvent.Id; var types = new Type(); matchModel.Sport = sport; matchModel.Time = eventDateEvent.Fixture.StartDate.AddHours(1); var firstTeam = await _context.Team .Where(t => t.Name == eventDateEvent.Fixture.Participants[0].Name) .FirstOrDefaultAsync(); var secondTeam = await _context.Team .Where(t => t.Name == eventDateEvent.Fixture.Participants[1].Name) .FirstOrDefaultAsync(); if (firstTeam == null) { firstTeam = new Team(); firstTeam.League = leagueDatabase; firstTeam.Name = eventDateEvent.Fixture.Participants[0].Name; _context.Team.AddRange(firstTeam); matchModel.HomeTeam = firstTeam; } if (firstTeam != null) { matchModel.HomeTeam = firstTeam; } if (secondTeam == null) { secondTeam = new Team(); secondTeam.League = leagueDatabase; secondTeam.Name = eventDateEvent.Fixture.Participants[1].Name; _context.Team.AddRange(secondTeam); matchModel.AwayTeam = secondTeam; } if (secondTeam != null) { matchModel.AwayTeam = secondTeam; } foreach (var market in eventDateEvent.Markets) { if (market.Name == "1x2") { foreach (var pick in market.Picks) { if (pick.Name == "1") { types._1 = pick.Odds; } if (pick.Name == "x") { types._X = pick.Odds; } if (pick.Name == "2") { types._2 = pick.Odds; } } } if (market.Name == "Double chance") { foreach (var pick in market.Picks) { if (pick.Name == "1x") { types._1X = pick.Odds; } if (pick.Name == "x2") { types._X2 = pick.Odds; } if (pick.Name == "12") { types._12 = pick.Odds; } } } } var matchExist = await _context.Match .Include(h => h.HomeTeam) .Include(a => a.AwayTeam) .Where(m => m.HomeTeam == matchModel.HomeTeam && m.AwayTeam == matchModel.AwayTeam && m.Time == matchModel.Time).FirstOrDefaultAsync(); if (matchExist == null && matchModel.HomeTeam != null && matchModel.AwayTeam != null) { matchModel.Type = types; matchModel.TopMatch = false; matchModel.Hide = false; _context.Match.Add(matchModel); _context.SaveChanges(); } } } } } }
public int UploadSport(Sport mySport) { object[] results = this.Invoke("UploadSport", new object[] { mySport}); return ((int)(results[0])); }
public void TestInit() { futbol = CreateFutbolSport(); river = CreateTeamThatBelongsInTheB(); boca = CreateBocaTeam(); }
public void UploadSportAsync(Sport mySport, object userState) { if ((this.UploadSportOperationCompleted == null)) { this.UploadSportOperationCompleted = new System.Threading.SendOrPostCallback(this.OnUploadSportCompleted); } this.InvokeAsync("UploadSport", new object[] { mySport}, this.UploadSportOperationCompleted, userState); }
public async Task <int> SaveSport(Sport sport) { return(await _db.Database.ExecuteSqlCommandAsync($"InsertSport {sport.SportName} ")); }
/// <summary> /// Set Sport field</summary> /// <param name="sport_">Nullable field value to be set</param> public void SetSport(Sport? sport_) { SetFieldValue(0, 0, sport_, Fit.SubfieldIndexMainField); }
public async Task <int> UpdateSport(Sport sport) { return(await _db.Database.ExecuteSqlCommandAsync($"[dbo].UpdateSport {sport.SportID},{sport.SportName}")); }