public static int TryCalculateQueueLatencyMs(DateTime?eventOpening, DateTime?queueCreated)
        {
            long temp = IntervalCalculator.CalculateInterval(eventOpening, queueCreated);

            if (temp >= 0 && temp <= Int32.MaxValue)
            {
                return((int)temp);
            }
            return(-1);
        }
Exemple #2
0
        public async Task <IHttpActionResult> Countdown()
        {
            try
            {
                Event evnt = await _eventRepository.GetActiveAsync();

                if (null == evnt)
                {
                    return(NotFound());
                }

                return(this.OkNoCache(new EventCountdown
                {
                    Opening = evnt.Opening,
                    Countdown = Math.Max(0, IntervalCalculator.CalculateInterval(DateTime.Now, evnt.Opening))
                }));
            }
            catch (Exception ex)
            {
                _log.Error(ex, "An unexpected exception occurred while getting the countdown.");
                throw;
            }
        }
 public BookingCandidateResponse(Guid candidateId, int queueSize, Event evnt)
 {
     Id        = candidateId;
     QueueSize = queueSize;
     Countdown = Math.Max(0, IntervalCalculator.CalculateInterval(DateTime.Now, evnt.Opening));
 }