Пример #1
0
 void IStreamStatusContext.TransitionToPossiblyOff()
 {
     _currentStatus       = _possiblyOffStatus;
     _latestStreamOffTime = _timeService.UtcNow;
     _unitOfWork.Command(u => {
         u.StateIntegers.StreamStatus        = StreamStatus.PossiblyOff;
         u.StateIntegers.LatestStreamOffTime = _latestStreamOffTime;
     });
 }
Пример #2
0
 void IStreamStatusContext.TransitionToOn(bool updateLatestStreamOnTime)
 {
     _currentStatus = _onStatus;
     if (updateLatestStreamOnTime)
     {
         _latestStreamOnTime = _timeService.UtcNow;
         _unitOfWork.Command(u => {
             u.StateIntegers.StreamStatus       = StreamStatus.On;
             u.StateIntegers.LatestStreamOnTime = _latestStreamOnTime;
         });
     }
     else
     {
         _unitOfWork.Command(u => u.StateIntegers.StreamStatus = StreamStatus.On);
     }
 }
Пример #3
0
        public StreamStateService(
            IQueryCommandService <IUnitOfWork> unitOfWork,
            ITimeService timeService,
            IDownloadMapper downloadMapper,
            ISettings settings
            )
        {
            _unitOfWork     = unitOfWork;
            _timeService    = timeService;
            _downloadMapper = downloadMapper;

            _onStatus          = new OnStatus(this);
            _offStatus         = new OffStatus(this);
            _possiblyOffStatus = new PossiblyOffStatus(this, _unitOfWork, _timeService, settings);

            var initialStatus = unitOfWork.Query(u => u.StateIntegers.StreamStatus);

            _latestStreamOnTime  = unitOfWork.Query(u => u.StateIntegers.LatestStreamOnTime);
            _latestStreamOffTime = unitOfWork.Query(u => u.StateIntegers.LatestStreamOffTime);
            switch (initialStatus)
            {
            case StreamStatus.On:
                _currentStatus = _onStatus;
                break;

            case StreamStatus.Off:
                _currentStatus = _offStatus;
                break;

            case StreamStatus.PossiblyOff:
                _currentStatus = _possiblyOffStatus;
                break;

            default:
                throw new NotSupportedException($"The stream status {initialStatus} is not registered");
            }
        }
Пример #4
0
 void IStreamStatusContext.TransitionToOff()
 {
     _currentStatus = _offStatus;
     _unitOfWork.Command(u => u.StateIntegers.StreamStatus = StreamStatus.Off);
 }