예제 #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;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack && !CallBack1.IsCallback)
            {
                string strExamId = Request.QueryString.Get("id");
                ViewState["BeginTime"] = DateTime.Now.ToString();
                ViewState["StudentID"] = Request.QueryString.Get("employeeID");

                if (strExamId != null && strExamId != "")
                {
                    RandomExamBLL             randomExamBLL = new RandomExamBLL();
                    RailExam.Model.RandomExam randomExam    = randomExamBLL.GetExam(int.Parse(strExamId));

                    #region 考前判断(屏蔽)
                    //if (randomExam.StartMode == 2 && randomExam.OrgId.ToString() != ConfigurationManager.AppSettings["StationID"].ToString() && randomExam.OrgId != 32)
                    //{
                    //    OrganizationBLL OrgBll = new OrganizationBLL();
                    //    string strOrgName = OrgBll.GetOrganization(randomExam.OrgId).ShortName;
                    //    Response.Write("<script>alert('该考试为" + strOrgName + "统一时间考试,必须在" + strOrgName + "参加!'); top.window.close();</script>");
                    //    return;
                    //}
                    ////如果当前考试为手动控制,则需判断考试是否开始
                    //if (randomExam.StartMode == 2 && randomExam.IsStart == 0)
                    //{
                    //    Response.Write("<script>alert('该考试还没有开始,请耐心等待!'); top.window.close();</script>");
                    //    return;
                    //}
                    //if (randomExam.StartMode == 2 && randomExam.IsStart == 2)
                    //{
                    //    Response.Write("<script>alert('该考试已经结束!'); top.window.close();</script>");
                    //    return;
                    //}
                    #endregion

                    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["StudentID"].ToString()),
                                                                       Convert.ToInt32(strExamId));
                    //设置当前考生本次考试还剩下的考试时间
                    HfExamTime.Value = ((randomExam.ExamTime * 60) - objResultCurrent.ExamTime).ToString();
                    FillPage(strExamId);
                }
            }
        }
예제 #3
0
        protected void Callback1_Callback(object sender, CallBackEventArgs e)
        {
            try
            {
                string strId = ViewState["ExamID"].ToString();
                RandomExamResultCurrentBLL             objResultCurrentBll = new RandomExamResultCurrentBLL();
                RailExam.Model.RandomExamResultCurrent objResultCurrent    =
                    objResultCurrentBll.GetRandomExamResult(Convert.ToInt32(ViewState["RandomExamResultID"].ToString()));

                if (objResultCurrent.RandomExamId == 0)
                {
                    hfStart.Value = "2";
                }
                else
                {
                    objResultCurrent.ExamTime = Convert.ToInt32(ViewState["LastExamTime"].ToString()) + GetSecondBetweenTwoDate(DateTime.Now, DateTime.Parse(ViewState["BeginTime"].ToString()));
                    objResultCurrentBll.UpdateRandomExamResultCurrent(objResultCurrent);

                    RandomExamBLL             objBll        = new RandomExamBLL();
                    RailExam.Model.RandomExam objRandomExam = objBll.GetExam(Convert.ToInt32(strId));
                    hfStart.Value = objRandomExam.IsStart.ToString();
                }

                if (hfStart.Value == "2")
                {
                    RandomExamResultBLL objResultBll = new RandomExamResultBLL();
                    RandomExamResult    objResult    =
                        objResultBll.GetNewRandomExamResultByExamineeID(Convert.ToInt32(ViewState["EmployeeID"].ToString()),
                                                                        Convert.ToInt32(strId));

                    hfResultID.Value = objResult.RandomExamResultId.ToString();
                }
            }
            catch
            {
                hfStart.Value = "-1";
            }

            hfResultID.RenderControl(e.Output);
            hfStart.RenderControl(e.Output);
        }
