Beispiel #1
0
        private void TimerTick(object sender, System.EventArgs e)
        {
            var now = _dateTimeService.Now();

            if (!_stopwatch.IsRunning)
            {
                // not yet started the meeting...
                if (now.Minute % 15 == 0)
                {
                    // start on the nearest quarter hour...
                    _stopwatch.Start();
                    _nextStartTime = now.TimeOfDay.Add(TimeSpan.FromMinutes(5));
                }

                return;
            }

            var status = _timerService.GetStatus();

            CheckIsCurrentTalk(status);

            if (_nextStartTime != null && now.TimeOfDay > _nextStartTime)
            {
                // Start the talk timer...
                CheckNotRunning(status);

                if (status.TalkId != null)
                {
                    _timerService.StartTalkTimerFromApi(status.TalkId.Value);
                }

                _nextStartTime = null;
                _nextStopTime  = now.TimeOfDay.Add(TimeSpan.FromSeconds(status.TargetSeconds));

                return;
            }

            if (_nextStopTime != null && now.TimeOfDay > _nextStopTime)
            {
                // Stop the talk timer...
                CheckIsRunning(status);

                if (status.TalkId != null)
                {
                    _timerService.StopTalkTimerFromApi(status.TalkId.Value);
                }

                _nextStopTime  = null;
                _nextStartTime = CalculateNextStartTime(status, now);

                if (_nextStartTime == null)
                {
                    // all done
                    _stopwatch.Stop();
                    _timer.Stop();
                }
            }
        }
Beispiel #2
0
        public TimersResponseData(
            ITalkScheduleService talkService,
            ITalkTimerService timerService,
            IOptionsService optionsService)
        {
            var talks = talkService.GetTalkScheduleItems();

            Status = timerService.GetStatus();

            TimerInfo = new List <TimerInfo>();

            var countUpByDefault = optionsService.Options.CountUp;

            foreach (var talk in talks)
            {
                TimerInfo.Add(CreateTimerInfo(talk, countUpByDefault));
            }
        }
Beispiel #3
0
        public TimersResponseData(
            ITalkScheduleService talkService,
            ITalkTimerService timerService,
            IOptionsService optionsService,
            int talkId)
        {
            var talks = talkService.GetTalkScheduleItems();
            var talk  = talks.SingleOrDefault(x => x.Id == talkId);

            if (talk == null)
            {
                throw new WebServerException(WebServerErrorCode.TimerDoesNotExist);
            }

            Status    = timerService.GetStatus();
            TimerInfo = new List <TimerInfo> {
                CreateTimerInfo(talk, optionsService.Options.CountUp)
            };
        }