public RecordedScore(CpScore cpScore, CycleIdentifier cycleIdentifier, int cp)
            : base(cycleIdentifier, cp)
        {

            ResistanceScore = cpScore.ResistanceScore;
            EnlightenedScore = cpScore.EnlightenedScore;
            Kudos = cpScore.Kudos;
        }
 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);
 }
        public CycleScore GetScoreForCycle(CycleIdentifier cycle)
        {
            ScoreEntity scoreEntity;

            if (_cycleScoresCache.TryGetValue(cycle.Id, out scoreEntity))
            {
                return(scoreEntity.CycleScore());
            }
            scoreEntity = ScoreForCycleFromStorage(cycle);
            _cycleScoresCache[cycle.Id] = scoreEntity;
            return(scoreEntity.CycleScore());
        }
        public CycleScore GetScoreForCycle(CycleIdentifier cycle)
        {
            CycleScore cycleScore;

            if (!_cycleScores.TryGetValue(cycle.Id, out cycleScore))
            {
                var timestamp = DateTimeOffset.Now;
                cycleScore             = new CycleScore(cycle, timestamp.Ticks);
                _timeStamps[cycle.Id]  = timestamp.Ticks;
                _cycleScores[cycle.Id] = cycleScore;
            }
            return(cycleScore);
        }
        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
        }
        private ScoreEntity ScoreForCycleFromStorage(CycleIdentifier cycle)
        {
            var scoreEntity = new ScoreEntity(cycle);

            var retrieveOperation = TableOperation.Retrieve <ScoreEntity>(ScoreEntity.CincinnatiArea, scoreEntity.RowKey);

            var retrievedResult = _cloudTable.Execute(retrieveOperation);

            if (retrievedResult.Result == null)
            {
                // Execute the insert operation.
                //don't insert yet
                //_cloudTable.Execute(TableOperation.Insert(scoreEntity));
                return(scoreEntity);
            }
            scoreEntity = (ScoreEntity)retrievedResult.Result;
            return(scoreEntity);
        }
        public MissingScore(int cp, CycleIdentifier cycleIdentifier)
            : base(cycleIdentifier, cp)
        {
            

        }
예제 #8
0
 /// <summary>
 ///     create a new checkpoint
 /// </summary>
 /// <param name="cycleScore"></param>
 public ScoreEntity(CycleIdentifier cycleScore)
 {
     PartitionKey = CincinnatiArea;
     RowKey       = cycleScore.Id.ToString();
     Timestamp    = DateTimeOffset.MinValue;
 }
예제 #9
0
        public FutureScore(int cp, CycleIdentifier cycleIdentifier)
            : base(cycleIdentifier, cp)
        {

            
        }