public void Process(List<CompetitionResultLive> lastResultList, FullResult result)
        {
            var totalSubResults = result.SubResult.Count;
            if (result.SubResult == null || totalSubResults <= 1) {
                return;
            }
            var setSubResult = result.SubResult[totalSubResults - 2];
            var generateScoreID = ScoreHelper.Instance.GenerateScoreID(setSubResult.CompetitorResultOne, setSubResult.CompetitorResultTwo);
            var lastResult = lastResultList.FirstOrDefault(lr => {
                var lra = lr.GetJoinedEntity<CompetitionResultLiveAdvanced>();
                return lra != null && lra.ScoreID == generateScoreID;
            });
            var lastAdvancedResult = lastResult?.GetJoinedEntity<CompetitionResultLiveAdvanced>();
            if (lastAdvancedResult == null) {
                lastAdvancedResult = new CompetitionResultLiveAdvanced {
                    ScoreID = generateScoreID,
                    CompetitionresultliveID = lastResultList.First().ID,
                    Datecreatedutc = DateTime.UtcNow,
                    Advancedparam = GetServeBit(setSubResult.Serve)
                };
            }
            var gameSubResult = result.SubResult[totalSubResults - 1];
            var internalScore1 = GetInternalScore(gameSubResult.CompetitorResultOne);
            var internalScore2 = GetInternalScore(gameSubResult.CompetitorResultTwo);

            lastAdvancedResult.Advancedparam = GetMinimalAdvanceParamForScore(lastAdvancedResult.Advancedparam, internalScore1, internalScore2);
            lastAdvancedResult.Save();
        }
Example #2
0
 public static string BuildStringFromResult(FullResult res)
 {
     return string.Format(_resultSerializeTpl, res.CompetitorResultOne, res.CompetitorResultTwo) +
         (res.SubResult != null && res.SubResult.Any()
             ? res.SubResult.Where(sr => sr != null).Select(sr => string.Format(_resultSerializeTpl, sr.CompetitorResultOne, sr.CompetitorResultTwo)).StrJoin(string.Empty)
             : string.Empty);
 }
 public static void TrySaveOrUpdateResult(ProcessStat processStat, int rawCompetitionItemID, FullResult fullResult)
 {
     if (rawCompetitionItemID == default(int)) {
         return;
     }
     var competitionResultRaw = RawCompetitionResult.DataSource.GetByKey(rawCompetitionItemID);
     if (competitionResultRaw != null) {
         return;
     }
     competitionResultRaw = new RawCompetitionResult {
         RawcompetitionitemID = rawCompetitionItemID,
         Rawresult = fullResult
     };
     competitionResultRaw.Insert();
     processStat.CreateRawCount++;
 }
        public void Process(List<CompetitionResultLive> lastResultList, FullResult result)
        {
            if (result.SubResult == null || result.SubResult.Count == 0) {
                return;
            }
            var lastSubResult = result.SubResult.Last();
            var generateScoreID = ScoreHelper.Instance.GenerateScoreID(lastSubResult.CompetitorResultOne, lastSubResult.CompetitorResultTwo);

            var lastResult = lastResultList.FirstOrDefault(lr => {
                var lra = lr.GetJoinedEntity<CompetitionResultLiveAdvanced>();
                return lra != null && lra.ScoreID == generateScoreID;
            });
            var lastAdvancedResult = lastResult?.GetJoinedEntity<CompetitionResultLiveAdvanced>();
            if (lastAdvancedResult == null) {
                lastAdvancedResult = new CompetitionResultLiveAdvanced {
                    ScoreID = generateScoreID,
                    CompetitionresultliveID = lastResultList.First().ID,
                    Datecreatedutc = DateTime.UtcNow,
                    Advancedparam = TennisLiveResultProcessor.GetServeBit(lastSubResult.Serve)
                };
                lastAdvancedResult.Save();
            }
        }
Example #5
0
 public static FullResult BuildResultFromString(SportType sportType, string resString)
 {
     FullResult result ;
     switch (sportType) {
         case SportType.Tennis:
         case SportType.Volleyball:
             var buildTennisResult = BuildFullResult(resString);
             if (buildTennisResult.SubResult.Count == 1) {
                 var tempTennisResult = new FullResult {
                     CompetitorResultOne = 0,
                     CompetitorResultTwo = 0
                 };
                 tempTennisResult.SubResult.Add(new SimpleResult {
                     CompetitorResultOne = buildTennisResult.CompetitorResultOne,
                     CompetitorResultTwo = buildTennisResult.CompetitorResultTwo
                 });
                 tempTennisResult.SubResult.AddRange(buildTennisResult.SubResult);
                 buildTennisResult = tempTennisResult;
             }
             result = buildTennisResult;
             break;
         case SportType.IceHockey:
             result = BuildFullResult(resString);
             break;
         case SportType.Basketball:
             result = BuildFullResult(resString);
             break;
         case SportType.Football:
             result = BuildFullResult(resString);
             break;
         default:
             result = BuildFullResult(resString);
             break;
     }
     return result;
 }
Example #6
0
 private static FullResult BuildFullResult(string resString)
 {
     try {
         var tempResult = ParseStringToSimpleResults(resString).ToList();
         var fullResult = new FullResult {
             CompetitorResultOne = tempResult[0].CompetitorResultOne,
             CompetitorResultTwo = tempResult[0].CompetitorResultTwo
         };
         for (var i = 1; i < tempResult.Count; i++) {
             fullResult.SubResult.Add(tempResult[i]);
         }
         return fullResult;
     }
     catch (Exception ex) {
         _logger.Error(ex);
     }
     return null;
 }
 public void Process(List<CompetitionResultLive> lastResultList, FullResult result)
 {
 }
Example #8
0
 public void SaveResults(ProcessStat processStat, CompetitionItemRawTransport competitionRawTransport, SportType sportType, FullResult fullResult)
 {
     InvokeSafeSingleCall(() => {
         processStat.TotalCount++;
         if (competitionRawTransport == null || fullResult == null) {
             return null;
         }
         RawCompetitionResultHelper.TrySaveOrUpdateResult(processStat, competitionRawTransport.RawCompetitionItemID, fullResult);
         if (competitionRawTransport.CompetitionItemID == default(int)) {
             return null;
         }
         CompetitionResult.ProcessResult(processStat, competitionRawTransport.CompetitionItemID, sportType, fullResult);
         processStat.FinallySuccessCount++;
         return (object) null;
     }, null);
 }