예제 #1
0
        protected void btnOK_Click(object sender, EventArgs e)
        {
            //获取当前考试的生成试卷的状态和次数
            RandomExamBLL objBll = new RandomExamBLL();

            RailExam.Model.RandomExam obj = objBll.GetExam(Convert.ToInt32(ViewState["ExamID"].ToString()));

            string strSql = "select * from Random_Exam_Computer_Server where Random_Exam_ID=" + ViewState["ExamID"].ToString()
                            + " and Computer_Server_No=" + PrjPub.ServerNo;
            OracleAccess db = new OracleAccess();
            DataRow      dr = db.RunSqlDataSet(strSql).Tables[0].Rows[0];

            if (txtCode.Text != dr["Random_Exam_Code"].ToString())
            {
                SessionSet.PageMessage = "验证码输入有误,请重新输入!";
                txtCode.Text           = "";
                return;
            }

            //获取当前考生即将考试的试卷
            string strIP = Pub.GetRealIP();
            RandomExamResultCurrentBLL objResultCurrentBll = new RandomExamResultCurrentBLL();

            RailExam.Model.RandomExamResultCurrent objResultCurrent =
                objResultCurrentBll.GetNowRandomExamResultInfo(Convert.ToInt32(ViewState["StudentID"].ToString()),
                                                               Convert.ToInt32(ViewState["ExamID"].ToString()));

            ViewState["CurrentID"] = objResultCurrent.RandomExamResultId;
            //objResultCurrentBll.UpdateRandomExamResultCurrentIP(Convert.ToInt32(ViewState["CurrentID"].ToString()), strIP);

            RandomExamApplyBLL objApplyBll = new RandomExamApplyBLL();
            RandomExamApply    objNowApply = objApplyBll.GetRandomExamApplyByExamResultCurID(objResultCurrent.RandomExamResultId);

            if (objNowApply.RandomExamApplyID == 0)
            {
                RandomExamApply objApply = new RandomExamApply();
                objApply.RandomExamResultCurID = Convert.ToInt32(ViewState["CurrentID"].ToString());
                objApply.RandomExamID          = Convert.ToInt32(ViewState["ExamID"].ToString());
                objApply.CodeFlag    = txtCode.Text == dr["Random_Exam_Code"].ToString();
                objApply.ApplyStatus = 0;
                objApply.IPAddress   = strIP;
                hfID.Value           = objApplyBll.AddRandomExamApply(objApply).ToString();
            }
            else
            {
                objNowApply.CodeFlag    = txtCode.Text == dr["Random_Exam_Code"].ToString();
                objNowApply.ApplyStatus = 0;
                objNowApply.IPAddress   = Pub.GetRealIP();
                objApplyBll.UpdateRandomExamApply(objNowApply);
                hfID.Value = objNowApply.RandomExamApplyID.ToString();
            }

            lblApply.Text    = "已提交考试请求,请等待回复......";
            btnClose.Visible = true;
            btnOK.Visible    = false;
            lblTitle.Visible = false;
            txtCode.Visible  = false;
            img.Visible      = true;
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack && !Callback1.IsCallback && !ItemAnswerChangeCallBack.IsCallback)
            {
                string strExamId = Request.QueryString.Get("id");
                ViewState["ExamID"]    = strExamId;
                ViewState["BeginTime"] = DateTime.Now.ToString();
                //记录当前考试所在地的OrgID
                ViewState["OrgID"]      = ConfigurationManager.AppSettings["StationID"];
                ViewState["EmployeeID"] = Request.QueryString.Get("employeeID");

                if (strExamId != null && strExamId != "")
                {
                    RandomExamBLL             randomExamBLL = new RandomExamBLL();
                    RailExam.Model.RandomExam randomExam    = randomExamBLL.GetExam(int.Parse(strExamId));
                    ViewState["Year"]         = randomExam.BeginTime.Year.ToString();
                    HiddenFieldExamTime.Value = DateTime.Now.AddMinutes(randomExam.ExamTime).ToString();
                    HfExamTime.Value          = (randomExam.ExamTime * 60).ToString();

                    //获取当前考生最新需要做的考试试卷主表记录
                    RandomExamResultCurrentBLL             objResultCurrentBll = new RandomExamResultCurrentBLL();
                    RailExam.Model.RandomExamResultCurrent objResultCurrent    =
                        objResultCurrentBll.GetNowRandomExamResultInfo(Convert.ToInt32(ViewState["EmployeeID"].ToString()),
                                                                       Convert.ToInt32(strExamId));
                    ViewState["LastExamTime"] = objResultCurrent.ExamTime.ToString();
                    HfExamTime.Value          = ((randomExam.ExamTime * 60) - objResultCurrent.ExamTime).ToString();

                    if (objResultCurrent.ExamTime < 600 && randomExam.ExamTime * 60 > 600)
                    {
                        hfNeed.Value = (600 - objResultCurrent.ExamTime).ToString();
                    }
                    else
                    {
                        hfNeed.Value = "";
                    }

                    //获取该考生当前考试次数
                    RandomExamResultBLL RandomExamResultBLL = new RandomExamResultBLL();
                    int nowCount;

                    //如果在站段考试为随到随考,需要检测路局异地考试的情况
                    //if (randomExam.StartMode == PrjPub.START_MODE_NO_CONTROL && !PrjPub.IsServerCenter)
                    //{
                    //    IList<RandomExamResult> RandomExamResultsServer =
                    //    RandomExamResultBLL.GetRandomExamResultByExamineeIDFromServer(PrjPub.CurrentStudent.EmployeeID,
                    //                                                        int.Parse(strExamId));
                    //    nowCount = RandomExamResultsServer.Count;
                    //}
                    //else
                    //{
                    //    IList<RandomExamResult> RandomExamResults = RandomExamResultBLL.GetRandomExamResultByExamineeID(PrjPub.CurrentStudent.EmployeeID, int.Parse(strExamId));
                    //    nowCount = RandomExamResults.Count;
                    //}

                    //如果是随到随考,需要往回复请求表加入一条记录
                    //if (randomExam.StartMode == PrjPub.START_MODE_NO_CONTROL)
                    //{
                    RandomExamApplyBLL objApplyBll = new RandomExamApplyBLL();
                    RandomExamApply    objNowApply = objApplyBll.GetRandomExamApplyByExamResultCurID(objResultCurrent.RandomExamResultId);
                    if (objNowApply.RandomExamApplyID == 0)
                    {
                        RandomExamApply objApply = new RandomExamApply();
                        objApply.RandomExamID          = Convert.ToInt32(strExamId);
                        objApply.RandomExamResultCurID = objResultCurrent.RandomExamResultId;
                        objApply.ApplyStatus           = 1;
                        objApply.CodeFlag  = true;
                        objApply.IPAddress = Pub.GetRealIP();
                        objApplyBll.AddRandomExamApply(objApply);
                    }
                    else
                    {
                        objNowApply.IPAddress = Pub.GetRealIP();
                        objApplyBll.UpdateRandomExamApply(objNowApply);
                    }
                    //}

                    IList <RandomExamResult> RandomExamResults = RandomExamResultBLL.GetRandomExamResultByExamineeID(Convert.ToInt32(ViewState["EmployeeID"].ToString()), int.Parse(strExamId));
                    nowCount = RandomExamResults.Count;

                    ViewState["NowStartMode"] = randomExam.StartMode.ToString();
                    HiddenFieldMaxCount.Value = (randomExam.MaxExamTimes - nowCount - 1).ToString();

                    //更新考试状态
                    UpdateResultToDB(strExamId);
                    FillPage(strExamId);
                }
            }

            string strAnswer = Request.Form.Get("strreturnAnswer");

            if (strAnswer != null && strAnswer != "")
            {
                ViewState["EndTime"] = DateTime.Now.ToString();
                SaveAnswerToDB(strAnswer);

                //int examTime = Convert.ToInt32(ViewState["LastExamTime"].ToString()) +
                //GetSecondBetweenTwoDate(DateTime.Parse(ViewState["EndTime"].ToString()),
                //                        DateTime.Parse(ViewState["BeginTime"].ToString()));
                //ClientScript.RegisterStartupScript(GetType(), "jsHide", "<script>showProgressbar(" +
                //                                                        Request.QueryString.Get("id") + "," +
                //                                                        ViewState["RandomExamResultID"] + "," +
                //                                                        ViewState["EmployeeID"]+ "," + ViewState["OrgID"]+
                //                                                        ",'" +
                //                                                        ViewState["EndTime"] + "'," +
                //                                                        examTime + ")</script>");
            }
        }