Exemple #1
0
 public Event(string eventID, string competitionType, Team team1, Team team2)
 {
     EventId = eventID;
     CompetitionType = competitionType;
     Team1 = team1;
     Team2 = team2;
 }
Exemple #2
0
        public Event GetTennisEventInformation(string id)
        {
            Subscribe(id);

            var header = new WebHeaderCollection {{"method", "1"}};
            var requestPow = powRequest(2, header);
            if (requestPow.Length < 50)
            {
                Debug.Write("Error. Repsonse from server" + requestPow);
                Unsubscribe(id);
                GetTennisEventInformation(id);
            }
            var eventExpandedData = requestPow.Split((char) 0x01);
            eventExpandedData = eventExpandedData[eventExpandedData.Length - 1].Split((char) 0x7c);

            var resultList = new List<Dictionary<string, string>>();
            var currentRoot = new Dictionary<string, string>();

            resultList.Add(new Dictionary<string, string>());
            resultList.Add(new Dictionary<string, string>());

            var firstItem = true;

            string currentKey = null;
            string competitionType = null;
            string eventName = null;

            string team1Score = null;
            string team2Score = null;

            string name1Player = null;
            string name2Player = null;

            foreach (var anEventExpandedData in eventExpandedData)
            {
                var parsedLine = parameterizeLine(anEventExpandedData);

                if (parsedLine == null)
                    continue;

                if (parsedLine.ContainsKey("EV"))
                {
                    //Event
                    parsedLine.TryGetValue("EV", out currentRoot);
                    Debug.Assert(currentRoot != null, "currentRoot != null");
                    currentRoot?.TryGetValue("CT", out competitionType);
                    currentRoot?.TryGetValue("NA", out eventName);
                }
                else if (parsedLine.ContainsKey("SC"))
                {
                    parsedLine.TryGetValue("SC", out currentRoot);
                    if (firstItem)
                    {
                        currentKey = "name";
                        firstItem = false;
                    }
                    else
                    {
                        Debug.Assert(currentRoot != null, "currentRoot != null");
                        currentRoot.TryGetValue("NA", out currentKey);
                    }
                }
                else if (parsedLine.ContainsKey("TE"))
                {
                    parsedLine.TryGetValue("TE", out currentRoot);
                    var equelsValue = "";
                    currentRoot.TryGetValue("OR", out equelsValue);
                    if (string.Equals(equelsValue, "0"))
                    {
                        currentRoot.TryGetValue("PO", out team1Score);
                        currentRoot.TryGetValue("NA", out name1Player);
                    }
                    else
                    {
                        currentRoot.TryGetValue("NA", out name2Player);
                        currentRoot.TryGetValue("PO", out team2Score);
                    }
                }
            }
            Unsubscribe(id);
            if (competitionType == null)
            {
                Debug.WriteLine("[Bet365] Competition Type null");
                Debug.Write("Repsonse from server" + requestPow);
                return null;
            }
            var team1 = new Team(name1Player, team1Score);
            var team2 = new Team(name2Player, team2Score);
            var eEvent = new Event(id, competitionType, team1, team2);
            return eEvent;
        }