示例#1
0
        /// <summary>
        /// Obtain events messages of all takers
        /// </summary>
        private async Task GetEvents()
        {
            var(ret, warnings) = await ExamServices.GetEvents(_examId, Consts.MessageTypeWarning);

            // Warning messages
            if (ret == ErrorCodes.Success)
            {
                foreach (var ev in warnings)
                {
                    GetExamTakerVideoCard(ev.Sender).AddOldMessage(ev);
                }
            }

            var(ret2, takerMessage) = await ExamServices.GetEvents(_examId, Consts.MessageTypeTaker);

            // Exam taker sent messages
            if (ret2 == ErrorCodes.Success)
            {
                foreach (var ev in takerMessage)
                {
                    if (!_takerMessages.ContainsKey(ev.Sender))
                    {
                        _takerMessages[ev.Sender] = new List <EventItem>();
                    }

                    _takerMessages[ev.Sender].Add(ev);
                }
            }
            // Proctor sent messages
            var(ret3, proctorMessage) = await ExamServices.GetEvents(_examId, Consts.MessageTypeProctor);

            if (ret3 == ErrorCodes.Success)
            {
                foreach (var ev in proctorMessage)
                {
                    if (ev.Receipt == null)
                    {
                        // Broadcast messages
                        _broadcastMessages.Add(ev);
                    }
                    else
                    {
                        if (!_takerMessages.ContainsKey(ev.Receipt))
                        {
                            _takerMessages[ev.Receipt] = new List <EventItem>();
                        }

                        _takerMessages[ev.Receipt].Add(ev);
                    }
                }
            }

            foreach (var key in _takerMessages.Keys)
            {
                // Sort messages
                _takerMessages[key].Sort((x, y) => DateTime.Compare(x.Time, y.Time));
            }

            _broadcastMessages.Sort((x, y) => DateTime.Compare(x.Time, y.Time));
        }
示例#2
0
        private async Task GetEvents()
        {
            var(res, proctorEvents) = await ExamServices.GetEvents(_examId, Consts.MessageTypeProctor);

            if (res == ErrorCodes.Success)
            {
                _messages.AddRange(proctorEvents);
            }

            var(res2, takerEvents) = await ExamServices.GetEvents(_examId, Consts.MessageTypeTaker);

            if (res == ErrorCodes.Success)
            {
                _messages.AddRange(takerEvents);
            }

            _messages.Sort((a, b) => DateTime.Compare(a.Time, b.Time));
        }