Esempio n. 1
0
        protected void btnStop_Click(object sender, EventArgs e)
        {
            ViewState["EndTime"] = DateTime.Now.ToString();
            //记录当前考试所在地的OrgID
            ViewState["OrgID"] = ConfigurationManager.AppSettings["StationID"];

            string strId = Request.QueryString.Get("RandomExamID");

            if (string.IsNullOrEmpty(strId))
            {
                SessionSet.PageMessage = "缺少参数!";
                return;
            }

            //获取当前考试的生成试卷的状态和次数
            RandomExamBLL objBll = new RandomExamBLL();

            RailExam.Model.RandomExam objExam = objBll.GetExam(Convert.ToInt32(strId));

            RandomExamComputerServerBLL serverBll = new RandomExamComputerServerBLL();
            RandomExamComputerServer    server    = serverBll.GetRandomExamComputerServer(objExam.RandomExamId,
                                                                                          PrjPub.ServerNo);


            if (server.IsStart == 0)
            {
                if (objExam.EndTime >= DateTime.Today)
                {
                    SessionSet.PageMessage = "当前考试还未开始考试!";
                    return;
                }
            }
            else if (server.IsStart == 2)
            {
                SessionSet.PageMessage = "当前考试已经结束!";
                return;
            }

            RandomExamResultCurrentBLL      objResultCurrentBll = new RandomExamResultCurrentBLL();
            IList <RandomExamResultCurrent> objResultCurrent    =
                objResultCurrentBll.GetStartRandomExamResultInfo(Convert.ToInt32(strId));

            IList <RandomExamResultCurrent> objResultCurrentNew = new List <RandomExamResultCurrent>();

            try
            {
                RandomExamResultBLL objResultBll = new RandomExamResultBLL();

                foreach (RandomExamResultCurrent current in objResultCurrent)
                {
                    current.CurrentDateTime = DateTime.Parse(ViewState["EndTime"].ToString());
                    current.ExamTime        = GetSecondBetweenTwoDate(DateTime.Parse(ViewState["EndTime"].ToString()),
                                                                      current.BeginDateTime);

                    current.EndDateTime    = DateTime.Parse(ViewState["EndTime"].ToString());
                    current.Score          = 0;
                    current.OrganizationId = int.Parse(ViewState["OrgID"].ToString());
                    current.Memo           = "";
                    //参加考试将当前考试的标志置为2-已经结束
                    current.StatusId    = 2;
                    current.AutoScore   = 0;
                    current.CorrectRate = 0;
                    //objResultCurrentNew.Add(current);
                    objResultCurrentBll.UpdateRandomExamResultCurrent(current);

                    int randomExamResultID = objResultBll.RemoveResultAnswer(Convert.ToInt32(current.RandomExamResultId));
                    //int randomExamResultID = objResultBll.RemoveResultAnswerCurrent(Convert.ToInt32(current.RandomExamResultId));

                    try
                    {
                        OracleAccess dbPhoto = new OracleAccess();
                        string       strSql  = "select * from Random_Exam_Result_Detail where Random_Exam_Result_ID=" +
                                               randomExamResultID + " and Random_Exam_ID=" + current.RandomExamId;
                        DataSet dsPhoto = dbPhoto.RunSqlDataSet(strSql);

                        if (dsPhoto.Tables[0].Rows.Count > 0)
                        {
                            DataRow drPhoto    = dsPhoto.Tables[0].Rows[0];
                            int     employeeId = Convert.ToInt32(drPhoto["Employee_ID"]);
                            if (drPhoto["FingerPrint"] != DBNull.Value)
                            {
                                Pub.SavePhotoToLocal(current.RandomExamId, employeeId, (byte[])drPhoto["FingerPrint"], 0, randomExamResultID);
                            }
                            if (drPhoto["Photo1"] != DBNull.Value)
                            {
                                Pub.SavePhotoToLocal(current.RandomExamId, employeeId, (byte[])drPhoto["Photo1"], 1, randomExamResultID);
                            }
                            if (drPhoto["Photo2"] != DBNull.Value)
                            {
                                Pub.SavePhotoToLocal(current.RandomExamId, employeeId, (byte[])drPhoto["Photo2"], 2, randomExamResultID);
                            }
                            if (drPhoto["Photo3"] != DBNull.Value)
                            {
                                Pub.SavePhotoToLocal(current.RandomExamId, employeeId, (byte[])drPhoto["Photo3"], 3, randomExamResultID);
                            }
                        }
                    }
                    catch
                    {
                        hfSql.Value = GetSql();
                    }
                }

                hfSql.Value = GetSql();
                examsGrid.DataBind();
                SystemLogBLL objLogBll = new SystemLogBLL();
                objLogBll.WriteLog("“" + objExam.ExamName + "”终止正在进行的所有考试");
                SessionSet.PageMessage = "终止当前考试成功!";
            }
            catch
            {
                SessionSet.PageMessage = "终止当前考试失败!";
            }
        }