예제 #4
0
        public void FillPaper()
        {
            string strId = Request.QueryString.Get("id");

            RandomExamBLL randomExamBLL = new RandomExamBLL();

            RailExam.Model.RandomExam randomExam = randomExamBLL.GetExam(int.Parse(strId));
            ViewState["Year"] = randomExam.BeginTime.Year.ToString();

            RandomExamResultCurrentBLL objResultCurrentBll = new RandomExamResultCurrentBLL();

            RailExam.Model.RandomExamResultCurrent randomExamResult = objResultCurrentBll.GetNowRandomExamResultInfo(Convert.ToInt32(Request.QueryString.Get("employeeID")), Convert.ToInt32(strId));

            int RandomExamId       = Convert.ToInt32(strId);
            int randomExamResultId = randomExamResult.RandomExamResultId;

            RandomExamItemBLL         randomItemBLL      = new RandomExamItemBLL();
            RandomExamSubjectBLL      subjectBLL         = new RandomExamSubjectBLL();
            IList <RandomExamSubject> randomExamSubjects = subjectBLL.GetRandomExamSubjectByRandomExamId(RandomExamId);

            RandomExamResultAnswerCurrentBLL      randomExamResultAnswerBLL = new RandomExamResultAnswerCurrentBLL();
            IList <RandomExamResultAnswerCurrent> examResultAnswers         = new List <RandomExamResultAnswerCurrent>();

            examResultAnswers = randomExamResultAnswerBLL.GetExamResultAnswersCurrent(randomExamResultId);

            OracleAccess db = new OracleAccess();

            if (randomExamSubjects != null)
            {
                for (int i = 0; i < randomExamSubjects.Count; i++)
                {
                    RandomExamSubject      paperSubject = randomExamSubjects[i];
                    IList <RandomExamItem> PaperItems   = new List <RandomExamItem>();
                    PaperItems = randomItemBLL.GetItemsCurrent(paperSubject.RandomExamSubjectId, randomExamResultId, Convert.ToInt32(ViewState["Year"].ToString()));

                    Response.Write("<br>");
                    Response.Write("<span class='StudentLeftInfo'><b> 第" + GetNo(i) + "大题:" + paperSubject.SubjectName + "</b></span>");
                    Response.Write("<br>");

                    if (PaperItems != null)
                    {
                        Response.Write("<table width='100%'  border='1'>");
                        int z     = 1;
                        int tempK = 0;
                        int count = 1;
                        for (int j = 0; j < PaperItems.Count; j++)
                        {
                            RandomExamItem paperItem = PaperItems[j];
                            int            k         = j + 1;


                            if (paperItem.TypeId != PrjPub.ITEMTYPE_FILLBLANKDETAIL && paperItem.TypeId != PrjPub.ITEMTYPE_FILLBLANK)
                            {
                                z = 1;

                                if (k % 5 == 1)
                                {
                                    Response.Write("</tr >");
                                    Response.Write("<tr><td class='StudentTableInfo' id='Item" + i + j + "' >"
                                                   + "<a href='AttendExamNew.aspx?id=" + strId + "&employeeID=" + Request.QueryString.Get("employeeID")
                                                   + "#Test" + i + j + "' target='ifExamInfo' style='cursor: hand;'><b>" + k + "</b></a></td>");
                                }
                                else
                                {
                                    Response.Write("<td class='StudentTableInfo' id='Item" + i + j + "' >"
                                                   + "<a href='AttendExamNew.aspx?id=" + strId + "&employeeID=" + Request.QueryString.Get("employeeID")
                                                   + "#Test" + i + j + "' target='ifExamInfo' style='cursor: hand;'><b>" + k + "</b></a></td>");
                                }
                            }
                            else
                            {
                                if (paperItem.TypeId == PrjPub.ITEMTYPE_FILLBLANK)
                                {
                                    z = 1;
                                    tempK++;
                                }

                                if (count % 3 == 1)
                                {
                                    Response.Write("</tr >");
                                    Response.Write("<tr><td class='StudentTableInfo' id='Item" + i + j + "' >"
                                                   + "<a href='AttendExamNew.aspx?id=" + strId + "&employeeID=" + Request.QueryString.Get("employeeID")
                                                   + "#Test" + i + j + "' target='ifExamInfo' style='cursor: hand;'><b>" + tempK + "-(" + z + ")</b></a></td>");
                                }
                                else
                                {
                                    Response.Write("<td class='StudentTableInfo' id='Item" + i + j + "' >"
                                                   + "<a href='AttendExamNew.aspx?id=" + strId + "&employeeID=" + Request.QueryString.Get("employeeID")
                                                   + "#Test" + i + j + "' target='ifExamInfo' style='cursor: hand;'><b>" + tempK + "-(" + z + ")</b></a></td>");
                                }

                                z++;
                                count++;
                            }
                        }

                        Response.Write("</tr >");
                        Response.Write("</table>");
                    }
                }

                //ClientScript.RegisterStartupScript(GetType(), "StartStyle", "<script>StartStyle()</script>");
            }
            else
            {
                SessionSet.PageMessage = "未找到记录!";
            }
        }
