private void PushProcess(int oIndex, int sIndex) { try { if (oIndex + 1 > Odds.Length) { Log.Info($"賽事編號:{MatchId} 第{sIndex + 1}次走地資料送完"); Log.Info($"賽事編號:{MatchId},第{oIndex + 1}次賠率資料送完"); DataSave.SwitchOddsActive(MatchId); //賠率送完即結算 DataSave.DoSettle(MatchId, 1); //全場 DataSave.DoSettle(MatchId, 2); //半場 CacheTool.MatchRemove(MatchId); return; } if (sIndex == 0 || oIndex == modIndex || (oIndex - modIndex) % avgIndex == 0) { PushScoutToMq(sIndex); } PushOddstToSportServer(oIndex); } catch (Exception ex) { Log.Info($"賽事編號:{MatchId},第{oIndex + 1}次oIndex失敗,失敗原因:{ex.Message},失敗原因:{ex.StackTrace}"); } }
private void PushProcessByScout(int ssIndex, int ooIndex) { try { if (ssIndex + 1 > Scout.Length) { Log.Info($"賽事編號:{MatchId} 第{ssIndex + 1}次走地資料送完"); Log.Info($"賽事編號:{MatchId},第{ooIndex + 1}次賠率資料送完"); //賠率送完即結算 DataSave.DoSettle(MatchId, 1); //全場 DataSave.DoSettle(MatchId, 2); //半場 CacheTool.MatchRemove(MatchId); return; } if (ooIndex == 0 || ssIndex == modIndex || (ssIndex - modIndex) % avgIndex == 0) { PushOddsToRiskMan(ooIndex); } PushScoutToMq(ssIndex); } catch (Exception ex) { Log.Info($"賽事編號:{MatchId},第{ssIndex + 1}次ssIndex失敗,失敗原因:{ex.Message},失敗原因:{ex.StackTrace}"); } }
public MatchV1(long matchId, int totaltime) { //先結算上一場賽事的單 DataSave.DoSettle(matchId, 1); //全場 DataSave.DoSettle(matchId, 2); //半場 Scout = DataSave.FetchLiveScout(matchId); Odds = DataSave.FetchOdds(matchId); MatchId = matchId; var totalMiSec = totaltime * 60 * 1000; //基本上賠率資料會大於動畫資料 modTimeForOdds = totalMiSec % (Odds.Length - 1); avgTimeForOdds = totalMiSec / (Odds.Length - 1); modIndex = (Odds.Length - 1) % (Scout.Length - 2); avgIndex = ((Odds.Length - 1) - modIndex) / (Scout.Length - 2); }
private void PushOddsToRiskMan(int index) { try { if (index + 1 > RiskOddsDataList.Count) { Log.Info($"賽事編號:{MatchId},第{index + 1}次賠率資料送完"); //賠率送完即結算 DataSave.DoSettle(MatchId, 1); //全場 DataSave.DoSettle(MatchId, 2); //半場 //DataSave.SwitchOddsActive(MatchId); CacheTool.MatchRemove(MatchId); return; } var message = $"賽事編號:{MatchId},第{index + 1}次賠率資料傳送"; SendRisk.DoOddsBatch(message, JsonConvert.SerializeObject(RiskOddsDataList[index])); Log.Info(message + $", Data => {JsonConvert.SerializeObject(RiskOddsDataList[index])}"); int timer = 0; if (index <= RiskOddsDataList.Count - 1) { timer = avgTimeForOddsRisk; } else { timer = modTimeForOddsRisk; } Nami.Delay(timer).Do(() => { PushOddsToRiskMan(index + 1); }); } catch (Exception ex) { var lodData = JsonConvert.SerializeObject(Odds[index]); Log.Info($"賽事編號:{MatchId},第{index + 1}次失敗,失敗原因:{ex.Message},失敗原因:{ex.StackTrace}"); } }
public Match(long matchId, int totaltime) { //先結算上一場賽事的單 DataSave.DoSettle(matchId, 1); //全場 DataSave.DoSettle(matchId, 2); //半場 RiskOddsDataList = new List <RiskData>(); Scout = DataSave.FetchLiveScout(matchId); Odds = DataSave.FetchOdds(matchId); long tempMsgnr = -1L; #region 組批次檔 RiskData rData = new RiskData(); LiveMatchData lData = new LiveMatchData(); for (int i = 0; i < Odds.Length; i++) { var tmpOddsTypeId = long.Parse(string.IsNullOrEmpty(Odds[i].OddsTypeID) ? "0" : Odds[i].OddsTypeID); var tmpSubtype = long.Parse(string.IsNullOrEmpty(Odds[i].Subtype) ? "0" : Odds[i].Subtype); if (Odds[i].MsgNr == tempMsgnr) { //RiskMan 如果有不同的 TypeId & SubType 要新增 bool isNeedToInsert = true; foreach (var typeIdList in rData.OddsTypeIdList) { if (typeIdList.OddsTypeId == tmpOddsTypeId && typeIdList.SubType == tmpSubtype) { isNeedToInsert = false; break; } } if (isNeedToInsert) { rData.OddsTypeIdList.Add( new OddsTypeIdList() { OddsTypeId = tmpOddsTypeId, SubType = tmpSubtype } ); } rData.OddsTypeIdList.Where(x => x.OddsTypeId == tmpOddsTypeId && x.SubType == tmpSubtype).First().OddsChangeList.Add( new OddsChangeList() { OddsId = Odds[i].OddsId, OddsIdOri = Odds[i].OddsIdOri.ToString(), Odds = Odds[i].Odds.ToString(), SpecialBetValue = Odds[i].SpecialBetValue, ForTheRest = Odds[i].ForTheRest, Score = Odds[i].Score, Status = 1, Timestamp = Odds[i].CreateTime }); if (i == Odds.Length - 1) { RiskOddsDataList.Add(rData); } } else { if (i != 0) { RiskOddsDataList.Add(rData); rData = new RiskData(); } tempMsgnr = Odds[i].MsgNr; rData.MatchId = Odds[i].MatchId; rData.Msgnr = Odds[i].MsgNr; rData.Source = 1; rData.OddsKind = 2; //RiskMan 如果有不同的 TypeId & SubType 要新增 bool isNeedToInsert = true; foreach (var typeIdList in rData.OddsTypeIdList) { if (typeIdList.OddsTypeId == tmpOddsTypeId && typeIdList.SubType == tmpSubtype) { isNeedToInsert = false; break; } } if (isNeedToInsert) { rData.OddsTypeIdList.Add( new OddsTypeIdList() { OddsTypeId = tmpOddsTypeId, SubType = tmpSubtype } ); } rData.OddsTypeIdList.Where(x => x.OddsTypeId == tmpOddsTypeId && x.SubType == tmpSubtype).First().OddsChangeList.Add( new OddsChangeList() { OddsId = Odds[i].OddsId, OddsIdOri = Odds[i].OddsIdOri.ToString(), Odds = Odds[i].Odds.ToString(), SpecialBetValue = Odds[i].SpecialBetValue, ForTheRest = Odds[i].ForTheRest, Score = Odds[i].Score, Status = 1, Timestamp = Odds[i].CreateTime }); } } #endregion MatchId = matchId; var totalMiSec = totaltime * 60 * 1000; modTimeForOddsRisk = totalMiSec % RiskOddsDataList.Count; avgTimeForOddsRisk = totalMiSec / RiskOddsDataList.Count; modTimeForOdds = totalMiSec % Odds.Length; avgTimeForOdds = totalMiSec / Odds.Length; modTimeForScout = totalMiSec % Scout.Length; avgTimeForScout = totalMiSec / Scout.Length; }