public BlockingCollection <MatchDTO> ConvertFullData(string data, out string updateTime, bool isLive) { BlockingCollection <MatchDTO> list = new BlockingCollection <MatchDTO>(); updateTime = string.Empty; if (!string.IsNullOrEmpty(data)) { //list = new List<MatchOddDTO>(); data = JavaScriptConvert.CleanScriptTag(data); string[] arrayData = data.Split(new[] { ';' }, StringSplitOptions.None); string jarrayName = isLive ? "Nl" : "Nt"; //string[] array2 = array; for (int i = 0; i < arrayData.Length; i++) { string text = arrayData[i]; if (text.StartsWith(jarrayName)) { string value = text.Split(new string[] { "]=" }, StringSplitOptions.None)[1]; this.ConvertNewMatch(value, ref list); } else if (text.StartsWith("window")) { updateTime = text.Substring(43, 19); } } } return(list); }
public void ConvertUpdateData(string data, out string updateTime, BlockingCollection <MatchDTO> sourceData) { updateTime = string.Empty; data = JavaScriptConvert.CleanScriptTag(data); string[] arrayData = data.Split(new[] { ';' }, StringSplitOptions.None); for (int i = 0; i < arrayData.Length; i++) { string textData = arrayData[i]; if (textData.StartsWith("uOl")) { string valueNewOdd = textData.Split(new[] { "]=" }, StringSplitOptions.None)[1]; JArray jArrayNewOdds = JavaScriptConvert.DeserializeObject(valueNewOdd); int oddTypeValue = (int)jArrayNewOdds[1]; if (!IbetConfig.ODDTYPE_VALUES_UPDATED.Contains(oddTypeValue)) { continue; } if (string.IsNullOrEmpty((string)jArrayNewOdds[4]) || string.IsNullOrEmpty((string)jArrayNewOdds[4])) { continue; } MatchDTO oldMatchOddDto = sourceData.FirstOrDefault(mo => mo.MatchID == jArrayNewOdds[0].ToString()); if (oldMatchOddDto != null) { if (oldMatchOddDto.Odds == null) { oldMatchOddDto.Odds = new List <OddDTO>() { new OddDTO() { OddID = jArrayNewOdds[2].ToString() } }; } var oddDto = oldMatchOddDto.Odds.FirstOrDefault(o => o.OddID == jArrayNewOdds[2].ToString()); switch (oddTypeValue) { case 1: oddDto.Odd = ConvertOdd(jArrayNewOdds[3].ToString(), jArrayNewOdds[6].ToString()); oddDto.OddType = eOddType.HCP; break; case 3: oddDto.Odd = ConvertOdd(jArrayNewOdds[3].ToString()); oddDto.OddType = eOddType.OU; break; case 7: oddDto.Odd = ConvertOdd(jArrayNewOdds[3].ToString(), jArrayNewOdds[6].ToString()); oddDto.OddType = eOddType.HalfHCP; break; case 8: oddDto.Odd = ConvertOdd(jArrayNewOdds[3].ToString()); oddDto.OddType = eOddType.HalfOU; break; } //oddDto.HomeOdd = (float)jArrayNewOdds[4]; //oddDto.AwayOdd = (float)jArrayNewOdds[5]; float hOdd; float aOdd; float.TryParse(jArrayNewOdds[4].ToString(), out hOdd); float.TryParse(jArrayNewOdds[5].ToString(), out aOdd); oddDto.HomeOdd = hOdd; oddDto.AwayOdd = aOdd; } else { Logger.Warn("??????????????????KHONG TIM THAY THONG TIN DATA MATCH"); } } else if (textData.StartsWith("uLl")) { string valueNewTime = textData.Split(new[] { "]=" }, StringSplitOptions.None)[1]; JArray jArrayTime = JavaScriptConvert.DeserializeObject(valueNewTime); int min; var timeType = ConvertMatchTime(jArrayTime[1].ToString(), out min); sourceData.Where(x => x.MatchID == jArrayTime[0].ToString()).Select(m => { m.TimeType = timeType; m.Minutes = min; return(m); }).ToList(); } else if (textData.StartsWith("Insl")) { string valueNewMatch = textData.Split(new[] { "]=" }, StringSplitOptions.None)[1]; this.ConvertNewMatch(valueNewMatch, ref sourceData); } else if (textData.StartsWith("var Dell")) { JArray jArrayDeleteId = JavaScriptConvert.DeserializeObject(textData.Split(new[] { '=' }, StringSplitOptions.None)[1]); var deletedIds = jArrayDeleteId.Select(deletedId => (string)deletedId); sourceData.Where(s => deletedIds.Contains(s.MatchID)).Select(c => { c.IsDeleted = true; c.Odds.Select(o => { o.IsDeleted = true; return(o); }).ToList(); return(c); }).ToList(); // sourceData.RemoveAll(x => deletedIds.Contains(x.MatchID)); } else if (textData.StartsWith("window")) { updateTime = textData.Substring(43, 19); } } }