예제 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string strExamId = Request.QueryString.Get("id");
                ViewState["StudentID"] = Request.QueryString.Get("employeeID");
                ViewState["ExamID"]    = strExamId;

                if (strExamId != null && strExamId != "")
                {
                    RandomExamBLL             randomExamBLL = new RandomExamBLL();
                    RailExam.Model.RandomExam randomExam    = randomExamBLL.GetExam(int.Parse(strExamId));

                    OracleAccess db     = new OracleAccess();
                    string       strSql =
                        @"select * from Random_Exam_Result_Answer_Cur where Random_Exam_Result_ID in (
                        select Random_Exam_Result_ID from Random_Exam_Result_Current 
                        where Examinee_ID=" +
                        ViewState["StudentID"] + " and  Random_Exam_ID=" + strExamId + ")";
                    DataSet dsAnswer = db.RunSqlDataSet(strSql);

                    strSql = "select * from Random_Exam_Result_Current  where Examinee_ID=" +
                             ViewState["StudentID"] + " and  Random_Exam_ID=" + strExamId;
                    DataSet dsCurrent = db.RunSqlDataSet(strSql);

                    if (dsAnswer.Tables[0].Rows.Count == 0 && dsCurrent.Tables[0].Rows.Count > 0)
                    {
                        Response.Write("<script>alert('您的考试试卷生成有误,请联系监考老师删除您的考试试卷后重新生成!'); top.close();</script>");
                        return;
                    }

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

                    //如果当前考试为手动控制,则需判断考试是否开始
                    if (randomExam.StartMode == 2 && dr["Is_Start"].ToString() == "0")
                    {
                        Response.Write("<script>alert('该考试还没有开始,请耐心等待!'); top.close();</script>");
                        return;
                    }
                    if (randomExam.StartMode == 2 && dr["Is_Start"].ToString() == "2")
                    {
                        Response.Write("<script>alert('该考试已经结束!'); top.close();</script>");
                        return;
                    }

                    RandomExamResultBLL RandomExamResultBLL = new RandomExamResultBLL();
                    int nowCount;

                    IList <RandomExamResult> RandomExamResults =
                        RandomExamResultBLL.GetRandomExamResultByExamineeID(
                            Convert.ToInt32(Request.QueryString.Get("employeeID")), int.Parse(strExamId));
                    nowCount = RandomExamResults.Count;

                    if (nowCount > (randomExam.MaxExamTimes - 1))
                    {
                        Response.Write("<script>alert('您参加考试的次数已经达到考试设定的最大次数!'); top.close();</script>");
                        return;
                    }

                    RandomExamResultCurrentBLL             objResultCurrentBll = new RandomExamResultCurrentBLL();
                    RailExam.Model.RandomExamResultCurrent randomExamResult    =
                        objResultCurrentBll.GetNowRandomExamResultInfo(
                            Convert.ToInt32(Request.QueryString.Get("employeeID")), Convert.ToInt32(strExamId));

                    if (randomExamResult.RandomExamResultId == 0)
                    {
                        Response.Write("<script>alert('该考试已经结束!'); top.close();</script>");
                        return;
                    }
                }
                FillPage();
            }
        }
