Exemplo n.º 1
0
        private void parseJsonEvent(string message, SPORT sport)
        {
            try
            {
                string json = getJsonFromResponse(message);
                if (string.IsNullOrEmpty(json))
                {
                    return;
                }

                JsonEventGroup result = JsonConvert.DeserializeObject <JsonEventGroup>(json);
                if (result == null || result.list == null || result.list.Count < 1)
                {
                    return;
                }

                foreach (JsonEventGroupList groupList in result.list)
                {
                    if (groupList.eve == null)
                    {
                        continue;
                    }

                    // check sports and leagues here
                    if (sport == SPORT.Horse || sport == SPORT.Dog)
                    {
                        TempMatchInfo matchInfo = new TempMatchInfo();
                        matchInfo.id    = groupList.id;
                        matchInfo.sport = sport;
                        matchInfo.name  = groupList.eve.nameTranslations.unpiped;

                        matchInfos.Add(matchInfo);

                        continue;
                    }
                }
            }
            catch (Exception e)
            {
                onWriteLog(string.Format("[{0}]{1} (parseJsonEvent) ---> {2}", DateTime.Now.ToString(), getLogTitle(), e.ToString()));
            }
        }
Exemplo n.º 2
0
        private List <TempMatchInfo> parseSocketResponseDog(string response)
        {
            List <TempMatchInfo> infos = new List <TempMatchInfo>();
            string temp = response.Substring(response.LastIndexOf("NA=Greyhounds;"));

            bool bBasketball = false;

            TempMatchInfo info = new TempMatchInfo();

            while (temp.Contains(";"))
            {
                string semicolonString = temp.Substring(0, temp.IndexOf(";"));
                temp = temp.Substring(temp.IndexOf(";") + 1, temp.Length - temp.IndexOf(";") - 1);

                if (semicolonString == "NA=Greyhounds")
                {
                    bBasketball = true;
                }
                else if (bBasketball)
                {
                    if (semicolonString.Contains("NA="))
                    {
                        string naString = semicolonString.Replace("NA=", string.Empty);
                        info.name = naString;
                    }
                    else if (semicolonString.Contains("TU="))
                    {
                        info.time = semicolonString.Replace("TU=", string.Empty);
                    }
                    else if (semicolonString.Contains("TD="))
                    {
                        info.td = semicolonString.Replace("TD=", string.Empty);
                    }
                    else if (semicolonString.Contains("TM="))
                    {
                        info.tm = semicolonString.Replace("TM=", string.Empty);
                    }
                    else if (semicolonString.Contains("TT="))
                    {
                        info.tt = semicolonString.Replace("TT=", string.Empty);
                    }
                    else if (semicolonString.Contains("TS="))
                    {
                        info.ts = semicolonString.Replace("TS=", string.Empty);
                    }
                    else if (semicolonString.Contains("ID="))
                    {
                        string id = semicolonString.Replace("ID=", string.Empty);
                        if (id.Contains("_"))
                        {
                            info.id = id;
                        }
                    }

                    if (info.isComplete())
                    {
                        info.sport = SPORT.Dog;
                        infos.Add(info);
                        info = new TempMatchInfo();
                    }
                }
            }

            return(infos);
        }
Exemplo n.º 3
0
        private List <TempMatchInfo> parseSocketResponseHorse(string response)
        {
            List <TempMatchInfo> infos = new List <TempMatchInfo>();
            string temp = response.Substring(response.LastIndexOf("NA=Horse Racing;"));

            bool bSoccer = false;

            TempMatchInfo info = new TempMatchInfo();

            while (temp.Contains(";"))
            {
                string semicolonString = temp.Substring(0, temp.IndexOf(";"));
                temp = temp.Substring(temp.IndexOf(";") + 1, temp.Length - temp.IndexOf(";") - 1);

                if (semicolonString == "NA=Horse Racing")
                {
                    bSoccer = true;
                }
                else if (bSoccer)
                {
                    if (semicolonString.Contains("NA="))
                    {
                        string naString = semicolonString.Replace("NA=", string.Empty);
                        info.name = naString;
                    }
                    else if (semicolonString.Contains("TU="))
                    {
                        info.time = semicolonString.Replace("TU=", string.Empty);
                    }
                    else if (semicolonString.Contains("TD="))
                    {
                        info.td = semicolonString.Replace("TD=", string.Empty);
                    }
                    else if (semicolonString.Contains("TM="))
                    {
                        info.tm = semicolonString.Replace("TM=", string.Empty);
                    }
                    else if (semicolonString.Contains("TT="))
                    {
                        info.tt = semicolonString.Replace("TT=", string.Empty);
                    }
                    else if (semicolonString.Contains("TS="))
                    {
                        info.ts = semicolonString.Replace("TS=", string.Empty);
                    }
                    else if (semicolonString.Contains("ID="))
                    {
                        string id = semicolonString.Replace("ID=", string.Empty);
                        if (id.Contains("_"))
                        {
                            //info.id = Regex.Replace(id, "_\\d_\\d", string.Empty);
                            info.id = id;
                        }
                    }

                    if (info.isComplete())
                    {
                        info.sport = SPORT.Horse;
                        infos.Add(info);

                        info = new TempMatchInfo();
                    }
                }
            }

            return(infos);
        }