Ejemplo n.º 1
0
        protected void ItemAnswerChangeCallBack_Callback(object sender, CallBackEventArgs e)
        {
            try
            {
                RandomExamResultAnswerCurrentBLL objAnswerCurrentBll = new RandomExamResultAnswerCurrentBLL();
                RandomExamResultAnswerCurrent    objAnswerCurrent    =
                    objAnswerCurrentBll.GetExamResultAnswerCurrent(
                        Convert.ToInt32(ViewState["RandomExamResultID"].ToString()), Convert.ToInt32(e.Parameters[0]));
                //objAnswerCurrent.RandomExamResultId = Convert.ToInt32(ViewState["RandomExamResultID"].ToString());
                //objAnswerCurrent.RandomExamItemId = Convert.ToInt32(e.Parameters[0]);
                objAnswerCurrent.JudgeStatusId = 0;
                objAnswerCurrent.JudgeRemark   = string.Empty;
                objAnswerCurrent.ExamTime      = 0;

                if (e.Parameters[3] == "radio")
                {
                    objAnswerCurrent.Answer = e.Parameters[1];
                }
                else
                {
                    if (e.Parameters[2] == "true")
                    {
                        objAnswerCurrent.Answer = (objAnswerCurrent.Answer + "|" + e.Parameters[1]).TrimStart('|');
                    }
                    else
                    {
                        objAnswerCurrent.Answer =
                            (("|" + objAnswerCurrent.Answer + "|").Replace("|" + e.Parameters[1] + "|", "|")).TrimStart(
                                '|').TrimEnd('|');
                    }
                }


                objAnswerCurrentBll.UpdateExamResultAnswerCurrent(objAnswerCurrent);

                RandomExamResultCurrentBLL             objResultCurrentBll = new RandomExamResultCurrentBLL();
                RailExam.Model.RandomExamResultCurrent objResultCurrent    =
                    objResultCurrentBll.GetRandomExamResult(Convert.ToInt32(ViewState["RandomExamResultID"].ToString()));
                objResultCurrent.ExamTime = Convert.ToInt32(ViewState["LastExamTime"].ToString()) + GetSecondBetweenTwoDate(DateTime.Now, DateTime.Parse(ViewState["BeginTime"].ToString()));
                objResultCurrentBll.UpdateRandomExamResultCurrent(objResultCurrent);


                //OracleAccess db = new OracleAccess();
                //string sqlCommand = "USP_Random_EXAM_ANSWER_Cur_U";
                //OracleParameter para1 = new OracleParameter("p_random_exam_result_id", OracleType.Number);
                //para1.Value = objAnswerCurrent.RandomExamResultId;
                //OracleParameter para2 = new OracleParameter("p_random_exam_item_id", OracleType.Number);
                //para2.Value = objAnswerCurrent.RandomExamItemId;
                //OracleParameter para3 = new OracleParameter("p_answer", OracleType.NVarChar);
                //para3.Value = objAnswerCurrent.Answer;
                //OracleParameter para4 = new OracleParameter("p_exam_time", OracleType.Number);
                //para4.Value = objAnswerCurrent.ExamTime;
                //OracleParameter para5 = new OracleParameter("p_judge_remark", OracleType.NVarChar);
                //para5.Value = objAnswerCurrent.JudgeRemark;
                //IDataParameter[] paras = new IDataParameter[] { para1, para2, para3, para4, para5};
                //db.ExecuteNonQueryPro(sqlCommand, paras);
            }
            catch
            {
                Response.Write("<script>window.parent.parent.location='/RailExamBao/Common/Error.aspx?error=考试出现异常,请重启微机重新登录考试!'</script>");
            }
        }