예제 #6
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;
            }
        }
예제 #7
0
        private void AddResultToDB(string strId)
        {
            RandomExamSubjectBLL       subjectBLL          = new RandomExamSubjectBLL();
            RandomExamItemBLL          randomItemBLL       = new RandomExamItemBLL();
            RandomExamResultCurrentBLL randomExamResultBLL = new RandomExamResultCurrentBLL();
            RandomExamStrategyBLL      strategyBLL         = new RandomExamStrategyBLL();

            RandomExamResultAnswerCurrentBLL randomExamResultAnswerBLL = new RandomExamResultAnswerCurrentBLL();
            IList <RandomExamItem>           randomExamItems           = new List <RandomExamItem>();

            RailExam.Model.RandomExamResultCurrent randomExamResult = new RailExam.Model.RandomExamResultCurrent();

            randomExamResult.RandomExamId    = int.Parse(strId);
            randomExamResult.AutoScore       = 0;
            randomExamResult.BeginDateTime   = DateTime.Parse(ViewState["BeginTime"].ToString());
            randomExamResult.CurrentDateTime = DateTime.Parse(ViewState["BeginTime"].ToString());
            randomExamResult.ExamTime        = 0;
            randomExamResult.EndDateTime     = DateTime.Parse(ViewState["BeginTime"].ToString());
            randomExamResult.Score           = 0;
            randomExamResult.OrganizationId  = int.Parse(ViewState["OrgID"].ToString());
            randomExamResult.Memo            = "";
            randomExamResult.StatusId        = 1;
            randomExamResult.AutoScore       = 0;
            randomExamResult.CorrectRate     = 0;
            randomExamResult.ExamineeId      = int.Parse(ViewState["EmployeeID"].ToString());

            int    nRandomExamResultPK = randomExamResultBLL.AddRandomExamResultCurrent(randomExamResult);
            string strSql = "select a.* from Computer_Room a "
                            + "inner join Computer_Server b on a.Computer_Server_ID=b.Computer_Server_ID "
                            + "where Computer_Server_No='" + PrjPub.ServerNo + "'";
            OracleAccess db             = new OracleAccess();
            DataSet      ds             = db.RunSqlDataSet(strSql);
            string       computerRoomID = string.Empty;

            if (ds.Tables[0].Rows.Count > 0)
            {
                computerRoomID = ds.Tables[0].Rows[0]["Computer_Room_ID"].ToString();
            }

            strSql = @"insert into Random_Exam_Result_Detail values("
                     + nRandomExamResultPK + "," + int.Parse(strId) + ","
                     + ViewState["EmployeeID"].ToString() + ",0,null,null,null,Random_Exam_Result_Detail_Seq.Nextval,"
                     + "0,null," + (computerRoomID == string.Empty ? "null" : computerRoomID) + ",null,null,null,null)";
            db.ExecuteNonQuery(strSql);

            ViewState["RandomExamResultID"] = nRandomExamResultPK;

            IList <RandomExamSubject> randomExamSubjects = subjectBLL.GetRandomExamSubjectByRandomExamId(int.Parse(strId));

            Hashtable hashTableItemIds    = new Hashtable();
            Hashtable htRandomExamItemIds = new Hashtable();

            for (int i = 0; i < randomExamSubjects.Count; i++)
            {
                int nSubjectId = randomExamSubjects[i].RandomExamSubjectId;
                // int nItemCount = randomExamSubjects[i].ItemCount;

                IList <RandomExamStrategy> strategys = strategyBLL.GetRandomExamStrategys(nSubjectId);
                for (int j = 0; j < strategys.Count; j++)
                {
                    int nStrategyId = strategys[j].RandomExamStrategyId;
                    int nItemCount  = strategys[j].ItemCount;
                    IList <RandomExamItem> itemList = randomItemBLL.GetItemsByStrategyId(nStrategyId, Convert.ToInt32(ViewState["Year"].ToString()));
                    Random    ObjRandom             = new Random();
                    Hashtable hashTable             = new Hashtable();
                    Hashtable hashTableCount        = new Hashtable();
                    while (hashTable.Count < nItemCount)
                    {
                        int k = ObjRandom.Next(itemList.Count);
                        hashTableCount[k] = k;
                        int itemID     = itemList[k].ItemId;
                        int examItemID = itemList[k].RandomExamItemId;
                        if (!hashTableItemIds.ContainsKey(itemID))
                        {
                            hashTable[examItemID]           = examItemID;
                            hashTableItemIds[itemID]        = itemID;
                            htRandomExamItemIds[examItemID] = examItemID;
                        }
                        if (hashTableCount.Count == itemList.Count && hashTable.Count < nItemCount)
                        {
                            SessionSet.PageMessage = "随机考试在设定的取题范围内的试题量不够,请重新设置取题范围!";
                            return;
                        }
                    }
                }
            }

            string strAll = "";

            foreach (int key in htRandomExamItemIds.Keys)
            {
                if (strAll == "")
                {
                    strAll += htRandomExamItemIds[key].ToString();
                }
                else
                {
                    strAll += "," + htRandomExamItemIds[key].ToString();
                }
            }
            randomExamResultAnswerBLL.AddExamResultAnswerCurrent(nRandomExamResultPK, strAll);
        }
