Ejemplo n.º 1
0
        /// <summary>
        /// 初始化闹钟提醒
        /// </summary>
        private void InitClock()
        {
            if (ExamClock == null)
            {
                throw new Exception("闹钟初始化失败");
            }

            //已经交过卷了,不能再考了
            if (OneStaffExam.EXST_ENDTIME != null)
            {
                Messenger.Default.Send("已经交卷,不能再继续考试。");
                Application.Current.Shutdown();
                return;
            }

            //超时试卷处理
            DateTime nextTime = OneStaffExam.EXST_BEGINTIME.Value.AddMinutes(ThExamInfo.EXAM_TIME);

            if (nextTime < ExamHandle.GetNowDateTime())
            {
                Messenger.Default.Send("您第一次进入考试时间为:" + ((DateTime)OneStaffExam.EXST_BEGINTIME.Value).ToString("yyyy-MM-dd HH:mm:ss") + "。\n已超过考试时长[考试时长为" + ThExamInfo.EXAM_TIME + "分钟],不能再继续考试!");
                Application.Current.Shutdown();
                return;
            }

            // 初始化定时器
            DateTime now     = ExamHandle.GetNowDateTime();
            TimeSpan t       = now - ExamBeginTime;
            var      seconds = Convert.ToInt32((ThExamInfo.EXAM_TIME * 60 - Convert.ToInt32(t.TotalSeconds)));

            ExamClock.AddSeconds(seconds);
            ExamClock.TimeIsEnd   += new LedClock2.TimeIsEndHandle(ExamClock_TimeIsEnd);
            ExamClock.EveryMinute += new LedClock2.EveryMinuteHandle(ExamClock_EveryMinute);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     初始化闹钟提醒
        /// </summary>
        private void InitClock()
        {
            ////if (ExamClock == null) throw new Exception("闹钟初始化失败");

            //////初始化闹钟时间
            ////ExamClock.CurrentTime = ExamHandle.GetNowDateTime();

            ////if (CurrentExam.Valid_Minute == -1) //Valid_Minute为-1 则为定长考试
            ////{
            ////    //10秒为误差值,小于误差表示为首次进入
            ////    if (ExamHandle.GetNowDateTime() - PaperData.BeginTime < TimeSpan.FromSeconds(10))
            ////    {
            ////        ExamClock.AddAlert(AlertType.ExamOver, new TimeSpan(0, CurrentExam.Exam_Space, 0));
            ////    }
            ////    else
            ////    {
            ////        DateTime nextTime = PaperData.BeginTime.Value.AddMinutes(CurrentExam.Exam_Space);

            ////        //超时试卷处理
            ////        if (nextTime < ExamHandle.GetNowDateTime())
            ////        {
            ////            Messenger.Default.Send("超过考试时间,距离第一次进入考试已经超过" + CurrentExam.Exam_Space + "分钟,已进行交卷");
            ////            SubmitPaper(true);
            ////            return;
            ////        }

            ////        ExamClock.AddAlert(AlertType.ExamOver, nextTime);
            ////    }
            ////}
            ////else //否则Exam_Space应为-1,为定时考试
            ////{
            ////    ExamClock.AddAlert(AlertType.ExamOver, CurrentExam.End_Datetime);
            ////}

            ////ExamClock.TimeAlert += ExamClock_TimeAlert;

            ////ExamClock.Start();

            if (ExamClock == null)
            {
                throw new Exception("闹钟初始化失败");
            }

            // 已经交过卷了,不能再考了
            if (PaperData.EndTime != null)
            {
                Messenger.Default.Send("已经交卷,不能再继续考试。");
                Application.Current.Shutdown();
                return;
            }

            //超时试卷处理
            DateTime nextTime = PaperData.BeginTime.Value.AddMinutes(CurrentExam.Exam_Space);

            if (nextTime < ExamHandle.GetNowDateTime())
            {
                Messenger.Default.Send("超过考试时间,距离第一次进入考试已经超过" + CurrentExam.Exam_Space + "分钟,已进行交卷");
                SubmitPaper(true);
                return;
            }

            // 初始化定时器
            DateTime now = ExamHandle.GetNowDateTime();
            TimeSpan t   = now - (DateTime)PaperData.BeginTime;

            ExamClock.AddSeconds(int.Parse((CurrentExam.Exam_Space * 60 - t.TotalSeconds).ToString()));
            ExamClock.TimeIsEnd += new LedClock2.TimeIsEndHandle(ExamClock_TimeIsEnd);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     收到监考端发送来的消息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void socketObject_DataReceived(object sender, ExamSys.ServiceProxy.DataReceivedEventArgs e)
        {
            //TODO:处理DATA数据,序列化为消息类
            CommandMessage command = e.Data;

            string[] param = command.MessageInfo.Params.Split(new[] { '#' }, StringSplitOptions.RemoveEmptyEntries);
            switch ((MessageType)int.Parse(command.Type))
            {
            //文本消息提示
            case MessageType.Text:
            {
                Messenger.Default.Send(command, MessageToken.NotifyMessageToken);
            }
            break;

            //强制交卷
            case MessageType.Submit:
            {
                Messenger.Default.Send("监考人员强制提交了你的试卷");
                GalaSoft.MvvmLight.Threading.DispatcherHelper.CheckBeginInvokeOnUI(new Action(() => { SubmitPaper(true); }));
            }
            break;

            //暂停考试
            case MessageType.Pause:
            {
                ExamClock.StopTime();
                Messenger.Default.Send("监考人员暂停了你的考试");
                this.PaperData.IsPauseVisiability = Visibility.Visible;
                //Messenger.Default.Send(Visibility.Visible, MessageToken.ExamIsPauseToken);
            }
            break;

            //考试结束(关闭程序)
            case MessageType.Over:
            {
                Messenger.Default.Send("监考人员强制关闭了你的系统");
                GalaSoft.MvvmLight.Threading.DispatcherHelper.CheckBeginInvokeOnUI(new Action(() => { Close(); }));
            }
            break;

            //延长考试
            case MessageType.Delay:
            {
                ExamClock.AddSeconds(Convert.ToInt32(int.Parse(param[0]) * 60));
            }
            break;

            //考试继续
            case MessageType.Continue:
            {
                ExamClock.StartTime();
                Messenger.Default.Send("监考人员恢复了你的考试");
                this.PaperData.IsPauseVisiability = Visibility.Collapsed;
                //Messenger.Default.Send(Visibility.Collapsed, MessageToken.ExamIsPauseToken);
            }
            break;

            default:
                break;
            }
        }