Esempio n. 2
0
        private void SaveAnswerToDB(string strAnswer)
        {
            try
            {
                string strId = Request.QueryString.Get("ExamID");

                RandomExamResultCurrentBLL             objResultCurrentBll = new RandomExamResultCurrentBLL();
                RailExam.Model.RandomExamResultCurrent objResultCurrent    =
                    objResultCurrentBll.GetNowRandomExamResultInfo(Convert.ToInt32(Request.QueryString["StudentID"].ToString()),
                                                                   Convert.ToInt32(strId));

                //更新考试成绩表时传入的主键应为站段的成绩表的主键ID
                objResultCurrent.RandomExamResultId = int.Parse(Request.QueryString["RandomExamResultID"].ToString());
                objResultCurrent.RandomExamId       = int.Parse(strId);
                objResultCurrent.AutoScore          = 0;
                objResultCurrent.CurrentDateTime    = DateTime.Parse(ViewState["EndTime"].ToString());
                objResultCurrent.ExamTime           = Convert.ToInt32(Request.QueryString["ExamTime"]);
                objResultCurrent.EndDateTime        = DateTime.Parse(ViewState["EndTime"].ToString());
                objResultCurrent.Score          = 0;
                objResultCurrent.OrganizationId = int.Parse(Request.QueryString["OrgID"].ToString());
                objResultCurrent.Memo           = "";
                objResultCurrent.StatusId       = 2;
                objResultCurrent.AutoScore      = 0;
                objResultCurrent.CorrectRate    = 0;
                objResultCurrent.ExamineeId     = int.Parse(Request.QueryString["StudentID"].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(Request.QueryString["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.AddExamResultAnswerCurrentSave(randomExamResultId, randomExamResultAnswers);

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

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

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

                Response.Write(
                    "<script>window.dialogArguments.parent.location = '/RailExamBao/Online/Exam/ExamSuccess.aspx?ExamType=1&ExamResultID=" +
                    randomExamResultID + "';window.close();</script>");
            }
            catch
            {
                SessionSet.PageMessage = "提交失败!";
                btnUpload.Visible      = true;
                btnClose.Visible       = true;
            }
        }
Esempio n. 3
0
        private void StopExam(string strResultID)
        {
            ViewState["EndTime"] = DateTime.Now.ToString();
            //记录当前考试所在地的OrgID
            ViewState["OrgID"] = ConfigurationManager.AppSettings["StationID"];

            RandomExamResultCurrentBLL objResultCurrentBll = new RandomExamResultCurrentBLL();
            RandomExamResultCurrent    objResultCurrent    = objResultCurrentBll.GetRandomExamResult(Convert.ToInt32(strResultID));

            objResultCurrent.CurrentDateTime = DateTime.Parse(ViewState["EndTime"].ToString());
            objResultCurrent.ExamTime        = GetSecondBetweenTwoDate(DateTime.Parse(ViewState["EndTime"].ToString()),
                                                                       objResultCurrent.BeginDateTime);

            objResultCurrent.EndDateTime    = DateTime.Parse(ViewState["EndTime"].ToString());
            objResultCurrent.Score          = 0;
            objResultCurrent.OrganizationId = int.Parse(ViewState["OrgID"].ToString());
            objResultCurrent.Memo           = "";
            //参加考试将当前考试的标志置为2-已经结束
            objResultCurrent.StatusId    = 2;
            objResultCurrent.AutoScore   = 0;
            objResultCurrent.CorrectRate = 0;

            RandomExamResultBLL objResultBll = new RandomExamResultBLL();

            try
            {
                objResultCurrentBll.UpdateRandomExamResultCurrent(objResultCurrent);
                int randomExamResultID = objResultBll.RemoveResultAnswer(Convert.ToInt32(strResultID));

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

                try
                {
                    OracleAccess dbPhoto = new OracleAccess();
                    string       strSql  = "select * from Random_Exam_Result_Detail where Random_Exam_Result_ID=" +
                                           randomExamResultID + " and Random_Exam_ID=" + objResultCurrent.RandomExamId;
                    DataSet dsPhoto = dbPhoto.RunSqlDataSet(strSql);

                    if (dsPhoto.Tables[0].Rows.Count > 0)
                    {
                        DataRow drPhoto    = dsPhoto.Tables[0].Rows[0];
                        int     employeeId = Convert.ToInt32(drPhoto["Employee_ID"]);
                        if (drPhoto["FingerPrint"] != DBNull.Value)
                        {
                            Pub.SavePhotoToLocal(objResultCurrent.RandomExamId, employeeId, (byte[])drPhoto["FingerPrint"], 0, randomExamResultID);
                        }
                        if (drPhoto["Photo1"] != DBNull.Value)
                        {
                            Pub.SavePhotoToLocal(objResultCurrent.RandomExamId, employeeId, (byte[])drPhoto["Photo1"], 1, randomExamResultID);
                        }
                        if (drPhoto["Photo2"] != DBNull.Value)
                        {
                            Pub.SavePhotoToLocal(objResultCurrent.RandomExamId, employeeId, (byte[])drPhoto["Photo2"], 2, randomExamResultID);
                        }
                        if (drPhoto["Photo3"] != DBNull.Value)
                        {
                            Pub.SavePhotoToLocal(objResultCurrent.RandomExamId, employeeId, (byte[])drPhoto["Photo3"], 3, randomExamResultID);
                        }
                    }
                }
                catch
                {
                    hfSql.Value = GetSql();
                }

                #region   路局
                //try
                //{
                //    if (!PrjPub.IsServerCenter)
                //    {
                //        RandomExamResult randomExamResult =
                //            objResultBll.GetRandomExamResult(randomExamResultID);
                //        objResultBll.AddRandomExamResultToServer(randomExamResult);
                //    }
                //}
                //catch
                //{
                //    Pub.ShowErrorPage("无法连接路局服务器,请检查站段服务器网络连接是否正常!");
                //}
                #endregion

                hfSql.Value = GetSql();
                examsGrid.DataBind();
                RandomExamBLL objBll    = new RandomExamBLL();
                SystemLogBLL  objLogBll = new SystemLogBLL();
                objLogBll.WriteLog("“" + objBll.GetExam(objResultCurrent.RandomExamId).ExamName + "”中的“" + objResultCurrent.ExamineeName + "”终止考试");
                SessionSet.PageMessage = "终止考试成功!";
            }
            catch
            {
                SessionSet.PageMessage = "终止考试失败!";
            }
        }