예제 #8
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>");
            }
        }
예제 #9
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>");
            }
        }
예제 #10
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"]));
            //}
        }
예제 #11
0
        private void UpdateResultToDB(string strId)
        {
            //获取当前考试的考试结果ID,并且更新考试状态和开考时间
            RandomExamResultCurrentBLL objResultCurrentBll = new RandomExamResultCurrentBLL();

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

            if (randomExamResult.RandomExamResultId == 0)
            {
                //AddResultToDB(strId);
                return;
            }
            else
            {
                ViewState["RandomExamResultID"] = randomExamResult.RandomExamResultId;
            }

            if (randomExamResult.StatusId == 0)
            {
                randomExamResult.BeginDateTime = DateTime.Parse(ViewState["BeginTime"].ToString());
                randomExamResult.ExamTime      = 0;
            }
            randomExamResult.CurrentDateTime = DateTime.Parse(ViewState["BeginTime"].ToString());
            randomExamResult.EndDateTime     = DateTime.Parse(ViewState["BeginTime"].ToString());
            randomExamResult.OrganizationId  = int.Parse(ViewState["OrgID"].ToString());
            randomExamResult.Memo            = "";
            //参加考试将当前考试的标志置为1-正在进行
            randomExamResult.StatusId   = 1;
            randomExamResult.ExamineeId = int.Parse(ViewState["EmployeeID"].ToString());

            objResultCurrentBll.UpdateRandomExamResultCurrent(randomExamResult);

            //更新考试机位
            string strSql   = "";
            string mac_dest = "";

            try
            {
                mac_dest = GetCustomerMac(GetClientIP());
            }
            catch
            {
                mac_dest = "";
            }

            if (!string.IsNullOrEmpty(mac_dest))
            {
                strSql = "select * from Computer_Room_Detail"
                         + " where MAC_Address='" + mac_dest + "'";

                OracleAccess db = new OracleAccess();

                DataSet ds = db.RunSqlDataSet(strSql);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    strSql = "update Random_Exam_Result_Detail set Computer_Room_Seat=" +
                             ds.Tables[0].Rows[0]["Computer_Room_Seat"]
                             + " where Random_Exam_ID=" + randomExamResult.RandomExamId +
                             " and Random_Exam_Result_ID=" + randomExamResult.RandomExamResultId +
                             " and Employee_ID=" + randomExamResult.ExamineeId;
                    db.ExecuteNonQuery(strSql);
                }
            }
        }