コード例 #1
0
 public UpdateScore(CpScore cpScore, long timeStamp):this(timeStamp)
 {
     TimeStamp = timeStamp.ToString();
     ResistanceScore = cpScore.ResistanceScore;
     EnlightenedScore = cpScore.EnlightenedScore;
     Kudos = cpScore.Kudos;
 }
コード例 #2
0
        public RecordedScore(CpScore cpScore, CycleIdentifier cycleIdentifier, int cp)
            : base(cycleIdentifier, cp)
        {

            ResistanceScore = cpScore.ResistanceScore;
            EnlightenedScore = cpScore.EnlightenedScore;
            Kudos = cpScore.Kudos;
        }
コード例 #3
0
        private void SetEnlightenedScore(int cp, int enlightenedScore)
        {
            CpScore cpScore;

            if (!_scores.TryGetValue(cp, out cpScore))
            {
                cpScore = new CpScore(0, enlightenedScore);
                _scores.Add(cp, cpScore);
                return;
            }
            cpScore.EnlightenedScore = enlightenedScore;
        }
コード例 #4
0
        private void SetResistanceScore(int cp, int resistanceScore)
        {
            CpScore cpScore;

            if (!_scores.TryGetValue(cp, out cpScore))
            {
                cpScore = new CpScore(resistanceScore, 0);
                _scores.Add(cp, cpScore);
                return;
            }
            cpScore.ResistanceScore = resistanceScore;
        }
コード例 #5
0
        public bool UpdateScore(CycleIdentifier cycle, int checkpoint, long timestampTicks, CpScore cpScore)
        {
            var scoreEntity = _cycleScoresCache[cycle.Id];

            if (scoreEntity.Timestamp.Ticks != timestampTicks)//final check before we overwrite something we didn't mean to
            {
                return(false);
            }
            scoreEntity.SaveScores(checkpoint, cpScore);
            //this does update scoreEntity.TimeStamp
            _cloudTable.Execute(scoreEntity.Timestamp == DateTimeOffset.MinValue ? TableOperation.Insert(scoreEntity) : TableOperation.Replace(scoreEntity));
            //should we check the _cloudTable.Execute().HttpStatusCode ??
            return(true);
            //what is the new TimeStamp??
            //else it's not the right timestamp
        }
コード例 #6
0
 public bool UpdateScore(CycleIdentifier cycle, int checkpoint, long timestampTicks, CpScore cpScore)
 {
     if (_timeStamps[cycle.Id] == timestampTicks)
     {
         //shouldn't need to update _cycleScores since the CycleScore is updated elsewhere. This method is for persisting somewhere
         _timeStamps[cycle.Id] = DateTimeOffset.Now.Ticks;
         return(true);
     }
     return(false);
 }
コード例 #7
0
 public void SaveScores(int checkpoint, CpScore cpScore)
 {
     _scores[checkpoint] = cpScore;
 }