Ejemplo n.º 2
0
        private void SaveAnswerToDB(string strAnswer)
        {
            string strId = Request.QueryString.Get("id");

            RandomExamItemBLL          randomItemBLL       = new RandomExamItemBLL();
            RandomExamResultCurrentBLL objResultCurrentBll = new RandomExamResultCurrentBLL();

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

            //更新考试成绩表时传入的主键应为站段的成绩表的主键ID
            objResultCurrent.RandomExamResultId = int.Parse(ViewState["RandomExamResultID"].ToString());
            objResultCurrent.RandomExamId       = int.Parse(strId);
            objResultCurrent.AutoScore          = 0;
            objResultCurrent.CurrentDateTime    = DateTime.Parse(ViewState["EndTime"].ToString());
            objResultCurrent.ExamTime           = Convert.ToInt32(ViewState["LastExamTime"].ToString()) +
                                                  GetSecondBetweenTwoDate(DateTime.Parse(ViewState["EndTime"].ToString()),
                                                                          DateTime.Parse(ViewState["BeginTime"].ToString()));
            objResultCurrent.EndDateTime    = DateTime.Parse(ViewState["EndTime"].ToString());
            objResultCurrent.Score          = 0;
            objResultCurrent.OrganizationId = int.Parse(ViewState["OrgID"].ToString());
            objResultCurrent.Memo           = "";
            objResultCurrent.StatusId       = 2;
            objResultCurrent.AutoScore      = 0;
            objResultCurrent.CorrectRate    = 0;
            objResultCurrent.ExamineeId     = int.Parse(ViewState["EmployeeID"].ToString());

            string[] str1 = strAnswer.Split(new char[] { '$' });
            RandomExamResultAnswerCurrentBLL randomExamResultAnswerBLL = new RandomExamResultAnswerCurrentBLL();
            //randomExamResultAnswerBLL.DeleteExamResultAnswerCurrent(Convert.ToInt32(ViewState["RandomExamResultID"].ToString()));
            //IList<RandomExamResultAnswerCurrent> randomExamResultAnswers = new List<RandomExamResultAnswerCurrent>();
            int randomExamResultId = int.Parse(ViewState["RandomExamResultID"].ToString());

            for (int n = 0; n < str1.Length; n++)
            {
                string   str2           = str1[n].ToString();
                string[] str3           = str2.Split(new char[] { '|' });
                string   strPaperItemId = str3[0].ToString();
                string   strTrueAnswer  = str2.ToString().Substring(strPaperItemId.Length + 1);

                RandomExamResultAnswerCurrent randomExamResultAnswer = new RandomExamResultAnswerCurrent();
                randomExamResultAnswer.RandomExamResultId = randomExamResultId;
                randomExamResultAnswer.RandomExamItemId   = int.Parse(strPaperItemId);
                randomExamResultAnswer.JudgeStatusId      = 0;
                randomExamResultAnswer.JudgeRemark        = string.Empty;
                randomExamResultAnswer.ExamTime           = 0;
                randomExamResultAnswer.Answer             = strTrueAnswer;
                //randomExamResultAnswers.Add(randomExamResultAnswer);
                randomExamResultAnswerBLL.UpdateExamResultAnswerCurrent(randomExamResultAnswer);
            }

            try
            {
                //将更新答卷信息
                //randomExamResultAnswerBLL.AddExamResultAnswerCurrentSave(randomExamResultId, randomExamResultAnswers);

                //更新实时考试记录
                objResultCurrentBll.UpdateRandomExamResultCurrent(objResultCurrent);

                //获取最后考试成绩
                //RandomExamResultCurrent randomExamResultCurrent = objResultCurrentBll.GetRandomExamResult(Convert.ToInt32(ViewState["RandomExamResultID"].ToString()));
                //decimal nowScore = randomExamResultCurrent.Score;

                //将实时考试记录(临时表)转存到正式考试成绩表和答卷表
                RandomExamResultBLL objResultBll = new RandomExamResultBLL();
                //int randomExamResultID = objResultBll.RemoveResultAnswer(Convert.ToInt32(ViewState["RandomExamResultID"].ToString()));

                //将实时考试记录(临时表)转存到中间考试成绩表和答卷表
                int randomExamResultID = objResultBll.RemoveResultAnswerCurrent(Convert.ToInt32(ViewState["RandomExamResultID"].ToString()));

                //删除登录信息
                SystemUserLoginBLL objloginBll = new SystemUserLoginBLL();
                objloginBll.DeleteSystemUserLogin(Convert.ToInt32(ViewState["EmployeeID"].ToString()));

                Response.Write("<script>window.parent.parent.location = '/RailExamBao/Online/Exam/ExamSuccess.aspx?ExamType=1&ExamResultID=" + randomExamResultID + "'</script>");
            }
            catch
            {
                SystemUserLoginBLL objloginBll = new SystemUserLoginBLL();
                objloginBll.DeleteSystemUserLogin(Convert.ToInt32(ViewState["EmployeeID"].ToString()));

                string       strSql = "update Random_Exam_Result_Current set Exam_Time=Exam_Time-180 where Random_Exam_ID=" + strId + " and Examinee_ID=" + ViewState["EmployeeID"];
                OracleAccess db     = new OracleAccess();
                db.ExecuteNonQuery(strSql);

                Response.Write("<script>window.parent.parent.location = '/RailExamBao/Common/OtherError.aspx?error=提交试卷失败,请重新进入考试再次进行提交'</script>");
            }


            //如果在站段是随到随考考试,成绩自动上传至路局
            //if(ViewState["NowStartMode"].ToString() == PrjPub.START_MODE_NO_CONTROL.ToString() && !PrjPub.IsServerCenter)
            //{
            //    objResultBll.RemoveRandomExamResultToServer(Convert.ToInt32(strId), Convert.ToInt32(ConfigurationManager.AppSettings["StationID"]));
            //}
        }